Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==PREPROCESSOR==
- // @name "Youtube Radio"
- // @author "Mire777"
- // @feature "v1.4"
- // @feature "watch-metadb"
- // ==/PREPROCESSOR==
- // Paths
- var fbfolder = (fb.ProfilePath + "Artist_info");
- var lfm_folder = fbfolder;
- //image download size
- size = "high";
- //Download server
- auto_yt = window.GetProperty("YT Radio", "0");
- //auto_lfm = window.GetProperty("LFM Radio", "0");
- ooo2 = window.GetProperty("YT Track", "");
- START_ARTIST = window.GetProperty("Artist Station", "madonna");
- //Download server
- last_fm = window.GetProperty("YT Similar", "");
- //Search terms(google,yahoo)
- terms = "";
- //Cycle
- cycle2 = 15;
- var VERSION = "7.2013-10-19.01";
- var DT_LEFT = 0x00000000;
- var DT_CENTER = 0x00000001;
- var DT_RIGHT = 0x00000002;
- var DT_VCENTER = 0x00000004;
- var DT_WORDBREAK = 0x00000010;
- var DT_CALCRECT = 0x00000400;
- var DT_NOPREFIX = 0x00000800;
- var DT_END_ELLIPSIS = 0x00008000;
- var MF_GRAYED = 0x00000001;
- var MF_STRING = 0x00000000;
- var IDC_ARROW = 32512;
- var IDC_HAND = 32649;
- var ONE_DAY = 86400000;
- var ONE_WEEK = 604800000;
- String.prototype.addCommas = function() {
- return this.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
- }
- String.prototype.trim = function() {
- return this.replace(/^\s+|\s+$/g, "");
- }
- String.prototype.ucfirst = function() {
- return this.charAt(0).toUpperCase() + this.substr(1);
- }
- function RGB(r, g, b) {
- return (0xff000000 | (r << 16) | (g << 8) | (b));
- }
- function RGBA(r, g, b, a) {
- return ((a << 24) | (r << 16) | (g << 8) | (b));
- }
- function on_colors_changed() {
- p.colors_changed();
- }
- function on_font_changed() {
- p.font_changed();
- }
- function on_selection_changed() {
- p.item_focus_change();
- }
- function on_playlist_switch() {
- p.item_focus_change();
- }
- function on_playback_new_track() {
- p.item_focus_change();
- //im.download();
- im.downloadLFM();
- }
- function on_playback_dynamic_info_track() {
- p.item_focus_change();
- }
- function on_playback_stop() {
- p.item_focus_change();
- }
- function on_item_focus_change() {
- p.item_focus_change();
- }
- function on_mouse_leave() {
- if (typeof b == "object") b.leave();
- if (typeof r == "object") r.leave();
- if (typeof li == "object") li.leave();
- if (typeof s == "object") s.leave();
- }
- function on_mouse_rbtn_up(x, y) {
- p.rbtn_up(x, y);
- return true;
- }
- function on_notify_data(name, data) {
- if (name == "lastfm" && data == "update" && typeof l == "object") l.notify_data(name, data);
- if (name == "autoplaylists" && data == "update" && typeof li == "object" && li.mode == "autoplaylists") li.update();
- if (name == "images" && data == "update" && typeof im == "object") im.update();
- if (name == "love" && typeof ps == "object") l.post(fb.TitleFormat("%LASTFM_LOVED_DB%").EvalWithMetadb(data) == 1 ? "track.unlove" : "track.love", data);
- }
- function panel(name, features) {
- this.item_focus_change = function() {
- if (!this.metadb_func) return;
- switch(this.selection_mode) {
- case 0:
- this.metadb = fb.GetSelection();
- break;
- case 1:
- this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
- break;
- case 2:
- this.metadb = fb.GetFocusItem();
- break;
- }
- if (this.metadb) on_metadb_changed();
- }
- this.colors_changed = function() {
- if (this.dui) {
- this.background_mode=(1);
- this.textcolour = window.GetColorDUI(0);
- this.textcolour_hl = window.GetColorDUI(2);
- this.backcolour = window.GetColorDUI(1);
- } else {
- this.background_mode=(0);
- this.textcolour = window.GetColorCUI(0);
- this.textcolour_hl = window.GetColorCUI(0);
- this.backcolour = window.GetColorCUI(3);
- }
- window.Repaint();
- }
- this.font_changed = function() {
- this.font = this.dui ? window.GetFontDUI(0) : window.GetFontCUI(0);
- try {
- this.font_name = this.font.Name;
- } catch(e) {
- this.console("Unable to use your default font. Using Segoe UI instead.");
- this.font_name = "Segoe ui";
- }
- this.title_font = gdi.Font(this.font_name, 16, 1);
- this.normal_font = gdi.Font("segoe ui", 12, 1);
- this.fixed_font = gdi.Font("Lucida Console", this.normal_font_size);
- this.list_font = gdi.Font(this.font_name, this.list_font_size);
- this.row_height = this.normal_font.Height + 2;
- if (typeof t == "object") t.size();
- window.Repaint();
- }
- this.size = function() {
- this.w = window.Width;
- this.h = window.Height;
- }
- this.move = function(x, y) {
- this.mx = x;
- this.my = y;
- }
- this.rbtn_up = function(x, y) {
- var _menu = window.CreatePopupMenu();
- var _custom_background = window.CreatePopupMenu();
- var _metadb = window.CreatePopupMenu();
- var _cover = window.CreatePopupMenu();
- var _font = window.CreatePopupMenu();
- var _sub1 = window.CreatePopupMenu();
- var _sub2 = window.CreatePopupMenu();
- var _sub3 = window.CreatePopupMenu();
- var _sub4 = window.CreatePopupMenu();
- var _sub5 = window.CreatePopupMenu();
- var idx;
- switch(true) {
- case typeof a == "object" && a.trace(x, y):
- /*_menu.AppendMenuItem(MF_STRING, 1, "Refresh");
- _menu.AppendMenuSeparator();
- _menu.AppendMenuItem(MF_STRING, 2, "Front");
- _menu.AppendMenuItem(MF_STRING, 3, "Back");
- _menu.AppendMenuItem(MF_STRING, 4, "Disc");
- _menu.AppendMenuItem(MF_STRING, 5, "Icon");
- _menu.AppendMenuItem(MF_STRING, 6, "Artist");
- _menu.CheckMenuRadioItem(2, 6, a.id + 2);
- _menu.AppendMenuSeparator();*/
- _menu.AppendMenuItem(MF_STRING, 15, "Crop (focus on centre)");
- _menu.AppendMenuItem(MF_STRING, 16, "Crop (focus on top)");
- _menu.AppendMenuItem(MF_STRING, 17, "adjust");
- _menu.AppendMenuItem(MF_STRING, 18, "Stretch");
- _menu.CheckMenuRadioItem(15, 18, a.type == "centre" ? 15 : a.type == "top" ? 16 : a.type == "adjust" ? 17 : 18);
- _menu.AppendMenuSeparator();
- _cover.AppendMenuItem(this.metadb ? MF_STRING : MF_GRAYED, 21, "Google images (launches browser)");
- _cover.AppendMenuItem(this.metadb ? MF_STRING : MF_GRAYED, 22, "Album Art Downloader");
- _cover.AppendMenuSeparator();
- //_cover.AppendMenuItem(MF_STRING, 23, "Help");
- //_cover.AppendTo(_menu, MF_STRING, "Cover search");
- //_menu.AppendMenuSeparator();
- break;
- case typeof c == "object" && c.trace(x, y):
- if (this.check_feature("now_playing") && !np_cd) break;
- /*_menu.AppendMenuItem(MF_STRING, 1, "Refresh");
- _menu.AppendMenuSeparator();
- _menu.AppendMenuItem(MF_STRING, 11, "Gloss effect");
- _menu.CheckMenuItem(11, c.gloss);
- _menu.AppendMenuItem(MF_STRING, 12, "Shadow effect");
- _menu.CheckMenuItem(12, c.shadow);
- _menu.AppendMenuSeparator();
- _cover.AppendMenuItem(this.metadb ? MF_STRING : MF_GRAYED, 21, "Google images (launches browser)");
- _cover.AppendMenuItem(this.metadb ? MF_STRING : MF_GRAYED, 22, "Album Art Downloader");
- _cover.AppendMenuSeparator();
- _cover.AppendMenuItem(MF_STRING, 23, "Help");
- _cover.AppendTo(_menu, MF_STRING, "Cover search");
- _menu.AppendMenuSeparator();*/
- break;
- case typeof li == "object" && li.trace(x, y):
- switch(li.mode) {
- case "autoplaylists":
- _menu.AppendMenuItem(MF_STRING, 600, "Change title...");
- _menu.AppendMenuSeparator();
- for (i = 1; i < 9; i++) {
- _sub1.AppendMenuItem(MF_STRING, i + 600, i);
- }
- _sub1.AppendTo(_menu, MF_STRING, "Save slot");
- _sub1.CheckMenuRadioItem(601, 608, li.autoplaylists_slot + 600);
- _menu.AppendMenuSeparator();
- _sub2.AppendMenuItem(MF_STRING, 610, "run query");
- _sub2.AppendMenuItem(MF_STRING, 611, "do nothing");
- _sub2.CheckMenuRadioItem(610, 611, li.autoplaylists_success ? 610 : 611);
- _sub2.AppendTo(_menu, MF_STRING, "On successful creation/edit");
- for (i = 0; i < li.autoplaylists_deleted_items.length; i++) {
- var temp = li.autoplaylists_deleted_items[i].split("¬");
- _sub3.AppendMenuItem(MF_STRING, i + 620, temp[0]);
- }
- if (li.autoplaylists_deleted_items.length > 0) _sub3.AppendTo(_menu, MF_STRING, "Restore");
- _menu.AppendMenuSeparator();
- _menu.AppendMenuItem(MF_STRING, 650, "Replace exisiting playlists with the same name");
- _menu.CheckMenuItem(650, li.autoplaylists_remove_duplicates);
- _menu.AppendMenuSeparator();
- break;
- case "discogs":
- _menu.AppendMenuItem(MF_STRING, 29, "Show exact artist matches only");
- _menu.CheckMenuItem(29, li.discogs_match);
- _menu.AppendMenuSeparator();
- _menu.AppendMenuItem(MF_STRING, 28, "Show timestamp");
- _menu.CheckMenuItem(28, li.show_timestamp);
- _menu.AppendMenuSeparator();
- break;
- case "echonest":
- for (i = 0; i < li.echonest_modes.length; i++) {
- _menu.AppendMenuItem(MF_STRING, i + 500, li.echonest_modes[i].ucfirst());
- }
- _menu.CheckMenuRadioItem(500, 502, li.echonest_mode + 500);
- _menu.AppendMenuSeparator();
- _menu.AppendMenuItem(MF_STRING, 28, "Show timestamp");
- _menu.CheckMenuItem(28, li.show_timestamp);
- _menu.AppendMenuSeparator();
- break;
- case "lastfm":
- for (i = 0; i < li.lastfm_modes.length; i++) {
- _menu.AppendMenuItem(MF_STRING, 801 + i, li.lastfm_modes[i].ucfirst());
- }
- _menu.CheckMenuRadioItem(801, 805, li.lastfm_mode + 801);
- _menu.AppendMenuSeparator();
- if (li.lastfm_mode == 0) {
- if (li.lastfm_button == "spotify") {
- _menu.AppendMenuItem(MF_STRING, 810, "Pause playback when launching Spotify");
- _menu.CheckMenuItem(810, li.lastfm_pause);
- _menu.AppendMenuSeparator();
- }
- /*_sub1.AppendMenuItem(MF_STRING, 811, "Spotify");
- _sub1.AppendMenuItem(MF_STRING, 812, "Autoplaylist");
- _sub1.CheckMenuRadioItem(811, 812, li.lastfm_button == "spotify" ? 811 : 812);
- _sub1.AppendTo(_menu, MF_STRING, "Buttons");
- _menu.AppendMenuSeparator();*/
- }
- /*_menu.AppendMenuItem(MF_STRING, 28, "Show timestamp");
- _menu.CheckMenuItem(28, li.show_timestamp);
- _menu.AppendMenuSeparator();
- _menu.AppendMenuItem(MF_STRING, 51, "Last.fm auto-correct");
- _menu.CheckMenuItem(51, l.auto_correct);
- _menu.AppendMenuSeparator();*/
- break;
- case "lastfm_charts":
- _menu.AppendMenuItem(l.username.length > 0 ? MF_STRING : MF_GRAYED, 1000, "Refresh");
- _menu.AppendMenuSeparator();
- for (i = 0; i < li.lastfm_charts_modes.length; i++) {
- _menu.AppendMenuItem(MF_STRING, i + 1001, li.lastfm_charts_modes[i].ucfirst());
- }
- _menu.CheckMenuRadioItem(1001, 1003, li.lastfm_charts_mode + 1001);
- _menu.AppendMenuSeparator();
- for (i = 0; i < li.lastfm_charts_periods_display.length; i++) {
- _menu.AppendMenuItem(MF_STRING, i + 1004, li.lastfm_charts_periods_display[i].ucfirst());
- }
- /*_menu.CheckMenuRadioItem(1004, 1009, li.lastfm_charts_period + 1004);
- _menu.AppendMenuSeparator();
- _menu.AppendMenuItem(MF_STRING, 1010, "Bar colour...");
- _menu.AppendMenuSeparator();
- _menu.AppendMenuItem(MF_STRING, 28, "Show timestamp");
- _menu.CheckMenuItem(28, li.show_timestamp);
- _menu.AppendMenuSeparator();*/
- break;
- case "musicbrainz":
- _menu.AppendMenuItem(MF_STRING, 700, "Releases");
- _menu.AppendMenuItem(MF_STRING, 701, "Links");
- _menu.CheckMenuRadioItem(700, 701, li.musicbrainz_mode == "releases" ? 700 : 701);
- _menu.AppendMenuSeparator();
- if (li.musicbrainz_mode == "releases") {
- /*_menu.AppendMenuItem(MF_STRING, 702, "Include albums");
- _menu.CheckMenuItem(702, li.musicbrainz_album);
- _menu.AppendMenuItem(MF_STRING, 703, "Include EPs");
- _menu.CheckMenuItem(703, li.musicbrainz_ep);
- _menu.AppendMenuItem(MF_STRING, 704, "Include singles");
- _menu.CheckMenuItem(704, li.musicbrainz_single);
- _menu.AppendMenuSeparator();
- _menu.AppendMenuItem(MF_STRING, 705, "Include 'Live' releases");
- _menu.CheckMenuItem(705, li.musicbrainz_live);
- _menu.AppendMenuItem(MF_STRING, 706, "Include 'Remix' releases");
- _menu.CheckMenuItem(706, li.musicbrainz_remix);
- _menu.AppendMenuItem(MF_STRING, 707, "Include 'Compilation' releases");
- _menu.CheckMenuItem(707, li.musicbrainz_compilation);
- _menu.AppendMenuSeparator();
- _menu.AppendMenuItem(MF_STRING, 708, "Show release type");
- _menu.CheckMenuItem(708, li.musicbrainz_show_release_type);
- _menu.AppendMenuSeparator();*/
- }
- /*_menu.AppendMenuItem(MF_STRING, 28, "Show timestamp");
- _menu.CheckMenuItem(28, li.show_timestamp);
- _menu.AppendMenuSeparator();*/
- break;
- }
- break;
- case typeof ps == "object" && b.buttons.ps.trace(x, y):
- /*_sub1.AppendMenuItem(utils.CheckComponent("foo_customdb", true) && !ps.loved_working && !ps.playcount_working && l.username.length > 0 ? MF_STRING : MF_GRAYED, 1100, "loved tracks and playcount");
- _sub1.AppendMenuItem(utils.CheckComponent("foo_customdb", true) && !ps.loved_working && !ps.playcount_working && l.username.length > 0 ? MF_STRING : MF_GRAYED, 1109, "loved tracks only");
- _sub1.AppendMenuSeparator();
- _sub1.AppendMenuItem(utils.CheckComponent("foo_customdb", true) && this.fso.FileExists(ps.sql_file) ? MF_STRING : MF_GRAYED, 1101, "from file");
- _sub1.AppendMenuSeparator();
- _sub1.AppendMenuItem(MF_STRING, 1102, "Show console");
- _sub1.CheckMenuItem(1102, ps.show_console);
- _sub1.AppendTo(_menu, MF_STRING, "Library import");
- _menu.AppendMenuSeparator();
- _sub2.AppendMenuItem(MF_STRING, 1103, "Only update tracks in library");
- _sub2.CheckMenuItem(1103, ps.library);
- _sub2.AppendMenuItem(MF_STRING, 52, "Last.fm auto-correct");
- _sub2.CheckMenuItem(52, l.auto_correct);
- _sub2.AppendTo(_menu, MF_STRING, "Auto-updates");
- _menu.AppendMenuSeparator();
- _sub3.AppendMenuItem(MF_STRING, 1104, "Off");
- _sub3.AppendMenuItem(MF_STRING, 1105, "On");
- _sub3.CheckMenuRadioItem(1104, 1105, ps.auto_love ? 1105 : 1104);
- _sub3.AppendMenuSeparator();
- _sub3.AppendMenuItem(ps.auto_love ? MF_STRING : MF_GRAYED, 1106, "Condition");
- _sub3.AppendTo(_menu, MF_STRING, "Automatically love tracks");
- _menu.AppendMenuSeparator();
- _sub4.AppendMenuItem(MF_STRING, 1107, "tango");
- _sub4.AppendMenuItem(MF_STRING, 1108, "silk");
- _sub4.CheckMenuRadioItem(1107, 1108, ps.icon == "tango" ? 1107 : 1108);
- _sub4.AppendTo(_menu, MF_STRING, "Icon");
- _menu.AppendMenuSeparator();*/
- break;
- case typeof s == "object" && s.mode == "spectrogram" && s.trace(x, y) :
- /*_menu.AppendMenuItem(MF_STRING, 1804, "SoX options...");
- _menu.AppendMenuSeparator();
- _menu.AppendMenuItem(MF_STRING, 1805, "Marker colour...");
- _menu.AppendMenuSeparator();
- _menu.AppendMenuItem(MF_STRING, 1803, "Only analyse tracks in library");
- _menu.CheckMenuItem(1803, s.library);
- _menu.AppendMenuSeparator();
- _sub1.AppendMenuItem(MF_STRING, 1800, "Clear all");
- _sub1.AppendMenuItem(MF_STRING, 1801, "Clear older than 1 day");
- _sub1.AppendMenuItem(MF_STRING, 1802, "Clear older than 1 week");
- _sub1.AppendMenuSeparator();
- _sub1.AppendMenuItem(MF_GRAYED, 1803, "In use: " + (this.fso.GetFolder(spectrogram_cache).size / 1048576).toFixed(2) + "MB");
- _sub1.AppendTo(_menu, MF_STRING, "Cached images");
- _menu.AppendMenuSeparator();*/
- break;
- case typeof t == "object" && t.trace(x, y):
- if (this.check_feature("now_playing") && !np_bio) break;
- /*_font.AppendMenuItem(MF_STRING, 30, 12);
- _font.AppendMenuItem(MF_STRING, 31, 14);
- _font.AppendMenuItem(MF_STRING, 32, 16);
- _font.AppendTo(_menu, MF_STRING, "Font size");
- _font.CheckMenuRadioItem(30, 33, this.normal_font_size == 12 ? 30 : this.normal_font_size == 14 ? 31 : 32);
- _menu.AppendMenuSeparator();*/
- switch(t.mode) {
- case "lastfm_album":
- /*_menu.AppendMenuItem(MF_STRING, 53, "Last.fm auto-correct");
- _menu.CheckMenuItem(53, l.auto_correct);
- _menu.AppendMenuSeparator();*/
- break;
- case "lastfm_wiki":
- /*_menu.AppendMenuItem(MF_STRING, 25, "Last.fm");
- _menu.AppendMenuItem(MF_STRING, 26, "Wikipedia");
- _menu.CheckMenuRadioItem(25, 26, t.source == "last.fm" ? 25 : 26);
- _menu.AppendMenuSeparator();*/
- break;
- case "simple_tag":
- /*_menu.AppendMenuItem(MF_STRING, 1700, "Custom title...");
- _menu.AppendMenuItem(MF_STRING, 1701, "Custom tag...");
- _menu.AppendMenuSeparator();
- _menu.AppendMenuItem(MF_STRING, 1702, "Centre text");
- _menu.CheckMenuItem(1702, t.centre);
- _menu.AppendMenuSeparator();*/
- break;
- case "simple_text":
- /*_menu.AppendMenuItem(MF_STRING, 1700, "Custom title...");
- _menu.AppendMenuItem(MF_STRING, 200, "Custom path...");
- _menu.AppendMenuSeparator();
- _menu.AppendMenuItem(MF_STRING, 201, "Fixed width font");
- _menu.CheckMenuItem(201, t.fixed);
- _menu.AppendMenuSeparator();*/
- break;
- }
- break;
- case typeof th == "object":
- case typeof im == "object" && im.trace(x, y):
- if (im.mode == "last.fm") {
- /*_menu.AppendMenuItem(this.metadb ? MF_STRING : MF_GRAYED, 450, "Download artist art from Last.fm");
- _menu.AppendMenuSeparator();
- _sub1.AppendMenuItem(MF_STRING, 451, "Off");
- _sub1.AppendMenuItem(MF_STRING, 452, "Library tracks only");
- _sub1.AppendMenuItem(MF_STRING, 453, "All tracks");
- _sub1.CheckMenuRadioItem(451, 453, im.auto_download == "off" ? 451 : im.auto_download == "library" ? 452 : 453);
- //_sub1.AppendTo(_menu, MF_STRING, "Automatic download");
- _sub2.AppendMenuItem(MF_STRING, 461, "1");
- _sub2.AppendMenuItem(MF_STRING, 463, "3");
- _sub2.AppendMenuItem(MF_STRING, 465, "5");
- //_sub2.AppendMenuItem(MF_STRING, 470, "10");
- //_sub2.AppendMenuItem(MF_STRING, 480, "20");
- _sub2.CheckMenuRadioItem(461, 480, im.limit + 460);
- //_sub2.AppendTo(_menu, MF_STRING, "Limit");*/
- } else {
- //_menu.AppendMenuItem(MF_STRING, 442, "Set custom folder...");
- }
- var _settings = window.CreatePopupMenu();
- var _auto_cycle = window.CreatePopupMenu();
- var _download_source = window.CreatePopupMenu();
- var _download_limit = window.CreatePopupMenu();
- var _download_quality = window.CreatePopupMenu();
- var _thumbs = window.CreatePopupMenu();
- var MF_POPUP = 0x00000010;
- var MF_GRAYED = 0x00000001;
- //_menu.AppendMenuSeparator();
- //_menu.AppendMenuItem(MF_STRING, 403, "Auto YT");
- //_menu.AppendMenuSeparator();
- //Settings Menu
- //_menu.AppendMenuItem(MF_STRING | MF_POPUP, _settings.ID, "Auto YT");
- //_menu.AppendMenuSeparator();
- //_settings.AppendMenuItem(MF_STRING | MF_POPUP, _auto_cycle.ID, "Auto Cycle");
- //_auto_cycle.AppendMenuItem(MF_STRING, 415, "05 sec");
- //_auto_cycle.AppendMenuItem(MF_STRING, 420, "10 sec");
- //_auto_cycle.AppendMenuItem(MF_STRING, 425, "15 sec");
- //_auto_cycle.AppendMenuItem(MF_STRING, 430, "20 sec");
- //_auto_cycle.AppendMenuItem(MF_STRING, 410, "Off");
- //_auto_cycle.CheckMenuRadioItem(410, 430, cycle2 + 410);
- //_settings.AppendMenuItem(MF_STRING | MF_POPUP, _download_source.ID, "Download Source");
- if(auto_yt==1) _menu.AppendMenuItem(MF_STRING, 1902, "Youtube Radio");
- if(auto_yt==0) _menu.AppendMenuItem(MF_STRING, 1903, "Youtube Radio");
- _menu.CheckMenuItem(1902, auto_yt?1:0);
- //if(auto_lfm==1) _menu.AppendMenuItem(MF_STRING, 1905, "Last.fm Radio");
- //if(auto_lfm==0) _menu.AppendMenuItem(MF_STRING, 1906, "Last.fm Radio");
- //_menu.CheckMenuItem(1905, auto_lfm?1:0);
- _menu.AppendMenuSeparator();
- //_settings.AppendMenuItem(MF_STRING | MF_POPUP, _download_limit.ID, "Download Limit");
- //_download_limit.AppendMenuItem(MF_STRING, 1905, "1x");
- //_download_limit.AppendMenuItem(MF_STRING, 1906, "2x");
- //_download_limit.AppendMenuItem(MF_STRING, 1907, "3x");
- //_download_limit.AppendMenuItem(MF_STRING, 1908, "4x");
- //_download_limit.AppendMenuItem(MF_STRING, 1909, "5x");
- //_download_limit.AppendMenuItem(MF_STRING, 1910, "6x");
- //_download_limit.CheckMenuRadioItem(1905, 1910, im.limit + 1904);
- //if (server=="last.fm") _settings.AppendMenuItem(MF_STRING | MF_POPUP, _download_quality.ID, "Download Quality");
- /*_download_quality.AppendMenuItem(MF_STRING, 1911, "Low");
- _download_quality.AppendMenuItem(MF_STRING, 1912, "Medium");
- _download_quality.AppendMenuItem(MF_STRING, 1913, "High");
- _download_quality.CheckMenuRadioItem(1911, 1913, size == "low" ? 1911 : size == "medium" ? 1912 : size == "high" ? 1913 : 1913);
- _settings.AppendMenuItem(MF_STRING | MF_POPUP, _thumbs.ID, "Thumbs");
- _thumbs.AppendMenuItem(MF_STRING, 1201, "Left");
- _thumbs.AppendMenuItem(MF_STRING, 1202, "Right");
- _thumbs.AppendMenuItem(MF_STRING, 1203, "Top");
- _thumbs.AppendMenuItem(MF_STRING, 1204, "Bottom");
- _thumbs.AppendMenuItem(MF_STRING, 1205, "Off");
- _thumbs.CheckMenuRadioItem(1200, 1205, th.mode == "grid" ? 1200 : th.mode == "left" ? 1201 : th.mode == "right" ? 1202 : th.mode == "top" ? 1203 : th.mode == "bottom" ? 1204 : 1205);
- if (th.mode == "left" | th.mode == "right" | th.mode == "top" | th.mode == "bottom")
- {
- _thumbs.AppendMenuSeparator();
- _thumbs.AppendMenuItem(MF_STRING, 1240, "40px");
- _thumbs.AppendMenuItem(MF_STRING, 1250, "50px");
- _thumbs.AppendMenuItem(MF_STRING, 1260, "60px");
- _thumbs.AppendMenuItem(MF_STRING, 1270, "70px");
- _thumbs.AppendMenuItem(MF_STRING, 1280, "80px");
- _thumbs.AppendMenuItem(MF_STRING, 1290, "90px");
- _thumbs.AppendMenuItem(MF_STRING, 1300, "100px");
- _thumbs.AppendMenuItem(MF_STRING, 1350, "150px");
- _thumbs.AppendMenuItem(MF_STRING, 1400, "200px");
- _thumbs.AppendMenuItem(MF_STRING, 1450, "250px");
- _thumbs.AppendMenuItem(MF_STRING, 1500, "300px");
- _thumbs.CheckMenuRadioItem(1240, 1500, th.px + 1200);
- }*/
- /* _sub3.AppendMenuItem(MF_STRING, 440, "Last.fm artist art");
- _sub3.AppendMenuItem(MF_STRING, 441, "Custom folder");
- _sub3.CheckMenuRadioItem(440, 441, im.mode == "last.fm" ? 440 : 441);
- //_sub3.AppendTo(_menu, MF_STRING, "Image source");
- _menu.AppendMenuSeparator();
- /*_sub4.AppendMenuItem(MF_STRING, 410, "Off");
- _sub4.AppendMenuItem(MF_STRING, 415, "5 seconds");
- _sub4.AppendMenuItem(MF_STRING, 420, "10 seconds");
- _sub4.AppendMenuItem(MF_STRING, 430, "20 seconds");
- _sub4.CheckMenuRadioItem(410, 430, im.cycle + 410);
- _sub4.CheckMenuRadioItem(410, 430, im.cycle + 410);
- _menu.AppendMenuSeparator();*/
- if (typeof th == "object") {
- if (!this.check_feature("now_playing")) _sub5.AppendMenuItem(MF_STRING, 1200, "Grid");
- /*_sub5.AppendMenuItem(MF_STRING, 1201, "Left");
- _sub5.AppendMenuItem(MF_STRING, 1202, "Right");
- _sub5.AppendMenuItem(MF_STRING, 1203, "Top");
- _sub5.AppendMenuItem(MF_STRING, 1204, "Bottom");
- _sub5.AppendMenuItem(MF_STRING, 1205, "Off");
- _sub5.CheckMenuRadioItem(1200, 1205, th.mode == "grid" ? 1200 : th.mode == "left" ? 1201 : th.mode == "right" ? 1202 : th.mode == "top" ? 1203 : th.mode == "bottom" ? 1204 : 1205);*/
- if (th.mode != "off") {
- /*_sub5.AppendMenuSeparator();
- _sub5.AppendMenuItem(MF_STRING, 1275, "75px");
- _sub5.AppendMenuItem(MF_STRING, 1300, "100px");
- _sub5.AppendMenuItem(MF_STRING, 1350, "150px");
- _sub5.AppendMenuItem(MF_STRING, 1400, "200px");
- _sub5.AppendMenuItem(MF_STRING, 1450, "250px");
- _sub5.AppendMenuItem(MF_STRING, 1500, "300px");
- _sub5.CheckMenuRadioItem(1275, 1500, th.px + 1200);*/
- }
- //_sub5.AppendTo(_menu, MF_STRING, "Thumbs");
- //_menu.AppendMenuSeparator();
- }
- //if (im.trace(x, y) && im.images.length > 0 && (!this.check_feature("thumbs") || th.mode != "grid"))
- {
- if (auto_yt=="1") _menu.AppendMenuItem(MF_STRING, 22, "Get Next Video");
- //if (auto_lfm=="1") _menu.AppendMenuItem(MF_STRING, 22, "Get Next Video");
- if (auto_yt=="0") _menu.AppendMenuItem(MF_STRING, 21, "Get Next Video");
- //_menu.AppendMenuItem(MF_STRING, 400, "Get All Videos")
- _menu.AppendMenuItem(MF_STRING, 401, "Search Videos");
- _menu.AppendMenuSeparator();
- //_menu.AppendMenuItem(MF_STRING, 402, "Search For Artist");
- _menu.AppendMenuItem(MF_STRING, 1914, "Start Radio");
- _menu.AppendMenuItem(MF_STRING, 1915, "Open Artist Radio");
- _menu.AppendMenuSeparator();
- _menu.AppendMenuItem(MF_STRING, 403, "'Artist+Title' Video");
- _menu.AppendMenuItem(MF_STRING, 404, "Open In Browser");
- //_menu.AppendMenuItem(MF_STRING, 402, "Delete image");
- //_menu.AppendMenuSeparator();
- //_menu.AppendMenuItem(MF_STRING, 405, "Top");
- //_menu.AppendMenuItem(MF_STRING, 404, "Centre");
- //_menu.AppendMenuItem(MF_STRING, 406, "Adjust");
- //_menu.AppendMenuItem(MF_STRING, 407, "Stretch");
- _menu.CheckMenuRadioItem(404, 407, im.type == "centre" ? 404 : im.type == "top" ? 405 : im.type == "adjust" ? 406 : 407);
- _menu.AppendMenuSeparator();
- }
- break;
- }
- if (this.check_feature("now_playing")) {
- /*_menu.AppendMenuItem(MF_STRING, 44, "Top style");
- _menu.AppendMenuItem(MF_STRING, 45, "Bottom style");
- _menu.CheckMenuRadioItem(44, 45, np_track_top ? 44 : 45);
- _menu.AppendMenuSeparator();
- _menu.AppendMenuItem(MF_STRING, 41, "Show CD cover");
- _menu.CheckMenuItem(41, np_cd);
- _menu.AppendMenuItem(MF_STRING, 42, "Show track info");
- _menu.CheckMenuItem(42, np_track);
- _menu.AppendMenuItem(MF_STRING, 46, "Show rating");
- _menu.CheckMenuItem(46, np_rating);
- _menu.AppendMenuItem(MF_STRING, 40, "Show web links");
- _menu.CheckMenuItem(40, np_buttons);
- _menu.AppendMenuItem(MF_STRING, 43, "Show biography");
- _menu.CheckMenuItem(43, np_bio);
- _menu.AppendMenuSeparator();*/
- }
- if (this.check_feature("custom_background")) {
- if (!this.dui) _custom_background.AppendMenuItem(MF_STRING, 100, "None");
- /*_custom_background.AppendMenuItem(MF_STRING, 101, this.dui ? "Use default UI setting" : "Use columns UI setting");
- _custom_background.AppendMenuItem(MF_STRING, 102, "Splitter");
- _custom_background.AppendMenuItem(MF_STRING, 104, "Pattern");
- _custom_background.AppendMenuItem(MF_STRING, 103, "Custom");
- _custom_background.AppendMenuSeparator();
- _custom_background.AppendMenuItem(this.background_mode == 3 ? MF_STRING : MF_GRAYED, 105, "Set custom colour...");
- _custom_background.CheckMenuRadioItem(101, 104, this.background_mode + 100);
- _custom_background.AppendTo(_menu, MF_STRING, "Background");
- _menu.AppendMenuSeparator();*/
- }
- if (typeof l == "object") {
- //_menu.AppendMenuItem(MF_STRING, 1900, "Last.fm username...");
- if (typeof ps == "object") _menu.AppendMenuItem(l.username.length > 0 ? MF_STRING : MF_GRAYED, 1901, "Last.fm password...");
- //_menu.AppendMenuSeparator();
- }
- if (this.check_feature("metadb")) {
- /*_metadb.AppendMenuItem(MF_STRING, 900, "Use display preferences");
- _metadb.AppendMenuItem(MF_STRING, 901, "Prefer now playing");
- _metadb.AppendMenuItem(MF_STRING, 902, "Follow selected track");
- _metadb.CheckMenuRadioItem(900, 903, this.selection_mode + 900);*/
- //_metadb.AppendTo(_menu, MF_STRING, "Selection mode");
- //_menu.AppendMenuSeparator();
- }
- if (this.check_feature("remap")) {
- //_menu.AppendMenuItem(MF_STRING, 7, "Artist field remapping...");
- //_menu.AppendMenuSeparator();
- }
- //_menu.AppendMenuItem(MF_STRING, 20, "Update script");
- //_menu.AppendMenuSeparator();
- //if (utils.IsKeyPressed(0x10)) _menu.AppendMenuItem(MF_STRING, 9, "Properties");
- _menu.AppendMenuItem(MF_STRING, 9, "Properties...");
- if (utils.IsKeyPressed(0x10)) _menu.AppendMenuItem(MF_STRING, 10, "Configure...");
- idx = _menu.TrackPopupMenu(x, y);
- switch(idx) {
- case 1:
- on_item_focus_change();
- break;
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- a.id = idx - 2;
- window.SetProperty("artreader_id", a.id);
- on_item_focus_change();
- break;
- case 7:
- this.artist_tf = this.InputBox("The default is %artist%\n\nYou can use the full foobar2000 title formatting syntax here.", "Artist field remapping", this.artist_tf);
- if (this.artist_tf == "") this.artist_tf = "%path%";
- window.SetProperty("YT Search", this.artist_tf);
- on_item_focus_change();
- break;
- case 9:
- window.ShowProperties();
- break;
- case 10:
- window.ShowConfigure();
- break;
- case 11:
- c.gloss = !c.gloss;
- window.SetProperty("cd_gloss", c.gloss);
- window.Repaint();
- break;
- case 12:
- c.shadow = !c.shadow;
- window.SetProperty("cd_shadow", c.shadow);
- window.Repaint();
- break;
- case 15:
- case 16:
- case 17:
- case 18:
- a.type = idx == 15 ? "centre" : idx == 16 ? "top" : idx == 17 ? "adjust" : "stretch";
- window.SetProperty("artreader_image_type", a.type);
- window.RepaintRect(a.x, a.y, a.w, a.h);
- break;
- case 20:
- this.update_script();
- break;
- case 21:
- im.downloadLFM1();
- break;
- case 22:
- im.downloadLFM();
- break;
- case 23:
- fb.ShowPopupMessage("You can get Album Art Downloader here:\n\nhttp://www.hydrogenaudio.org/forums/index.php?showtopic=57392", this.name);
- break;
- case 25:
- case 26:
- t.source = idx == 25 ? "last.fm" : "wikipedia";
- window.SetProperty("biography_source", t.source);
- t.artist = "";
- on_item_focus_change();
- break;
- case 28:
- li.show_timestamp = !li.show_timestamp;
- window.SetProperty("show_timestamp", li.show_timestamp);
- window.RepaintRect(li.x, li.y, li.w, li.h);
- break;
- case 29:
- li.discogs_match = !li.discogs_match;
- window.SetProperty("discogs_match", li.discogs_match);
- li.artist = "";
- on_item_focus_change();
- break;
- case 30:
- case 31:
- case 32:
- this.normal_font_size = idx == 30 ? 12 : idx == 31 ? 14 : 16;
- window.SetProperty("normal_font_size", this.normal_font_size);
- this.font_changed();
- break;
- case 40:
- np_buttons = !np_buttons;
- window.SetProperty("np_buttons", np_buttons);
- on_size();
- window.Repaint();
- break;
- case 41:
- np_cd = !np_cd;
- window.SetProperty("np_cd", np_cd);
- window.Repaint();
- break;
- case 42:
- np_track = !np_track;
- window.SetProperty("np_track", np_track);
- on_size();
- window.Repaint();
- break;
- case 43:
- np_bio = !np_bio;
- window.SetProperty("np_bio", np_bio);
- window.Repaint();
- break;
- case 44:
- case 45:
- np_track_top = idx == 44 ? true : false;
- window.SetProperty("np_track_top", np_track_top);
- on_size();
- window.Repaint();
- break;
- case 46:
- np_rating = !np_rating;
- window.SetProperty("np_rating", np_rating);
- on_size();
- window.Repaint();
- break;
- case 51:
- case 52:
- case 53:
- l.auto_correct = !l.auto_correct;
- window.SetProperty("lastfm_auto_correct", l.auto_correct);
- if (this.metadb) {
- if (idx == 51) li.get();
- if (idx == 53) t.get();
- }
- break;
- case 100:
- case 101:
- case 102:
- case 103:
- case 104:
- this.background_mode = idx - 100;
- window.SetProperty("background_mode", this.background_mode);
- window.Repaint();
- break;
- case 105:
- this.background_custom_colour = this.InputBox("Enter a custom colour for the background. Uses RGB. Example usage:\n\n234-211-74", this.name, this.background_custom_colour);
- window.SetProperty("background_custom_colour", this.background_custom_colour);
- window.Repaint();
- break;
- case 200:
- t.filename_tf = this.InputBox("Use title formatting to specify a path to your text file. eg: $directory_path(%path%)\\info.txt\n\nIf you prefer, you can specify just the path to a folder and the first txt or log file will be used.", this.name, t.filename_tf);
- window.SetProperty("text_filename_tf", t.filename_tf);
- on_item_focus_change();
- break;
- case 201:
- t.fixed = !t.fixed;
- window.SetProperty("text_fixed_font", t.fixed);
- t.calc();
- window.RepaintRect(t.x, t.y, t.w, t.h);
- break;
- case 400:
- im.downloadALL();
- break;
- case 401:
- fb.RunMainMenuCommand("View/Youtube Source");
- break;
- case 402:
- im.downloadART();
- break;
- case 403:
- im.downloadART_TITLE();
- break;
- case 404:
- p.artist = p.eval("%artist% %title%");
- p.browser("http://www.youtube.com/results?search_query=" + encodeURIComponent(p.artist));
- break;
- case 405:
- case 406:
- case 407:
- im.type = idx == 404 ? "centre" : idx == 405 ? "top" : idx == 406 ? "adjust" : "stretch";
- //window.SetProperty("Image type", im.type);
- window.Repaint();
- break;
- case 410:
- case 415:
- case 420:
- case 425:
- case 430:
- cycle2 = idx - 410;
- window.SetProperty("Image cycle", cycle2);
- cicleTimer = undefined;
- cicleTimerStarted = false;
- stopTimer();
- startTimer();
- cicleTimerStarted = true;
- break;
- case 440:
- case 441:
- im.mode = idx == 440 ? "last.fm" : "custom";
- window.SetProperty("image_mode", im.mode);
- im.artist = "";
- im.folder = "";
- on_item_focus_change();
- break;
- case 442:
- im.custom_folder_tf = this.InputBox("Enter title formatting or an absolute path to a folder. You can specify multiple folders using | as a separator.", this.name, im.custom_folder_tf);
- if (im.custom_folder_tf == "") im.custom_folder_tf = "$directory_path(%path%)";
- window.SetProperty("image_custom_folder_tf", im.custom_folder_tf);
- im.folder = "";
- on_item_focus_change();
- break;
- case 450:
- im.download();
- break;
- case 451:
- case 452:
- case 453:
- im.auto_download = idx == 451 ? "on" : idx == 452 ? "library" : "off";
- window.SetProperty("image_auto_download", im.auto_download);
- break;
- case 461:
- case 463:
- case 465:
- im.limit = idx - 460;
- window.SetProperty("image_limit", 50);
- break;
- case 490:
- case 491:
- case 492:
- case 493:
- im.type = idx == 490 ? "centre" : idx == 491 ? "top" : idx == 492 ? "adjust" : "stretch";
- window.SetProperty("image_type", im.type);
- window.RepaintRect(im.x, im.y, im.w, im.h);
- break;
- case 500:
- case 501:
- case 502:
- li.echonest_mode = idx - 500;
- window.SetProperty("echonest_mode", li.echonest_mode);
- li.artist = "";
- on_item_focus_change();
- break;
- case 600:
- li.autoplaylists_title = this.InputBox("Enter a new title", this.name, li.autoplaylists_title);
- if (li.autoplaylists_title == "") li.autoplaylists_title = "Autoplaylists";
- window.SetProperty("autoplaylists_title", li.autoplaylists_title);
- window.Repaint();
- break;
- case 601:
- case 602:
- case 603:
- case 604:
- case 605:
- case 606:
- case 607:
- case 608:
- li.autoplaylists_slot = idx - 600;
- window.SetProperty("autoplaylists_slot", li.autoplaylists_slot);
- li.filename = this.settings_folder + "autoplaylists" + li.autoplaylists_slot;
- li.offset = 0;
- li.update();
- break;
- case 610:
- case 611:
- li.autoplaylists_success = idx == 610 ? true : false;
- window.SetProperty("autoplaylists_success", li.autoplaylists_success);
- break;
- case 620:
- case 621:
- case 622:
- case 623:
- case 624:
- case 625:
- case 626:
- case 627:
- li.data.push(li.autoplaylists_deleted_items[idx - 620]);
- if (li.data.length > li.rows) li.offset = li.data.length - li.rows;
- li.autoplaylists_deleted_items.splice(idx - 620, 1);
- this.save(li.data.join("\n"), li.filename);
- window.NotifyOthers("autoplaylists", "update");
- li.update();
- break;
- case 650:
- li.autoplaylists_remove_duplicates = !li.autoplaylists_remove_duplicates
- window.SetProperty("autoplaylists_remove_duplicates", li.autoplaylists_remove_duplicates);
- break;
- case 700:
- case 701:
- li.musicbrainz_mode = idx == 700 ? "releases" : "URLs";
- window.SetProperty("musicbrainz_mode", li.musicbrainz_mode);
- li.artist = "";
- on_item_focus_change();
- break;
- case 702:
- li.musicbrainz_album = !li.musicbrainz_album;
- window.SetProperty("musicbrainz_album", li.musicbrainz_album);
- li.artist = "";
- on_item_focus_change();
- break;
- case 703:
- li.musicbrainz_ep = !li.musicbrainz_ep;
- window.SetProperty("musicbrainz_ep", li.musicbrainz_ep);
- li.artist = "";
- on_item_focus_change();
- break;
- case 704:
- li.musicbrainz_single = !li.musicbrainz_single;
- window.SetProperty("musicbrainz_single", li.musicbrainz_single);
- li.artist = "";
- on_item_focus_change();
- break;
- case 705:
- li.musicbrainz_live = !li.musicbrainz_live;
- window.SetProperty("musicbrainz_live", li.musicbrainz_live);
- li.artist = "";
- on_item_focus_change();
- break;
- case 706:
- li.musicbrainz_remix = !li.musicbrainz_remix;
- window.SetProperty("musicbrainz_remix", li.musicbrainz_remix);
- li.artist = "";
- on_item_focus_change();
- break;
- case 707:
- li.musicbrainz_compilation = !li.musicbrainz_compilation;
- window.SetProperty("musicbrainz_compilation", li.musicbrainz_compilation);
- li.artist = "";
- on_item_focus_change();
- break;
- case 708:
- li.musicbrainz_show_release_type = !li.musicbrainz_show_release_type;
- window.SetProperty("musicbrainz_show_release_type", li.musicbrainz_show_release_type);
- window.RepaintRect(li.x, li.y, li.w, li.h);
- break;
- case 801:
- case 802:
- case 803:
- case 804:
- case 805:
- li.lastfm_mode = idx - 801;
- window.SetProperty("lastfm_mode", li.lastfm_mode);
- li.artist = "";
- on_item_focus_change();
- break;
- case 810:
- li.lastfm_pause = !li.lastfm_pause;
- window.SetProperty("lastfm_pause", li.lastfm_pause);
- break;
- case 811:
- case 812:
- li.lastfm_button = idx == 811 ? "spotify" : "auto";
- window.SetProperty("lastfm_button", li.lastfm_button);
- window.RepaintRect(li.x, li.y, li.w, li.h);
- break;
- case 900:
- case 901:
- case 902:
- this.selection_mode = idx - 900;
- window.SetProperty("selection_mode", this.selection_mode);
- on_item_focus_change();
- break;
- case 1000:
- li.get();
- break;
- case 1001:
- case 1002:
- case 1003:
- li.lastfm_charts_mode = idx - 1001;
- window.SetProperty("lastfm_charts_mode", li.lastfm_charts_mode);
- li.update();
- break;
- case 1004:
- case 1005:
- case 1006:
- case 1007:
- case 1008:
- case 1009:
- li.lastfm_charts_period = idx - 1004;
- window.SetProperty("lastfm_charts_period", li.lastfm_charts_period);
- li.update();
- break;
- case 1010:
- li.lastfm_charts_bar_colour = this.InputBox("Enter a custom colour for the bars. Uses RGB. Example usage:\n\n234-211-74", this.name, li.lastfm_charts_bar_colour);
- window.SetProperty("lastfm_charts_bar_colour", li.lastfm_charts_bar_colour);
- window.Repaint();
- break;
- case 1100:
- case 1109:
- ps.full_import = idx == 1100 ? true : false;
- ps.start_import();
- break;
- case 1101:
- ps.finish_import();
- break;
- case 1102:
- ps.show_console = !ps.show_console;
- window.SetProperty("playcount_sync_show_console", ps.show_console);
- break;
- case 1103:
- ps.library = !ps.library;
- window.SetProperty("playcount_sync_library", ps.library);
- break;
- case 1104:
- case 1105:
- ps.auto_love = idx == 1104 ? false : true;
- window.SetProperty("playcount_sync_auto_love", ps.auto_love);
- break;
- case 1106:
- ps.auto_love_tf = this.InputBox("The result of the title formatting set here must equal 1 for a track to be automatically loved.\n\nExample:\n\n$ifequal(%rating%,5,1,0)", this.name, ps.auto_love_tf);
- window.SetProperty("playcount_sync_auto_love_tf", ps.auto_love_tf);
- break;
- case 1107:
- case 1108:
- ps.icon = idx == 1107 ? "tango" : "silk";
- window.SetProperty("playcount_sync_icon", ps.icon);
- b.update();
- break;
- case 1200:
- case 1201:
- case 1202:
- case 1203:
- case 1204:
- case 1205:
- th.mode = idx == 1200 ? "grid" : idx == 1201 ? "left" : idx == 1202 ? "right" : idx == 1203 ? "top" : idx == 1204 ? "bottom" : "off";
- //window.SetProperty("Thumbs mode", th.mode);
- th.nc = true;
- on_size();
- window.Repaint();
- break;
- case 1240:
- case 1250:
- case 1260:
- case 1270:
- case 1280:
- case 1290:
- case 1300:
- case 1350:
- case 1400:
- case 1450:
- case 1500:
- th.px = idx - 1200;
- th.nc = true;
- on_size();
- window.Repaint();
- break;
- case 1700:
- t.title = this.InputBox("You can use full title formatting here.", this.name, t.title);
- window.SetProperty("text_title", t.title);
- window.Repaint();
- break;
- case 1701:
- t.tag = this.InputBox("Enter a custom tag.", this.name, t.tag);
- window.SetProperty("text_tag", t.tag);
- t.filename = "";
- on_item_focus_change();
- break;
- case 1702:
- t.centre = !t.centre;
- window.SetProperty("text_centre", t.centre);
- window.RepaintRect(t.x, t.y, t.w, t.h);
- break;
- case 1800:
- case 1801:
- case 1802:
- var period = idx == 1800 ? 0 : idx == 1801 ? ONE_DAY : ONE_WEEK;
- s.clear_images(period);
- break;
- case 1803:
- s.library = !s.library;
- window.SetProperty("seekbar_library", s.library);
- break;
- case 1804:
- s.sox_params = this.InputBox("All SoX spectrogram options should work here.\n\n-r, -d and -o are already configured so do not use those. Check sox.pdf for everything else.", this.name, s.sox_params);
- window.SetProperty("sox_params", s.sox_params);
- if (fb.IsPlaying) s.playback_new_track();
- break;
- case 1805:
- s.marker = this.InputBox("Enter a custom colour for the marker. Uses RGB. Example usage:\n\n234-211-74", this.name, s.marker);
- window.SetProperty("seekbar_marker", s.marker);
- break;
- case 1900:
- l.update_username();
- break;
- case 1901:
- l.update_password();
- break;
- case 1902:
- auto_yt = 0;
- window.SetProperty("YT Radio", "0");
- break;
- case 1903:
- auto_yt = 1;
- window.SetProperty("YT Radio", "1");
- break;
- case 1904:
- if (server=="on")server = window.SetProperty("YT Radio", "off");
- if (server=="off")server = window.SetProperty("YT Radio", "on");
- break;
- case 1905:
- auto_lfm = 0;
- window.SetProperty("LFM Radio", "0");
- break;
- case 1906:
- auto_lfm = 1;
- window.SetProperty("LFM Radio", "1");
- break;
- case 1907:
- case 1908:
- case 1909:
- case 1910:
- im.limit = idx - 1904;
- //window.SetProperty("Download limit", im.limit);
- break;
- case 1911:
- case 1912:
- case 1913:
- size = idx == 1911 ? "low" : idx == 1912 ? "medium" : idx == 1913 ? "high" : "high";
- window.SetProperty("Download quality", size);
- break;
- case 1914:
- Start = START_ARTIST;
- START_ARTIST = this.InputBox("Type Artist to Start Radio", this.name, START_ARTIST);
- window.SetProperty("Artist Station", START_ARTIST);
- auto_yt = 1;
- window.SetProperty("YT Radio", "1");
- if (START_ARTIST==Start)
- {
- }
- else
- {
- im.downloadLFM1();
- }
- break;
- case 1915:
- Start = START_ARTIST;
- p.artist = p.eval("%artist%");
- if (p.artist == "" || p.artist == "?") return;
- START_ARTIST = p.artist;
- window.SetProperty("Artist Station", p.artist);
- auto_yt = 1;
- window.SetProperty("YT Radio", "1");
- on_item_focus_change();
- /*if (START_ARTIST==Start)
- {
- }
- else
- {*/
- im.downloadLFM1();
- //}
- break;
- }
- _menu.Dispose();
- _custom_background.Dispose();
- _metadb.Dispose();
- _cover.Dispose();
- _font.Dispose();
- _sub1.Dispose();
- _sub2.Dispose();
- _sub3.Dispose();
- _sub4.Dispose();
- _sub5.Dispose();
- }
- this.features_init = function() {
- for (i = 0; i < this.features.length; i++) {
- switch(this.features[i]) {
- case "custom_background":
- //this.background_mode = (0);
- //window.GetProperty("background_mode", 0);
- //this.background_custom_colour = ("0-0-0");
- //window.GetProperty("background_custom_colour", "0-0-0");
- break;
- case "metadb":
- this.selection_mode = 1;
- break;
- case "themes":
- this.themed_seekbar = window.CreateThemeManager("Progress");
- this.themed_header = window.CreateThemeManager("Header");
- this.themed_header.SetPartAndStateId(1, 1);
- this.themed_button = window.CreateThemeManager("Button");
- break;
- case "remap":
- this.artist_tf = window.GetProperty("YT Search", "%path%");
- break;
- }
- }
- }
- this.check_feature = function(f) {
- for (i = 0; i < this.features.length; i++) {
- if (this.features[i] == f) return true;
- }
- return false;
- }
- this.eval = function(tf) {
- if (!this.metadb || tf == "") return "";
- if (fb.IsPlaying && this.metadb.RawPath.indexOf("file://") != 0) {
- return fb.TitleFormat(tf).Eval();
- } else {
- return fb.TitleFormat(tf).EvalWithMetadb(this.metadb);
- }
- }
- this.open = function(filename) {
- return utils.ReadTextFile(filename);
- }
- this.save = function(t, f) {
- try {
- var ts = this.fso.OpenTextFile(f, 2, true, -1);
- ts.WriteLine(t);
- ts.Close();
- return true;
- } catch(e) {
- return false;
- }
- }
- this.console = function(message) {
- fb.trace(this.name + ": " + message);
- }
- this.strip_tags = function(value) {
- if (!this.doc) this.doc = new ActiveXObject("htmlfile");
- try {
- this.doc.open();
- var div = this.doc.createElement("div");
- div.innerHTML = value.replace(/\n/g, "<br>");
- return div.innerText.trim();
- } catch(e) {
- return "Error reading content.";
- }
- }
- this.InputBox = function(prompt, title, value) {
- prompt = prompt.replace(/"/g, '" + Chr(34) + "').replace(/\n/g, '" + Chr(13) + "');
- title = title.replace(/"/g, '" + Chr(34) + "');
- value = value.replace(/"/g, '" + Chr(34) + "');
- var temp_value = this.vb.eval('InputBox' + '("' + prompt + '", "' + title + '", "' + value + '")');
- if (typeof temp_value == "undefined") return value;
- if (temp_value.length == 254) this.MsgBox("Your entry was too long and will be truncated.\n\nSee the WSH panel mod script discussion thread on hydrogenaudio forums for help.", 0, this.name);
- return temp_value.trim();
- }
- this.MsgBox = function(prompt, buttons, title) {
- prompt = prompt.replace(/"/g, '" + Chr(34) + "').replace(/\n/g, '" + Chr(13) + "');
- title = title.replace(/"/g, '" + Chr(34) + "');
- return this.vb.eval('MsgBox' + '("' + prompt + '", "' + buttons + '", "' + title + '")');
- }
- this.browser = function(command) {
- if (!this.run(command)) this.MsgBox("Unable to launch your default browser.", 0, this.name);
- }
- this.run = function(command) {
- try {
- this.WshShell.Run(command);
- return true;
- } catch(e) {
- return false;
- }
- }
- this.aad = function() {
- if (!this.app) this.app = new ActiveXObject("Shell.Application");
- var aad_path = window.GetProperty("aad_path", "");
- if (!this.fso.FileExists(aad_path)) {
- var folder = this.app.BrowseForFolder(0, "Locate Album Art Downloader", 0x00000200);
- var file = folder ? folder.items().item().path + "\\AlbumArt.exe" : "";
- if (this.fso.FileExists(file)) {
- aad_path = file;
- window.SetProperty("aad_path", file);
- }
- }
- if (this.fso.FileExists(aad_path)) {
- var album_artist = "/ar \"" + this.eval("[%album artist%]") + "\"";
- var album = " /al \"" + this.eval("[%album%]") + "\"";
- this.run("\"" + aad_path + "\"" + album_artist + album);
- }
- }
- this.tt = function(t) {
- if (this.tooltip.Text == t) return;
- this.tooltip.Text = t;
- this.tooltip.Activate();
- }
- this.ttd = function() {
- this.tooltip.Text = "";
- this.tooltip.Deactivate();
- }
- this.splitRGB = function(value) {
- var temp_col = value.split("-");
- return RGB(temp_col[0], temp_col[1], temp_col[2]);
- }
- this.draw_background = function(gr) {
- if (this.check_feature("custom_background")) {
- var col;
- switch(this.background_mode) {
- case 0:
- col = null;
- break;
- case 1:
- col = this.backcolour;
- break;
- case 2:
- col = utils.GetSysColor(15);
- break;
- case 3:
- col = this.splitRGB(this.background_custom_colour);
- break;
- case 4:
- col = null;
- var spacing = 3;
- var line_thickness = 1;
- var bg = RGB(65, 65, 65);
- var colour = RGB(92, 92, 92);
- gr.FillSolidRect(0, 0, this.w, this.h, bg);
- for (i = 0; i < Math.ceil(this.w / spacing); i++) {
- gr.DrawLine(i * spacing, 0, i * spacing, this.h, line_thickness, colour);
- }
- for (i = 0; i < Math.ceil(this.h / spacing); i++) {
- gr.DrawLine(0, i * spacing, this.w, i * spacing, line_thickness, colour);
- }
- break;
- }
- if (col) gr.FillSolidRect(0, 0, this.w, this.h, col);
- } else {
- gr.FillSolidRect(0, 0, this.w, this.h, this.backcolour);
- }
- }
- this.draw_image = function(gr, img, pos_x, pos_y, width, height, type, border, alpha) {
- if (!img) return;
- gr.SetInterpolationMode(7);
- switch(type) {
- case "centre":
- case "top":
- {
- var sr = img.Width / img.Height;
- var dr = width / height;
- if (sr < dr) {
- var r = img.Width / width;
- var ch = height * r;
- var sy = Math.round((img.Height - ch) / (type == "top" ? 1000 : 2));
- var cw = img.Width;
- var sx = 0;
- } else {
- var r = img.Height / height;
- var cw = width * r;
- var sx = Math.round((img.Width - cw) / 2);
- var ch = img.Height;
- var sy = 0;
- }
- {
- gr.DrawImage(img, pos_x, pos_y, width, height, sx + 5, sy + 5, cw - 10, ch - 10, 0, alpha || 255);
- if (border) gr.DrawRect(pos_x, pos_y, width - 1, height - 1, 1, border);
- }
- }
- break;
- case "stretch":
- //strech
- gr.DrawImage(img, pos_x, pos_y, width, height, 5, 5, img.Width-10, img.Height-10, 0, alpha || 255);
- if (border) gr.DrawRect(pos_x, pos_y, width - 1, height - 1, 1, border);
- break;
- case "adjust":
- default:
- //adjust
- var s = Math.min(width / img.Width, height / img.Height);
- var nw = Math.round(img.Width * s);
- var nh = Math.round(img.Height * s);
- pos_x += Math.round((width - nw) / 2);
- pos_y += Math.round((height - nh) / 2);
- gr.DrawImage(img, pos_x, pos_y, nw, nh, 5, 5, img.Width-10, img.Height-10, 0, alpha || 255);
- if (border) gr.DrawRect(pos_x, pos_y, nw - 1, nh - 1, 1, border);
- break;
- }
- }
- this.header = function(gr, text) {
- this.left_text(gr, text, this.title_font, this.textcolour_hl, 6, 6, this.w - 77, 24);
- gr.DrawLine(6, 29, this.w - 6, 29, 1, this.textcolour_hl);
- }
- this.centre_text = function(gr, text, font, colour, x, y, w, h) {
- gr.GdiDrawText(text, font, colour, x, y, w, h, DT_VCENTER | DT_CENTER | DT_WORDBREAK | DT_CALCRECT | DT_NOPREFIX);
- }
- this.left_text = function(gr, text, font, colour, x, y, w, h) {
- gr.GdiDrawText(text, font, colour, x, y, w, h, DT_VCENTER | DT_END_ELLIPSIS | DT_CALCRECT | DT_NOPREFIX);
- }
- this.right_text = function(gr, text, font, colour, x, y, w, h) {
- gr.GdiDrawText(text, font, colour, x, y, w, h, DT_VCENTER | DT_RIGHT | DT_END_ELLIPSIS | DT_CALCRECT | DT_NOPREFIX);
- }
- this.format_time = function(t) {
- var h = Math.floor(t / 3600);
- var m = Math.floor((t -= h * 3600) / 60);
- var s = Math.floor(t -= m * 60);
- return((h > 0 ? h + ":" + (m < 10 ? "0" + m : m) : m) + ":" + (s < 10 ? "0" + s : s));
- }
- this.check_version = function() {
- //not used any more but will leave intact so old scripts don't crash.
- return;
- }
- this.update_script = function() {
- if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
- this.xmlhttp.open("GET", this.common_url, true);
- this.xmlhttp.send();
- this.xmlhttp.onreadystatechange = function() {
- if (p.xmlhttp.readyState == 4) {
- switch(p.xmlhttp.status) {
- case 200:
- var text = p.xmlhttp.responsetext;
- switch (true) {
- case text.indexOf("function panel") == -1:
- p.MsgBox("Unexpected server error. Not updating.", 0, p.name);
- break;
- case text.indexOf('var VERSION = "' + VERSION) == 0:
- p.MsgBox("Already using latest version.", 0, p.name);
- break;
- default:
- if (p.save(text, p.common_filename)) {
- if (p.MsgBox("Download successful. Restart foobar2000 now?", 4, p.name) == 6) fb.RunMainMenuCommand("File/Restart");
- } else {
- p.MsgBox("Unexpected error. Not updating.", 0, p.name);
- }
- break;
- }
- break;
- case 404:
- fb.ShowPopupMessage("The script reports that the update file has not been found. It could be a temporary problem with dropbox but if this error persists then it is most likely due to support stopping for this version. Check the hydrogenaudio thread or the full zip for updates.\n\nhttp://www.hydrogenaudio.org/forums/index.php?showtopic=77883\n" + p.root_url + "samples.zip", p.name);
- break;
- default:
- p.console(p.xmlhttp.responsetext || "HTTP error: " + p.xmlhttp.status);
- break;
- }
- }
- }
- }
- //remove false string from file names
- this.clean_filename = function(filename) {
- return filename.replace(/[\/\\|:]/g, '-').replace(/\*/g, 'x').replace(/"/g, "''").replace(/[?<>]/g, '_');
- }
- this.json_parse = function(text) {
- try {
- var data = JSON.parse(text);
- return data;
- } catch(e) {
- this.console("JSON.parse error.");
- return false;
- }
- }
- this.name = name;
- this.features = features;
- this.dui = window.InstanceType;
- this.script_path = fb.ProfilePath;
- this.images_path = this.script_path + "images\\";
- this.root_url = "https://dl.dropboxusercontent.com/u/22801321/wsh/"
- this.common_url = this.root_url + "marc2003/common7.js";
- this.common_filename = this.script_path + "common7.js";
- this.tooltip = window.CreateTooltip();
- this.w = 0;
- this.h = 0;
- this.mx = 0;
- this.my = 0;
- this.metadb = fb.GetFocusItem();
- this.WshShell = new ActiveXObject("WScript.Shell");
- this.fso = new ActiveXObject("Scripting.FileSystemObject");
- this.vb = new ActiveXObject("ScriptControl");
- this.vb.Language = "VBScript";
- //this.settings_folder = fb.ProfilePath + "last_fm\\";
- //if (!this.fso.FolderExists(this.settings_folder)) this.fso.CreateFolder(this.settings_folder);
- //this.data_folder = lfm_folder + "\\";
- //if (lfm_folder==fb.ProfilePath + "Artist_info") if (!this.fso.FolderExists(this.data_folder)) this.fso.CreateFolder(this.data_folder), this.data_folder=this.data_folder;
- //if (!this.fso.FolderExists(this.data_folder)) return;
- this.artist = "";
- this.artist_tf = "%path%";
- this.normal_font_size = (12);
- //window.GetProperty("normal_font_size", 12);
- this.list_font_size = 11;
- this.up_img = gdi.Image(this.images_path + "down.png");
- this.down_img = gdi.Image(this.images_path + "down.png");
- this.metadb_func = typeof on_metadb_changed == "function";
- this.features_init();
- this.colors_changed();
- this.font_changed();
- }
- function artreader(x, y, w, h) {
- this.draw = function(gr) {
- if (!this.img) return;
- p.draw_image(gr, this.img, this.x, this.y, this.w, this.h, this.type);
- }
- this.metadb_changed = function() {
- if (!p.metadb) return;
- this.img && this.img.Dispose();
- this.path = "";
- this.img = utils.GetAlbumArtV2(p.metadb, this.id);
- window.RepaintRect(this.x, this.y, this.w, this.h);
- utils.GetAlbumArtAsync(window.ID, p.metadb, this.id);
- }
- this.get_album_art_done = function(ip) {
- this.path = ip;
- }
- this.trace = function(x, y) {
- return (x > this.x && x < this.x + this.w && y > this.y && y < this.y + this.h);
- }
- this.wheel = function(step) {
- if (!this.trace(p.mx, p.my)) return false;
- this.id -= step;
- if (this.id < 0) this.id = 4;
- if (this.id > 4) this.id = 0;
- window.SetProperty("artreader_id", this.id);
- this.metadb_changed();
- return true;
- }
- this.move = function(x, y) {
- if (this.trace(x, y)) {
- if (this.img) p.tt("Original size: " + this.img.Width + "x" + this.img.Height + "px");
- return true;
- } else {
- p.ttd();
- return false;
- }
- }
- this.lbtn_dblclk = function(x, y) {
- if (!this.trace(x, y)) return false;
- if (this.img) p.run("explorer /select,\"" + this.path + "\"");
- return true;
- }
- this.x = x;
- this.y = y;
- this.w = w;
- this.h = h;
- this.id = window.GetProperty("artreader_id", 0);
- this.img = null;
- this.path = null;
- this.type = window.GetProperty("artreader_image_type", "top");
- }
- function buttons() {
- this.draw = function(gr) {
- for (i in this.buttons) {
- this.buttons[i].draw(gr);
- }
- }
- this.move = function(x, y) {
- this.tmp_btn = null;
- for (i in this.buttons) {
- if (this.buttons[i].trace(x, y)) this.tmp_btn = i;
- }
- if (this.btn == this.tmp_btn) return this.btn;
- if (this.tmp_btn) this.buttons[this.tmp_btn].state("hover");
- if (this.btn) this.buttons[this.btn].state("normal");
- this.btn = this.tmp_btn;
- return this.btn;
- }
- this.lbtn_up = function(x, y) {
- if (!this.btn) return false;
- this.buttons[this.btn].lbtn_up(x, y);
- return true;
- }
- this.leave = function() {
- if (this.btn) this.buttons[this.btn].state("normal");
- this.btn = null;
- }
- this.buttons = [];
- this.btn = null;
- }
- function button(x, y, w, h, img_src, func, tiptext, themed) {
- this.draw = function (gr) {
- if (this.themed) {
- p.themed_button.SetPartAndStateId(1, this.id);
- p.themed_button.DrawThemeBackground(gr, this.x, this.y, this.w, this.h);
- this.img && p.draw_image(gr, this.img, this.x + Math.round((this.w - this.img.Width) / 2), this.y + Math.round((this.h - this.img.Height) / 2), this.img.Width, this.img.Height, "adjust");
- } else {
- this.img && p.draw_image(gr, this.img, this.x, this.y, this.w, this.h, "adjust");
- }
- }
- this.trace = function(x, y) {
- return (x > this.x && x < this.x + this.w && y > this.y && y < this.y + this.h);
- }
- this.lbtn_up = function () {
- this.func && this.func(x, y);
- }
- this.state = function(s) {
- if (s == "hover") {
- this.img = this.img_hover;
- this.id = 2;
- p.tt(this.tiptext);
- } else {
- this.img = this.img_normal;
- this.id = 0;
- p.ttd();
- }
- window.RepaintRect(this.x, this.y, this.w, this.h);
- }
- this.x = x;
- this.y = y;
- this.w = w;
- this.h = h;
- this.func = func;
- this.tiptext = tiptext;
- this.themed = themed;
- this.id = 0;
- this.img_normal = gdi.Image(p.images_path + img_src.normal);
- this.img_hover = img_src.hover ? gdi.Image(p.images_path + img_src.hover) : this.img_normal;
- this.img = this.img_normal;
- }
- function cd(x, y, w, h) {
- this.draw = function(gr) {
- if (this.shadow) p.draw_image(gr, this.shadow_img, this.x, this.y, this.w, this.h, "adjust");
- p.draw_image(gr, this.case_img, this.x, this.y, this.w, this.h, "adjust");
- if (this.img) {
- this.ratio = Math.min(this.w / this.case_img.Width, this.h / this.case_img.Height);
- this.nw = 488 * this.ratio;
- this.nh = 476 * this.ratio;
- this.nx = Math.round((this.w - (452 * this.ratio)) / 2);
- this.ny = Math.round((this.h - this.nh) / 2);
- p.draw_image(gr, this.img, this.nx + this.x, this.ny + this.y, this.nw, this.nh, "top");
- }
- p.draw_image(gr, this.semi_img, this.x, this.y, this.w, this.h, "adjust");
- if (this.gloss) p.draw_image(gr, this.gloss_img, this.x, this.y, this.w, this.h, "adjust");
- }
- this.metadb_changed = function() {
- if (!p.metadb) return;
- this.img && this.img.Dispose();
- this.path = "";
- this.img = utils.GetAlbumArtV2(p.metadb, 0);
- window.Repaint();
- utils.GetAlbumArtAsync(window.ID, p.metadb, 0);
- }
- this.get_album_art_done = function(ip) {;
- this.path = ip;
- }
- this.trace = function(x, y) {
- return (x > this.x && x < this.x + this.w && y > this.y && y < this.y + this.h);
- }
- this.move = function(x, y) {
- if (this.trace(x, y)) {
- if (this.img) p.tt("Original size: " + this.img.Width + "x" + this.img.Height + "px");
- return true;
- } else {
- p.ttd();
- return false;
- }
- }
- this.lbtn_dblclk = function(x, y) {
- if (!this.trace(x, y)) return false;
- if (this.img) p.run("explorer /select,\"" + this.path + "\"");
- return true;
- }
- this.x = x;
- this.y = y;
- this.w = w;
- this.h = h;
- this.shadow_img = gdi.Image(p.images_path + "shadow.png");
- this.case_img = gdi.Image(p.images_path + "case.png");
- this.semi_img = gdi.Image(p.images_path + "semi.png");
- this.gloss_img = gdi.Image(p.images_path + "gloss.png");
- this.gloss = window.GetProperty("cd_gloss", false);
- this.shadow = window.GetProperty("cd_shadow", false);
- this.img = null;
- this.path = null;
- }
- function images(x, y, w, h) {
- this.playback_time = function(time) {
- if (this.mode == "last.fm" && time == 1 && this.files.length == 0 && p.metadb.RawPath == fb.GetNowPlaying().RawPath && ((this.auto_download == "library" && fb.IsMetadbInMediaLibrary(p.metadb)) || this.auto_download == "on")) this.download();
- if (this.cycle > 0 && this.images.length > 1 && time % this.cycle == 0) {
- this.index++;
- if (this.index == this.images.length) this.index = 0;
- window.RepaintRect(this.x, this.y, this.w, this.h);
- }
- }
- this.draw = function (gr) {
- if (this.images.length == 0) return;
- p.draw_image(gr, this.images[this.index], this.x, this.y, this.w, this.h, this.type);
- }
- this.metadb_changed = function() {
- if (!p.metadb) return false;
- switch(this.mode) {
- case "last.fm":
- p.artist = p.eval(p.artist_tf);
- if (this.artist == p.artist) return false;
- this.artist = p.artist;
- //this.folder = p.data_folder + p.clean_filename(p.artist);
- //if (!p.fso.FolderExists(this.folder)) p.fso.CreateFolder(this.folder);
- break;
- case "custom":
- this.temp_folder = p.eval(this.custom_folder_tf);
- if (this.temp_folder == this.folder) return false;
- this.folder = this.temp_folder;
- break;
- }
- this.update();
- return true;
- }
- this.trace = function(x, y) {
- return (x > this.x && x < this.x + this.w && y > this.y && y < this.y + this.h);
- }
- this.wheel = function(step) {
- if (!p.metadb || this.images.length < 2 || !this.trace(p.mx, p.my) || (typeof th == "object" && th.mode == "grid" && !th.overlay)) return false;
- this.index -= step;
- if (this.index < 0) this.index = this.images.length - 1;
- if (this.index >= this.images.length) this.index = 0;
- window.RepaintRect(this.x, this.y, this.w, this.h);
- return true;
- }
- this.lbtn_dblclk = function(x, y) {
- if (!this.trace(x, y)) return false;
- p.run("\"" + this.files[this.index] + "\"");
- return true;
- }
- //LAST.FM RADIO--------------------------------------------------------------------------------------------------
- //open simmilar artist
- this.downloadLFM = function()
- {
- //if (!p.fso.FolderExists(this.folder)) return;
- {
- if (auto_yt=="1")
- {
- if (p.artist.indexOf("3dydfy://")== 0 | p.artist.indexOf("www.youtube.com/")== 0 | p.artist.indexOf("youtube.com/")== 0 | p.artist.indexOf("http://www.youtube.com/")== 0 | p.artist.indexOf("3dydfy://www.youtube.com:80/")== 0 | p.artist.indexOf("www.youtube.com:80/")== 0 | p.artist.indexOf("youtube.com:80/")== 0 | p.artist.indexOf("http://www.youtube.com:80/")== 0)
- { var randomnumber=Math.floor(Math.random()*18)
- var a=randomnumber;
- this.working=true;
- if (START_ARTIST == "" || START_ARTIST == "?") return;
- //var folder = this.folder + "\\";
- if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
- this.xmlhttp.open("GET", "http://www.last.fm/music/" + START_ARTIST + "/+similar"+ "?page=" + a, true);
- this.xmlhttp.send();
- this.xmlhttp.onreadystatechange = function() {
- if (im.xmlhttp.readyState == 4) {
- if (im.xmlhttp.status == 200) {
- var text = im.xmlhttp.responsetext;
- if (!im.doc) im.doc = new ActiveXObject("htmlfile");
- im.doc.open();
- var div = im.doc.createElement("div");
- div.innerHTML = text;
- var data = div.getElementsByTagName("a");
- var urls = [];
- for (i = 0; i < data.length; i++) {
- if (data[i].href.indexOf("about:/music/") == 0) urls.push(data[i].href.replace(/about:\//,"").replace("music/","").replace("/_/"," - ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("free-music-downloads","").replace("/+similar?page=2","").replace("/+events","").replace("/+wiki","").replace("-+","").replace("/+albums","").replace("/+tags","").replace("/+images","").replace("/journal","").replace("/charts","").replace("/images","").replace("/listeners","").replace("/similar?page=17","").replace("/news","").replace("/groups","").replace("/albums","").replace("/videos","").replace("/tracks","").replace("/similar","").replace("/tags","").replace("noredirect/","").replace("listeners/+tracks","").replace("videos/+tracks","").replace("/+videos/","").replace("?page=1","").replace("?page=8","").replace("?page=5","").replace("?page=7","").replace("?page=9","").replace("?page=8","").replace("0","").replace("6","").replace("4","").replace("3","").replace("2","").replace("1","").replace("5","").replace("9","").replace("7","").replace("%20"," ").replace("%E2%80%99","").replace("%7","").replace(" wiki/edit","").replace("/ similar","").replace("%","").replace("C%","").replace("%","").replace("%C2%B4","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("C%","").replace("C%","").replace("C%","").replace("C%","").replace("C%","").replace("C%","").replace("%5D","").replace("%5D","").replace("%5D","").replace("%5D","").replace("%5D","").replace("%C3%","").replace("%C3%","").replace("%C3%","").replace("%C3%","").replace("%C3%","").replace("%C3%","").replace("%C3%B3","ó").replace("%C3%B3","ó").replace("%C3%B3","ó").replace("%C3%B3","ó").replace("%C3%B3","ó").replace("%C2%B4","'").replace("%C2%B4","'").replace("%C2%B4","'").replace("%C2%B4","'").replace("%C2%B4","'").replace("%C2%B4","'").replace("%C2%B4","'").replace("?page=","'").replace("/ charts","'"));
- }
- //select random URL
- var randomnumber = Math.floor(Math.random()*(20-50)+50);
- do{
- randomnumber = Math.floor(Math.random()*(20-50)+50);
- } while(randomnumber%2!=1);
- i=randomnumber;
- //select all url
- //for (i = 0; i < urls.length; i++)
- {
- //do something with urls[i]
- p.console("" + urls[i]);
- last_fm = window.SetProperty("YT Similar", urls[i]);
- last_fm = urls[i];
- window.SetProperty("YT Similar", urls[i]);
- //var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath;
- //p.run(tmppath+"\\foobar2000.exe /immediate /add "+"\ " + urls[i] + "\"");
- }
- //open YT in playlist
- //var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath;
- //p.run(tmppath+"\\foobar2000.exe /immediate /add "+"\""+urls[i] + "\"");
- //fb.RunMainMenuCommand("File/Add Youtube URL(s)...") + ("/immediate /add "+"\""+ urls[i]);
- im.doc.close();
- im.working=false;
- im.downloadTRACK();
- im.update();
- window.NotifyOthers("images", "update");
- } else {
- p.console("HTTP error: " + im.xmlhttp.status);
- }
- }
- }
- }
- }}
- }
- //Open track
- this.downloadTRACK = function()
- {
- //if (!p.fso.FolderExists(this.folder)) return;
- //if (server==ooo) return true;
- //else
- {
- {
- {var randomnumber=Math.floor(Math.random()*18)
- var a=randomnumber;
- this.working=true;
- if (last_fm == "" || last_fm == "?") return;
- //var folder = this.folder + "\\";
- if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
- this.xmlhttp.open("GET", "http://www.last.fm/music/" + last_fm + "/+tracks" + "?page=" + a, true);
- this.xmlhttp.send();
- this.xmlhttp.onreadystatechange = function() {
- if (im.xmlhttp.readyState == 4) {
- if (im.xmlhttp.status == 200) {
- var text = im.xmlhttp.responsetext;
- if (!im.doc) im.doc = new ActiveXObject("htmlfile");
- im.doc.open();
- var div = im.doc.createElement("td");
- div.innerHTML = text;
- var data = div.getElementsByTagName("a");
- var urls = [];
- for (i = 0; i < data.length; i++) {
- if (data[i].href.indexOf("about:/music/") == 0) urls.push(data[i].href.replace(/about:\//,"").replace("music/","").replace("/_/"," - ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("free-music-downloads","").replace("/+similar?page=2","").replace("/+events","").replace("/+wiki","").replace("-+","").replace("/+albums","").replace("/+tags","").replace("/+images","").replace("/journal","").replace("/charts","").replace("/images","").replace("/listeners","").replace("/similar?page=17","").replace("/news","").replace("/groups","").replace("/albums","").replace("/videos","").replace("/tracks","").replace("/similar","").replace("/tags","").replace("noredirect/","").replace("listeners/+tracks","").replace("videos/+tracks","").replace("?page=1","").replace("/+videos/","").replace("?page=2","").replace("+Video","").replace("?page=1","").replace("?page=8","").replace("?page=5","").replace("?page=7","").replace("?page=9","").replace("?page=8","").replace("0/","/").replace("6/","/").replace("4/","/").replace("3/","/").replace("2/","/").replace("5/","").replace("9/","/").replace("%20"," ").replace("%E2%80%99","").replace("%7","").replace("%27","'").replace("text=%22","").replace("%22","").replace("%22 song_spot=%22M%22 MediaBaseId=%221091514%22 itunesTrackId=%220%22 amgTrackId=%220%22 amgArtistId=%220%22 TAID=%223521%22 TPID=%222497707%22 cartcutId=%220776526001%22","").replace("%5B","").replace("%27%5D","").replace("%C2%B4","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("C%","").replace("C%","").replace("C%","").replace("C%","").replace("C%","").replace("C%","").replace("%5D","").replace("%5D","").replace("%5D","").replace("%5D","").replace("%5D","").replace("%C3%","").replace("%C3%","").replace("%C3%","").replace("%C3%","").replace("%C3%","").replace("%C3%","").replace("%C3%B3","ó").replace("%C3%B3","ó").replace("%C3%B3","ó").replace("%C3%B3","ó").replace("%C3%B3","ó").replace("%C2%B4","'").replace("%C2%B4","'").replace("%C2%B4","'").replace("%C2%B4","'").replace("%C2%B4","'").replace("%C2%B4","'").replace("%C2%B4","'").replace("/ tracks","").replace("%3C002%3E -","").replace("%3C002%3E","").replace("%EF%BD%88%EF%BD%95%EF%BD%8D%EF%BD%81%EF%BD%8E%E3%80%80%EF%BD%87%EF%BD%81%EF%BD%94%EF%BD%85","").replace("%2520"," ").replace("%2520"," ").replace("%2520"," ").replace("%2520"," ").replace("%2520"," ").replace("%2520"," ").replace("%2520","").replace("%2520"," ").replace("%2520"," ").replace("%2520"," ").replace("%3C3","").replace("%D1%81%D0%B0%D0%BD0%B0%D1%8F %D0%B0%D0%BA%D1%82%D1%83%D0%B0%D0%BB%D1%8D0%BD%D0%B0%D1%8F %D0%BA%D0%BB%D1%83%D0%B1%D0%BD%D0%B0%D1%8F %D0%BD1%83%D0%B7%D1%8B%D0%BA%D0%B0 %D0%B7%D0%B0%D1%85%D0%BE%D0%B4%D0%B8 %D0%BA %D0%BD%D0%B0%D0%BC vk.com%2Fclubmusictlt",""));
- }
- //select random URL
- var randomnumber = Math.floor(Math.random()*(20-119)+119);
- do{
- randomnumber = Math.floor(Math.random()*(20-119)+119);
- } while(randomnumber%2!=1);
- i=randomnumber;
- {
- //do something with urls[i]
- p.console("" + urls[i]);
- //var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath;
- //p.run(tmppath+"\\foobar2000.exe /immediate /add "+"\ " + urls[i] + "\"");
- ooo2 = window.SetProperty("YT Track", urls[i]);
- ooo2 = urls[i];
- window.SetProperty("YT Track", urls[i]);
- }
- //open YT in playlist
- //var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath;
- //p.run(tmppath+"\\foobar2000.exe /immediate /add "+"\""+urls[i] + "\"");
- //fb.RunMainMenuCommand("File/Add Youtube URL(s)...") + ("/immediate /add "+"\""+ urls[i]);
- im.doc.close();
- im.working=false;
- im.downloadYT();
- im.update();
- window.NotifyOthers("images", "update");
- } else {
- p.console("HTTP error: " + im.xmlhttp.status);
- im.downloadLFM1();
- }
- }
- }
- }
- }}}
- //open Youtube
- this.downloadYT = function()
- {
- //if (!p.fso.FolderExists(this.folder)) return;
- {
- //if (server=="last.fm")
- {
- //if (p.artist.indexOf("3dydfy://")== 0)
- {
- this.working=true;
- if (ooo2 == "" || ooo2 == "?") return;
- //var folder = this.folder + "\\";
- if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
- this.xmlhttp.open("GET", "http://www.youtube.com/results?search_query=" + ooo2, true);
- this.xmlhttp.send();
- this.xmlhttp.onreadystatechange = function() {
- if (im.xmlhttp.readyState == 4) {
- if (im.xmlhttp.status == 200) {
- var text = im.xmlhttp.responsetext;
- if (!im.doc) im.doc = new ActiveXObject("htmlfile");
- im.doc.open();
- var div = im.doc.createElement("li");
- div.innerHTML = text;
- var data = div.getElementsByTagName("a");
- var urls = [];
- for (i = 0; i < data.length; i++) {
- if (data[i].href.indexOf("about:/watch?v=") == 0) urls.push("http://www.youtube.com/" + data[i].href.replace(/about:\//,""));
- }
- //select random URL
- //var randomnumber = Math.floor(Math.random()*Math.max(urls.length-1))+1;
- //i=randomnumber;
- i = 1;
- {
- //do something with urls[i]
- p.console("" + urls[i]);
- if (ooo2 > "")
- var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath;
- p.run(tmppath+"\\foobar2000.exe /add "+"\ " + urls[i] + "\"");
- }
- //open YT in playlist
- //var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath;
- //p.run(tmppath+"\\foobar2000.exe /immediate /add "+"\""+urls[i] + "\"");
- //fb.RunMainMenuCommand("File/Add Youtube URL(s)...") + ("/immediate /add "+"\""+ urls[i]);
- im.doc.close();
- im.working=false;
- im.update();
- window.NotifyOthers("images", "update");
- } else {
- p.console("HTTP error: " + im.xmlhttp.status);
- }
- }
- }
- }
- }}}
- //LAST.FM RADIO(One)--------------------------------------------------------------------------------------------------
- //open simmilar artist
- this.downloadLFM1 = function()
- {
- //if (!p.fso.FolderExists(this.folder)) return;
- {
- {
- //if (p.artist.indexOf("3dydfy://")== 0 | p.artist.indexOf("www.youtube.com/")== 0 | p.artist.indexOf("youtube.com/")== 0 | p.artist.indexOf("http://www.youtube.com/")== 0 | p.artist.indexOf("3dydfy://www.youtube.com:80/")== 0 | p.artist.indexOf("www.youtube.com:80/")== 0 | p.artist.indexOf("youtube.com:80/")== 0 | p.artist.indexOf("http://www.youtube.com:80/")== 0)
- { var randomnumber=Math.floor(Math.random()*18)
- var a=randomnumber;
- this.working=true;
- if (START_ARTIST == "" || START_ARTIST == "?") return;
- //var folder = this.folder + "\\";
- if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
- this.xmlhttp.open("GET", "http://www.last.fm/music/" + START_ARTIST + "/+similar"+ "?page=" + a, true);
- this.xmlhttp.send();
- this.xmlhttp.onreadystatechange = function() {
- if (im.xmlhttp.readyState == 4) {
- if (im.xmlhttp.status == 200) {
- var text = im.xmlhttp.responsetext;
- if (!im.doc) im.doc = new ActiveXObject("htmlfile");
- im.doc.open();
- var div = im.doc.createElement("div");
- div.innerHTML = text;
- var data = div.getElementsByTagName("a");
- var urls = [];
- for (i = 0; i < data.length; i++) {
- if (data[i].href.indexOf("about:/music/") == 0) urls.push(data[i].href.replace(/about:\//,"").replace("music/","").replace("/_/"," - ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("free-music-downloads","").replace("/+similar?page=2","").replace("/+events","").replace("/+wiki","").replace("-+","").replace("/+albums","").replace("/+tags","").replace("/+images","").replace("/journal","").replace("/charts","").replace("/images","").replace("/listeners","").replace("/similar?page=17","").replace("/news","").replace("/groups","").replace("/albums","").replace("/videos","").replace("/tracks","").replace("/similar","").replace("/tags","").replace("noredirect/","").replace("listeners/+tracks","").replace("videos/+tracks","").replace("/+videos/","").replace("?page=1","").replace("?page=8","").replace("?page=5","").replace("?page=7","").replace("?page=9","").replace("?page=8","").replace("0","").replace("6","").replace("4","").replace("3","").replace("2","").replace("1","").replace("5","").replace("9","").replace("7","").replace("%20"," ").replace("%E2%80%99","").replace("%7","").replace(" wiki/edit","").replace("/ similar","").replace("%","").replace("C%","").replace("%","").replace("%C2%B4","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("C%","").replace("C%","").replace("C%","").replace("C%","").replace("C%","").replace("C%","").replace("%5D","").replace("%5D","").replace("%5D","").replace("%5D","").replace("%5D","").replace("%C3%","").replace("%C3%","").replace("%C3%","").replace("%C3%","").replace("%C3%","").replace("%C3%","").replace("%C3%B3","ó").replace("%C3%B3","ó").replace("%C3%B3","ó").replace("%C3%B3","ó").replace("%C3%B3","ó").replace("%C2%B4","'").replace("%C2%B4","'").replace("%C2%B4","'").replace("%C2%B4","'").replace("%C2%B4","'").replace("%C2%B4","'").replace("%C2%B4","'").replace("?page=","'").replace("/ charts","'"));
- }
- //select random URL
- var randomnumber = Math.floor(Math.random()*(20-50)+50);
- do{
- randomnumber = Math.floor(Math.random()*(20-50)+50);
- } while(randomnumber%2!=1);
- i=randomnumber;
- //select all url
- //for (i = 0; i < urls.length; i++)
- {
- //do something with urls[i]
- p.console("" + urls[i]);
- last_fm = window.SetProperty("YT Similar", urls[i]);
- last_fm = urls[i];
- window.SetProperty("YT Similar", urls[i]);
- //var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath;
- //p.run(tmppath+"\\foobar2000.exe /immediate /add "+"\ " + urls[i] + "\"");
- }
- //open YT in playlist
- //var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath;
- //p.run(tmppath+"\\foobar2000.exe /immediate /add "+"\""+urls[i] + "\"");
- //fb.RunMainMenuCommand("File/Add Youtube URL(s)...") + ("/immediate /add "+"\""+ urls[i]);
- im.doc.close();
- im.working=false;
- im.downloadTRACK();
- im.update();
- window.NotifyOthers("images", "update");
- } else {
- p.console("HTTP error: " + im.xmlhttp.status);
- }
- }
- }
- }
- }}
- }
- //Open track
- this.downloadTRACK = function()
- {
- //if (!p.fso.FolderExists(this.folder)) return;
- //if (server==ooo) return true;
- //else
- {
- {
- {var randomnumber=Math.floor(Math.random()*18)
- var a=randomnumber;
- this.working=true;
- if (last_fm == "" || last_fm == "?") return;
- //var folder = this.folder + "\\";
- if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
- this.xmlhttp.open("GET", "http://www.last.fm/music/" + last_fm + "/+tracks" + "?page=" + a, true);
- this.xmlhttp.send();
- this.xmlhttp.onreadystatechange = function() {
- if (im.xmlhttp.readyState == 4) {
- if (im.xmlhttp.status == 200) {
- var text = im.xmlhttp.responsetext;
- if (!im.doc) im.doc = new ActiveXObject("htmlfile");
- im.doc.open();
- var div = im.doc.createElement("td");
- div.innerHTML = text;
- var data = div.getElementsByTagName("a");
- var urls = [];
- for (i = 0; i < data.length; i++) {
- if (data[i].href.indexOf("about:/music/") == 0) urls.push(data[i].href.replace(/about:\//,"").replace("music/","").replace("/_/"," - ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("free-music-downloads","").replace("/+similar?page=2","").replace("/+events","").replace("/+wiki","").replace("-+","").replace("/+albums","").replace("/+tags","").replace("/+images","").replace("/journal","").replace("/charts","").replace("/images","").replace("/listeners","").replace("/similar?page=17","").replace("/news","").replace("/groups","").replace("/albums","").replace("/videos","").replace("/tracks","").replace("/similar","").replace("/tags","").replace("noredirect/","").replace("listeners/+tracks","").replace("videos/+tracks","").replace("?page=1","").replace("/+videos/","").replace("?page=2","").replace("+Video","").replace("?page=1","").replace("?page=8","").replace("?page=5","").replace("?page=7","").replace("?page=9","").replace("?page=8","").replace("0/","/").replace("6/","/").replace("4/","/").replace("3/","/").replace("2/","/").replace("5/","").replace("9/","/").replace("%20"," ").replace("%E2%80%99","").replace("%7","").replace("%27","'").replace("text=%22","").replace("%22","").replace("%22 song_spot=%22M%22 MediaBaseId=%221091514%22 itunesTrackId=%220%22 amgTrackId=%220%22 amgArtistId=%220%22 TAID=%223521%22 TPID=%222497707%22 cartcutId=%220776526001%22","").replace("%5B","").replace("%27%5D","").replace("%C2%B4","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("C%","").replace("C%","").replace("C%","").replace("C%","").replace("C%","").replace("C%","").replace("%5D","").replace("%5D","").replace("%5D","").replace("%5D","").replace("%5D","").replace("%C3%","").replace("%C3%","").replace("%C3%","").replace("%C3%","").replace("%C3%","").replace("%C3%","").replace("%C3%B3","ó").replace("%C3%B3","ó").replace("%C3%B3","ó").replace("%C3%B3","ó").replace("%C3%B3","ó").replace("%C2%B4","'").replace("%C2%B4","'").replace("%C2%B4","'").replace("%C2%B4","'").replace("%C2%B4","'").replace("%C2%B4","'").replace("%C2%B4","'").replace("/ tracks","").replace("%3C002%3E -","").replace("%3C002%3E","").replace("%EF%BD%88%EF%BD%95%EF%BD%8D%EF%BD%81%EF%BD%8E%E3%80%80%EF%BD%87%EF%BD%81%EF%BD%94%EF%BD%85","").replace("%2520"," ").replace("%2520"," ").replace("%2520"," ").replace("%2520"," ").replace("%2520"," ").replace("%2520"," ").replace("%2520","").replace("%2520"," ").replace("%2520"," ").replace("%2520"," ").replace("%3C3","").replace("%D1%81%D0%B0%D0%BD0%B0%D1%8F %D0%B0%D0%BA%D1%82%D1%83%D0%B0%D0%BB%D1%8D0%BD%D0%B0%D1%8F %D0%BA%D0%BB%D1%83%D0%B1%D0%BD%D0%B0%D1%8F %D0%BD1%83%D0%B7%D1%8B%D0%BA%D0%B0 %D0%B7%D0%B0%D1%85%D0%BE%D0%B4%D0%B8 %D0%BA %D0%BD%D0%B0%D0%BC vk.com%2Fclubmusictlt",""));
- }
- //select random URL
- var randomnumber = Math.floor(Math.random()*(20-119)+119);
- do{
- randomnumber = Math.floor(Math.random()*(20-119)+119);
- } while(randomnumber%2!=1);
- i=randomnumber;
- {
- //do something with urls[i]
- p.console("" + urls[i]);
- //var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath;
- //p.run(tmppath+"\\foobar2000.exe /immediate /add "+"\ " + urls[i] + "\"");
- ooo2 = window.SetProperty("YT Track", urls[i]);
- ooo2 = urls[i];
- window.SetProperty("YT Track", urls[i]);
- //server = window.SetProperty("Download source", "");
- //server = "";
- //window.SetProperty("Download source", "");
- }
- //open YT in playlist
- //var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath;
- //p.run(tmppath+"\\foobar2000.exe /immediate /add "+"\""+urls[i] + "\"");
- //fb.RunMainMenuCommand("File/Add Youtube URL(s)...") + ("/immediate /add "+"\""+ urls[i]);
- im.doc.close();
- im.working=false;
- im.downloadYT();
- im.update();
- window.NotifyOthers("images", "update");
- } else {
- p.console("HTTP error: " + im.xmlhttp.status);
- im.download();
- }
- }
- }
- }
- }}}
- //open Youtube
- this.downloadYT = function()
- {
- //if (!p.fso.FolderExists(this.folder)) return;
- {
- //if (server=="last.fm")
- {
- //if (p.artist.indexOf("3dydfy://")== 0)
- {
- //this.working=true;
- if (ooo2 == "" || ooo2 == "?") return;
- //var folder = this.folder + "\\";
- if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
- this.xmlhttp.open("GET", "http://www.youtube.com/results?search_query=" + ooo2, true);
- this.xmlhttp.send();
- this.xmlhttp.onreadystatechange = function() {
- if (im.xmlhttp.readyState == 4) {
- if (im.xmlhttp.status == 200) {
- var text = im.xmlhttp.responsetext;
- if (!im.doc) im.doc = new ActiveXObject("htmlfile");
- im.doc.open();
- var div = im.doc.createElement("li");
- div.innerHTML = text;
- var data = div.getElementsByTagName("a");
- var urls = [];
- for (i = 0; i < data.length; i++) {
- if (data[i].href.indexOf("about:/watch?v=") == 0) urls.push("http://www.youtube.com/" + data[i].href.replace(/about:\//,""));
- }
- //select random URL
- //var randomnumber = Math.floor(Math.random()*Math.max(urls.length-1))+1;
- //i=randomnumber;
- i = 1;
- {
- //do something with urls[i]
- p.console("" + urls[i]);
- if (ooo2 > "")
- var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath;
- p.run(tmppath+"\\foobar2000.exe /add "+"\ " + urls[i] + "\"");
- }
- //open YT in playlist
- //var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath;
- //p.run(tmppath+"\\foobar2000.exe /immediate /add "+"\""+urls[i] + "\"");
- //fb.RunMainMenuCommand("File/Add Youtube URL(s)...") + ("/immediate /add "+"\""+ urls[i]);
- im.doc.close();
- //im.working=false;
- im.update();
- window.NotifyOthers("images", "update");
- } else {
- p.console("HTTP error: " + im.xmlhttp.status);
- }
- }
- }
- }
- }}}
- //YT--------------------------------------------------------------------------------
- this.download = function()
- {
- //if (!p.fso.FolderExists(this.folder)) return;
- {
- if (auto_yt=="1")
- {
- if (p.artist.indexOf("3dydfy://")== 0 | p.artist.indexOf("www.youtube.com/")== 0 | p.artist.indexOf("youtube.com/")== 0 | p.artist.indexOf("http://www.youtube.com/")== 0 | p.artist.indexOf("3dydfy://www.youtube.com:80/")== 0 | p.artist.indexOf("www.youtube.com:80/")== 0 | p.artist.indexOf("youtube.com:80/")== 0 | p.artist.indexOf("http://www.youtube.com:80/")== 0)
- {
- this.working=true;
- if (p.artist == "" || p.artist == "?") return;
- var folder = this.folder + "\\";
- if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
- this.xmlhttp.open("GET", "http://www.youtube.com/" + p.artist.replace("3dydfy://www.youtube.com/","").replace("3dydfy://youtube.com/","").replace("3dydfy://www.youtube.com:80/","").replace("www.youtube.com:80/","").replace("youtube.com:80/","").replace("http://www.youtube.com:80/","").replace("www.youtube.com/","").replace("youtube.com/","").replace("http://www.youtube.com/",""), true);
- this.xmlhttp.send();
- this.xmlhttp.onreadystatechange = function() {
- if (im.xmlhttp.readyState == 4) {
- if (im.xmlhttp.status == 200) {
- var text = im.xmlhttp.responsetext;
- if (!im.doc) im.doc = new ActiveXObject("htmlfile");
- im.doc.open();
- var div = im.doc.createElement("div");
- div.innerHTML = text;
- var data = div.getElementsByTagName("a");
- var urls = [];
- for (i = 0; i < data.length; i++) {
- if (data[i].href.indexOf("about:/watch?v=") == 0) urls.push("http://www.youtube.com/" + data[i].href.replace(/about:\//,""));
- }
- //select random URL
- var randomnumber = Math.floor(Math.random()*Math.max(urls.length-1))+1;
- i=randomnumber;
- {
- //do something with urls[i]
- p.console("" + urls[i]);
- var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath;
- p.run(tmppath+"\\foobar2000.exe /add "+"\ " + urls[i] + "\"");
- }
- im.doc.close();
- im.working=false;
- im.update();
- window.NotifyOthers("images", "update");
- } else {
- p.console("HTTP error: " + im.xmlhttp.status);
- }
- }
- }
- }
- }
- }
- }
- this.downloadALL = function()
- {
- //if (!p.fso.FolderExists(this.folder)) return;
- {
- {
- if (p.artist.indexOf("3dydfy://")== 0 | p.artist.indexOf("www.youtube.com/")== 0 | p.artist.indexOf("youtube.com/")== 0 | p.artist.indexOf("http://www.youtube.com/")== 0 | p.artist.indexOf("3dydfy://www.youtube.com:80/")== 0 | p.artist.indexOf("www.youtube.com:80/")== 0 | p.artist.indexOf("youtube.com:80/")== 0 | p.artist.indexOf("http://www.youtube.com:80/")== 0)
- {
- this.working=true;
- if (p.artist == "" || p.artist == "?") return;
- var folder = this.folder + "\\";
- if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
- this.xmlhttp.open("GET", "http://www.youtube.com/" + p.artist.replace("3dydfy://www.youtube.com/","").replace("3dydfy://youtube.com/","").replace("3dydfy://www.youtube.com:80/","").replace("www.youtube.com:80/","").replace("youtube.com:80/","").replace("http://www.youtube.com:80/","").replace("www.youtube.com/","").replace("youtube.com/","").replace("http://www.youtube.com/",""), true);
- this.xmlhttp.send();
- this.xmlhttp.onreadystatechange = function() {
- if (im.xmlhttp.readyState == 4) {
- if (im.xmlhttp.status == 200) {
- var text = im.xmlhttp.responsetext;
- if (!im.doc) im.doc = new ActiveXObject("htmlfile");
- im.doc.open();
- var div = im.doc.createElement("div");
- div.innerHTML = text;
- var data = div.getElementsByTagName("a");
- var urls = [];
- for (i = 0; i < data.length; i++) {
- if (data[i].href.indexOf("about:/watch?v=") == 0) urls.push("http://www.youtube.com/" + data[i].href.replace(/about:\//,""));
- }
- for (i = 0; i < urls.length; i++) {
- //do something with urls[i]
- p.console("" + urls[i]);
- var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath;
- p.run(tmppath+"\\foobar2000.exe /add "+"\ " + urls[i] + "\"");
- }
- im.doc.close();
- im.working=false;
- im.update();
- window.NotifyOthers("images", "update");
- } else {
- p.console("HTTP error: " + im.xmlhttp.status);
- }
- }
- }
- }
- }
- }
- }
- this.downloadONE = function()
- {
- //if (!p.fso.FolderExists(this.folder)) return;
- {
- {
- if (p.artist.indexOf("3dydfy://")== 0 | p.artist.indexOf("www.youtube.com/")== 0 | p.artist.indexOf("youtube.com/")== 0 | p.artist.indexOf("http://www.youtube.com/")== 0 | p.artist.indexOf("3dydfy://www.youtube.com:80/")== 0 | p.artist.indexOf("www.youtube.com:80/")== 0 | p.artist.indexOf("youtube.com:80/")== 0 | p.artist.indexOf("http://www.youtube.com:80/")== 0)
- {
- this.working=true;
- if (p.artist == "" || p.artist == "?") return;
- var folder = this.folder + "\\";
- if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
- this.xmlhttp.open("GET", "http://www.youtube.com/" + p.artist.replace("3dydfy://www.youtube.com/","").replace("3dydfy://youtube.com/","").replace("3dydfy://www.youtube.com:80/","").replace("www.youtube.com:80/","").replace("youtube.com:80/","").replace("http://www.youtube.com:80/","").replace("www.youtube.com/","").replace("youtube.com/","").replace("http://www.youtube.com/",""), true);
- this.xmlhttp.send();
- this.xmlhttp.onreadystatechange = function() {
- if (im.xmlhttp.readyState == 4) {
- if (im.xmlhttp.status == 200) {
- var text = im.xmlhttp.responsetext;
- if (!im.doc) im.doc = new ActiveXObject("htmlfile");
- im.doc.open();
- var div = im.doc.createElement("div");
- div.innerHTML = text;
- var data = div.getElementsByTagName("a");
- var urls = [];
- for (i = 0; i < data.length; i++) {
- if (data[i].href.indexOf("about:/watch?v=") == 0) urls.push("http://www.youtube.com/" + data[i].href.replace(/about:\//,""));
- }
- //select random URL
- var randomnumber = Math.floor(Math.random()*Math.max(urls.length-1))+1;
- i=randomnumber;
- {
- //do something with urls[i]
- p.console("" + urls[i]);
- var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath;
- p.run(tmppath+"\\foobar2000.exe /add "+"\ " + urls[i] + "\"");
- }
- im.doc.close();
- im.working=false;
- im.update();
- window.NotifyOthers("images", "update");
- } else {
- p.console("HTTP error: " + im.xmlhttp.status);
- }
- }
- }
- }
- }
- }
- }
- this.downloadART_TITLE = function()
- {
- {
- {
- {
- this.working=true;
- p.artist = p.eval("%artist% %title%");
- if (p.artist == "" || p.artist == "?") return;
- var folder = this.folder + "\\";
- if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
- this.xmlhttp.open("GET", "http://www.youtube.com/results?search_query=" + encodeURIComponent(p.artist), true);
- this.xmlhttp.send();
- this.xmlhttp.onreadystatechange = function() {
- if (im.xmlhttp.readyState == 4) {
- if (im.xmlhttp.status == 200) {
- var text = im.xmlhttp.responsetext;
- if (!im.doc) im.doc = new ActiveXObject("htmlfile");
- im.doc.open();
- var div = im.doc.createElement("li");
- div.innerHTML = text;
- var data = div.getElementsByTagName("a");
- var urls = [];
- for (i = 0; i < data.length; i++) {
- if (data[i].href.indexOf("about:/watch?v=") == 0) urls.push("http://www.youtube.com/" + data[i].href.replace(/about:\//,""));
- }
- //select random URL
- //var randomnumber = Math.floor(Math.random()*Math.max(urls.length-1))+1;
- //i=randomnumber;
- //i = Math.min(urls.length-38);
- i=1;
- {
- //do something with urls[i]
- p.console("" + urls[i]);
- var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath;
- p.run(tmppath+"\\foobar2000.exe /add "+"\ " + urls[i] + "\"");
- }
- //open YT in playlist
- //var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath;
- //p.run(tmppath+"\\foobar2000.exe /immediate /add "+"\""+urls[i] + "\"");
- //fb.RunMainMenuCommand("File/Add Youtube URL(s)...") + ("/immediate /add "+"\""+ urls[i]);
- im.doc.close();
- im.working=false;
- im.update();
- window.NotifyOthers("images", "update");
- } else {
- p.console("HTTP error: " + im.xmlhttp.status);
- }
- }
- }
- }
- }}}
- this.downloadART = function()
- {
- {
- {
- {
- this.working=true;
- p.artist = p.eval("%artist%");
- if (p.artist == "" || p.artist == "?") return;
- var folder = this.folder + "\\";
- if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
- this.xmlhttp.open("GET", "http://www.youtube.com/results?search_query=" + encodeURIComponent(p.artist), true);
- this.xmlhttp.send();
- this.xmlhttp.onreadystatechange = function() {
- if (im.xmlhttp.readyState == 4) {
- if (im.xmlhttp.status == 200) {
- var text = im.xmlhttp.responsetext;
- if (!im.doc) im.doc = new ActiveXObject("htmlfile");
- im.doc.open();
- var div = im.doc.createElement("li");
- div.innerHTML = text;
- var data = div.getElementsByTagName("a");
- var urls = [];
- for (i = 0; i < data.length; i++) {
- if (data[i].href.indexOf("about:/watch?v=") == 0) urls.push("http://www.youtube.com/" + data[i].href.replace(/about:\//,""));
- }
- //select random URL
- var randomnumber = Math.floor(Math.random()*Math.max(urls.length-1))+1;
- i=randomnumber;
- //i = Math.min(urls.length-38);
- {
- //do something with urls[i]
- p.console("HTTP: " + urls[i]);
- var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath;
- p.run(tmppath+"\\foobar2000.exe /add "+"\ " + urls[i] + "\"");
- }
- //open YT in playlist
- //var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath;
- //p.run(tmppath+"\\foobar2000.exe /immediate /add "+"\""+urls[i] + "\"");
- //fb.RunMainMenuCommand("File/Add Youtube URL(s)...") + ("/immediate /add "+"\""+ urls[i]);
- im.doc.close();
- im.working=false;
- im.update();
- window.NotifyOthers("images", "update");
- } else {
- p.console("HTTP error: " + im.xmlhttp.status);
- }
- }
- }
- }
- }
- }}
- this.update0 = function() {
- this.index = 0;
- for (i = 0; i < this.images.length; i++) {
- try { this.images[i].Dispose(); } catch(e) {}
- }
- this.folders = this.folder.split("|");
- this.files = [];
- for (i = 0; i < this.folders.length; i++) {
- if (p.fso.FolderExists(this.folders[i])) this.files = this.files.concat(utils.Glob(this.folders[i] + "\\" + p.clean_filename(p.artist) + "_0" + "*.jpg").toArray(), utils.Glob(this.folders[i] + "\\" + p.clean_filename(p.artist) + "_0" + "*.jpeg").toArray(), utils.Glob(this.folders[i] + "\\" + p.clean_filename(p.artist) + "_0" + "*.png").toArray(), utils.Glob(this.folders[i] + "\\" + p.clean_filename(p.artist) + "_0" + "*.gif").toArray());
- }
- this.images = [];
- for (i = 0; i < this.files.length; i++) {
- this.images[i] = gdi.Image(this.files[i]);
- }
- if (typeof th == "object") {
- th.nc = true;
- th.calc();
- }
- window.Repaint();
- }
- this.update = function() {
- this.index = 0;
- for (i = 0; i < this.images.length; i++) {
- try { this.images[i].Dispose(); } catch(e) {}
- }
- this.folders = this.folder.split("|");
- this.files = [];
- for (i = 0; i < this.folders.length; i++) {
- if (p.fso.FolderExists(this.folders[i])) this.files = this.files.concat(utils.Glob(this.folders[i] + "\\*.jpg").toArray(), utils.Glob(this.folders[i] + "\\*.jpeg").toArray(), utils.Glob(this.folders[i] + "\\*.png").toArray(), utils.Glob(this.folders[i] + "\\*.gif").toArray());
- }
- this.images = [];
- for (i = 0; i < this.files.length; i++) {
- this.images[i] = gdi.Image(this.files[i]);
- }
- if (typeof th == "object") {
- th.nc = true;
- th.calc();
- }
- window.Repaint();
- }
- this.delete_image = function() {
- if (!this.app) this.app = new ActiveXObject("Shell.Application");
- this.app.Namespace(10).MoveHere(this.files[this.index]);
- window.SetTimeout(function() {
- im.update();
- window.NotifyOthers("images", "update");
- }, 100);
- }
- this.x = x;
- this.y = y;
- this.w = w;
- this.h = h;
- this.files = [];
- this.images = [];
- this.index = 0;
- this.artist = "";
- this.folder = "";
- this.limit = 0;
- //this.cycle = window.GetProperty("image_cycle", 0);
- this.mode = ("last.fm");
- //window.GetProperty("image_mode", "last.fm");
- this.type = "adjust";
- this.auto_download = "off";
- this.custom_folder_tf = "$directory_path(%path%)";
- }
- function lastfm() {
- this.notify_data = function(name, data) {
- if (name == "lastfm" && data == "update") {
- this.username = p.open(this.username_file).trim();
- this.sk = p.open(this.sk_file).trim();
- if (p.check_feature("lastfm_charts")) li.update();
- if (typeof ps == "object") {
- ps.loved_working = false;
- ps.playcount_working = false;
- b.update();
- on_item_focus_change();
- }
- if (p.check_feature("lastfm")) {
- li.artist = "";
- on_item_focus_change();
- }
- if (p.check_feature("lastfm_album")) {
- t.artist = "";
- t.album = "";
- on_item_focus_change();
- }
- window.Repaint();
- }
- }
- this.post = function(method, metadb) {
- if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
- switch(method) {
- case "auth.getMobileSession":
- var func = function() {
- var json_data = p.json_parse(l.xmlhttp.responsetext);
- if (!json_data) return;
- if (json_data.error) {
- p.MsgBox(json_data.message, 0, p.name);
- } else if (json_data.session) {
- p.save(json_data.session.key, l.sk_file);
- window.NotifyOthers("lastfm", "update");
- l.notify_data("lastfm", "update");
- }
- }
- this.authToken = hex_md5(this.username + hex_md5(this.password));
- this.api_sig = hex_md5("api_key" + this.api_key + "authToken" + this.authToken + "method" + method + "username" + this.username + this.secret);
- this.data = "method=" + method + "&api_key=" + this.api_key + "&api_sig=" + this.api_sig + "&format=json&authToken=" + this.authToken + "&username=" + this.username;
- break;
- case "track.love":
- case "track.unlove":
- var func = function() {
- var json_data = p.json_parse(l.xmlhttp.responsetext);
- if (!json_data) return;
- if (json_data.error) {
- p.console(json_data.message);
- } else if (json_data.status && json_data.status == "ok") {
- p.console("Track " + (method == "track.love" ? "loved successfully." : "unloved successfully."));
- fb.RunContextCommandWithMetadb("Customdb Love " + (method == "track.love" ? 1 : 0), metadb, 8);
- }
- }
- if (!metadb || this.username.length == 0 || this.sk.length != 32) return;
- this.artist = fb.TitleFormat(p.artist_tf).EvalWithMetadb(metadb);
- this.track = fb.TitleFormat("%title%").EvalWithMetadb(metadb);
- if (this.artist == "" || this.artist == "?" || this.track == "?") return;
- p.console("Attempting to " + (method == "track.love" ? "love \"" : "unlove \"") + this.track + "\" by \"" + this.artist + "\"");
- p.console("Contacting Last.fm....");
- this.api_sig = hex_md5("api_key" + this.api_key + "artist" + this.artist + "method" + method + "sk" + this.sk + "track" + this.track + this.secret);
- this.data = "method=" + method + "&api_key=" + this.api_key + "&api_sig=" + this.api_sig + "&format=json&sk=" + this.sk + "&artist=" + encodeURIComponent(this.artist) + "&track=" + encodeURIComponent(this.track);
- break;
- default:
- return;
- }
- this.xmlhttp.open("POST", "https://ws.audioscrobbler.com/2.0/", true);
- this.xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
- this.xmlhttp.setRequestHeader("User-Agent", this.user_agent);
- this.xmlhttp.send(this.data);
- this.xmlhttp.onreadystatechange = function() {
- if (l.xmlhttp.readyState == 4) {
- if (l.xmlhttp.status == 200) {
- func();
- } else {
- p.console(l.xmlhttp.responsetext || "HTTP error: " + l.xmlhttp.status);
- }
- }
- }
- }
- this.update_username = function() {
- var old_username = this.username;
- this.username = p.InputBox("Enter your Last.fm username.", p.name, this.username);
- if (this.username.length > 0 && this.username != old_username) p.save("", this.sk_file);
- p.save(this.username, this.username_file);
- window.NotifyOthers("lastfm", "update");
- this.notify_data("lastfm", "update");
- }
- this.update_password = function() {
- this.password = p.InputBox("Enter your Last.fm password\n\nThis is only required to love/unlove tracks.", p.name, "");
- if (this.password.length > 0) {
- this.sk = "";
- p.save(this.sk, this.sk_file);
- window.NotifyOthers("lastfm", "update");
- this.notify_data("lastfm", "update");
- this.post("auth.getMobileSession");
- }
- }
- this.get_url = function() {
- return "http://ws.audioscrobbler.com/2.0/?format=json&api_key=" + this.api_key + "&user=" + this.username + "&username=" + this.username + "&s=" + Math.random();
- }
- this.username_error = "Use the right click menu to set your Last.fm username.";
- this.password_error = "Use the right click menu to set your Last.fm password.";
- this.url = "http://www.last.fm/";
- this.api_key = "56d9e050cc2d6b36102c8b4a5fe6152d";
- this.secret = "9f1f4346ce3ba206390074ff8cb4c6ce";
- this.user_agent = "foobar2000_wsh_panel_mod_scripts";
- this.username_file = p.settings_folder + "username";
- this.username = p.open(this.username_file).trim();
- this.sk_file = p.settings_folder + "sk";
- this.sk = p.open(this.sk_file).trim();
- this.auto_correct = window.GetProperty("lastfm_auto_correct", true);
- }
- function list(x, y, w, h) {
- this.size = function() {
- this.row_height = this.mode == "echonest" ? 90 : 20;
- this.rows = Math.floor((this.h - (this.mode == "echonest" ? 50 : 30)) / this.row_height);
- this.index = 0;
- this.offset = 0;
- switch(true) {
- case this.mode == "lastfm_charts":
- this.text_width = Math.round(this.w / 3);
- this.lastfm_charts_bar_x = this.text_width + 30;
- break;
- case this.mode == "musicbrainz" && this.musicbrainz_mode == "releases":
- this.text_width = this.w - 120;
- break;
- default:
- this.text_width = this.w - 50;
- break;
- }
- this.but_x = this.x + Math.round((this.w - 15) / 2);
- this.up_btn = new sb(this.but_x, this.y, 15, 15, p.up_img, "li.offset > 0", function() { li.wheel(1); });
- this.down_btn = new sb(this.but_x, this.y + this.h - 15, 15, 15, p.down_img, "li.offset < li.items - li.rows", function() { li.wheel(-1); });
- }
- this.draw = function(gr) {
- switch(this.mode) {
- case "discogs":
- for (i = 0; i < Math.min(this.items, this.rows); i++) {
- p.left_text(gr, this.names[i + this.offset], p.list_font, p.textcolour, this.x + this.text_x, this.y + 15 + (i * this.row_height), this.text_width, 20);
- p.right_text(gr, this.dates[i + this.offset], p.list_font, p.textcolour_hl, this.x, this.y + 15 + (i * this.row_height), this.w, 20);
- }
- break;
- case "lastfm_charts":
- var max_bar_width = (this.w - this.lastfm_charts_bar_x - 40) / this.playcounts[0];
- for (i = 0; i < Math.min(this.items, this.rows); i++) {
- p.right_text(gr, this.ranks[i + this.offset] + ".", p.list_font, p.textcolour_hl, this.x, this.y + 15 + (i * this.row_height), 17, 20);
- var bar_width = max_bar_width * this.playcounts[i + this.offset];
- var bar_colour = p.splitRGB(this.lastfm_charts_bar_colour);
- gr.FillSolidRect(this.lastfm_charts_bar_x + this.x, this.y + 16 + (i * this.row_height), bar_width, 18, bar_colour);
- p.left_text(gr, this.playcounts[i + this.offset].addCommas(), p.list_font, p.textcolour, this.x + 5 + this.lastfm_charts_bar_x + bar_width, this.y + 15 + (i * this.row_height), 50, 20);
- p.left_text(gr, this.names[i + this.offset], p.list_font, p.textcolour, this.x + this.text_x, this.y + 15 + (i * this.row_height), this.text_width, 20);
- }
- break;
- case "lastfm":
- for (i = 0; i < Math.min(this.items, this.rows); i++) {
- if (this.lastfm_mode == 0) p.draw_image(gr, this.lastfm_button == "spotify" ? this.lastfm_spotify_img : this.autoplaylist_img, this.x, this.y + 16 + (i * this.row_height), 16, 16, "adjust");
- if (this.lastfm_mode == 1 || this.lastfm_mode == 3 || this.lastfm_mode == 4) p.draw_image(gr, this.autoplaylist_img, this.x, this.y + 16 + (i * this.row_height), 16, 16, "adjust");
- p.left_text(gr, this.names[i + this.offset], p.list_font, p.textcolour, this.x + this.text_x, this.y + 15 + (i * this.row_height), this.text_width, 20);
- }
- break;
- case "musicbrainz":
- for (i = 0; i < Math.min(this.items, this.rows); i++) {
- if (this.musicbrainz_mode == "URLs") p.draw_image(gr, this.musicbrainz_images[this.images[i + this.offset]], this.x, this.y + 16 + (i * this.row_height), 16, 16, "adjust");
- if (this.musicbrainz_mode == "releases") {
- p.draw_image(gr, this.autoplaylist_img, this.x, this.y + 16 + (i * this.row_height), 16, 16, "adjust");
- if (this.musicbrainz_show_release_type) p.right_text(gr, this.release_types[i + this.offset], p.list_font, p.textcolour, this.x, this.y + 15 + (i * this.row_height), this.w - 30, 20);
- p.right_text(gr, this.dates[i + this.offset], p.list_font, p.textcolour_hl, this.x, this.y + 15 + (i * this.row_height), this.w, 20);
- }
- p.left_text(gr, this.names[i + this.offset], p.list_font, p.textcolour, this.x + this.text_x, this.y + 15 + (i * this.row_height), this.text_width, 20);
- }
- break;
- case "autoplaylists":
- for (i = 0; i < Math.min(this.items, this.rows); i++) {
- p.left_text(gr, this.names[i + this.offset], p.list_font, p.textcolour, this.x, this.y + 15 + (i * this.row_height), this.text_width, 20);
- if (!this.autoplaylists_editing && this.autoplaylists_hover && this.index == i + this.offset) {
- p.draw_image(gr, this.autoplaylists_edit_img, this.x + this.w - 40, this.y + 16 + (i * this.row_height), 16, 16, "adjust");
- p.draw_image(gr, this.autoplaylists_del_img, this.x + this.w - 20, this.y + 16 + (i * this.row_height), 16, 16, "adjust");
- }
- }
- break;
- case "echonest":
- for (i = 0; i < Math.min(this.items, this.rows); i++) {
- p.left_text(gr, this.names[i + this.offset], p.title_font, p.textcolour_hl, this.x, this.y + 15 + (i * this.row_height), this.w - 110, 24);
- p.right_text(gr, this.dates[i + this.offset], p.title_font, p.textcolour_hl, this.x, this.y + 15 + (i * this.row_height), this.w, 24);
- gr.GdiDrawText(this.summaries[i + this.offset], p.normal_font, p.textcolour, this.x, this.y + 37 + (i * this.row_height), this.w, p.normal_font.Height * Math.floor(64 / p.normal_font.Height), DT_WORDBREAK | DT_CALCRECT | DT_NOPREFIX);
- }
- break;
- }
- this.up_btn.draw(gr);
- this.down_btn.draw(gr);
- if (this.show_timestamp) p.left_text(gr, this.date, p.list_font, p.textcolour_hl, this.x, this.y + this.h - 15, this.w, 15);
- }
- this.metadb_changed = function() {
- p.artist = p.eval(p.artist_tf);
- if (this.artist == p.artist) return false;
- this.artist = p.artist;
- this.folder = p.data_folder + p.artist_tf;
- //if (!p.fso.FolderExists(this.folder)) p.fso.CreateFolder(this.folder);
- this.update();
- return true;
- }
- this.trace = function(x, y) {
- return (x > this.x && x < this.x + this.w && y > this.y && y < this.y + this.h);
- }
- this.wheel = function(step) {
- if (!this.trace(p.mx, p.my)) return false;
- if (this.items > this.rows) {
- this.offset -= step * (this.mode == "echonest" ? 1 : 3);
- if (this.offset < 0) this.offset = 0;
- if (this.rows + this.offset > this.items) this.offset = this.items - this.rows;
- window.RepaintRect(this.x, this.y, this.w, this.h);
- }
- return true;
- }
- this.move = function(x, y) {
- this.index = Math.floor((y - this.y - 15) / this.row_height) + this.offset;
- this.in_range = this.index >= this.offset && this.index < this.offset + Math.min(this.rows, this.items);
- switch(true) {
- case !this.trace(x, y):
- case this.mode == "autoplaylists" && this.autoplaylists_editing:
- case this.mode == "lastfm" && l.username.length == 0:
- window.SetCursor(IDC_ARROW);
- this.leave();
- return false;
- case this.up_btn.trace(x, y):
- case this.down_btn.trace(x, y):
- window.SetCursor(IDC_HAND);
- break;
- case !this.in_range:
- window.SetCursor(IDC_ARROW);
- this.leave();
- break;
- case this.mode == "musicbrainz" && this.musicbrainz_mode == "releases" && x > this.x && x < this.x + 20:
- case this.mode == "lastfm" && this.text_x == 20 && x > this.x && x < this.x + 20:
- window.SetCursor(IDC_HAND);
- switch(true) {
- case this.lastfm_mode == 0 && this.lastfm_button == "spotify":
- p.tt('spotify:search:"' + this.names[this.index].replace(/\s+/g, "+") + '"');
- break;
- default:
- p.tt("Autoplaylist: " + this.queries[this.index]);
- break;
- }
- break;
- case this.mode == "autoplaylists":
- switch(true) {
- case x > this.x && x < this.x + Math.min(this.names_widths[this.index], this.text_width):
- window.SetCursor(IDC_HAND);
- p.tt('Run "' + this.names[this.index] + '"');
- break;
- case x > this.x + this.w - 40 && x < this.x + this.w - 20:
- window.SetCursor(IDC_HAND);
- p.tt('Edit "' + this.names[this.index] + '"');
- break;
- case x > this.x + this.w - 20 && x < this.x + this.w:
- window.SetCursor(IDC_HAND);
- p.tt('Delete "' + this.names[this.index] + '"');
- break;
- default:
- window.SetCursor(IDC_ARROW);
- this.leave();
- break;
- }
- this.autoplaylists_hover = true;
- window.RepaintRect(this.x + this.w - 40, this.y + 15, 40, Math.min(this.rows, this.items) * this.row_height);
- break;
- case this.mode == "echonest":
- case x > this.x + this.text_x && x < this.x + this.text_x + Math.min(this.names_widths[this.index], this.text_width):
- window.SetCursor(IDC_HAND);
- p.tt(this.urls[this.index]);
- break;
- default:
- window.SetCursor(IDC_ARROW);
- p.ttd();
- break;
- }
- return true;
- }
- this.lbtn_up = function(x, y) {
- switch(true) {
- case !this.trace(x, y):
- return false;
- case this.mode == "autoplaylists" && this.autoplaylists_editing:
- case this.mode == "lastfm" && l.username.length == 0:
- case this.up_btn.lbtn_up(x, y):
- case this.down_btn.lbtn_up(x, y):
- case !this.in_range:
- break;
- case this.mode == "musicbrainz" && this.musicbrainz_mode == "releases" && x > this.x && x < this.x + 20:
- case this.mode == "lastfm" && this.text_x == 20 && x > this.x && x < this.x + 20:
- switch(true) {
- case this.lastfm_mode == 0 && this.lastfm_button == "spotify":
- if (p.run('spotify:search:"' + this.names[this.index].replace(/\s+/g, "+") + '"')) {
- if (fb.IsPlaying && !fb.IsPaused && this.lastfm_pause) fb.Pause();
- } else {
- p.MsgBox("Unable to launch Spotify.", 0, p.name);
- }
- break;
- default:
- fb.CreateAutoPlaylist(fb.PlaylistCount, this.names[this.index], this.queries[this.index]);
- fb.ActivePlaylist = fb.PlaylistCount - 1;
- break;
- }
- break;
- case this.mode == "autoplaylists":
- switch(true) {
- case x > this.x && x < this.x + Math.min(this.names_widths[this.index], this.text_width):
- this.autoplaylists_run(this.names[this.index], this.queries[this.index], this.sorts[this.index], this.forced[this.index]);
- break;
- case x > this.x + this.w - 40 && x < this.x + this.w - 20:
- this.autoplaylists_edit(x, y);
- break;
- case x > this.x + this.w - 20 && x < this.x + this.w:
- this.autoplaylists_delete();
- break
- }
- break;
- case this.mode == "echonest":
- case x > this.x + this.text_x && x < this.x + this.text_x + Math.min(this.names_widths[this.index], this.text_width):
- p.browser(this.urls[this.index]);
- break;
- }
- return true;
- }
- this.leave = function() {
- p.ttd();
- if (this.mode != "autoplaylists") return;
- this.autoplaylists_hover = false;
- window.RepaintRect(this.x, this.y, this.w, this.h);
- }
- this.update = function() {
- this.items = 0;
- this.offset = 0;
- this.index = 0;
- this.names = [];
- this.names_widths = [];
- this.urls = [];
- this.dates = [];
- this.queries = [];
- this.ranks = [];
- this.playcounts = [];
- this.sorts = [];
- this.summaries = [];
- this.release_types = [];
- this.images = [];
- this.forced = [];
- this.data = [];
- this.file = null;
- this.date = "";
- var temp_bmp = gdi.CreateImage(1, 1);
- var temp_gr = temp_bmp.GetGraphics();
- switch(this.mode) {
- case "autoplaylists":
- this.text = p.open(this.filename);
- this.data = this.text.split(/\r?\n/g);
- this.items = this.data.length;
- for (i = 0; i < this.items; i++) {
- var temp = this.data[i].split("¬");
- this.names[i] = temp[0];
- this.queries[i] = temp[1];
- this.sorts[i] = temp[2];
- this.forced[i] = temp[3];
- this.names_widths[i] = temp_gr.CalcTextWidth(this.names[i], p.list_font);
- }
- break;
- case "lastfm":
- this.text_x = 20;
- this.filename = this.folder + "\\" + this.lastfm_methods[this.lastfm_mode] + ".json";
- if (p.fso.fileExists(this.filename)) {
- this.file = p.fso.Getfile(this.filename);
- this.json_text = p.open(this.filename);
- this.json_data = p.json_parse(this.json_text);
- if (this.json_data) {
- switch(true) {
- case this.json_data.error > 0:
- p.console(this.json_data.message);
- break;
- case this.lastfm_mode == 0 && this.json_data.similarartists && typeof this.json_data.similarartists.artist == "object":
- this.data = this.json_data.similarartists.artist;
- break;
- case this.lastfm_mode == 1 && this.json_data.toptags && typeof this.json_data.toptags.tag == "object":
- this.data = this.json_data.toptags.tag;
- break;
- case this.lastfm_mode == 2 && this.json_data.topfans && typeof this.json_data.topfans.user == "object":
- this.text_x = 0;
- this.data = this.json_data.topfans.user;
- break;
- case this.lastfm_mode == 3 && this.json_data.topalbums && typeof this.json_data.topalbums.album == "object":
- this.data = this.json_data.topalbums.album;
- break;
- case this.lastfm_mode == 4 && this.json_data.toptracks && typeof this.json_data.toptracks.track == "object":
- this.data = this.json_data.toptracks.track;
- break;
- }
- this.items = this.data.length;
- for (i = 0; i < this.items; i++) {
- this.names[i] = this.data[i].name;
- this.urls[i] = this.data[i].url;
- this.names_widths[i] = temp_gr.CalcTextWidth(this.names[i], p.list_font);
- if (this.lastfm_mode == 0) this.queries[i] = "artist HAS " + this.names[i];
- if (this.lastfm_mode == 1) this.queries[i] = "genre HAS " + this.names[i];
- if (this.lastfm_mode == 3) this.queries[i] = "album HAS " + this.names[i] + " OR title HAS " + this.names[i];
- if (this.lastfm_mode == 4) this.queries[i] = "title HAS " + this.names[i];
- }
- }
- if (Date.parse(Date()) - Date.parse(this.file.DateLastModified) > ONE_DAY) this.get();
- } else {
- this.get();
- }
- break;
- case "lastfm_charts":
- this.filename = this.folder + "\\" + l.username + "_" + this.lastfm_charts_modes[this.lastfm_charts_mode] + "_" + this.lastfm_charts_periods[this.lastfm_charts_period] + ".json";
- if (p.fso.fileExists(this.filename)) {
- this.file = p.fso.Getfile(this.filename);
- this.json_text = p.open(this.filename);
- this.json_data = p.json_parse(this.json_text);
- if (this.json_data) {
- switch(true) {
- case this.json_data.error > 0:
- p.console(this.json_data.message);
- break;
- case this.lastfm_charts_mode == 0 && this.json_data.topartists && typeof this.json_data.topartists.artist == "object":
- this.data = this.json_data.topartists.artist;
- break;
- case this.lastfm_charts_mode == 1 && this.json_data.topalbums && typeof this.json_data.topalbums.album == "object":
- this.data = this.json_data.topalbums.album;
- break;
- case this.lastfm_charts_mode == 2 && this.json_data.toptracks && typeof this.json_data.toptracks.track == "object":
- this.data = this.json_data.toptracks.track;
- break;
- }
- this.items = this.data.length;
- for (i = 0; i < this.items; i++) {
- this.names[i] = this.lastfm_charts_mode != 0 ? this.data[i].artist.name + " - " + this.data[i].name : this.data[i].name;
- this.ranks[i] = (i > 0 && this.data[i].playcount == this.data[i - 1].playcount) ? this.ranks[i - 1] : this.data[i]["@attr"].rank;
- this.urls[i] = this.data[i].url;
- this.names_widths[i] = temp_gr.CalcTextWidth(this.names[i], p.list_font);
- this.playcounts[i] = this.data[i].playcount;
- }
- }
- if (Date.parse(Date()) - Date.parse(this.file.DateLastModified) > ONE_DAY) this.get();
- } else {
- this.get();
- }
- break;
- case "discogs":
- this.filename = this.folder + "\\discogs.json";
- if (p.fso.fileExists(this.filename)) {
- this.file = p.fso.Getfile(this.filename);
- this.json_text = p.open(this.filename);
- this.json_data = p.json_parse(this.json_text);
- if (this.json_data && this.json_data.results) {
- this.data = this.json_reverse_sort(this.json_data.results, "year");
- var swap_artist = fb.TitleFormat("$swapprefix($lower(" + p.artist + ")) - ").Eval(true);
- for (i = 0; i < this.data.length; i++) {
- var temp_artist = this.data[i].title.replace(/\s{2,}/g,' ');
- if (this.discogs_match && temp_artist.toLowerCase().indexOf(swap_artist) != 0) continue;
- this.dates.push(this.data[i].year || "");
- this.urls.push("http://www.discogs.com" + this.data[i].uri);
- this.names.push(temp_artist);
- this.names_widths.push(temp_gr.CalcTextWidth(temp_artist, p.list_font));
- }
- this.items = this.names.length;
- }
- if (Date.parse(Date()) - Date.parse(this.file.DateLastModified) > ONE_DAY) this.get();
- } else {
- this.get();
- }
- break;
- case "musicbrainz":
- this.filename = this.folder + "\\musicbrainz_" + this.musicbrainz_mode + ".json";
- if (p.fso.fileExists(this.filename)) {
- this.file = p.fso.Getfile(this.filename);
- this.json_text = p.open(this.filename);
- this.json_data = p.json_parse(this.json_text);
- if (this.json_data) {
- switch(this.musicbrainz_mode) {
- case "releases":
- this.data = this.json_data["release-groups"] || [];
- this.data = this.json_reverse_sort(this.data, "first-release-date");
- var primary, secondary, name;
- for (i = 0; i < this.data.length; i++) {
- primary = this.data[i]["primary-type"];
- secondary = this.data[i]["secondary-types"].join("").toLowerCase();
- switch(true) {
- case !this.musicbrainz_remix && secondary.indexOf("remix") > -1:
- case !this.musicbrainz_compilation && secondary.indexOf("compilation") > -1:
- case !this.musicbrainz_live && secondary.indexOf("live") > -1:
- break;
- case this.musicbrainz_single && primary == "Single":
- case this.musicbrainz_ep && primary == "EP":
- case this.musicbrainz_album && primary == "Album":
- name = this.data[i].title;
- this.dates.push(this.data[i]["first-release-date"].substring(0,4));
- this.names.push(name);
- this.urls.push("http://musicbrainz.org/release-group/" + this.data[i].id);
- this.names_widths.push(temp_gr.CalcTextWidth(name, p.list_font));
- this.queries.push("album HAS " + name + " OR title HAS " + name);
- switch(true) {
- case secondary.indexOf("remix") > -1:
- this.release_types.push("Remix");
- break;
- case secondary.indexOf("compilation") > -1:
- this.release_types.push("Compilation");
- break;
- case secondary.indexOf("live") > -1:
- this.release_types.push("Live");
- break;
- default:
- this.release_types.push(primary);
- break;
- }
- }
- }
- this.items = this.names.length;
- break;
- case "URLs":
- this.data = this.json_data.relations || [];
- this.items = this.data.length;
- for (i = 0; i < this.items; i++) {
- this.urls[i] = this.data[i].url.resource;
- this.images[i] = "";
- if (this.data[i].type == "official homepage") {
- this.images[i] = "home";
- } else {
- for (name in this.musicbrainz_images) {
- if (this.urls[i].indexOf(name) > -1) {
- this.images[i] = name;
- break;
- }
- }
- if (this.images[i].length == 0) this.images[i] = "external";
- }
- this.names[i] = decodeURIComponent(this.urls[i]);
- this.names_widths[i] = temp_gr.CalcTextWidth(this.names[i], p.list_font);
- }
- break;
- }
- }
- if (Date.parse(Date()) - Date.parse(this.file.DateLastModified) > ONE_DAY) this.get();
- } else {
- this.get();
- }
- break;
- case "echonest":
- this.filename = this.folder + "\\echonest_" + this.echonest_modes[this.echonest_mode] + ".json";
- if (p.fso.fileExists(this.filename)) {
- this.file = p.fso.Getfile(this.filename);
- this.json_text = p.open(this.filename);
- this.json_data = p.json_parse(this.json_text);
- if (this.json_data && this.json_data.response && this.json_data.response.status && this.json_data.response.status.code == 0) {
- this.data = this.json_data.response[this.echonest_modes[this.echonest_mode]] || [];
- this.items = this.data.length;
- for (i = 0; i < this.items; i++) {
- this.names[i] = p.strip_tags(this.data[i].name);
- this.urls[i] = (this.data[i].url || "").replace(/\\/g, "");
- this.temp_date = (this.data[i].date_posted || this.data[i].date_reviewed || this.data[i].date_found || "").substring(0, 10);
- this.dates[i] = this.temp_date.substring(8,10) + "-" + this.temp_date.substring(5,7) + "-" + this.temp_date.substring(0,4);
- this.summaries[i] = p.strip_tags(this.data[i].summary);
- }
- }
- if (Date.parse(Date()) - Date.parse(this.file.DateLastModified) > ONE_DAY) this.get();
- } else {
- this.get();
- }
- break;
- }
- temp_bmp.ReleaseGraphics(temp_gr);
- temp_bmp.Dispose();
- temp_gr = null;
- temp_bmp = null;
- if (this.file) {
- var temp_date = new Date(this.file.DateLastModified);
- this.date = "Updated: " + temp_date.toLocaleTimeString() + ", " + temp_date.toLocaleDateString();
- }
- window.Repaint();
- }
- this.get = function() {
- var fn = this.filename;
- var func = function() {
- if (!p.save(li.xmlhttp.responsetext, fn)) return;
- li.update();
- }
- var url = "";
- var user_agent = "";
- switch(this.mode) {
- case "discogs":
- if (this.artist == "" || this.artist == "?") return;
- url = "http://api.discogs.com/database/search?per_page=100&type=master&artist=" + encodeURIComponent(this.artist);
- user_agent = "foobar2000_wsh_panel_mod_discogs +http://www.hydrogenaudio.org/forums/index.php?showuser=19379";
- break;
- case "lastfm_charts":
- if (l.username.length == 0) return(p.console(l.username_error));
- url = l.get_url() + "&method=user." + this.lastfm_charts_methods[this.lastfm_charts_mode] + "&period=" + this.lastfm_charts_periods[this.lastfm_charts_period];
- user_agent = l.user_agent;
- break;
- case "lastfm":
- if (this.artist == "" || this.artist == "?") return;
- if (l.username.length == 0) return(p.console(l.username_error));
- url = l.get_url() + "&method=" + this.lastfm_methods[this.lastfm_mode] + "&artist=" + encodeURIComponent(this.artist) + "&autocorrect=" + (l.auto_correct ? 1 : 0);
- user_agent = l.user_agent;
- break;
- case "musicbrainz":
- user_agent = "foobar2000_wsh_panel_mod_musicbrainz +http://www.hydrogenaudio.org/forums/index.php?showuser=19379";
- var fn1 = this.folder + "\\MUSICBRAINZ_ARTISTID.txt";
- this.musicbrainz_id = p.eval("$if3(%musicbrainz_artistid%,%musicbrainz artist id%,)");
- this.musicbrainz_id = this.musicbrainz_id.substring(0, 36);
- if (this.musicbrainz_id.length == 0) this.musicbrainz_id = p.open(fn1);
- if (this.musicbrainz_id.length == 0) {
- if (this.artist == "" || this.artist == "?") return;
- url = "https://musicbrainz.org/ws/2/artist/?query=artist:" + encodeURIComponent(this.artist.toLowerCase()) + "&fmt=json";
- var func = function() {
- var json_data = p.json_parse(li.xmlhttp.responsetext);
- if (!json_data) return;
- var artist = li.artist.toLowerCase();
- var artists = json_data.artist || [];
- for (i = 0; i < artists.length; i++) {
- if (artist == artists[i].name.toLowerCase()) {
- if (!p.save(artists[i].id, fn1)) return;
- li.get();
- break;
- }
- }
- }
- } else {
- if (this.musicbrainz_mode == "releases") url = "https://musicbrainz.org/ws/2/release-group?artist=" + this.musicbrainz_id + "&limit=100&offset=0&fmt=json";
- else url = "https://musicbrainz.org/ws/2/artist/" + this.musicbrainz_id + "?inc=url-rels&fmt=json";
- }
- break;
- case "echonest":
- if (this.artist == "" || this.artist == "?") return;
- url = "http://developer.echonest.com/api/v4/artist/" + this.echonest_modes[this.echonest_mode] + "/?name=" + encodeURIComponent(this.artist) + "&api_key=EKWS4ESQLKN3G2ZWV";
- break;
- }
- if (url.length == 0) return;
- this.xmlhttp.open("GET", url, true);
- if (user_agent.length > 0) this.xmlhttp.setRequestHeader('User-Agent', user_agent);
- this.xmlhttp.send();
- this.xmlhttp.onreadystatechange = function() {
- if (li.xmlhttp.readyState == 4) {
- if (li.xmlhttp.status == 200) {
- func();
- } else {
- p.console(li.xmlhttp.responsetext || "HTTP error: " + li.xmlhttp.status);
- }
- }
- }
- }
- this.json_reverse_sort = function(data, prop) {
- data = data.sort(function(a, b) {
- if (!a[prop] || b[prop] > a[prop]) return 1;
- if (!b[prop] || b[prop] < a[prop]) return -1;
- return 0;
- });
- return data;
- }
- this.init = function() {
- switch(true) {
- case p.check_feature("discogs"):
- this.mode = "discogs";
- this.discogs_match = window.GetProperty("discogs_match", false);
- break;
- case p.check_feature("lastfm_charts"):
- this.mode = "lastfm_charts";
- this.text_x = 20;
- this.lastfm_charts_modes = ["artist", "album", "track"];
- this.lastfm_charts_mode = window.GetProperty("lastfm_charts_mode", 0);
- this.lastfm_charts_methods = ["getTopArtists", "getTopAlbums", "getTopTracks"];
- this.lastfm_charts_periods_display = ["overall", "last 7 days", "1 month", "3 month", "6 month", "12 month"];
- this.lastfm_charts_periods = ["overall", "7day", "1month", "3month", "6month", "12month"];
- this.lastfm_charts_period = window.GetProperty("lastfm_charts_period", 0);
- this.lastfm_charts_bar_colour = window.GetProperty("lastfm_charts_bar_colour", "72-127-221");
- this.folder = p.data_folder + "charts";
- //if (!p.fso.FolderExists(this.folder)) p.fso.CreateFolder(this.folder);
- break;
- case p.check_feature("lastfm"):
- this.mode = "lastfm";
- this.lastfm_methods = ["artist.getSimilar", "artist.getTopTags", "artist.getTopFans", "artist.getTopAlbums", "artist.getTopTracks"];
- this.lastfm_modes = ["similar artists", "top tags", "top fans", "top albums", "top tracks"];
- this.lastfm_mode = window.GetProperty("lastfm_mode", 0);
- this.lastfm_button = window.GetProperty("lastfm_button", "spotify");
- this.lastfm_pause = window.GetProperty("lastfm_pause", true);
- this.lastfm_spotify_img = gdi.Image(p.images_path + "spotify.png");
- break;
- case p.check_feature("musicbrainz"):
- this.mode = "musicbrainz";
- this.text_x = 20;
- this.musicbrainz_images = {
- "viaf.org": gdi.Image(p.images_path + "viaf_small.png"),
- "allmusic.com": gdi.Image(p.images_path + "allmusic_small.png"),
- "external": gdi.Image(p.images_path + "external_small.png"),
- "bbc.co.uk": gdi.Image(p.images_path + "bbc_small.png"),
- "facebook.com": gdi.Image(p.images_path + "facebook_small.png"),
- "home": gdi.Image(p.images_path + "home_small.png"),
- "last.fm": gdi.Image(p.images_path + "lastfm_small.png"),
- "twitter.com": gdi.Image(p.images_path + "twitter_small.png"),
- "soundcloud.com": gdi.Image(p.images_path + "soundcloud_small.png"),
- "wikipedia.org": gdi.Image(p.images_path + "wikipedia_small.png"),
- "discogs.com": gdi.Image(p.images_path + "discogs_small.png"),
- "myspace.com": gdi.Image(p.images_path + "myspace_small.png"),
- "youtube.com": gdi.Image(p.images_path + "youtube_small.png"),
- "imdb.com": gdi.Image(p.images_path + "imdb_small.png"),
- "plus.google.com": gdi.Image(p.images_path + "google_plus_small.png"),
- "lyrics.wikia.com": gdi.Image(p.images_path + "lyrics_wikia_small.png"),
- "flickr.com": gdi.Image(p.images_path + "flickr_small.png"),
- "secondhandsongs.com": gdi.Image(p.images_path + "secondhandsongs_small.png"),
- "vimeo.com": gdi.Image(p.images_path + "vimeo_small.png"),
- "rateyourmusic.com": gdi.Image(p.images_path + "rateyourmusic_small.png"),
- "instagram.com": gdi.Image(p.images_path + "instagram_small.png"),
- "tumblr.com": gdi.Image(p.images_path + "tumblr_small.png"),
- "decoda.com": gdi.Image(p.images_path + "decoda_small.png"),
- "wikidata.org": gdi.Image(p.images_path + "wikidata_small.png")
- }
- this.musicbrainz_mode = window.GetProperty("musicbrainz_mode", "releases");
- this.musicbrainz_show_release_type = window.GetProperty("musicbrainz_show_release_type", true);
- this.musicbrainz_live = window.GetProperty("musicbrainz_live", false);
- this.musicbrainz_ep = window.GetProperty("musicbrainz_ep", true);
- this.musicbrainz_single = window.GetProperty("musicbrainz_single", true);
- this.musicbrainz_album = window.GetProperty("musicbrainz_album", true);
- this.musicbrainz_remix = window.GetProperty("musicbrainz_remix", true);
- this.musicbrainz_compilation = window.GetProperty("musicbrainz_compilation", true);
- break;
- case p.check_feature("echonest"):
- this.mode = "echonest";
- this.echonest_modes = ["news", "reviews", "blogs"];
- this.echonest_mode = window.GetProperty("echonest_mode", 0);
- break;
- case p.check_feature("autoplaylists"):
- this.autoplaylists_add = function() {
- if (this.autoplaylists_editing) return;
- this.autoplaylists_editing = true;
- var new_name = p.InputBox("Enter a name for your autoplaylist", p.name, "");
- if (new_name == "") { this.autoplaylists_editing = false; return; }
- var new_query = p.InputBox("Enter your autoplaylist query", p.name, "");
- if (new_query == "") { this.autoplaylists_editing = false; return; }
- var new_sort = p.InputBox("Enter a sort pattern\n\n(optional)", p.name, "");
- var new_force = new_sort.length > 0 ? p.MsgBox("Force sort?", 4, p.name) : 7;
- this.data.push(new_name + "¬" + new_query + "¬" + new_sort + "¬" + new_force);
- if (this.data.length > this.rows) this.offset = this.data.length - this.rows;
- p.save(this.data.join("\n"), this.filename);
- if (this.autoplaylists_success) this.autoplaylists_run(new_name, new_query, new_sort, new_force);
- window.NotifyOthers("autoplaylists", "update");
- this.update();
- this.autoplaylists_editing = false;
- }
- this.autoplaylists_run = function(n, q, s, f) {
- if (this.autoplaylists_remove_duplicates) {
- i = 0;
- while(i < fb.PlaylistCount) {
- if (fb.GetPlaylistName(i) == n) fb.RemovePlaylist(i);
- else i++;
- }
- }
- fb.CreateAutoPlaylist(fb.PlaylistCount, n, q, s, f == 6 ? true : false);
- fb.ActivePlaylist = fb.PlaylistCount - 1;
- }
- this.autoplaylists_edit = function(x, y) {
- var _menu = window.CreatePopupMenu();
- var i = this.index;
- _menu.AppendMenuItem(MF_STRING, 1, "Rename...");
- _menu.AppendMenuItem(MF_STRING, 2, "Edit query...");
- _menu.AppendMenuItem(MF_STRING, 3, "Edit sort pattern...");
- _menu.AppendMenuItem(MF_STRING, 4, "Force Sort");
- _menu.CheckMenuItem(4, this.forced[i] == 6 ? true : false);
- this.autoplaylists_editing = true;
- this.autoplaylists_hover = false;
- window.RepaintRect(this.x + this.w - 40, this.y + 15, 40, Math.min(this.rows, this.items) * this.row_height);
- idx = _menu.TrackPopupMenu(x, y);
- switch(idx) {
- case 0:
- this.autoplaylists_editing = false;
- _menu.Dispose();
- return;
- case 1:
- var new_name = p.InputBox("Rename your autoplaylist", p.name, this.names[i]);
- if (new_name != "") this.names[i] = new_name;
- break;
- case 2:
- var new_query = p.InputBox("Enter your autoplaylist query", p.name, this.queries[i]);
- if (new_query != "") this.queries[i] = new_query;
- break;
- case 3:
- var new_sort = p.InputBox("Enter a sort pattern\n\n(optional)", p.name, this.sorts[i]);
- this.sorts[i] = new_sort;
- this.forced[i] = new_sort.length > 0 ? p.MsgBox("Force sort?", 4, p.name) : 7;
- break;
- case 4:
- this.forced[i] = this.forced[i] == 6 ? 7 : 6;
- break;
- }
- _menu.Dispose();
- var temp = this.names[i] + "¬" + this.queries[i] + "¬" + this.sorts[i] + "¬" + this.forced[i];
- if (this.data[i] != temp) {
- this.data[i] = temp;
- p.save(this.data.join("\n"), this.filename);
- if (this.autoplaylists_success) this.autoplaylists_run(this.names[i], this.queries[i], this.sorts[i], this.forced[i]);
- window.NotifyOthers("autoplaylists", "update");
- this.update();
- }
- this.autoplaylists_editing = false;
- }
- this.autoplaylists_delete = function() {
- if (this.offset > 1) this.offset--;
- this.autoplaylists_deleted_items.unshift(this.data[this.index]);
- this.data.splice(this.index, 1);
- p.save(this.data.join("\n"), this.filename);
- window.NotifyOthers("autoplaylists", "update");
- this.update();
- }
- this.mode = "autoplaylists";
- this.autoplaylists_del_img = gdi.Image(p.images_path + "cross.png");
- this.autoplaylists_edit_img = gdi.Image(p.images_path + "edit.png");
- this.autoplaylists_hover = false;
- this.autoplaylists_editing = false;
- this.autoplaylists_remove_duplicates = window.GetProperty("autoplaylists_remove_duplicates", true);
- this.autoplaylists_success = window.GetProperty("autoplaylists_success", true);
- this.autoplaylists_title = window.GetProperty("autoplaylists_title", "Autoplaylists");
- this.autoplaylists_slot = window.GetProperty("autoplaylists_slot", 1);
- this.filename = p.settings_folder + "autoplaylists" + this.autoplaylists_slot;
- this.autoplaylists_deleted_items = [];
- break;
- }
- }
- this.x = x;
- this.y = y;
- this.w = w;
- this.h = h;
- this.index = 0;
- this.offset = 0;
- this.items = 0;
- this.text = "";
- this.artist = "";
- this.url = "";
- this.text_x = 0;
- this.show_timestamp = window.GetProperty("show_timestamp", true);
- this.autoplaylist_img = gdi.Image(p.images_path + "search_small.png");
- this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
- this.init();
- }
- function playcount_sync(x, y) {
- this.playback_time = function() {
- this.time_elapsed++;
- if (this.time_elapsed == 3 && this.auto_love && fb.TitleFormat(this.auto_love_tf).Eval() == 1 && this.old_userloved == 0) {
- p.console("Automatically loving this track....");
- this.love_track();
- }
- if (this.time_elapsed == this.target_time) {
- if (!this.library || fb.IsMetadbInMediaLibrary(p.metadb)) this.sync_track();
- else p.console("Skipping... Track not in library.");
- }
- }
- this.metadb_changed = function() {
- if (!p.metadb) return false;
- this.artist = fb.TitleFormat(p.artist_tf).EvalWithMetadb(p.metadb);
- this.track = fb.TitleFormat("%title%").EvalWithMetadb(p.metadb);
- this.old_userloved = fb.TitleFormat("%LASTFM_LOVED_DB%").EvalWithMetadb(p.metadb) == 1 ? 1 : 0;
- this.old_userplaycount = fb.TitleFormat("%LASTFM_PLAYCOUNT_DB%").EvalWithMetadb(p.metadb);
- this.method = this.old_userloved == 1 ? "track.unlove" : "track.love";
- this.tooltip = (this.old_userloved == 1 ? "Unlove" : "Love") + " \"" + this.track + "\" by \"" + this.artist + "\".";
- this.crc32 = fb.TitleFormat("$crc32($lower(%artist%%title%))").EvalWithMetadb(p.metadb);
- b.update();
- return true;
- }
- this.playback_new_track = function() {
- this.auto_love_count = 0;
- this.time_elapsed = 0;
- switch(true) {
- case fb.PlaybackLength == 0:
- this.target_time = 240;
- break;
- case fb.PlaybackLength >= 30:
- this.target_time = Math.min(Math.floor(fb.PlaybackLength / 2), 240);
- break;
- default:
- this.target_time = 5;
- break;
- }
- on_item_focus_change();
- }
- this.playback_edited = function() {
- if (this.auto_love && fb.TitleFormat(this.auto_love_tf).Eval() == 1 && this.old_userloved == 0 && this.auto_love_count == 0) {
- this.auto_love_count = 1;
- p.console("Automatically loving this track....");
- this.love_track();
- }
- }
- this.tf = function(value) {
- return(value.replace(/'/g, "''").replace(/,/g, "','").replace(/\//g, "'/'").replace(/\(/g, "'('").replace(/\)/g, "')'").replace(/\[/g, "'['").replace(/\]/g, "']'"));
- }
- this.love_track = function() {
- l.post(this.method, p.metadb);
- }
- this.sync_track = function() {
- switch(true) {
- case this.loved_working || this.playcount_working:
- return;
- case !utils.CheckComponent("foo_customdb", true):
- p.console("Not contacting Last.fm. foo_customdb is missing.");
- return;
- default:
- p.console("Contacting Last.fm....");
- this.get(l.get_url() + "&method=track.getinfo&artist=" + encodeURIComponent(this.artist) + "&track=" + encodeURIComponent(this.track) + "&autocorrect=" + (l.auto_correct ? 1 : 0), function() {
- ps.update_track();
- });
- }
- }
- this.get = function(url, func) {
- if (l.username.length == 0) {
- this.loved_working = false;
- this.playcount_working = false;
- p.console(l.username_error);
- return;
- }
- this.xmlhttp.open("GET", url, true);
- this.xmlhttp.setRequestHeader('User-Agent', l.user_agent);
- this.xmlhttp.send();
- this.xmlhttp.onreadystatechange = function() {
- if (ps.xmlhttp.readyState == 4) {
- if (ps.xmlhttp.status == 200) {
- func();
- } else {
- p.console(ps.xmlhttp.responsetext || "HTTP error: " + ps.xmlhttp.status);
- }
- }
- }
- }
- this.update_track = function() {
- this.json_data = p.json_parse(ps.xmlhttp.responsetext);
- if (!this.json_data || this.json_data.error > 0 || !this.json_data.track) {
- p.console(ps.xmlhttp.responsetext);
- return;
- }
- this.userplaycount = this.json_data.track.userplaycount > 0 ? ++this.json_data.track.userplaycount : 1;
- this.userloved = this.json_data.track.userloved == 1 ? 1 : 0;
- if (fb.IsPlaying && this.time_elapsed >= this.target_time && fb.PlaybackLength > 29 && fb.PlaybackLength < 10800) {
- switch(true) {
- case this.userplaycount < this.old_userplaycount:
- p.console("Playcount returned from Last.fm is lower than current value. Not updating.");
- break;
- case this.old_userplaycount == this.userplaycount:
- p.console("No changes found. Not updating.");
- break;
- default:
- p.console("Last.fm responded ok. Attempting to update playcount...");
- fb.RunContextCommandWithMetadb("Customdb Delete Playcount", p.metadb, 8);
- if (this.old_userloved == 1) fb.RunContextCommandWithMetadb("Customdb Love 0", p.metadb, 8);
- var attempt = 0;
- while(fb.TitleFormat("%LASTFM_PLAYCOUNT_DB%").EvalWithMetadb(p.metadb) != this.userplaycount && attempt <= 3) {
- var query1 = '\"INSERT INTO quicktag(url,subsong,fieldname,value) VALUES(\\"' + this.crc32 + '\\",\\"-1\\",\\"LASTFM_PLAYCOUNT_DB\\",\\"' + this.userplaycount + '\\")\";';
- p.WshShell.Run(p.fso.GetFile(p.script_path + "sqlite3.exe").ShortPath + " " + p.fso.GetFile(fb.ProfilePath + "customdb_sqlite.db").ShortPath + " " + query1, 0, true);
- attempt++;
- }
- fb.RunContextCommandWithMetadb("Customdb Refresh", p.metadb, 8);
- if (fb.TitleFormat("%LASTFM_PLAYCOUNT_DB%").EvalWithMetadb(p.metadb) == this.userplaycount) p.console("Playcount updated successfully.");
- else p.console("Database error. Playcount not updated.");
- break;
- }
- }
- if (this.old_userloved != this.userloved) fb.RunContextCommandWithMetadb("Customdb Love " + this.userloved, p.metadb, 8);
- }
- this.start_import = function() {
- if (this.show_console) fb.ShowConsole();
- this.loved_page_errors = 0;
- this.playcount_page_errors = 0;
- ps.pages = 0;
- this.r = 1;
- this.sql = "BEGIN TRANSACTION;\n";
- this.loved_working = true;
- this.sync_loved(1);
- }
- this.sync_loved = function(page) {
- if (!this.loved_working) return(p.console("Import aborted."));
- this.page = page;
- this.get(l.get_url() + "&method=user.getlovedtracks&limit=200&page=" + this.page, function() {
- ps.update_loved();
- });
- }
- this.update_loved = function() {
- this.json_data = p.json_parse(ps.xmlhttp.responsetext);
- if (this.json_data && this.json_data.error > 0) {
- this.loved_working = false;
- p.MsgBox("There is a problem with the Last.fm web services. Please try again later.\n\n" + ps.xmlhttp.responsetext, 0, p.name);
- return;
- }
- if (this.json_data && this.json_data.lovedtracks && this.json_data.lovedtracks.track) {
- if (this.page == 1) this.pages = this.json_data.lovedtracks["@attr"].totalPages;
- for (i = 0; i < this.json_data.lovedtracks.track.length; i++) {
- var data = [];
- data[0] = this.json_data.lovedtracks.track[i].artist.name;
- data[1] = this.json_data.lovedtracks.track[i].name;
- data[2] = 1;
- if (data.length == 3) {
- p.console(this.r + ": " + data[0] + " - " + data[1]);
- var url = fb.TitleFormat("$crc32($lower(" + this.tf(data[0]) + this.tf(data[1]) + "))").Eval(true);
- this.sql += 'INSERT OR REPLACE INTO quicktag(url,subsong,fieldname,value) VALUES("' + url + '","-1","LASTFM_LOVED_DB","' + data[2] + '");' + "\n";
- this.r++;
- }
- }
- p.console("Loved tracks: completed page " + this.page + " of " + this.pages);
- } else if (this.pages > 0) {
- this.loved_page_errors++;
- }
- if (this.page < this.pages) {
- this.page++;
- this.sync_loved(this.page);
- } else {
- this.loved_working = false;
- if (this.full_import) {
- this.playcount_working = true;
- this.pages = 0;
- this.r = 1;
- this.sync_playcount(1);
- } else {
- try {
- this.sql += "COMMIT;"
- var ts = p.fso.OpenTextFile(this.sql_file, 2, true, 0);
- ts.WriteLine(this.sql);
- ts.Close();
- this.finish_import();
- } catch(e) {
- }
- if (this.loved_page_errors > 0) {
- p.console("Loved track page errors: " + this.loved_page_errors + " (200 records are lost for every page that fails.)");
- } else {
- p.console("There were no errors reported.");
- }
- }
- }
- }
- this.sync_playcount = function(page) {
- if (this.playcount_working == false) return(p.console("Import aborted."));
- this.page = page;
- this.get(l.get_url() + "&method=library.gettracks&limit=100&page=" + this.page, function() {
- ps.update_playcount();
- });
- }
- this.update_playcount = function() {
- this.json_data = p.json_parse(ps.xmlhttp.responsetext);
- if (this.json_data && this.json_data.error > 0) {
- this.playcount_working = false;
- p.MsgBox("There is a problem with the Last.fm web services. Please try again later.\n\n" + ps.xmlhttp.responsetext, 0, p.name);
- return;
- }
- if (this.json_data && this.json_data.tracks && this.json_data.tracks.track) {
- if (this.page == 1) this.pages = this.json_data.tracks["@attr"].totalPages
- for (i = 0; i < this.json_data.tracks.track.length; i++) {
- var data = [];
- data[0] = this.json_data.tracks.track[i].artist.name;
- data[1] = this.json_data.tracks.track[i].name;
- data[2] = this.json_data.tracks.track[i].playcount;
- if (data[2] == 0) {
- this.page = this.pages;
- break;
- }
- if (data.length == 3) {
- p.console(this.r + ": " + data[0] + " - " + data[1] + " " + data[2]);
- var url = fb.TitleFormat("$crc32($lower(" + this.tf(data[0]) + this.tf(data[1]) + "))").Eval(true);
- this.sql += 'INSERT OR REPLACE INTO quicktag(url,subsong,fieldname,value) VALUES("' + url + '","-1","LASTFM_PLAYCOUNT_DB","' + data[2] + '");' + "\n";
- this.r++;
- }
- }
- p.console("Playcount: completed page " + this.page + " of " + this.pages);
- } else if (this.pages > 0) {
- this.playcount_page_errors++;
- }
- if (this.page < this.pages) {
- this.page++;
- this.sync_playcount(this.page);
- } else {
- try {
- this.sql += "COMMIT;"
- var ts = p.fso.OpenTextFile(this.sql_file, 2, true, 0);
- ts.WriteLine(this.sql);
- ts.Close();
- this.finish_import();
- } catch(e) {
- }
- this.playcount_working = false;
- if (this.loved_page_errors + this.playcount_page_errors > 0) {
- p.console("Loved track page errors: " + this.loved_page_errors + " (200 records are lost for every page that fails.)");
- p.console("Playcount page errors: " + this.playcount_page_errors + " (100 records are lost for every page that fails.)");
- } else {
- p.console("There were no errors reported.");
- }
- }
- }
- this.finish_import = function() {
- try {
- var cmd_file = p.fso.GetFile(p.script_path + "lastfm_sql.cmd").ShortPath;
- var db_file = p.fso.GetFile(fb.ProfilePath + "customdb_sqlite.db").ShortPath;
- p.run(cmd_file + " " + p.fso.GetFile(p.script_path + "sqlite3.exe").ShortPath + " " + db_file + " " + p.fso.GetFile(this.sql_file).ShortPath);
- } catch(e) {
- }
- }
- this.update_button = function() {
- var exclamation = this.icon == "tango" ? "exclamation.png" : "exclamation_small.png";
- var love = this.icon == "tango" ? "love.png" : "love_small.png";
- var love_h = this.icon == "tango" ? "love_h.png" : "love_h_small.png";
- this.size = this.icon == "tango" ? 32 : 20;
- switch(true) {
- case l.username.length == 0:
- this.n = exclamation;
- this.h = exclamation;
- this.tooltip = l.username_error;
- this.func = null;
- break;
- case l.sk.length != 32:
- this.n = exclamation;
- this.h = exclamation;
- this.tooltip = l.password_error;
- this.func = null;
- break;
- case !p.metadb:
- this.n = exclamation;
- this.h = exclamation;
- this.tooltip = "No selection";
- this.func = null;
- break;
- case !utils.CheckComponent("foo_customdb", true):
- this.n = exclamation;
- this.h = exclamation;
- this.tooltip = "The foo_customdb component is not installed. Please refer to the readme.";
- this.func = null;
- break;
- default:
- this.n = this.old_userloved == 1 ? love_h : love;
- this.h = this.old_userloved == 1 ? love : love_h;
- this.func = function() { ps.love_track(); }
- break;
- }
- }
- this.x = x;
- this.y = y;
- this.loved_working = false;
- this.playcount_working = false;
- this.sql_file = p.data_folder + "lastfm.sql";
- this.page = 0;
- this.last_page = 0;
- this.auto_love = window.GetProperty("playcount_sync_auto_love", false);
- this.auto_love_tf = window.GetProperty("playcount_sync_auto_love_tf", "");
- this.icon = window.GetProperty("playcount_sync_icon", "tango");
- this.show_console = window.GetProperty("playcount_sync_show_console", true);
- this.library = window.GetProperty("playcount_sync_library", false);
- this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
- window.SetInterval(function() {
- var temp = ps.page > 1 ? ps.page - 1 : 1;
- if (ps.loved_working && ps.page == ps.last_page) {
- ps.xmlhttp.abort();
- ps.sync_loved(temp);
- } else if (ps.playcount_working && ps.page == ps.last_page) {
- ps.xmlhttp.abort();
- ps.sync_playcount(temp);
- } else {
- ps.last_page = ps.page;
- }
- }, 15000);
- }
- function rating(x, y, bs) {
- this.draw = function(gr) {
- if (!p.metadb) return;
- for (i = 1; i < 6; i++) {
- this.img = i > (this.hover ? this.lrating : this.rating) ? this.off_img : this.on_img;
- p.draw_image(gr, this.img, this.x + this.bs * (i - 1), this.y, this.bs, this.bs, "adjust");
- }
- }
- this.metadb_changed = function() {
- if (!p.metadb) return false;
- this.hover = false;
- this.rating = p.eval("$if2(%rating%,0)");
- this.tiptext = p.eval(this.tiptext_tf);
- this.lrating = this.rating;
- window.RepaintRect(this.x, this.y, this.w, this.bs);
- return true;
- }
- this.trace = function(x, y) {
- return x > this.x - this.bs && x < this.x + (this.bs * 5) && y > this.y && y < this.y + this.bs;
- }
- this.move = function(x, y) {
- if (!this.trace(x, y)) {
- if (this.hover) this.leave();
- return false;
- }
- if (p.metadb) {
- if (x > this.x) p.tt(this.tiptext);
- this.hover = true;
- this.lrating = Math.ceil((x - this.x) / this.bs);
- window.RepaintRect(this.x, this.y, this.w, this.bs);
- }
- return true;
- }
- this.lbtn_up = function(x, y) {
- if (!this.trace(x, y)) return false;
- if (this.check) {
- if (this.lrating != this.rating && this.hover == 1) fb.RunContextCommandWithMetadb("Rating/" + (this.lrating == 0 ? "<not set>" : this.lrating), p.metadb, 8);
- } else {
- p.MsgBox(this.error_text, 0, p.name);
- p.browser("http://www.foobar2000.org/components/view/foo_playcount");
- }
- return true;
- }
- this.leave = function() {
- p.ttd();
- this.hover = false;
- window.RepaintRect(this.x, this.y, this.w, this.bs);
- }
- this.x = x;
- this.y = y;
- this.bs = bs;
- this.w = this.bs * 5;
- this.hover = false;
- this.rating = null;
- this.lrating = null;
- this.img = null;
- this.off_img = gdi.Image(p.images_path + "off.png");
- this.on_img = gdi.Image(p.images_path + "on.png");
- this.check = utils.CheckComponent("foo_playcount", true);
- this.error_text = "This script requires foo_playcount.";
- this.tiptext_tf = this.check ? 'Rate "%title%" by "%artist%"' : this.error_text;
- }
- function sb(x, y, w, h, img, isVisible, func) {
- this.x = x;
- this.y = y;
- this.w = w;
- this.h = h;
- this.img = img;
- this.isVisible = new Function("return (" + isVisible + ");");
- this.func = func;
- this.draw = function(gr) {
- if (this.isVisible()) p.draw_image(gr, this.img, this.x, this.y, this.w, this.h, "adjust");
- }
- this.trace = function(x, y) {
- return(x > this.x && x < this.x + this.w && y > this.y && y < this.y + this.h && this.isVisible());
- }
- this.lbtn_up = function(x, y) {
- if (!this.trace(x, y)) return false;
- this.func && this.func(x, y);
- return true;
- }
- }
- function seekbar(x, y, w, h) {
- this.trace = function(x, y) {
- return (x > this.x && x < this.x + this.w && y > this.y - (this.drag ? 200 : 0) && y < this.y + this.h + (this.drag ? 200 : 0));
- }
- this.draw = function(gr) {
- p.draw_background(gr);
- switch(this.mode) {
- case "spectrogram":
- if (this.working) {
- p.draw_image(gr, this.hourglass_img, this.x, this.y + Math.round((this.h - 32) / 2), this.w, 32, "adjust");
- } else {
- p.draw_image(gr, this.img, this.x, this.y, this.w, this.h, "stretch");
- }
- if (fb.IsPlaying && fb.PlaybackLength > 0) {
- this.calc_pos();
- gr.FillSolidRect(this.x + this.pos - 2, this.y, 2, this.h, p.splitRGB(this.marker));
- }
- break;
- case "nyan_cat":
- if (fb.IsPlaying && fb.PlaybackLength > 0) {
- this.calc_pos();
- for (i = 0; i < this.offsets.length; i++) {
- gr.FillSolidRect(this.x - 48, this.y + this.offsets[i], this.pos + 2, this.heights[i], this.colours[i]);
- }
- p.draw_image(gr, this.cat_img[this.z], this.pos, this.y, 48, 30);
- } else {
- p.draw_image(gr, this.cat_img[0], 0, this.y, 48, 30);
- }
- break;
- }
- }
- this.playback_new_track = function() {
- if (this.mode != "spectrogram") return;
- var metadb = fb.GetNowPlaying();
- this.img && this.img.Dispose();
- this.img = null;
- try {
- this.png_filename = spectrogram_cache + "\\" + fb.TitleFormat("$crc32(%path%)").EvalWithMetadb(metadb) + this.sox_params + ".png";
- switch(true) {
- case !metadb:
- case metadb.RawPath.indexOf("file") != 0:
- p.console("Skipping... Not a valid file type.");
- break;
- case fb.PlaybackLength == 0:
- p.console("Skipping... Unknown length.");
- break;
- case fb.TitleFormat("$if($or($strcmp(%__cue_embedded%,yes),$strcmp($right(%path%,3),cue)),cue,)").EvalWithMetadb(metadb) == "cue":
- p.console("Skipping... Cannot support cuesheets.");
- break;
- case fb.TitleFormat("%subsong%").EvalWithMetadb(metadb) > 0:
- p.console("Skipping... Cannot support tracks with chapters.");
- break;
- case this.library && !fb.IsMetadbInMediaLibrary(metadb):
- p.console("Skipping... Track not in library.");
- break;
- case p.fso.FileExists(this.png_filename):
- this.img = gdi.Image(this.png_filename);
- break;
- default:
- this.working = true
- window.Repaint();
- var filename = metadb.Path;
- var length = fb.TitleFormat("%length%").EvalWithMetadb(metadb);
- var cmd = "cmd /c \"\"" + ffmpeg_exe + "\" -i \"" + filename + "\" -t " + length + " -f sox - | \"" + sox_exe + "\" -p -n " + this.sox_params + " -d " + length + " -r -o \"" + this.png_filename + "\"\"";
- //p.console(cmd);
- try { p.WshShell.Run(cmd, 0, true); } catch(e) {}
- this.working = false;
- this.img = gdi.Image(this.png_filename);
- break;
- }
- } catch(e) {
- //p.console(e);
- }
- window.Repaint();
- }
- this.playback_stop = function() {
- window.Repaint();
- }
- this.playback_seek = function() {
- this.update();
- }
- this.move = function(x, y) {
- if (this.drag) this.update();
- if (this.trace(x, y)) {
- if (fb.IsPlaying && fb.PlaybackLength > 0) {
- x -= this.x;
- this.drag_seek = x < 0 ? 0 : x > this.w ? 1 : x / this.w;
- if (x != this.old_x || y != this.old_y) {
- p.tt(p.format_time(fb.PlaybackLength * this.drag_seek));
- this.old_x = x;
- this.old_y = y;
- }
- }
- return true;
- } else {
- this.leave();
- return false;
- }
- }
- this.lbtn_down = function(x, y) {
- if (!this.trace(x, y)) return false;
- if (fb.IsPlaying && fb.PlaybackLength > 0) this.drag = true;
- return true;
- }
- this.lbtn_up = function(x, y) {
- if (!this.trace(x, y)) return false;
- if (this.drag) {
- this.drag = false;
- fb.PlaybackTime = fb.PlaybackLength * this.drag_seek;
- }
- return true;
- }
- this.leave = function() {
- this.drag = false;
- p.ttd();
- }
- this.update = function() {
- window.RepaintRect(0, this.y, p.w, this.h);
- }
- this.calc_pos = function() {
- this.pos = this.drag ? this.w * this.drag_seek : this.w * (fb.PlaybackTime / fb.PlaybackLength);
- }
- this.init = function() {
- switch(true) {
- case p.check_feature("spectrogram"):
- this.clear_images = function(period) {
- var now = Date.parse(Date());
- images = utils.Glob(spectrogram_cache + "\\*.*").toArray();
- for (i = 0; i < images.length; i++) {
- if (this.png_filename == images[i]) continue;
- var file = p.fso.Getfile(images[i]);
- var file_date = Date.parse(file.DateLastModified);
- if (now - file_date > period) {
- try {
- p.fso.DeleteFile(images[i]);
- } catch(e) {
- p.console("Could not delete " + images[i]);
- }
- }
- }
- }
- this.mode = "spectrogram";
- this.library = window.GetProperty("seekbar_library", false);
- this.marker = window.GetProperty("seekbar_marker", "240-240-240");
- this.sox_params = window.GetProperty("sox_params", "channels 1 spectrogram -Y 130").trim();
- this.working = false;
- this.img = false;
- this.hourglass_img = gdi.Image(p.images_path + "hourglass.png");
- //if (!p.fso.FolderExists(spectrogram_cache)) p.fso.CreateFolder(spectrogram_cache);
- if (fb.IsPlaying) {
- window.SetTimeout(function() {
- s.playback_new_track();
- }, 100);
- }
- break;
- case p.check_feature("nyan_cat"):
- this.mode = "nyan_cat";
- this.cat_img = [gdi.Image(p.images_path + "\\seekbar cat.png"), gdi.Image(p.images_path + "\\seekbar cat 2.png")];
- this.offsets = [2, 6, 10, 15, 20, 24];
- this.heights = [4, 4, 5, 5, 4, 4];
- this.colours = [RGB(255, 0, 0), RGB(255, 153, 0), RGB(255, 255, 0), RGB(51, 255, 0), RGB(0, 153, 255), RGB(102, 51, 255)];
- break;
- }
- }
- this.x = x;
- this.y = y;
- this.w = w;
- this.h = h;
- this.z = 0;
- this.pos = 0;
- this.drag = false;
- this.drag_seek = 0;
- this.old_x = 0;
- this.old_y = 0;
- this.init();
- this.seekbar_timer = window.SetInterval(function() {
- s.z = s.z == 0 ? 1 : 0;
- if (!fb.IsPlaying || fb.IsPaused || fb.PlaybackLength == 0) return;
- s.update();
- }, 150);
- }
- function text(x, y, w, h) {
- this.size = function() {
- this.rows = Math.floor((this.h - 36) / p.row_height);
- this.but_x = this.x + Math.round((this.w - 15) / 2);
- this.up_btn = new sb(this.but_x, this.y, 15, 15, p.up_img, "t.offset > 0", function() { t.wheel(1); });
- this.down_btn = new sb(this.but_x, this.y + this.h - 15, 15, 15, p.down_img, "t.offset < t.text_rows - t.rows", function() { t.wheel(-1); });
- this.calc();
- }
- this.draw = function(gr, colour) {
- for (i = 0; i < Math.min(this.rows, this.text_rows); i++) {
- if (this.centre) p.centre_text(gr, this.text_array[i + this.offset], this.fixed ? p.fixed_font : p.normal_font, colour || p.textcolour, this.x, 18 + this.y + (i * p.row_height), this.w, p.row_height);
- else p.left_text(gr, this.text_array[i + this.offset], this.fixed ? p.fixed_font : p.normal_font, colour || p.textcolour, this.x, 18 + this.y + (i * p.row_height), this.w, p.row_height);
- }
- this.up_btn.draw(gr);
- this.down_btn.draw(gr);
- }
- this.metadb_changed = function() {
- if (!p.metadb) return false;
- switch(this.mode) {
- case "simple_tag":
- this.temp_filename = p.metadb.Path;
- if (this.filename == this.temp_filename) return false;
- this.filename = this.temp_filename;
- this.text = p.eval(this.tag);
- break;
- case "simple_text":
- this.temp_filename = p.eval(this.filename_tf);
- if (this.filename == this.temp_filename) return false;
- this.text = "";
- this.filename = this.temp_filename;
- if (p.fso.FolderExists(this.filename)) {
- this.files = [];
- this.files = this.files.concat(utils.Glob(this.filename + "\\*.txt").toArray(), utils.Glob(this.filename + "\\*.log").toArray());
- this.files.sort();
- this.text = p.open(this.files[0]);
- } else {
- this.filenames = this.filename.split("|");
- for (i = 0; i < this.filenames.length; i++) {
- if (p.fso.fileExists(this.filenames[i])) {
- this.text = p.open(this.filenames[i]);
- break;
- }
- }
- }
- this.text = this.text.replace(/\t/g, " ");
- break;
- case "lastfm_wiki":
- p.artist = p.eval(p.artist_tf);
- if (this.artist == p.artist) return false;
- this.artist = p.artist;
- this.folder = p.data_folder + p.artist;
- if (!p.fso.FolderExists(this.folder)) p.fso.CreateFolder(this.folder);
- this.filename = this.folder + "\\artist.getInfo_mod.json";
- this.text = "Nothing found.";
- this.url = "http://www.last.fm/";
- if (p.fso.fileExists(this.filename)) {
- this.json_text = p.open(this.filename);
- this.json_data = p.json_parse(this.json_text);
- if (this.json_data && this.json_data.response && this.json_data.response.biographies) {
- this.items = this.json_data.response.biographies.length;
- for (i = 0; i < this.items; i++) {
- if (this.json_data.response.biographies[i].site == this.source) {
- this.text = this.json_data.response.biographies[i].text;
- this.url = this.json_data.response.biographies[i].license["attribution-url"];
- break;
- }
- }
- if (this.source == "last.fm") this.text = this.text.replace(/\. /g, ".\n\n");
- if (this.source == "wikipedia") this.text = this.text.replace(/\. \n/g, ".\n\n").replace(/\n\n\n/g, "\n\n").replace(/ edit:\n/g , ":\n").replace(/edit:\n/g , ":\n");
- }
- } else {
- this.get();
- }
- break;
- case "lastfm_album":
- var temp_album = p.eval("[%album%]");
- var temp_artist = p.eval("[%album artist%]");
- if (this.album == temp_album && this.artist == temp_artist) return false;
- this.artist = temp_artist;
- this.album = temp_album;
- this.folder = p.data_folder + p.eval("$crc32(%album artist%)");
- if (!p.fso.FolderExists(this.folder)) p.fso.CreateFolder(this.folder);
- this.filename = this.folder + "\\album.getInfo_" + p.eval("$crc32(%album%)") + ".json";
- this.text = "Nothing found.";
- this.url = l.url;
- if (p.fso.fileExists(this.filename)) {
- this.file = p.fso.GetFile(this.filename);
- this.json_text = p.open(this.filename);
- this.json_data = p.json_parse(this.json_text);
- if (this.json_data && this.json_data.album) {
- if (this.json_data.album.url) this.url = this.json_data.album.url;
- if (this.json_data.album.wiki && this.json_data.album.wiki.content) {
- this.text = p.strip_tags(this.json_data.album.wiki.content);
- this.text = this.text.replace("User-contributed text is available under the Creative Commons By-SA License and may also be available under the GNU FDL.", "").trim();
- }
- }
- if (Date.parse(Date()) - Date.parse(this.file.DateLastModified) > ONE_DAY) this.get();
- } else {
- this.get();
- }
- break;
- }
- this.calc();
- window.Repaint();
- return true;
- }
- this.trace = function(x, y) {
- return (x > this.x && x < this.x + this.w && y > this.y && y < this.y + this.h);
- }
- this.wheel = function(step) {
- if (!this.trace(p.mx, p.my)) return false;
- if (this.text_rows > this.rows) {
- this.offset -= step * 3;
- if (this.offset < 0) this.offset = 0;
- if (this.offset + this.rows > this.text_rows) this.offset = this.text_rows - this.rows;
- window.RepaintRect(this.x, this.y, this.w, this.h);
- }
- return true;
- }
- this.move = function(x, y) {
- switch(true) {
- case !this.trace(x, y):
- window.SetCursor(IDC_ARROW);
- return false;
- case this.up_btn.trace(x, y):
- case this.down_btn.trace(x, y):
- window.SetCursor(IDC_HAND);
- return true;
- default:
- window.SetCursor(IDC_ARROW);
- return false;
- }
- }
- this.lbtn_up = function(x, y) {
- if (!this.trace(x, y)) return false;
- this.up_btn.lbtn_up(x, y);
- this.down_btn.lbtn_up(x, y);
- return true;
- }
- this.get = function() {
- var fn = this.filename;
- var func = function() {
- if (!p.save(t.xmlhttp.responsetext, fn)) return;
- t.artist = "";
- t.album = "";
- on_item_focus_change();
- }
- var url = "";
- var user_agent = "";
- switch(this.mode) {
- case "lastfm_album":
- if (this.artist == "" || this.album == "") return;
- url = l.get_url() + "&method=album.getInfo&artist=" + encodeURIComponent(this.artist) + "&album=" + encodeURIComponent(this.album);
- user_agent = l.user_agent;
- break;
- case "lastfm_wiki":
- if (this.artist == "" || this.artist == "?") return;
- url = "http://developer.echonest.com/api/v4/artist/biographies?api_key=EKWS4ESQLKN3G2ZWV&format=json&name=" + encodeURIComponent(this.artist);
- break;
- }
- if (url.length == 0) return;
- this.xmlhttp.open("GET", url, true);
- if (user_agent.length > 0) this.xmlhttp.setRequestHeader('User-Agent', user_agent);
- this.xmlhttp.send();
- this.xmlhttp.onreadystatechange = function() {
- if (t.xmlhttp.readyState == 4) {
- if (t.xmlhttp.status == 200) {
- func();
- } else {
- p.console(t.xmlhttp.responsetext || "HTTP error: " + t.xmlhttp.status);
- }
- }
- }
- }
- this.calc = function() {
- this.offset = 0;
- this.text_rows = 0;
- if (this.w < 100 || this.text.length == 0) return;
- var temp_bmp = gdi.CreateImage(1, 1);
- var temp_gr = temp_bmp.GetGraphics();
- var paragraphs = this.text.split("\n");
- this.text_array = [];
- for (i = 0; i < paragraphs.length; i++) {
- if (this.fixed) {
- this.text_array.push(paragraphs[i]);
- } else {
- var lines = temp_gr.EstimateLineWrap(paragraphs[i], p.normal_font, this.w).toArray();
- for (j = 0; j < lines.length; j += 2) {
- this.text_array.push(lines[j].trim());
- }
- }
- }
- this.text_rows = this.text_array.length;
- temp_bmp.ReleaseGraphics(temp_gr);
- temp_bmp.Dispose();
- temp_gr = null;
- temp_bmp = null;
- }
- this.init = function() {
- switch(true) {
- case p.check_feature("lastfm_album"):
- this.mode = "lastfm_album";
- break;
- case p.check_feature("lastfm_wiki"):
- this.mode = "lastfm_wiki";
- this.source = window.GetProperty("biography_source", "last.fm");
- break;
- case p.check_feature("simple_text"):
- this.mode = "simple_text";
- this.title = window.GetProperty("text_title", "$directory_path(%path%)");
- this.filename_tf = window.GetProperty("text_filename_tf", "$directory_path(%path%)");
- this.filename = "";
- this.fixed = window.GetProperty("text_fixed_font", true);
- break;
- case p.check_feature("simple_tag"):
- this.mode = "simple_tag";
- this.title = window.GetProperty("text_title", "%title%");
- this.filename = "";
- this.centre = window.GetProperty("text_centre", false);
- this.tag = window.GetProperty("text_tag", "[%lyrics%]");
- break;
- }
- }
- this.x = x;
- this.y = y;
- this.w = w;
- this.h = h;
- this.text = "";
- this.artist = "";
- this.album = "";
- this.url = "";
- this.fixed = false;
- this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
- this.init();
- this.size();
- }
- function thumbs() {
- this.trace = function(x, y) {
- return (x > this.x && x < this.x + this.w && y > this.y && y < this.y + this.h);
- }
- this.draw = function(gr) {
- switch(true) {
- case im.images.length == 0:
- break;
- case this.mode == "off":
- p.draw_image(gr, im.images[im.index], im.x, im.y, im.w, im.h, im.type);
- break;
- case !this.img:
- break;
- case this.mode == "grid":
- gr.DrawImage(this.img, this.x, this.y, this.w, this.h, 0, this.offset * this.px, this.w, this.h);
- if (this.overlay) {
- gr.FillSolidRect(this.x, this.y, this.w, this.h, RGBA(0, 0, 0, 126));
- p.draw_image(gr, im.images[im.index], im.x, im.y, im.w, im.h, "adjust");
- }
- break;
- case this.mode == "left":
- case this.mode == "right":
- gr.DrawImage(this.img, this.x, this.y, this.w, this.h, 0, this.offset * this.px, this.w, this.h);
- p.draw_image(gr, im.images[im.index], im.x, im.y, im.w, im.h, im.type);
- break;
- case this.mode == "bottom":
- case this.mode == "top":
- gr.DrawImage(this.img, this.x, this.y, this.w, this.h, this.offset * this.px, 0, this.w, this.h);
- p.draw_image(gr, im.images[im.index], im.x, im.y, im.w, im.h, im.type);
- break;
- }
- }
- this.calc = function() {
- this.offset = 0;
- switch(true) {
- case p.w < this.px || p.h < this.px || this.mode == "off":
- this.nc = true;
- this.img && this.img.Dispose();
- this.img = null;
- im.x = 0;
- im.y = 0;
- im.w = p.w;
- im.h = p.h;
- break;
- case this.mode == "grid":
- this.x = 0;
- this.y = 0;
- this.w = p.w;
- this.h = p.h;
- im.x = 40;
- im.y = 40;
- im.w = this.w - 80;
- im.h = this.h - 80;
- if (!this.nc && this.columns != Math.floor(this.w / this.px)) this.nc = true;
- this.overlay = false;
- this.rows = Math.ceil(this.h / this.px);
- this.columns = Math.floor(this.w / this.px);
- this.img_rows = Math.ceil(im.images.length / this.columns);
- if (this.nc && im.images.length > 0) {
- this.nc = false;
- this.img && this.img.Dispose();
- this.img = null;
- this.img = gdi.CreateImage(Math.min(this.columns, im.images.length) * this.px, this.img_rows * this.px);
- var temp_gr = this.img.GetGraphics();
- temp_gr.SetInterpolationMode(7);
- var ci = 0;
- var row, col;
- for (row = 0; row < this.img_rows; row++) {
- for (col = 0; col < this.columns; col++) {
- if (ci == im.images.length) continue;
- p.draw_image(temp_gr, im.images[ci], col * this.px, row * this.px, this.px, this.px, "top");
- ci++;
- }
- }
- this.img.ReleaseGraphics(temp_gr);
- temp_gr = null;
- }
- break;
- case this.mode == "left":
- case this.mode == "right":
- this.x = this.mode == "left" ? 0 : p.w - this.px;
- this.y = 0;
- this.w = this.px;
- this.h = p.h;
- im.x = this.mode == "right" ? 0 : this.px;
- im.y = 0;
- im.w = p.w - this.px;
- im.h = p.h;
- this.rows = Math.ceil(this.h / this.px);
- if (this.nc && im.images.length > 0) {
- this.nc = false;
- this.img && this.img.Dispose();
- this.img = null;
- this.img = gdi.CreateImage(this.px, this.px * im.images.length);
- var temp_gr = this.img.GetGraphics();
- temp_gr.SetInterpolationMode(7);
- for (i = 0; i < im.images.length; i++) {
- p.draw_image(temp_gr, im.images[i], 0, i * this.px, this.px, this.px, "top");
- }
- this.img.ReleaseGraphics(temp_gr);
- temp_gr = null;
- }
- break;
- case this.mode == "bottom":
- case this.mode == "top":
- this.x = 0;
- this.y = this.mode == "top" ? 0 : p.h - this.px;
- this.w = p.w;
- this.h = this.px;
- im.x = 0;
- im.y = this.mode == "bottom" ? 0 : this.px;
- im.w = p.w;
- im.h = p.h - this.px;
- this.columns = Math.ceil(this.w / this.px);
- if (this.nc && im.images.length > 0) {
- this.nc = false;
- this.img && this.img.Dispose();
- this.img = null;
- this.img = gdi.CreateImage(this.px * im.images.length, this.px);
- var temp_gr = this.img.GetGraphics();
- temp_gr.SetInterpolationMode(7);
- for (i = 0; i < im.images.length; i++) {
- p.draw_image(temp_gr, im.images[i], i * this.px, 0, this.px, this.px, "top");
- }
- this.img.ReleaseGraphics(temp_gr);
- temp_gr = null;
- }
- break;
- }
- }
- this.wheel = function(step) {
- switch(true) {
- case !this.trace(p.mx, p.my):
- case this.overlay:
- return false;
- case this.mode == "grid":
- if (this.img_rows < this.rows) return true;
- this.offset -= step;
- if (this.offset < 0) this.offset = 0;
- if (this.offset > this.img_rows - this.rows) this.offset = this.img_rows - this.rows + 1;
- break;
- case this.mode == "left":
- case this.mode == "right":
- if (im.images.length < this.rows) return true;
- this.offset -= step;
- if (this.offset < 0) this.offset = 0;
- if (this.rows + this.offset > im.images.length) this.offset = im.images.length - this.rows + 1;
- break;
- case this.mode == "bottom":
- case this.mode == "top":
- if (im.images.length < this.columns) return true;
- this.offset -= step;
- if (this.offset < 0) this.offset = 0;
- if (this.columns + this.offset > im.images.length) this.offset = im.images.length - this.columns + 1;
- break;
- }
- window.RepaintRect(this.x, this.y, this.w, this.h);
- return true;
- }
- this.move = function(x, y) {
- switch(true) {
- case !this.trace(x, y):
- window.SetCursor(IDC_ARROW);
- return false;
- case this.overlay:
- window.SetCursor(IDC_ARROW);
- return true;
- case this.mode == "grid":
- this.index = Math.floor((x - this.x) / this.px) + (Math.floor((y - this.y) / this.px) * this.columns) + (this.offset * this.columns);
- break;
- case this.mode == "left":
- case this.mode == "right":
- this.index = Math.floor((y - this.y) / this.px) + this.offset;
- break;
- case this.mode == "bottom":
- case this.mode == "top":
- this.index = Math.floor((x - this.x) / this.px) + this.offset;
- break;
- }
- window.SetCursor(this.index < im.images.length ? IDC_HAND : IDC_ARROW);
- return true;
- }
- this.lbtn_up = function(x, y) {
- switch(true) {
- case !this.trace(x, y):
- return false;
- case this.mode == "grid" && this.overlay && im.trace(x, y):
- this.overlay = false;
- window.Repaint();
- break;
- case this.mode == "grid" && this.index < im.images.length && !this.overlay:
- this.overlay = true;
- im.index = this.index;
- window.Repaint();
- break;
- case this.overlay:
- break;
- case this.index < im.images.length:
- im.index = this.index;
- window.Repaint();
- }
- return true;
- }
- this.lbtn_dblclk = function(x, y) {
- if (!im.trace(x, y) || th.mode == "grid") return false;
- p.run("\"" + im.files[im.index] + "\"");
- return true;
- }
- this.nc = false;
- this.mode = "off";
- this.px = 40;
- this.img = null;
- }
- //json2.js
- if(typeof JSON!=='object'){JSON={};}
- (function(){'use strict';function f(n){return n<10?'0'+n:n;}
- if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+
- f(this.getUTCMonth()+1)+'-'+
- f(this.getUTCDate())+'T'+
- f(this.getUTCHours())+':'+
- f(this.getUTCMinutes())+':'+
- f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}
- var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}
- function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}
- if(typeof rep==='function'){value=rep.call(holder,key,value);}
- switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
- gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}
- v=partial.length===0?'[]':gap?'[\n'+gap+partial.join(',\n'+gap)+'\n'+mind+']':'['+partial.join(',')+']';gap=mind;return v;}
- if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){if(typeof rep[i]==='string'){k=rep[i];v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.prototype.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}
- v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}
- if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}
- rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}
- return str('',{'':value});};}
- if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.prototype.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}
- return reviver.call(holder,key,value);}
- text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+
- ('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}
- if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}
- throw new SyntaxError('JSON.parse');};}}());
- /*
- * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
- * Digest Algorithm, as defined in RFC 1321.
- * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
- * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
- * Distributed under the BSD License
- * See http://pajhome.org.uk/crypt/md5 for more info.
- */
- var hexcase=0;function hex_md5(a){return rstr2hex(rstr_md5(str2rstr_utf8(a)))}
- function hex_hmac_md5(a,b){return rstr2hex(rstr_hmac_md5(str2rstr_utf8(a),str2rstr_utf8(b)))}
- function md5_vm_test(){return hex_md5("abc").toLowerCase()=="900150983cd24fb0d6963f7d28e17f72"}
- function rstr_md5(a){return binl2rstr(binl_md5(rstr2binl(a),a.length*8))}
- function rstr_hmac_md5(c,f){var e=rstr2binl(c);if(e.length>16){e=binl_md5(e,c.length*8)}
- var a=Array(16),d=Array(16);for(var b=0;b<16;b++){a[b]=e[b]^909522486;d[b]=e[b]^1549556828}
- var g=binl_md5(a.concat(rstr2binl(f)),512+f.length*8);return binl2rstr(binl_md5(d.concat(g),512+128))}
- function rstr2hex(c){try{hexcase}catch(g){hexcase=0}
- var f=hexcase?"0123456789ABCDEF":"0123456789abcdef";var b="";var a;for(var d=0;d<c.length;d++){a=c.charCodeAt(d);b+=f.charAt((a>>>4)&15)+f.charAt(a&15)}
- return b}
- function str2rstr_utf8(c){var b="";var d=-1;var a,e;while(++d<c.length){a=c.charCodeAt(d);e=d+1<c.length?c.charCodeAt(d+1):0;if(55296<=a&&a<=56319&&56320<=e&&e<=57343){a=65536+((a&1023)<<10)+(e&1023);d++}
- if(a<=127){b+=String.fromCharCode(a)}else{if(a<=2047){b+=String.fromCharCode(192|((a>>>6)&31),128|(a&63))}else{if(a<=65535){b+=String.fromCharCode(224|((a>>>12)&15),128|((a>>>6)&63),128|(a&63))}else{if(a<=2097151){b+=String.fromCharCode(240|((a>>>18)&7),128|((a>>>12)&63),128|((a>>>6)&63),128|(a&63))}}}}}
- return b}
- function rstr2binl(b){var a=Array(b.length>>2);for(var c=0;c<a.length;c++){a[c]=0}
- for(var c=0;c<b.length*8;c+=8){a[c>>5]|=(b.charCodeAt(c/8)&255)<<(c%32)}
- return a}
- function binl2rstr(b){var a="";for(var c=0;c<b.length*32;c+=8){a+=String.fromCharCode((b[c>>5]>>>(c%32))&255)}
- return a}
- function binl_md5(p,k){p[k>>5]|=128<<((k)%32);p[(((k+64)>>>9)<<4)+14]=k;var o=1732584193;var n=-271733879;var m=-1732584194;var l=271733878;for(var g=0;g<p.length;g+=16){var j=o;var h=n;var f=m;var e=l;o=md5_ff(o,n,m,l,p[g+0],7,-680876936);l=md5_ff(l,o,n,m,p[g+1],12,-389564586);m=md5_ff(m,l,o,n,p[g+2],17,606105819);n=md5_ff(n,m,l,o,p[g+3],22,-1044525330);o=md5_ff(o,n,m,l,p[g+4],7,-176418897);l=md5_ff(l,o,n,m,p[g+5],12,1200080426);m=md5_ff(m,l,o,n,p[g+6],17,-1473231341);n=md5_ff(n,m,l,o,p[g+7],22,-45705983);o=md5_ff(o,n,m,l,p[g+8],7,1770035416);l=md5_ff(l,o,n,m,p[g+9],12,-1958414417);m=md5_ff(m,l,o,n,p[g+10],17,-42063);n=md5_ff(n,m,l,o,p[g+11],22,-1990404162);o=md5_ff(o,n,m,l,p[g+12],7,1804603682);l=md5_ff(l,o,n,m,p[g+13],12,-40341101);m=md5_ff(m,l,o,n,p[g+14],17,-1502002290);n=md5_ff(n,m,l,o,p[g+15],22,1236535329);o=md5_gg(o,n,m,l,p[g+1],5,-165796510);l=md5_gg(l,o,n,m,p[g+6],9,-1069501632);m=md5_gg(m,l,o,n,p[g+11],14,643717713);n=md5_gg(n,m,l,o,p[g+0],20,-373897302);o=md5_gg(o,n,m,l,p[g+5],5,-701558691);l=md5_gg(l,o,n,m,p[g+10],9,38016083);m=md5_gg(m,l,o,n,p[g+15],14,-660478335);n=md5_gg(n,m,l,o,p[g+4],20,-405537848);o=md5_gg(o,n,m,l,p[g+9],5,568446438);l=md5_gg(l,o,n,m,p[g+14],9,-1019803690);m=md5_gg(m,l,o,n,p[g+3],14,-187363961);n=md5_gg(n,m,l,o,p[g+8],20,1163531501);o=md5_gg(o,n,m,l,p[g+13],5,-1444681467);l=md5_gg(l,o,n,m,p[g+2],9,-51403784);m=md5_gg(m,l,o,n,p[g+7],14,1735328473);n=md5_gg(n,m,l,o,p[g+12],20,-1926607734);o=md5_hh(o,n,m,l,p[g+5],4,-378558);l=md5_hh(l,o,n,m,p[g+8],11,-2022574463);m=md5_hh(m,l,o,n,p[g+11],16,1839030562);n=md5_hh(n,m,l,o,p[g+14],23,-35309556);o=md5_hh(o,n,m,l,p[g+1],4,-1530992060);l=md5_hh(l,o,n,m,p[g+4],11,1272893353);m=md5_hh(m,l,o,n,p[g+7],16,-155497632);n=md5_hh(n,m,l,o,p[g+10],23,-1094730640);o=md5_hh(o,n,m,l,p[g+13],4,681279174);l=md5_hh(l,o,n,m,p[g+0],11,-358537222);m=md5_hh(m,l,o,n,p[g+3],16,-722521979);n=md5_hh(n,m,l,o,p[g+6],23,76029189);o=md5_hh(o,n,m,l,p[g+9],4,-640364487);l=md5_hh(l,o,n,m,p[g+12],11,-421815835);m=md5_hh(m,l,o,n,p[g+15],16,530742520);n=md5_hh(n,m,l,o,p[g+2],23,-995338651);o=md5_ii(o,n,m,l,p[g+0],6,-198630844);l=md5_ii(l,o,n,m,p[g+7],10,1126891415);m=md5_ii(m,l,o,n,p[g+14],15,-1416354905);n=md5_ii(n,m,l,o,p[g+5],21,-57434055);o=md5_ii(o,n,m,l,p[g+12],6,1700485571);l=md5_ii(l,o,n,m,p[g+3],10,-1894986606);m=md5_ii(m,l,o,n,p[g+10],15,-1051523);n=md5_ii(n,m,l,o,p[g+1],21,-2054922799);o=md5_ii(o,n,m,l,p[g+8],6,1873313359);l=md5_ii(l,o,n,m,p[g+15],10,-30611744);m=md5_ii(m,l,o,n,p[g+6],15,-1560198380);n=md5_ii(n,m,l,o,p[g+13],21,1309151649);o=md5_ii(o,n,m,l,p[g+4],6,-145523070);l=md5_ii(l,o,n,m,p[g+11],10,-1120210379);m=md5_ii(m,l,o,n,p[g+2],15,718787259);n=md5_ii(n,m,l,o,p[g+9],21,-343485551);o=safe_add(o,j);n=safe_add(n,h);m=safe_add(m,f);l=safe_add(l,e)}
- return Array(o,n,m,l)}
- function md5_cmn(h,e,d,c,g,f){return safe_add(bit_rol(safe_add(safe_add(e,h),safe_add(c,f)),g),d)}
- function md5_ff(g,f,k,j,e,i,h){return md5_cmn((f&k)|((~f)&j),g,f,e,i,h)}
- function md5_gg(g,f,k,j,e,i,h){return md5_cmn((f&j)|(k&(~j)),g,f,e,i,h)}
- function md5_hh(g,f,k,j,e,i,h){return md5_cmn(f^k^j,g,f,e,i,h)}
- function md5_ii(g,f,k,j,e,i,h){return md5_cmn(k^(f|(~j)),g,f,e,i,h)}
- function safe_add(a,d){var c=(a&65535)+(d&65535);var b=(a>>16)+(d>>16)+(c>>16);return(b<<16)|(c&65535)}
- function bit_rol(a,b){return(a<<b)|(a>>>(32-b))};
- var p = new panel("Youtube Radio", ["custom_background", "remap", "metadb"]);
- var im = new images(0, 0, 0, 0);
- var th = new thumbs();
- on_item_focus_change();
- function on_metadb_changed() {
- im.metadb_changed();
- }
- //Button
- var Buttons;
- var g_tooltip = window.CreateTooltip();
- var g_down = false;
- var btn_down = null;
- var cur_btn = null;
- ButtonStates = {
- normal: 0,
- hover: 1,
- down: 2
- }
- function Button(x, y, w, h, img_src, func, tiptext) {
- this.left = x;
- this.top = y;
- this.w = w;
- this.h = h;
- this.right = x + w;
- this.bottom = y + h;
- this.func = func;
- this.tiptext = tiptext;
- this.state = ButtonStates.normal;
- this.img_normal = img_src && img_src.normal ? gdi.Image(img_src.normal) : null;
- this.img_hover = img_src && img_src.hover ? gdi.Image(img_src.hover) : this.img_normal;
- this.img_down = img_src && img_src.down ? gdi.Image(img_src.down) : this.img_hover;
- this.img = this.img_normal;
- this.alterImage = function(img_src) {
- this.img_normal = img_src && img_src.normal ? gdi.Image(img_src.normal) : null;
- this.img_hover = img_src && img_src.hover ? gdi.Image(img_src.hover) : this.img_normal;
- this.img_down = img_src && img_src.down ? gdi.Image(img_src.down) : this.img_hover;
- this.changeState(this.state);
- }
- this.traceMouse = function (x, y) {
- var b = (this.left < x) && (x < this.right) && (this.top < y) && (y < this.bottom);
- if (b)
- g_down ? this.changeState(ButtonStates.down) : this.changeState(ButtonStates.hover);
- else
- this.changeState(ButtonStates.normal);
- return b;
- }
- this.changeState = function (newstate) {
- if (newstate != this.state)
- window.RepaintRect(this.left, this.top, this.w, this.h);
- this.state = newstate;
- switch (this.state)
- {
- case ButtonStates.normal:
- this.img = this.img_normal;
- break;
- case ButtonStates.hover:
- this.img = this.img_hover;
- break;
- case ButtonStates.down:
- this.img = this.img_down;
- break;
- default:
- this.img = null;
- }
- }
- this.draw = function (gr) {
- this.img && gr.DrawImage(this.img, this.left, this.top, this.w, this.h, 0, 0, this.w, this.h);
- }
- this.onClick = function () {
- this.func && this.func(x,y);
- }
- this.onMouseIn = function() {
- g_tooltip.Text = this.tiptext;
- g_tooltip.Activate();
- }
- this.onMouseOut = function() {
- g_tooltip.Deactivate();
- }
- }
- function buttonsDraw(gr) {
- for (i in Buttons) {
- Buttons[i].draw(gr);
- }
- }
- function buttonsTraceMouse(x, y) {
- var btn = null;
- for (i in Buttons) {
- if (Buttons[i].traceMouse(x, y) && !btn)
- btn = Buttons[i];
- }
- return btn;
- }
- function on_mouse_move(x, y) {
- var btn = buttonsTraceMouse(x, y);
- if (btn != cur_btn) {
- cur_btn && cur_btn.onMouseOut();
- btn && btn.onMouseIn();
- }
- cur_btn = btn;
- }
- function on_mouse_lbtn_down(x, y) {
- g_down = true;
- btn_down = cur_btn;
- if (cur_btn) {
- cur_btn.changeState(ButtonStates.down);
- }
- }
- function on_mouse_lbtn_up(x, y) {
- if (cur_btn) {
- cur_btn.changeState(ButtonStates.hover);
- if( btn_down == cur_btn )
- cur_btn.onClick(x, y);
- }
- g_down = false;
- }
- function on_mouse_leave() {
- if (cur_btn) {
- cur_btn.changeState(ButtonStates.normal);
- }
- }
- function on_size() {
- ww = window.Width;
- wh = window.Height;
- window.Repaint();
- }
- function on_paint(gr) {
- /*switch(window.GetProperty("mode", 1)) {
- case 1:
- //col = window.GetColorDUI(1);
- break;
- case 2:
- col = utils.GetSysColor(4);
- break;
- case 3:
- col = custom;
- break;
- }*/
- //gr.FillSolidRect(0, 0, ww, wh, col);
- buttonsDraw(gr);
- //gr.DrawRect(0,0, ww, wh, 1.0, -6250336);
- }
- function RGB(r,g,b) {
- return (0xff000000|(r<<16)|(g<<8)|(b));
- }
- function on_colors_changed() {
- window.Repaint();
- }
- //init Buttons
- //custom colour accessed through the context menu
- var custom = RGB(255,255,255);
- //button width
- var bw = 24;
- //button height
- var bh = 20;
- //Button position
- var top_margin = -1;
- var left_margin = 0;
- var image_path0 = window.GetProperty("Button Path", fb.ProfilePath + "image");
- var image_path = (image_path0 + "\\");
- //these 2 lines of code lock the panel size. you can comment them out or change the dimensions to suit
- //window.MinWidth = window.MaxWidth = 24;
- //window.MinHeight = window.MaxHeight = 20;
- Buttons = {
- but1: new Button(left_margin,top_margin,bw,bh, {normal: image_path + "youtube0.png", hover: image_path + "youtube1.png"}, function(){
- //if (p.artist.indexOf("3dydfy://")== 0 | p.artist.indexOf("www.youtube.com/")== 0 | p.artist.indexOf("youtube.com/")== 0 | p.artist.indexOf("http://www.youtube.com/")== 0)
- p.rbtn_up(24, 17);
- //im.downloadONE();
- /*else
- {
- p.artist = p.eval("%artist% %title%");
- p.browser("http://www.youtube.com/results?search_query=" + encodeURIComponent(p.artist) + "&ie=utf-8");
- }*/
- }, "Youtube")
- }
- //fb.RunMainMenuCommand("Library/Search");
- //fb.RunContextCommand("Open containing folder");
- function on_mouse_rbtn_up(x, y) {
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement