SHOW:
|
|
- or go back to the newest paste.
| 1 | // ==PREPROCESSOR== | |
| 2 | // @name "Youtube Radio" | |
| 3 | // @author "Mire777" | |
| 4 | // @feature "v1.4" | |
| 5 | // @feature "watch-metadb" | |
| 6 | // ==/PREPROCESSOR== | |
| 7 | ||
| 8 | // Paths | |
| 9 | var fbfolder = (fb.ProfilePath + "Artist_info"); | |
| 10 | var lfm_folder = fbfolder; | |
| 11 | ||
| 12 | //image download size | |
| 13 | size = "high"; | |
| 14 | ||
| 15 | //Download server | |
| 16 | auto_yt = window.GetProperty("YT Radio", "0");
| |
| 17 | //auto_lfm = window.GetProperty("LFM Radio", "0");
| |
| 18 | ||
| 19 | ooo2 = window.GetProperty("YT Track", "");
| |
| 20 | START_ARTIST = window.GetProperty("YT Station", "");
| |
| 21 | ||
| 22 | //Download server | |
| 23 | last_fm = window.GetProperty("YT Similar", "");
| |
| 24 | YT_URL = window.GetProperty("YT URL", "");
| |
| 25 | gnr = window.GetProperty("YT Tag(27-100)", "27");
| |
| 26 | ||
| 27 | //Search terms(google,yahoo) | |
| 28 | terms = ""; | |
| 29 | ||
| 30 | //Cycle | |
| 31 | cycle2 = 15; | |
| 32 | ||
| 33 | var VERSION = "7.2013-10-19.01"; | |
| 34 | var DT_LEFT = 0x00000000; | |
| 35 | var DT_CENTER = 0x00000001; | |
| 36 | var DT_RIGHT = 0x00000002; | |
| 37 | var DT_VCENTER = 0x00000004; | |
| 38 | var DT_WORDBREAK = 0x00000010; | |
| 39 | var DT_CALCRECT = 0x00000400; | |
| 40 | var DT_NOPREFIX = 0x00000800; | |
| 41 | var DT_END_ELLIPSIS = 0x00008000; | |
| 42 | ||
| 43 | var MF_GRAYED = 0x00000001; | |
| 44 | var MF_STRING = 0x00000000; | |
| 45 | ||
| 46 | var IDC_ARROW = 32512; | |
| 47 | var IDC_HAND = 32649; | |
| 48 | ||
| 49 | var ONE_DAY = 86400000; | |
| 50 | var ONE_WEEK = 604800000; | |
| 51 | ||
| 52 | String.prototype.addCommas = function() {
| |
| 53 | return this.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
| |
| 54 | } | |
| 55 | ||
| 56 | String.prototype.trim = function() {
| |
| 57 | return this.replace(/^\s+|\s+$/g, ""); | |
| 58 | } | |
| 59 | ||
| 60 | String.prototype.ucfirst = function() {
| |
| 61 | return this.charAt(0).toUpperCase() + this.substr(1); | |
| 62 | } | |
| 63 | ||
| 64 | function RGB(r, g, b) {
| |
| 65 | return (0xff000000 | (r << 16) | (g << 8) | (b)); | |
| 66 | } | |
| 67 | ||
| 68 | function RGBA(r, g, b, a) {
| |
| 69 | return ((a << 24) | (r << 16) | (g << 8) | (b)); | |
| 70 | } | |
| 71 | ||
| 72 | function on_colors_changed() {
| |
| 73 | p.colors_changed(); | |
| 74 | } | |
| 75 | ||
| 76 | function on_font_changed() {
| |
| 77 | p.font_changed(); | |
| 78 | } | |
| 79 | ||
| 80 | function on_selection_changed() {
| |
| 81 | p.item_focus_change(); | |
| 82 | } | |
| 83 | ||
| 84 | function on_playlist_switch() {
| |
| 85 | p.item_focus_change(); | |
| 86 | } | |
| 87 | ||
| 88 | function on_playback_new_track() {
| |
| 89 | p.item_focus_change(); | |
| 90 | //im.download(); | |
| 91 | im.downloadLFM(); | |
| 92 | } | |
| 93 | ||
| 94 | function on_playback_dynamic_info_track() {
| |
| 95 | p.item_focus_change(); | |
| 96 | } | |
| 97 | ||
| 98 | function on_playback_stop() {
| |
| 99 | p.item_focus_change(); | |
| 100 | } | |
| 101 | ||
| 102 | function on_item_focus_change() {
| |
| 103 | p.item_focus_change(); | |
| 104 | } | |
| 105 | ||
| 106 | function on_mouse_leave() {
| |
| 107 | if (typeof b == "object") b.leave(); | |
| 108 | if (typeof r == "object") r.leave(); | |
| 109 | if (typeof li == "object") li.leave(); | |
| 110 | if (typeof s == "object") s.leave(); | |
| 111 | } | |
| 112 | ||
| 113 | function on_mouse_rbtn_up(x, y) {
| |
| 114 | p.rbtn_up(x, y); | |
| 115 | return true; | |
| 116 | } | |
| 117 | ||
| 118 | function on_notify_data(name, data) {
| |
| 119 | if (name == "lastfm" && data == "update" && typeof l == "object") l.notify_data(name, data); | |
| 120 | if (name == "autoplaylists" && data == "update" && typeof li == "object" && li.mode == "autoplaylists") li.update(); | |
| 121 | if (name == "images" && data == "update" && typeof im == "object") im.update(); | |
| 122 | if (name == "love" && typeof ps == "object") l.post(fb.TitleFormat("%LASTFM_LOVED_DB%").EvalWithMetadb(data) == 1 ? "track.unlove" : "track.love", data);
| |
| 123 | } | |
| 124 | ||
| 125 | function panel(name, features) {
| |
| 126 | this.item_focus_change = function() {
| |
| 127 | if (!this.metadb_func) return; | |
| 128 | switch(this.selection_mode) {
| |
| 129 | case 0: | |
| 130 | this.metadb = fb.GetSelection(); | |
| 131 | break; | |
| 132 | case 1: | |
| 133 | this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem(); | |
| 134 | break; | |
| 135 | case 2: | |
| 136 | this.metadb = fb.GetFocusItem(); | |
| 137 | break; | |
| 138 | } | |
| 139 | if (this.metadb) on_metadb_changed(); | |
| 140 | } | |
| 141 | ||
| 142 | this.colors_changed = function() {
| |
| 143 | if (this.dui) {
| |
| 144 | this.background_mode=(1); | |
| 145 | this.textcolour = window.GetColorDUI(0); | |
| 146 | this.textcolour_hl = window.GetColorDUI(2); | |
| 147 | this.backcolour = window.GetColorDUI(1); | |
| 148 | } else {
| |
| 149 | this.background_mode=(0); | |
| 150 | this.textcolour = window.GetColorCUI(0); | |
| 151 | this.textcolour_hl = window.GetColorCUI(0); | |
| 152 | this.backcolour = window.GetColorCUI(3); | |
| 153 | } | |
| 154 | window.Repaint(); | |
| 155 | } | |
| 156 | ||
| 157 | this.font_changed = function() {
| |
| 158 | this.font = this.dui ? window.GetFontDUI(0) : window.GetFontCUI(0); | |
| 159 | try {
| |
| 160 | this.font_name = this.font.Name; | |
| 161 | } catch(e) {
| |
| 162 | this.console("Unable to use your default font. Using Segoe UI instead.");
| |
| 163 | this.font_name = "Segoe ui"; | |
| 164 | } | |
| 165 | this.title_font = gdi.Font(this.font_name, 16, 1); | |
| 166 | this.normal_font = gdi.Font("segoe ui", 12, 1);
| |
| 167 | this.fixed_font = gdi.Font("Lucida Console", this.normal_font_size);
| |
| 168 | this.list_font = gdi.Font(this.font_name, this.list_font_size); | |
| 169 | this.row_height = this.normal_font.Height + 2; | |
| 170 | if (typeof t == "object") t.size(); | |
| 171 | window.Repaint(); | |
| 172 | } | |
| 173 | ||
| 174 | this.size = function() {
| |
| 175 | this.w = window.Width; | |
| 176 | this.h = window.Height; | |
| 177 | } | |
| 178 | ||
| 179 | this.move = function(x, y) {
| |
| 180 | this.mx = x; | |
| 181 | this.my = y; | |
| 182 | } | |
| 183 | ||
| 184 | this.rbtn_up = function(x, y) {
| |
| 185 | var _menu = window.CreatePopupMenu(); | |
| 186 | var _custom_background = window.CreatePopupMenu(); | |
| 187 | var _metadb = window.CreatePopupMenu(); | |
| 188 | var _cover = window.CreatePopupMenu(); | |
| 189 | var _font = window.CreatePopupMenu(); | |
| 190 | var _sub1 = window.CreatePopupMenu(); | |
| 191 | var _sub2 = window.CreatePopupMenu(); | |
| 192 | var _sub3 = window.CreatePopupMenu(); | |
| 193 | var _sub4 = window.CreatePopupMenu(); | |
| 194 | var _sub5 = window.CreatePopupMenu(); | |
| 195 | var idx; | |
| 196 | switch(true) {
| |
| 197 | case typeof a == "object" && a.trace(x, y): | |
| 198 | /*_menu.AppendMenuItem(MF_STRING, 1, "Refresh"); | |
| 199 | _menu.AppendMenuSeparator(); | |
| 200 | _menu.AppendMenuItem(MF_STRING, 2, "Front"); | |
| 201 | _menu.AppendMenuItem(MF_STRING, 3, "Back"); | |
| 202 | _menu.AppendMenuItem(MF_STRING, 4, "Disc"); | |
| 203 | _menu.AppendMenuItem(MF_STRING, 5, "Icon"); | |
| 204 | _menu.AppendMenuItem(MF_STRING, 6, "Artist"); | |
| 205 | _menu.CheckMenuRadioItem(2, 6, a.id + 2); | |
| 206 | _menu.AppendMenuSeparator();*/ | |
| 207 | _menu.AppendMenuItem(MF_STRING, 15, "Crop (focus on centre)"); | |
| 208 | _menu.AppendMenuItem(MF_STRING, 16, "Crop (focus on top)"); | |
| 209 | _menu.AppendMenuItem(MF_STRING, 17, "adjust"); | |
| 210 | _menu.AppendMenuItem(MF_STRING, 18, "Stretch"); | |
| 211 | _menu.CheckMenuRadioItem(15, 18, a.type == "centre" ? 15 : a.type == "top" ? 16 : a.type == "adjust" ? 17 : 18); | |
| 212 | _menu.AppendMenuSeparator(); | |
| 213 | _cover.AppendMenuItem(this.metadb ? MF_STRING : MF_GRAYED, 21, "Google images (launches browser)"); | |
| 214 | _cover.AppendMenuItem(this.metadb ? MF_STRING : MF_GRAYED, 22, "Album Art Downloader"); | |
| 215 | _cover.AppendMenuSeparator(); | |
| 216 | //_cover.AppendMenuItem(MF_STRING, 23, "Help"); | |
| 217 | //_cover.AppendTo(_menu, MF_STRING, "Cover search"); | |
| 218 | //_menu.AppendMenuSeparator(); | |
| 219 | break; | |
| 220 | case typeof c == "object" && c.trace(x, y): | |
| 221 | if (this.check_feature("now_playing") && !np_cd) break;
| |
| 222 | /*_menu.AppendMenuItem(MF_STRING, 1, "Refresh"); | |
| 223 | _menu.AppendMenuSeparator(); | |
| 224 | _menu.AppendMenuItem(MF_STRING, 11, "Gloss effect"); | |
| 225 | _menu.CheckMenuItem(11, c.gloss); | |
| 226 | _menu.AppendMenuItem(MF_STRING, 12, "Shadow effect"); | |
| 227 | _menu.CheckMenuItem(12, c.shadow); | |
| 228 | _menu.AppendMenuSeparator(); | |
| 229 | _cover.AppendMenuItem(this.metadb ? MF_STRING : MF_GRAYED, 21, "Google images (launches browser)"); | |
| 230 | _cover.AppendMenuItem(this.metadb ? MF_STRING : MF_GRAYED, 22, "Album Art Downloader"); | |
| 231 | _cover.AppendMenuSeparator(); | |
| 232 | _cover.AppendMenuItem(MF_STRING, 23, "Help"); | |
| 233 | _cover.AppendTo(_menu, MF_STRING, "Cover search"); | |
| 234 | _menu.AppendMenuSeparator();*/ | |
| 235 | break; | |
| 236 | case typeof li == "object" && li.trace(x, y): | |
| 237 | switch(li.mode) {
| |
| 238 | case "autoplaylists": | |
| 239 | _menu.AppendMenuItem(MF_STRING, 600, "Change title..."); | |
| 240 | _menu.AppendMenuSeparator(); | |
| 241 | for (i = 1; i < 9; i++) {
| |
| 242 | _sub1.AppendMenuItem(MF_STRING, i + 600, i); | |
| 243 | } | |
| 244 | _sub1.AppendTo(_menu, MF_STRING, "Save slot"); | |
| 245 | _sub1.CheckMenuRadioItem(601, 608, li.autoplaylists_slot + 600); | |
| 246 | _menu.AppendMenuSeparator(); | |
| 247 | _sub2.AppendMenuItem(MF_STRING, 610, "run query"); | |
| 248 | _sub2.AppendMenuItem(MF_STRING, 611, "do nothing"); | |
| 249 | _sub2.CheckMenuRadioItem(610, 611, li.autoplaylists_success ? 610 : 611); | |
| 250 | _sub2.AppendTo(_menu, MF_STRING, "On successful creation/edit"); | |
| 251 | for (i = 0; i < li.autoplaylists_deleted_items.length; i++) {
| |
| 252 | var temp = li.autoplaylists_deleted_items[i].split("¬");
| |
| 253 | _sub3.AppendMenuItem(MF_STRING, i + 620, temp[0]); | |
| 254 | } | |
| 255 | if (li.autoplaylists_deleted_items.length > 0) _sub3.AppendTo(_menu, MF_STRING, "Restore"); | |
| 256 | _menu.AppendMenuSeparator(); | |
| 257 | _menu.AppendMenuItem(MF_STRING, 650, "Replace exisiting playlists with the same name"); | |
| 258 | _menu.CheckMenuItem(650, li.autoplaylists_remove_duplicates); | |
| 259 | _menu.AppendMenuSeparator(); | |
| 260 | break; | |
| 261 | case "discogs": | |
| 262 | _menu.AppendMenuItem(MF_STRING, 29, "Show exact artist matches only"); | |
| 263 | _menu.CheckMenuItem(29, li.discogs_match); | |
| 264 | _menu.AppendMenuSeparator(); | |
| 265 | _menu.AppendMenuItem(MF_STRING, 28, "Show timestamp"); | |
| 266 | _menu.CheckMenuItem(28, li.show_timestamp); | |
| 267 | _menu.AppendMenuSeparator(); | |
| 268 | break; | |
| 269 | case "echonest": | |
| 270 | for (i = 0; i < li.echonest_modes.length; i++) {
| |
| 271 | _menu.AppendMenuItem(MF_STRING, i + 500, li.echonest_modes[i].ucfirst()); | |
| 272 | } | |
| 273 | _menu.CheckMenuRadioItem(500, 502, li.echonest_mode + 500); | |
| 274 | _menu.AppendMenuSeparator(); | |
| 275 | _menu.AppendMenuItem(MF_STRING, 28, "Show timestamp"); | |
| 276 | _menu.CheckMenuItem(28, li.show_timestamp); | |
| 277 | _menu.AppendMenuSeparator(); | |
| 278 | break; | |
| 279 | case "lastfm": | |
| 280 | for (i = 0; i < li.lastfm_modes.length; i++) {
| |
| 281 | _menu.AppendMenuItem(MF_STRING, 801 + i, li.lastfm_modes[i].ucfirst()); | |
| 282 | } | |
| 283 | _menu.CheckMenuRadioItem(801, 805, li.lastfm_mode + 801); | |
| 284 | _menu.AppendMenuSeparator(); | |
| 285 | if (li.lastfm_mode == 0) {
| |
| 286 | if (li.lastfm_button == "spotify") {
| |
| 287 | _menu.AppendMenuItem(MF_STRING, 810, "Pause playback when launching Spotify"); | |
| 288 | _menu.CheckMenuItem(810, li.lastfm_pause); | |
| 289 | _menu.AppendMenuSeparator(); | |
| 290 | } | |
| 291 | /*_sub1.AppendMenuItem(MF_STRING, 811, "Spotify"); | |
| 292 | _sub1.AppendMenuItem(MF_STRING, 812, "Autoplaylist"); | |
| 293 | _sub1.CheckMenuRadioItem(811, 812, li.lastfm_button == "spotify" ? 811 : 812); | |
| 294 | _sub1.AppendTo(_menu, MF_STRING, "Buttons"); | |
| 295 | _menu.AppendMenuSeparator();*/ | |
| 296 | } | |
| 297 | /*_menu.AppendMenuItem(MF_STRING, 28, "Show timestamp"); | |
| 298 | _menu.CheckMenuItem(28, li.show_timestamp); | |
| 299 | _menu.AppendMenuSeparator(); | |
| 300 | _menu.AppendMenuItem(MF_STRING, 51, "Last.fm auto-correct"); | |
| 301 | _menu.CheckMenuItem(51, l.auto_correct); | |
| 302 | _menu.AppendMenuSeparator();*/ | |
| 303 | break; | |
| 304 | case "lastfm_charts": | |
| 305 | _menu.AppendMenuItem(l.username.length > 0 ? MF_STRING : MF_GRAYED, 1000, "Refresh"); | |
| 306 | _menu.AppendMenuSeparator(); | |
| 307 | for (i = 0; i < li.lastfm_charts_modes.length; i++) {
| |
| 308 | _menu.AppendMenuItem(MF_STRING, i + 1001, li.lastfm_charts_modes[i].ucfirst()); | |
| 309 | } | |
| 310 | _menu.CheckMenuRadioItem(1001, 1003, li.lastfm_charts_mode + 1001); | |
| 311 | _menu.AppendMenuSeparator(); | |
| 312 | for (i = 0; i < li.lastfm_charts_periods_display.length; i++) {
| |
| 313 | _menu.AppendMenuItem(MF_STRING, i + 1004, li.lastfm_charts_periods_display[i].ucfirst()); | |
| 314 | } | |
| 315 | /*_menu.CheckMenuRadioItem(1004, 1009, li.lastfm_charts_period + 1004); | |
| 316 | _menu.AppendMenuSeparator(); | |
| 317 | _menu.AppendMenuItem(MF_STRING, 1010, "Bar colour..."); | |
| 318 | _menu.AppendMenuSeparator(); | |
| 319 | _menu.AppendMenuItem(MF_STRING, 28, "Show timestamp"); | |
| 320 | _menu.CheckMenuItem(28, li.show_timestamp); | |
| 321 | _menu.AppendMenuSeparator();*/ | |
| 322 | break; | |
| 323 | case "musicbrainz": | |
| 324 | _menu.AppendMenuItem(MF_STRING, 700, "Releases"); | |
| 325 | _menu.AppendMenuItem(MF_STRING, 701, "Links"); | |
| 326 | _menu.CheckMenuRadioItem(700, 701, li.musicbrainz_mode == "releases" ? 700 : 701); | |
| 327 | _menu.AppendMenuSeparator(); | |
| 328 | if (li.musicbrainz_mode == "releases") {
| |
| 329 | /*_menu.AppendMenuItem(MF_STRING, 702, "Include albums"); | |
| 330 | _menu.CheckMenuItem(702, li.musicbrainz_album); | |
| 331 | _menu.AppendMenuItem(MF_STRING, 703, "Include EPs"); | |
| 332 | _menu.CheckMenuItem(703, li.musicbrainz_ep); | |
| 333 | _menu.AppendMenuItem(MF_STRING, 704, "Include singles"); | |
| 334 | _menu.CheckMenuItem(704, li.musicbrainz_single); | |
| 335 | _menu.AppendMenuSeparator(); | |
| 336 | _menu.AppendMenuItem(MF_STRING, 705, "Include 'Live' releases"); | |
| 337 | _menu.CheckMenuItem(705, li.musicbrainz_live); | |
| 338 | _menu.AppendMenuItem(MF_STRING, 706, "Include 'Remix' releases"); | |
| 339 | _menu.CheckMenuItem(706, li.musicbrainz_remix); | |
| 340 | _menu.AppendMenuItem(MF_STRING, 707, "Include 'Compilation' releases"); | |
| 341 | _menu.CheckMenuItem(707, li.musicbrainz_compilation); | |
| 342 | _menu.AppendMenuSeparator(); | |
| 343 | _menu.AppendMenuItem(MF_STRING, 708, "Show release type"); | |
| 344 | _menu.CheckMenuItem(708, li.musicbrainz_show_release_type); | |
| 345 | _menu.AppendMenuSeparator();*/ | |
| 346 | } | |
| 347 | /*_menu.AppendMenuItem(MF_STRING, 28, "Show timestamp"); | |
| 348 | _menu.CheckMenuItem(28, li.show_timestamp); | |
| 349 | _menu.AppendMenuSeparator();*/ | |
| 350 | break; | |
| 351 | } | |
| 352 | break; | |
| 353 | case typeof ps == "object" && b.buttons.ps.trace(x, y): | |
| 354 | /*_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");
| |
| 355 | _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");
| |
| 356 | _sub1.AppendMenuSeparator(); | |
| 357 | _sub1.AppendMenuItem(utils.CheckComponent("foo_customdb", true) && this.fso.FileExists(ps.sql_file) ? MF_STRING : MF_GRAYED, 1101, "from file");
| |
| 358 | _sub1.AppendMenuSeparator(); | |
| 359 | _sub1.AppendMenuItem(MF_STRING, 1102, "Show console"); | |
| 360 | _sub1.CheckMenuItem(1102, ps.show_console); | |
| 361 | _sub1.AppendTo(_menu, MF_STRING, "Library import"); | |
| 362 | _menu.AppendMenuSeparator(); | |
| 363 | _sub2.AppendMenuItem(MF_STRING, 1103, "Only update tracks in library"); | |
| 364 | _sub2.CheckMenuItem(1103, ps.library); | |
| 365 | _sub2.AppendMenuItem(MF_STRING, 52, "Last.fm auto-correct"); | |
| 366 | _sub2.CheckMenuItem(52, l.auto_correct); | |
| 367 | _sub2.AppendTo(_menu, MF_STRING, "Auto-updates"); | |
| 368 | _menu.AppendMenuSeparator(); | |
| 369 | _sub3.AppendMenuItem(MF_STRING, 1104, "Off"); | |
| 370 | _sub3.AppendMenuItem(MF_STRING, 1105, "On"); | |
| 371 | _sub3.CheckMenuRadioItem(1104, 1105, ps.auto_love ? 1105 : 1104); | |
| 372 | _sub3.AppendMenuSeparator(); | |
| 373 | _sub3.AppendMenuItem(ps.auto_love ? MF_STRING : MF_GRAYED, 1106, "Condition"); | |
| 374 | _sub3.AppendTo(_menu, MF_STRING, "Automatically love tracks"); | |
| 375 | _menu.AppendMenuSeparator(); | |
| 376 | _sub4.AppendMenuItem(MF_STRING, 1107, "tango"); | |
| 377 | _sub4.AppendMenuItem(MF_STRING, 1108, "silk"); | |
| 378 | _sub4.CheckMenuRadioItem(1107, 1108, ps.icon == "tango" ? 1107 : 1108); | |
| 379 | _sub4.AppendTo(_menu, MF_STRING, "Icon"); | |
| 380 | _menu.AppendMenuSeparator();*/ | |
| 381 | break; | |
| 382 | case typeof s == "object" && s.mode == "spectrogram" && s.trace(x, y) : | |
| 383 | /*_menu.AppendMenuItem(MF_STRING, 1804, "SoX options..."); | |
| 384 | _menu.AppendMenuSeparator(); | |
| 385 | _menu.AppendMenuItem(MF_STRING, 1805, "Marker colour..."); | |
| 386 | _menu.AppendMenuSeparator(); | |
| 387 | _menu.AppendMenuItem(MF_STRING, 1803, "Only analyse tracks in library"); | |
| 388 | _menu.CheckMenuItem(1803, s.library); | |
| 389 | _menu.AppendMenuSeparator(); | |
| 390 | _sub1.AppendMenuItem(MF_STRING, 1800, "Clear all"); | |
| 391 | _sub1.AppendMenuItem(MF_STRING, 1801, "Clear older than 1 day"); | |
| 392 | _sub1.AppendMenuItem(MF_STRING, 1802, "Clear older than 1 week"); | |
| 393 | _sub1.AppendMenuSeparator(); | |
| 394 | _sub1.AppendMenuItem(MF_GRAYED, 1803, "In use: " + (this.fso.GetFolder(spectrogram_cache).size / 1048576).toFixed(2) + "MB"); | |
| 395 | _sub1.AppendTo(_menu, MF_STRING, "Cached images"); | |
| 396 | _menu.AppendMenuSeparator();*/ | |
| 397 | break; | |
| 398 | case typeof t == "object" && t.trace(x, y): | |
| 399 | if (this.check_feature("now_playing") && !np_bio) break;
| |
| 400 | /*_font.AppendMenuItem(MF_STRING, 30, 12); | |
| 401 | _font.AppendMenuItem(MF_STRING, 31, 14); | |
| 402 | _font.AppendMenuItem(MF_STRING, 32, 16); | |
| 403 | _font.AppendTo(_menu, MF_STRING, "Font size"); | |
| 404 | _font.CheckMenuRadioItem(30, 33, this.normal_font_size == 12 ? 30 : this.normal_font_size == 14 ? 31 : 32); | |
| 405 | _menu.AppendMenuSeparator();*/ | |
| 406 | switch(t.mode) {
| |
| 407 | case "lastfm_album": | |
| 408 | /*_menu.AppendMenuItem(MF_STRING, 53, "Last.fm auto-correct"); | |
| 409 | _menu.CheckMenuItem(53, l.auto_correct); | |
| 410 | _menu.AppendMenuSeparator();*/ | |
| 411 | break; | |
| 412 | case "lastfm_wiki": | |
| 413 | /*_menu.AppendMenuItem(MF_STRING, 25, "Last.fm"); | |
| 414 | _menu.AppendMenuItem(MF_STRING, 26, "Wikipedia"); | |
| 415 | _menu.CheckMenuRadioItem(25, 26, t.source == "last.fm" ? 25 : 26); | |
| 416 | _menu.AppendMenuSeparator();*/ | |
| 417 | break; | |
| 418 | case "simple_tag": | |
| 419 | /*_menu.AppendMenuItem(MF_STRING, 1700, "Custom title..."); | |
| 420 | _menu.AppendMenuItem(MF_STRING, 1701, "Custom tag..."); | |
| 421 | _menu.AppendMenuSeparator(); | |
| 422 | _menu.AppendMenuItem(MF_STRING, 1702, "Centre text"); | |
| 423 | _menu.CheckMenuItem(1702, t.centre); | |
| 424 | _menu.AppendMenuSeparator();*/ | |
| 425 | break; | |
| 426 | case "simple_text": | |
| 427 | /*_menu.AppendMenuItem(MF_STRING, 1700, "Custom title..."); | |
| 428 | _menu.AppendMenuItem(MF_STRING, 200, "Custom path..."); | |
| 429 | _menu.AppendMenuSeparator(); | |
| 430 | _menu.AppendMenuItem(MF_STRING, 201, "Fixed width font"); | |
| 431 | _menu.CheckMenuItem(201, t.fixed); | |
| 432 | _menu.AppendMenuSeparator();*/ | |
| 433 | break; | |
| 434 | } | |
| 435 | break; | |
| 436 | case typeof th == "object": | |
| 437 | case typeof im == "object" && im.trace(x, y): | |
| 438 | if (im.mode == "last.fm") {
| |
| 439 | /*_menu.AppendMenuItem(this.metadb ? MF_STRING : MF_GRAYED, 450, "Download artist art from Last.fm"); | |
| 440 | _menu.AppendMenuSeparator(); | |
| 441 | _sub1.AppendMenuItem(MF_STRING, 451, "Off"); | |
| 442 | _sub1.AppendMenuItem(MF_STRING, 452, "Library tracks only"); | |
| 443 | _sub1.AppendMenuItem(MF_STRING, 453, "All tracks"); | |
| 444 | _sub1.CheckMenuRadioItem(451, 453, im.auto_download == "off" ? 451 : im.auto_download == "library" ? 452 : 453); | |
| 445 | //_sub1.AppendTo(_menu, MF_STRING, "Automatic download"); | |
| 446 | _sub2.AppendMenuItem(MF_STRING, 461, "1"); | |
| 447 | _sub2.AppendMenuItem(MF_STRING, 463, "3"); | |
| 448 | _sub2.AppendMenuItem(MF_STRING, 465, "5"); | |
| 449 | //_sub2.AppendMenuItem(MF_STRING, 470, "10"); | |
| 450 | //_sub2.AppendMenuItem(MF_STRING, 480, "20"); | |
| 451 | _sub2.CheckMenuRadioItem(461, 480, im.limit + 460); | |
| 452 | //_sub2.AppendTo(_menu, MF_STRING, "Limit");*/ | |
| 453 | ||
| 454 | } else {
| |
| 455 | //_menu.AppendMenuItem(MF_STRING, 442, "Set custom folder..."); | |
| 456 | } | |
| 457 | var _settings = window.CreatePopupMenu(); | |
| 458 | var _auto_cycle = window.CreatePopupMenu(); | |
| 459 | var _download_source = window.CreatePopupMenu(); | |
| 460 | var _download_limit = window.CreatePopupMenu(); | |
| 461 | var _download_quality = window.CreatePopupMenu(); | |
| 462 | var _thumbs = window.CreatePopupMenu(); | |
| 463 | var MF_POPUP = 0x00000010; | |
| 464 | var MF_GRAYED = 0x00000001; | |
| 465 | //_menu.AppendMenuSeparator(); | |
| 466 | //_menu.AppendMenuItem(MF_STRING, 403, "Auto YT"); | |
| 467 | //_menu.AppendMenuSeparator(); | |
| 468 | ||
| 469 | ||
| 470 | //Settings Menu | |
| 471 | //_menu.AppendMenuItem(MF_STRING | MF_POPUP, _settings.ID, "Auto YT"); | |
| 472 | ||
| 473 | //_menu.AppendMenuSeparator(); | |
| 474 | ||
| 475 | //_settings.AppendMenuItem(MF_STRING | MF_POPUP, _auto_cycle.ID, "Auto Cycle"); | |
| 476 | ||
| 477 | //_auto_cycle.AppendMenuItem(MF_STRING, 415, "05 sec"); | |
| 478 | //_auto_cycle.AppendMenuItem(MF_STRING, 420, "10 sec"); | |
| 479 | //_auto_cycle.AppendMenuItem(MF_STRING, 425, "15 sec"); | |
| 480 | //_auto_cycle.AppendMenuItem(MF_STRING, 430, "20 sec"); | |
| 481 | //_auto_cycle.AppendMenuItem(MF_STRING, 410, "Off"); | |
| 482 | //_auto_cycle.CheckMenuRadioItem(410, 430, cycle2 + 410); | |
| 483 | ||
| 484 | ||
| 485 | //_settings.AppendMenuItem(MF_STRING | MF_POPUP, _download_source.ID, "Download Source"); | |
| 486 | ||
| 487 | ||
| 488 | if(auto_yt==1) _menu.AppendMenuItem(MF_STRING, 1902, "Youtube Radio"); | |
| 489 | if(auto_yt==0) _menu.AppendMenuItem(MF_STRING, 1903, "Youtube Radio"); | |
| 490 | _menu.CheckMenuItem(1902, auto_yt?1:0); | |
| 491 | ||
| 492 | //if(auto_lfm==1) _menu.AppendMenuItem(MF_STRING, 1905, "Last.fm Radio"); | |
| 493 | //if(auto_lfm==0) _menu.AppendMenuItem(MF_STRING, 1906, "Last.fm Radio"); | |
| 494 | //_menu.CheckMenuItem(1905, auto_lfm?1:0); | |
| 495 | ||
| 496 | ||
| 497 | _menu.AppendMenuSeparator(); | |
| 498 | ||
| 499 | ||
| 500 | //_settings.AppendMenuItem(MF_STRING | MF_POPUP, _download_limit.ID, "Download Limit"); | |
| 501 | ||
| 502 | //_download_limit.AppendMenuItem(MF_STRING, 1905, "1x"); | |
| 503 | //_download_limit.AppendMenuItem(MF_STRING, 1906, "2x"); | |
| 504 | //_download_limit.AppendMenuItem(MF_STRING, 1907, "3x"); | |
| 505 | //_download_limit.AppendMenuItem(MF_STRING, 1908, "4x"); | |
| 506 | //_download_limit.AppendMenuItem(MF_STRING, 1909, "5x"); | |
| 507 | //_download_limit.AppendMenuItem(MF_STRING, 1910, "6x"); | |
| 508 | //_download_limit.CheckMenuRadioItem(1905, 1910, im.limit + 1904); | |
| 509 | ||
| 510 | ||
| 511 | //if (server=="last.fm") _settings.AppendMenuItem(MF_STRING | MF_POPUP, _download_quality.ID, "Download Quality"); | |
| 512 | /*_download_quality.AppendMenuItem(MF_STRING, 1911, "Low"); | |
| 513 | _download_quality.AppendMenuItem(MF_STRING, 1912, "Medium"); | |
| 514 | _download_quality.AppendMenuItem(MF_STRING, 1913, "High"); | |
| 515 | _download_quality.CheckMenuRadioItem(1911, 1913, size == "low" ? 1911 : size == "medium" ? 1912 : size == "high" ? 1913 : 1913); | |
| 516 | ||
| 517 | ||
| 518 | ||
| 519 | _settings.AppendMenuItem(MF_STRING | MF_POPUP, _thumbs.ID, "Thumbs"); | |
| 520 | ||
| 521 | _thumbs.AppendMenuItem(MF_STRING, 1201, "Left"); | |
| 522 | _thumbs.AppendMenuItem(MF_STRING, 1202, "Right"); | |
| 523 | _thumbs.AppendMenuItem(MF_STRING, 1203, "Top"); | |
| 524 | _thumbs.AppendMenuItem(MF_STRING, 1204, "Bottom"); | |
| 525 | _thumbs.AppendMenuItem(MF_STRING, 1205, "Off"); | |
| 526 | _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); | |
| 527 | ||
| 528 | ||
| 529 | ||
| 530 | if (th.mode == "left" | th.mode == "right" | th.mode == "top" | th.mode == "bottom") | |
| 531 | {
| |
| 532 | _thumbs.AppendMenuSeparator(); | |
| 533 | _thumbs.AppendMenuItem(MF_STRING, 1240, "40px"); | |
| 534 | _thumbs.AppendMenuItem(MF_STRING, 1250, "50px"); | |
| 535 | _thumbs.AppendMenuItem(MF_STRING, 1260, "60px"); | |
| 536 | _thumbs.AppendMenuItem(MF_STRING, 1270, "70px"); | |
| 537 | _thumbs.AppendMenuItem(MF_STRING, 1280, "80px"); | |
| 538 | _thumbs.AppendMenuItem(MF_STRING, 1290, "90px"); | |
| 539 | _thumbs.AppendMenuItem(MF_STRING, 1300, "100px"); | |
| 540 | _thumbs.AppendMenuItem(MF_STRING, 1350, "150px"); | |
| 541 | _thumbs.AppendMenuItem(MF_STRING, 1400, "200px"); | |
| 542 | _thumbs.AppendMenuItem(MF_STRING, 1450, "250px"); | |
| 543 | _thumbs.AppendMenuItem(MF_STRING, 1500, "300px"); | |
| 544 | _thumbs.CheckMenuRadioItem(1240, 1500, th.px + 1200); | |
| 545 | }*/ | |
| 546 | ||
| 547 | /* _sub3.AppendMenuItem(MF_STRING, 440, "Last.fm artist art"); | |
| 548 | _sub3.AppendMenuItem(MF_STRING, 441, "Custom folder"); | |
| 549 | _sub3.CheckMenuRadioItem(440, 441, im.mode == "last.fm" ? 440 : 441); | |
| 550 | //_sub3.AppendTo(_menu, MF_STRING, "Image source"); | |
| 551 | ||
| 552 | _menu.AppendMenuSeparator(); | |
| 553 | /*_sub4.AppendMenuItem(MF_STRING, 410, "Off"); | |
| 554 | _sub4.AppendMenuItem(MF_STRING, 415, "5 seconds"); | |
| 555 | _sub4.AppendMenuItem(MF_STRING, 420, "10 seconds"); | |
| 556 | _sub4.AppendMenuItem(MF_STRING, 430, "20 seconds"); | |
| 557 | _sub4.CheckMenuRadioItem(410, 430, im.cycle + 410); | |
| 558 | _sub4.CheckMenuRadioItem(410, 430, im.cycle + 410); | |
| 559 | _menu.AppendMenuSeparator();*/ | |
| 560 | if (typeof th == "object") {
| |
| 561 | if (!this.check_feature("now_playing")) _sub5.AppendMenuItem(MF_STRING, 1200, "Grid");
| |
| 562 | /*_sub5.AppendMenuItem(MF_STRING, 1201, "Left"); | |
| 563 | _sub5.AppendMenuItem(MF_STRING, 1202, "Right"); | |
| 564 | _sub5.AppendMenuItem(MF_STRING, 1203, "Top"); | |
| 565 | _sub5.AppendMenuItem(MF_STRING, 1204, "Bottom"); | |
| 566 | _sub5.AppendMenuItem(MF_STRING, 1205, "Off"); | |
| 567 | _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);*/ | |
| 568 | if (th.mode != "off") {
| |
| 569 | /*_sub5.AppendMenuSeparator(); | |
| 570 | _sub5.AppendMenuItem(MF_STRING, 1275, "75px"); | |
| 571 | _sub5.AppendMenuItem(MF_STRING, 1300, "100px"); | |
| 572 | _sub5.AppendMenuItem(MF_STRING, 1350, "150px"); | |
| 573 | _sub5.AppendMenuItem(MF_STRING, 1400, "200px"); | |
| 574 | _sub5.AppendMenuItem(MF_STRING, 1450, "250px"); | |
| 575 | _sub5.AppendMenuItem(MF_STRING, 1500, "300px"); | |
| 576 | _sub5.CheckMenuRadioItem(1275, 1500, th.px + 1200);*/ | |
| 577 | } | |
| 578 | //_sub5.AppendTo(_menu, MF_STRING, "Thumbs"); | |
| 579 | //_menu.AppendMenuSeparator(); | |
| 580 | } | |
| 581 | //if (im.trace(x, y) && im.images.length > 0 && (!this.check_feature("thumbs") || th.mode != "grid"))
| |
| 582 | {
| |
| 583 | if (auto_yt=="1") _menu.AppendMenuItem(MF_STRING, 22, "Get Next Video"); | |
| 584 | //if (auto_lfm=="1") _menu.AppendMenuItem(MF_STRING, 22, "Get Next Video"); | |
| 585 | if (auto_yt=="0") _menu.AppendMenuItem(MF_STRING, 21, "Get Next Video"); | |
| 586 | //_menu.AppendMenuItem(MF_STRING, 400, "Get All Videos") | |
| 587 | _menu.AppendMenuItem(MF_STRING, 401, "Search Videos"); | |
| 588 | _menu.AppendMenuSeparator(); | |
| 589 | //_menu.AppendMenuItem(MF_STRING, 402, "Search For Artist"); | |
| 590 | _menu.AppendMenuItem(MF_STRING, 1914, "Start Radio Station"); | |
| 591 | p.artist = p.eval("%artist%");
| |
| 592 | if (p.artist == "" || p.artist == "?") {_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Same Artist Station");}
| |
| 593 | else | |
| 594 | {_menu.AppendMenuItem(MF_STRING, 1915, "Same Artist Station");}
| |
| 595 | ||
| 596 | _menu.AppendMenuSeparator(); | |
| 597 | _menu.AppendMenuItem(MF_STRING, 403, "Open Same Video"); | |
| 598 | _menu.AppendMenuItem(MF_STRING, 404, "Find in Browser"); | |
| 599 | //_menu.AppendMenuItem(MF_STRING, 402, "Delete image"); | |
| 600 | //_menu.AppendMenuSeparator(); | |
| 601 | //_menu.AppendMenuItem(MF_STRING, 405, "Top"); | |
| 602 | //_menu.AppendMenuItem(MF_STRING, 404, "Centre"); | |
| 603 | //_menu.AppendMenuItem(MF_STRING, 406, "Adjust"); | |
| 604 | //_menu.AppendMenuItem(MF_STRING, 407, "Stretch"); | |
| 605 | _menu.CheckMenuRadioItem(404, 407, im.type == "centre" ? 404 : im.type == "top" ? 405 : im.type == "adjust" ? 406 : 407); | |
| 606 | _menu.AppendMenuSeparator(); | |
| 607 | } | |
| 608 | break; | |
| 609 | } | |
| 610 | if (this.check_feature("now_playing")) {
| |
| 611 | /*_menu.AppendMenuItem(MF_STRING, 44, "Top style"); | |
| 612 | _menu.AppendMenuItem(MF_STRING, 45, "Bottom style"); | |
| 613 | _menu.CheckMenuRadioItem(44, 45, np_track_top ? 44 : 45); | |
| 614 | _menu.AppendMenuSeparator(); | |
| 615 | _menu.AppendMenuItem(MF_STRING, 41, "Show CD cover"); | |
| 616 | _menu.CheckMenuItem(41, np_cd); | |
| 617 | _menu.AppendMenuItem(MF_STRING, 42, "Show track info"); | |
| 618 | _menu.CheckMenuItem(42, np_track); | |
| 619 | _menu.AppendMenuItem(MF_STRING, 46, "Show rating"); | |
| 620 | _menu.CheckMenuItem(46, np_rating); | |
| 621 | _menu.AppendMenuItem(MF_STRING, 40, "Show web links"); | |
| 622 | _menu.CheckMenuItem(40, np_buttons); | |
| 623 | _menu.AppendMenuItem(MF_STRING, 43, "Show biography"); | |
| 624 | _menu.CheckMenuItem(43, np_bio); | |
| 625 | _menu.AppendMenuSeparator();*/ | |
| 626 | } | |
| 627 | if (this.check_feature("custom_background")) {
| |
| 628 | if (!this.dui) _custom_background.AppendMenuItem(MF_STRING, 100, "None"); | |
| 629 | /*_custom_background.AppendMenuItem(MF_STRING, 101, this.dui ? "Use default UI setting" : "Use columns UI setting"); | |
| 630 | _custom_background.AppendMenuItem(MF_STRING, 102, "Splitter"); | |
| 631 | _custom_background.AppendMenuItem(MF_STRING, 104, "Pattern"); | |
| 632 | _custom_background.AppendMenuItem(MF_STRING, 103, "Custom"); | |
| 633 | _custom_background.AppendMenuSeparator(); | |
| 634 | _custom_background.AppendMenuItem(this.background_mode == 3 ? MF_STRING : MF_GRAYED, 105, "Set custom colour..."); | |
| 635 | _custom_background.CheckMenuRadioItem(101, 104, this.background_mode + 100); | |
| 636 | _custom_background.AppendTo(_menu, MF_STRING, "Background"); | |
| 637 | _menu.AppendMenuSeparator();*/ | |
| 638 | } | |
| 639 | if (typeof l == "object") {
| |
| 640 | //_menu.AppendMenuItem(MF_STRING, 1900, "Last.fm username..."); | |
| 641 | if (typeof ps == "object") _menu.AppendMenuItem(l.username.length > 0 ? MF_STRING : MF_GRAYED, 1901, "Last.fm password..."); | |
| 642 | //_menu.AppendMenuSeparator(); | |
| 643 | } | |
| 644 | if (this.check_feature("metadb")) {
| |
| 645 | /*_metadb.AppendMenuItem(MF_STRING, 900, "Use display preferences"); | |
| 646 | _metadb.AppendMenuItem(MF_STRING, 901, "Prefer now playing"); | |
| 647 | _metadb.AppendMenuItem(MF_STRING, 902, "Follow selected track"); | |
| 648 | _metadb.CheckMenuRadioItem(900, 903, this.selection_mode + 900);*/ | |
| 649 | //_metadb.AppendTo(_menu, MF_STRING, "Selection mode"); | |
| 650 | //_menu.AppendMenuSeparator(); | |
| 651 | } | |
| 652 | if (this.check_feature("remap")) {
| |
| 653 | //_menu.AppendMenuItem(MF_STRING, 7, "Artist field remapping..."); | |
| 654 | //_menu.AppendMenuSeparator(); | |
| 655 | } | |
| 656 | //_menu.AppendMenuItem(MF_STRING, 20, "Update script"); | |
| 657 | //_menu.AppendMenuSeparator(); | |
| 658 | //if (utils.IsKeyPressed(0x10)) _menu.AppendMenuItem(MF_STRING, 9, "Properties"); | |
| 659 | _menu.AppendMenuItem(MF_STRING, 9, "Properties..."); | |
| 660 | if (utils.IsKeyPressed(0x10)) _menu.AppendMenuItem(MF_STRING, 10, "Configure..."); | |
| 661 | idx = _menu.TrackPopupMenu(x, y); | |
| 662 | switch(idx) {
| |
| 663 | case 1: | |
| 664 | on_item_focus_change(); | |
| 665 | break; | |
| 666 | case 2: | |
| 667 | case 3: | |
| 668 | case 4: | |
| 669 | case 5: | |
| 670 | case 6: | |
| 671 | a.id = idx - 2; | |
| 672 | window.SetProperty("artreader_id", a.id);
| |
| 673 | on_item_focus_change(); | |
| 674 | break; | |
| 675 | case 7: | |
| 676 | 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);
| |
| 677 | if (this.artist_tf == "") this.artist_tf = "%path%"; | |
| 678 | window.SetProperty("YT Search", this.artist_tf);
| |
| 679 | on_item_focus_change(); | |
| 680 | break; | |
| 681 | case 9: | |
| 682 | window.ShowProperties(); | |
| 683 | break; | |
| 684 | case 10: | |
| 685 | window.ShowConfigure(); | |
| 686 | break; | |
| 687 | case 11: | |
| 688 | c.gloss = !c.gloss; | |
| 689 | window.SetProperty("cd_gloss", c.gloss);
| |
| 690 | window.Repaint(); | |
| 691 | break; | |
| 692 | case 12: | |
| 693 | c.shadow = !c.shadow; | |
| 694 | window.SetProperty("cd_shadow", c.shadow);
| |
| 695 | window.Repaint(); | |
| 696 | break; | |
| 697 | case 15: | |
| 698 | case 16: | |
| 699 | case 17: | |
| 700 | case 18: | |
| 701 | a.type = idx == 15 ? "centre" : idx == 16 ? "top" : idx == 17 ? "adjust" : "stretch"; | |
| 702 | window.SetProperty("artreader_image_type", a.type);
| |
| 703 | window.RepaintRect(a.x, a.y, a.w, a.h); | |
| 704 | break; | |
| 705 | case 20: | |
| 706 | this.update_script(); | |
| 707 | break; | |
| 708 | case 21: | |
| 709 | im.downloadLFM1(); | |
| 710 | break; | |
| 711 | case 22: | |
| 712 | im.downloadLFM1(); | |
| 713 | break; | |
| 714 | case 23: | |
| 715 | fb.ShowPopupMessage("You can get Album Art Downloader here:\n\nhttp://www.hydrogenaudio.org/forums/index.php?showtopic=57392", this.name);
| |
| 716 | break; | |
| 717 | case 25: | |
| 718 | case 26: | |
| 719 | t.source = idx == 25 ? "last.fm" : "wikipedia"; | |
| 720 | window.SetProperty("biography_source", t.source);
| |
| 721 | t.artist = ""; | |
| 722 | on_item_focus_change(); | |
| 723 | break; | |
| 724 | case 28: | |
| 725 | li.show_timestamp = !li.show_timestamp; | |
| 726 | window.SetProperty("show_timestamp", li.show_timestamp);
| |
| 727 | window.RepaintRect(li.x, li.y, li.w, li.h); | |
| 728 | break; | |
| 729 | case 29: | |
| 730 | li.discogs_match = !li.discogs_match; | |
| 731 | window.SetProperty("discogs_match", li.discogs_match);
| |
| 732 | li.artist = ""; | |
| 733 | on_item_focus_change(); | |
| 734 | break; | |
| 735 | case 30: | |
| 736 | case 31: | |
| 737 | case 32: | |
| 738 | this.normal_font_size = idx == 30 ? 12 : idx == 31 ? 14 : 16; | |
| 739 | window.SetProperty("normal_font_size", this.normal_font_size);
| |
| 740 | this.font_changed(); | |
| 741 | break; | |
| 742 | case 40: | |
| 743 | np_buttons = !np_buttons; | |
| 744 | window.SetProperty("np_buttons", np_buttons);
| |
| 745 | on_size(); | |
| 746 | window.Repaint(); | |
| 747 | break; | |
| 748 | case 41: | |
| 749 | np_cd = !np_cd; | |
| 750 | window.SetProperty("np_cd", np_cd);
| |
| 751 | window.Repaint(); | |
| 752 | break; | |
| 753 | case 42: | |
| 754 | np_track = !np_track; | |
| 755 | window.SetProperty("np_track", np_track);
| |
| 756 | on_size(); | |
| 757 | window.Repaint(); | |
| 758 | break; | |
| 759 | case 43: | |
| 760 | np_bio = !np_bio; | |
| 761 | window.SetProperty("np_bio", np_bio);
| |
| 762 | window.Repaint(); | |
| 763 | break; | |
| 764 | case 44: | |
| 765 | case 45: | |
| 766 | np_track_top = idx == 44 ? true : false; | |
| 767 | window.SetProperty("np_track_top", np_track_top);
| |
| 768 | on_size(); | |
| 769 | window.Repaint(); | |
| 770 | break; | |
| 771 | case 46: | |
| 772 | np_rating = !np_rating; | |
| 773 | window.SetProperty("np_rating", np_rating);
| |
| 774 | on_size(); | |
| 775 | window.Repaint(); | |
| 776 | break; | |
| 777 | case 51: | |
| 778 | case 52: | |
| 779 | case 53: | |
| 780 | l.auto_correct = !l.auto_correct; | |
| 781 | window.SetProperty("lastfm_auto_correct", l.auto_correct);
| |
| 782 | if (this.metadb) {
| |
| 783 | if (idx == 51) li.get(); | |
| 784 | if (idx == 53) t.get(); | |
| 785 | } | |
| 786 | break; | |
| 787 | case 100: | |
| 788 | case 101: | |
| 789 | case 102: | |
| 790 | case 103: | |
| 791 | case 104: | |
| 792 | this.background_mode = idx - 100; | |
| 793 | window.SetProperty("background_mode", this.background_mode);
| |
| 794 | window.Repaint(); | |
| 795 | break; | |
| 796 | case 105: | |
| 797 | 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);
| |
| 798 | window.SetProperty("background_custom_colour", this.background_custom_colour);
| |
| 799 | window.Repaint(); | |
| 800 | break; | |
| 801 | case 200: | |
| 802 | 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);
| |
| 803 | window.SetProperty("text_filename_tf", t.filename_tf);
| |
| 804 | on_item_focus_change(); | |
| 805 | break; | |
| 806 | case 201: | |
| 807 | t.fixed = !t.fixed; | |
| 808 | window.SetProperty("text_fixed_font", t.fixed);
| |
| 809 | t.calc(); | |
| 810 | window.RepaintRect(t.x, t.y, t.w, t.h); | |
| 811 | break; | |
| 812 | case 400: | |
| 813 | im.downloadALL(); | |
| 814 | break; | |
| 815 | case 401: | |
| 816 | fb.RunMainMenuCommand("View/Youtube Source");
| |
| 817 | break; | |
| 818 | case 402: | |
| 819 | im.downloadART(); | |
| 820 | break; | |
| 821 | case 403: | |
| 822 | im.downloadART_TITLE(); | |
| 823 | break; | |
| 824 | case 404: | |
| 825 | p.artist = p.eval("%artist% %title%");
| |
| 826 | p.browser("http://www.youtube.com/results?search_query=" + encodeURIComponent(p.artist));
| |
| 827 | break; | |
| 828 | case 405: | |
| 829 | case 406: | |
| 830 | case 407: | |
| 831 | im.type = idx == 404 ? "centre" : idx == 405 ? "top" : idx == 406 ? "adjust" : "stretch"; | |
| 832 | //window.SetProperty("Image type", im.type);
| |
| 833 | window.Repaint(); | |
| 834 | break; | |
| 835 | case 410: | |
| 836 | case 415: | |
| 837 | case 420: | |
| 838 | case 425: | |
| 839 | case 430: | |
| 840 | cycle2 = idx - 410; | |
| 841 | window.SetProperty("Image cycle", cycle2);
| |
| 842 | cicleTimer = undefined; | |
| 843 | cicleTimerStarted = false; | |
| 844 | stopTimer(); | |
| 845 | startTimer(); | |
| 846 | cicleTimerStarted = true; | |
| 847 | break; | |
| 848 | case 440: | |
| 849 | case 441: | |
| 850 | im.mode = idx == 440 ? "last.fm" : "custom"; | |
| 851 | window.SetProperty("image_mode", im.mode);
| |
| 852 | im.artist = ""; | |
| 853 | im.folder = ""; | |
| 854 | on_item_focus_change(); | |
| 855 | break; | |
| 856 | case 442: | |
| 857 | 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);
| |
| 858 | if (im.custom_folder_tf == "") im.custom_folder_tf = "$directory_path(%path%)"; | |
| 859 | window.SetProperty("image_custom_folder_tf", im.custom_folder_tf);
| |
| 860 | im.folder = ""; | |
| 861 | on_item_focus_change(); | |
| 862 | break; | |
| 863 | case 450: | |
| 864 | im.download(); | |
| 865 | break; | |
| 866 | case 451: | |
| 867 | case 452: | |
| 868 | case 453: | |
| 869 | im.auto_download = idx == 451 ? "on" : idx == 452 ? "library" : "off"; | |
| 870 | window.SetProperty("image_auto_download", im.auto_download);
| |
| 871 | break; | |
| 872 | case 461: | |
| 873 | case 463: | |
| 874 | case 465: | |
| 875 | im.limit = idx - 460; | |
| 876 | window.SetProperty("image_limit", 50);
| |
| 877 | break; | |
| 878 | case 490: | |
| 879 | case 491: | |
| 880 | case 492: | |
| 881 | case 493: | |
| 882 | im.type = idx == 490 ? "centre" : idx == 491 ? "top" : idx == 492 ? "adjust" : "stretch"; | |
| 883 | window.SetProperty("image_type", im.type);
| |
| 884 | window.RepaintRect(im.x, im.y, im.w, im.h); | |
| 885 | break; | |
| 886 | case 500: | |
| 887 | case 501: | |
| 888 | case 502: | |
| 889 | li.echonest_mode = idx - 500; | |
| 890 | window.SetProperty("echonest_mode", li.echonest_mode);
| |
| 891 | li.artist = ""; | |
| 892 | on_item_focus_change(); | |
| 893 | break; | |
| 894 | case 600: | |
| 895 | li.autoplaylists_title = this.InputBox("Enter a new title", this.name, li.autoplaylists_title);
| |
| 896 | if (li.autoplaylists_title == "") li.autoplaylists_title = "Autoplaylists"; | |
| 897 | window.SetProperty("autoplaylists_title", li.autoplaylists_title);
| |
| 898 | window.Repaint(); | |
| 899 | break; | |
| 900 | case 601: | |
| 901 | case 602: | |
| 902 | case 603: | |
| 903 | case 604: | |
| 904 | case 605: | |
| 905 | case 606: | |
| 906 | case 607: | |
| 907 | case 608: | |
| 908 | li.autoplaylists_slot = idx - 600; | |
| 909 | window.SetProperty("autoplaylists_slot", li.autoplaylists_slot);
| |
| 910 | li.filename = this.settings_folder + "autoplaylists" + li.autoplaylists_slot; | |
| 911 | li.offset = 0; | |
| 912 | li.update(); | |
| 913 | break; | |
| 914 | case 610: | |
| 915 | case 611: | |
| 916 | li.autoplaylists_success = idx == 610 ? true : false; | |
| 917 | window.SetProperty("autoplaylists_success", li.autoplaylists_success);
| |
| 918 | break; | |
| 919 | case 620: | |
| 920 | case 621: | |
| 921 | case 622: | |
| 922 | case 623: | |
| 923 | case 624: | |
| 924 | case 625: | |
| 925 | case 626: | |
| 926 | case 627: | |
| 927 | li.data.push(li.autoplaylists_deleted_items[idx - 620]); | |
| 928 | if (li.data.length > li.rows) li.offset = li.data.length - li.rows; | |
| 929 | li.autoplaylists_deleted_items.splice(idx - 620, 1); | |
| 930 | this.save(li.data.join("\n"), li.filename);
| |
| 931 | window.NotifyOthers("autoplaylists", "update");
| |
| 932 | li.update(); | |
| 933 | break; | |
| 934 | case 650: | |
| 935 | li.autoplaylists_remove_duplicates = !li.autoplaylists_remove_duplicates | |
| 936 | window.SetProperty("autoplaylists_remove_duplicates", li.autoplaylists_remove_duplicates);
| |
| 937 | break; | |
| 938 | case 700: | |
| 939 | case 701: | |
| 940 | li.musicbrainz_mode = idx == 700 ? "releases" : "URLs"; | |
| 941 | window.SetProperty("musicbrainz_mode", li.musicbrainz_mode);
| |
| 942 | li.artist = ""; | |
| 943 | on_item_focus_change(); | |
| 944 | break; | |
| 945 | case 702: | |
| 946 | li.musicbrainz_album = !li.musicbrainz_album; | |
| 947 | window.SetProperty("musicbrainz_album", li.musicbrainz_album);
| |
| 948 | li.artist = ""; | |
| 949 | on_item_focus_change(); | |
| 950 | break; | |
| 951 | case 703: | |
| 952 | li.musicbrainz_ep = !li.musicbrainz_ep; | |
| 953 | window.SetProperty("musicbrainz_ep", li.musicbrainz_ep);
| |
| 954 | li.artist = ""; | |
| 955 | on_item_focus_change(); | |
| 956 | break; | |
| 957 | case 704: | |
| 958 | li.musicbrainz_single = !li.musicbrainz_single; | |
| 959 | window.SetProperty("musicbrainz_single", li.musicbrainz_single);
| |
| 960 | li.artist = ""; | |
| 961 | on_item_focus_change(); | |
| 962 | break; | |
| 963 | case 705: | |
| 964 | li.musicbrainz_live = !li.musicbrainz_live; | |
| 965 | window.SetProperty("musicbrainz_live", li.musicbrainz_live);
| |
| 966 | li.artist = ""; | |
| 967 | on_item_focus_change(); | |
| 968 | break; | |
| 969 | case 706: | |
| 970 | li.musicbrainz_remix = !li.musicbrainz_remix; | |
| 971 | window.SetProperty("musicbrainz_remix", li.musicbrainz_remix);
| |
| 972 | li.artist = ""; | |
| 973 | on_item_focus_change(); | |
| 974 | break; | |
| 975 | case 707: | |
| 976 | li.musicbrainz_compilation = !li.musicbrainz_compilation; | |
| 977 | window.SetProperty("musicbrainz_compilation", li.musicbrainz_compilation);
| |
| 978 | li.artist = ""; | |
| 979 | on_item_focus_change(); | |
| 980 | break; | |
| 981 | case 708: | |
| 982 | li.musicbrainz_show_release_type = !li.musicbrainz_show_release_type; | |
| 983 | window.SetProperty("musicbrainz_show_release_type", li.musicbrainz_show_release_type);
| |
| 984 | window.RepaintRect(li.x, li.y, li.w, li.h); | |
| 985 | break; | |
| 986 | case 801: | |
| 987 | case 802: | |
| 988 | case 803: | |
| 989 | case 804: | |
| 990 | case 805: | |
| 991 | li.lastfm_mode = idx - 801; | |
| 992 | window.SetProperty("lastfm_mode", li.lastfm_mode);
| |
| 993 | li.artist = ""; | |
| 994 | on_item_focus_change(); | |
| 995 | break; | |
| 996 | case 810: | |
| 997 | li.lastfm_pause = !li.lastfm_pause; | |
| 998 | window.SetProperty("lastfm_pause", li.lastfm_pause);
| |
| 999 | break; | |
| 1000 | case 811: | |
| 1001 | case 812: | |
| 1002 | li.lastfm_button = idx == 811 ? "spotify" : "auto"; | |
| 1003 | window.SetProperty("lastfm_button", li.lastfm_button);
| |
| 1004 | window.RepaintRect(li.x, li.y, li.w, li.h); | |
| 1005 | break; | |
| 1006 | case 900: | |
| 1007 | case 901: | |
| 1008 | case 902: | |
| 1009 | this.selection_mode = idx - 900; | |
| 1010 | window.SetProperty("selection_mode", this.selection_mode);
| |
| 1011 | on_item_focus_change(); | |
| 1012 | break; | |
| 1013 | case 1000: | |
| 1014 | li.get(); | |
| 1015 | break; | |
| 1016 | case 1001: | |
| 1017 | case 1002: | |
| 1018 | case 1003: | |
| 1019 | li.lastfm_charts_mode = idx - 1001; | |
| 1020 | window.SetProperty("lastfm_charts_mode", li.lastfm_charts_mode);
| |
| 1021 | li.update(); | |
| 1022 | break; | |
| 1023 | case 1004: | |
| 1024 | case 1005: | |
| 1025 | case 1006: | |
| 1026 | case 1007: | |
| 1027 | case 1008: | |
| 1028 | case 1009: | |
| 1029 | li.lastfm_charts_period = idx - 1004; | |
| 1030 | window.SetProperty("lastfm_charts_period", li.lastfm_charts_period);
| |
| 1031 | li.update(); | |
| 1032 | break; | |
| 1033 | case 1010: | |
| 1034 | 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);
| |
| 1035 | window.SetProperty("lastfm_charts_bar_colour", li.lastfm_charts_bar_colour);
| |
| 1036 | window.Repaint(); | |
| 1037 | break; | |
| 1038 | case 1100: | |
| 1039 | case 1109: | |
| 1040 | ps.full_import = idx == 1100 ? true : false; | |
| 1041 | ps.start_import(); | |
| 1042 | break; | |
| 1043 | case 1101: | |
| 1044 | ps.finish_import(); | |
| 1045 | break; | |
| 1046 | case 1102: | |
| 1047 | ps.show_console = !ps.show_console; | |
| 1048 | window.SetProperty("playcount_sync_show_console", ps.show_console);
| |
| 1049 | break; | |
| 1050 | case 1103: | |
| 1051 | ps.library = !ps.library; | |
| 1052 | window.SetProperty("playcount_sync_library", ps.library);
| |
| 1053 | break; | |
| 1054 | case 1104: | |
| 1055 | case 1105: | |
| 1056 | ps.auto_love = idx == 1104 ? false : true; | |
| 1057 | window.SetProperty("playcount_sync_auto_love", ps.auto_love);
| |
| 1058 | break; | |
| 1059 | case 1106: | |
| 1060 | 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);
| |
| 1061 | window.SetProperty("playcount_sync_auto_love_tf", ps.auto_love_tf);
| |
| 1062 | break; | |
| 1063 | case 1107: | |
| 1064 | case 1108: | |
| 1065 | ps.icon = idx == 1107 ? "tango" : "silk"; | |
| 1066 | window.SetProperty("playcount_sync_icon", ps.icon);
| |
| 1067 | b.update(); | |
| 1068 | break; | |
| 1069 | case 1200: | |
| 1070 | case 1201: | |
| 1071 | case 1202: | |
| 1072 | case 1203: | |
| 1073 | case 1204: | |
| 1074 | case 1205: | |
| 1075 | th.mode = idx == 1200 ? "grid" : idx == 1201 ? "left" : idx == 1202 ? "right" : idx == 1203 ? "top" : idx == 1204 ? "bottom" : "off"; | |
| 1076 | //window.SetProperty("Thumbs mode", th.mode);
| |
| 1077 | th.nc = true; | |
| 1078 | on_size(); | |
| 1079 | window.Repaint(); | |
| 1080 | break; | |
| 1081 | case 1240: | |
| 1082 | case 1250: | |
| 1083 | case 1260: | |
| 1084 | case 1270: | |
| 1085 | case 1280: | |
| 1086 | case 1290: | |
| 1087 | case 1300: | |
| 1088 | case 1350: | |
| 1089 | case 1400: | |
| 1090 | case 1450: | |
| 1091 | case 1500: | |
| 1092 | th.px = idx - 1200; | |
| 1093 | ||
| 1094 | th.nc = true; | |
| 1095 | on_size(); | |
| 1096 | window.Repaint(); | |
| 1097 | break; | |
| 1098 | case 1700: | |
| 1099 | t.title = this.InputBox("You can use full title formatting here.", this.name, t.title);
| |
| 1100 | window.SetProperty("text_title", t.title);
| |
| 1101 | window.Repaint(); | |
| 1102 | break; | |
| 1103 | case 1701: | |
| 1104 | t.tag = this.InputBox("Enter a custom tag.", this.name, t.tag);
| |
| 1105 | window.SetProperty("text_tag", t.tag);
| |
| 1106 | t.filename = ""; | |
| 1107 | on_item_focus_change(); | |
| 1108 | break; | |
| 1109 | case 1702: | |
| 1110 | t.centre = !t.centre; | |
| 1111 | window.SetProperty("text_centre", t.centre);
| |
| 1112 | window.RepaintRect(t.x, t.y, t.w, t.h); | |
| 1113 | break; | |
| 1114 | case 1800: | |
| 1115 | case 1801: | |
| 1116 | case 1802: | |
| 1117 | var period = idx == 1800 ? 0 : idx == 1801 ? ONE_DAY : ONE_WEEK; | |
| 1118 | s.clear_images(period); | |
| 1119 | break; | |
| 1120 | case 1803: | |
| 1121 | s.library = !s.library; | |
| 1122 | window.SetProperty("seekbar_library", s.library);
| |
| 1123 | break; | |
| 1124 | case 1804: | |
| 1125 | 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);
| |
| 1126 | window.SetProperty("sox_params", s.sox_params);
| |
| 1127 | if (fb.IsPlaying) s.playback_new_track(); | |
| 1128 | break; | |
| 1129 | case 1805: | |
| 1130 | s.marker = this.InputBox("Enter a custom colour for the marker. Uses RGB. Example usage:\n\n234-211-74", this.name, s.marker);
| |
| 1131 | window.SetProperty("seekbar_marker", s.marker);
| |
| 1132 | break; | |
| 1133 | case 1900: | |
| 1134 | l.update_username(); | |
| 1135 | break; | |
| 1136 | case 1901: | |
| 1137 | l.update_password(); | |
| 1138 | break; | |
| 1139 | ||
| 1140 | ||
| 1141 | case 1902: | |
| 1142 | auto_yt = 0; | |
| 1143 | window.SetProperty("YT Radio", "0");
| |
| 1144 | break; | |
| 1145 | ||
| 1146 | case 1903: | |
| 1147 | auto_yt = 1; | |
| 1148 | window.SetProperty("YT Radio", "1");
| |
| 1149 | break; | |
| 1150 | ||
| 1151 | ||
| 1152 | case 1904: | |
| 1153 | if (server=="on")server = window.SetProperty("YT Radio", "off");
| |
| 1154 | if (server=="off")server = window.SetProperty("YT Radio", "on");
| |
| 1155 | break; | |
| 1156 | ||
| 1157 | case 1905: | |
| 1158 | auto_lfm = 0; | |
| 1159 | window.SetProperty("LFM Radio", "0");
| |
| 1160 | break; | |
| 1161 | ||
| 1162 | case 1906: | |
| 1163 | auto_lfm = 1; | |
| 1164 | window.SetProperty("LFM Radio", "1");
| |
| 1165 | break; | |
| 1166 | ||
| 1167 | case 1907: | |
| 1168 | case 1908: | |
| 1169 | case 1909: | |
| 1170 | case 1910: | |
| 1171 | im.limit = idx - 1904; | |
| 1172 | //window.SetProperty("Download limit", im.limit);
| |
| 1173 | break; | |
| 1174 | ||
| 1175 | case 1911: | |
| 1176 | case 1912: | |
| 1177 | case 1913: | |
| 1178 | size = idx == 1911 ? "low" : idx == 1912 ? "medium" : idx == 1913 ? "high" : "high"; | |
| 1179 | window.SetProperty("Download quality", size);
| |
| 1180 | break; | |
| 1181 | ||
| 1182 | case 1914: | |
| 1183 | Start = START_ARTIST; | |
| 1184 | START_ARTIST = this.InputBox("Type Artist to Start Station\n\n( *genre - will play genre station)", this.name, START_ARTIST);
| |
| 1185 | window.SetProperty("YT Station", START_ARTIST);
| |
| 1186 | if (START_ARTIST==Start) | |
| 1187 | {
| |
| 1188 | } | |
| 1189 | else | |
| 1190 | {
| |
| 1191 | auto_yt = 1; | |
| 1192 | window.SetProperty("YT Radio", "1");
| |
| 1193 | im.downloadLFM0(); | |
| 1194 | } | |
| 1195 | break; | |
| 1196 | ||
| 1197 | case 1915: | |
| 1198 | Start = START_ARTIST; | |
| 1199 | p.artist = p.eval("%artist%");
| |
| 1200 | if (p.artist == "" || p.artist == "?") return; | |
| 1201 | START_ARTIST = p.artist; | |
| 1202 | window.SetProperty("YT Station", p.artist);
| |
| 1203 | auto_yt = 1; | |
| 1204 | window.SetProperty("YT Radio", "1");
| |
| 1205 | on_item_focus_change(); | |
| 1206 | /*if (START_ARTIST==Start) | |
| 1207 | {
| |
| 1208 | } | |
| 1209 | else | |
| 1210 | {*/
| |
| 1211 | im.downloadLFM0(); | |
| 1212 | //} | |
| 1213 | break; | |
| 1214 | ||
| 1215 | ||
| 1216 | } | |
| 1217 | _menu.Dispose(); | |
| 1218 | _custom_background.Dispose(); | |
| 1219 | _metadb.Dispose(); | |
| 1220 | _cover.Dispose(); | |
| 1221 | _font.Dispose(); | |
| 1222 | _sub1.Dispose(); | |
| 1223 | _sub2.Dispose(); | |
| 1224 | _sub3.Dispose(); | |
| 1225 | _sub4.Dispose(); | |
| 1226 | _sub5.Dispose(); | |
| 1227 | } | |
| 1228 | ||
| 1229 | this.features_init = function() {
| |
| 1230 | for (i = 0; i < this.features.length; i++) {
| |
| 1231 | switch(this.features[i]) {
| |
| 1232 | case "custom_background": | |
| 1233 | //this.background_mode = (0); | |
| 1234 | //window.GetProperty("background_mode", 0);
| |
| 1235 | //this.background_custom_colour = ("0-0-0");
| |
| 1236 | //window.GetProperty("background_custom_colour", "0-0-0");
| |
| 1237 | break; | |
| 1238 | case "metadb": | |
| 1239 | this.selection_mode = 1; | |
| 1240 | break; | |
| 1241 | case "themes": | |
| 1242 | this.themed_seekbar = window.CreateThemeManager("Progress");
| |
| 1243 | this.themed_header = window.CreateThemeManager("Header");
| |
| 1244 | this.themed_header.SetPartAndStateId(1, 1); | |
| 1245 | this.themed_button = window.CreateThemeManager("Button");
| |
| 1246 | break; | |
| 1247 | case "remap": | |
| 1248 | this.artist_tf = window.GetProperty("YT Search", "%path%");
| |
| 1249 | break; | |
| 1250 | } | |
| 1251 | } | |
| 1252 | } | |
| 1253 | ||
| 1254 | this.check_feature = function(f) {
| |
| 1255 | for (i = 0; i < this.features.length; i++) {
| |
| 1256 | if (this.features[i] == f) return true; | |
| 1257 | } | |
| 1258 | return false; | |
| 1259 | } | |
| 1260 | ||
| 1261 | this.eval = function(tf) {
| |
| 1262 | if (!this.metadb || tf == "") return ""; | |
| 1263 | if (fb.IsPlaying && this.metadb.RawPath.indexOf("file://") != 0) {
| |
| 1264 | return fb.TitleFormat(tf).Eval(); | |
| 1265 | } else {
| |
| 1266 | return fb.TitleFormat(tf).EvalWithMetadb(this.metadb); | |
| 1267 | } | |
| 1268 | } | |
| 1269 | ||
| 1270 | this.open = function(filename) {
| |
| 1271 | return utils.ReadTextFile(filename); | |
| 1272 | } | |
| 1273 | ||
| 1274 | this.save = function(t, f) {
| |
| 1275 | try {
| |
| 1276 | var ts = this.fso.OpenTextFile(f, 2, true, -1); | |
| 1277 | ts.WriteLine(t); | |
| 1278 | ts.Close(); | |
| 1279 | return true; | |
| 1280 | } catch(e) {
| |
| 1281 | return false; | |
| 1282 | } | |
| 1283 | } | |
| 1284 | ||
| 1285 | this.console = function(message) {
| |
| 1286 | fb.trace(this.name + ": " + message); | |
| 1287 | } | |
| 1288 | ||
| 1289 | this.strip_tags = function(value) {
| |
| 1290 | if (!this.doc) this.doc = new ActiveXObject("htmlfile");
| |
| 1291 | try {
| |
| 1292 | this.doc.open(); | |
| 1293 | var div = this.doc.createElement("div");
| |
| 1294 | div.innerHTML = value.replace(/\n/g, "<br>"); | |
| 1295 | return div.innerText.trim(); | |
| 1296 | } catch(e) {
| |
| 1297 | return "Error reading content."; | |
| 1298 | } | |
| 1299 | } | |
| 1300 | ||
| 1301 | this.InputBox = function(prompt, title, value) {
| |
| 1302 | prompt = prompt.replace(/"/g, '" + Chr(34) + "').replace(/\n/g, '" + Chr(13) + "'); | |
| 1303 | title = title.replace(/"/g, '" + Chr(34) + "'); | |
| 1304 | value = value.replace(/"/g, '" + Chr(34) + "'); | |
| 1305 | var temp_value = this.vb.eval('InputBox' + '("' + prompt + '", "' + title + '", "' + value + '")');
| |
| 1306 | if (typeof temp_value == "undefined") return value; | |
| 1307 | 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);
| |
| 1308 | return temp_value.trim(); | |
| 1309 | } | |
| 1310 | ||
| 1311 | this.MsgBox = function(prompt, buttons, title) {
| |
| 1312 | prompt = prompt.replace(/"/g, '" + Chr(34) + "').replace(/\n/g, '" + Chr(13) + "'); | |
| 1313 | title = title.replace(/"/g, '" + Chr(34) + "'); | |
| 1314 | return this.vb.eval('MsgBox' + '("' + prompt + '", "' + buttons + '", "' + title + '")');
| |
| 1315 | } | |
| 1316 | ||
| 1317 | this.browser = function(command) {
| |
| 1318 | if (!this.run(command)) this.MsgBox("Unable to launch your default browser.", 0, this.name);
| |
| 1319 | } | |
| 1320 | ||
| 1321 | this.run = function(command) {
| |
| 1322 | try {
| |
| 1323 | this.WshShell.Run(command); | |
| 1324 | return true; | |
| 1325 | } catch(e) {
| |
| 1326 | return false; | |
| 1327 | } | |
| 1328 | } | |
| 1329 | ||
| 1330 | this.aad = function() {
| |
| 1331 | if (!this.app) this.app = new ActiveXObject("Shell.Application");
| |
| 1332 | var aad_path = window.GetProperty("aad_path", "");
| |
| 1333 | if (!this.fso.FileExists(aad_path)) {
| |
| 1334 | var folder = this.app.BrowseForFolder(0, "Locate Album Art Downloader", 0x00000200); | |
| 1335 | var file = folder ? folder.items().item().path + "\\AlbumArt.exe" : ""; | |
| 1336 | if (this.fso.FileExists(file)) {
| |
| 1337 | aad_path = file; | |
| 1338 | window.SetProperty("aad_path", file);
| |
| 1339 | } | |
| 1340 | } | |
| 1341 | if (this.fso.FileExists(aad_path)) {
| |
| 1342 | var album_artist = "/ar \"" + this.eval("[%album artist%]") + "\"";
| |
| 1343 | var album = " /al \"" + this.eval("[%album%]") + "\"";
| |
| 1344 | this.run("\"" + aad_path + "\"" + album_artist + album);
| |
| 1345 | } | |
| 1346 | } | |
| 1347 | ||
| 1348 | this.tt = function(t) {
| |
| 1349 | if (this.tooltip.Text == t) return; | |
| 1350 | this.tooltip.Text = t; | |
| 1351 | this.tooltip.Activate(); | |
| 1352 | } | |
| 1353 | ||
| 1354 | this.ttd = function() {
| |
| 1355 | this.tooltip.Text = ""; | |
| 1356 | this.tooltip.Deactivate(); | |
| 1357 | } | |
| 1358 | ||
| 1359 | this.splitRGB = function(value) {
| |
| 1360 | var temp_col = value.split("-");
| |
| 1361 | return RGB(temp_col[0], temp_col[1], temp_col[2]); | |
| 1362 | } | |
| 1363 | ||
| 1364 | this.draw_background = function(gr) {
| |
| 1365 | if (this.check_feature("custom_background")) {
| |
| 1366 | var col; | |
| 1367 | switch(this.background_mode) {
| |
| 1368 | case 0: | |
| 1369 | col = null; | |
| 1370 | break; | |
| 1371 | case 1: | |
| 1372 | col = this.backcolour; | |
| 1373 | break; | |
| 1374 | case 2: | |
| 1375 | col = utils.GetSysColor(15); | |
| 1376 | break; | |
| 1377 | case 3: | |
| 1378 | col = this.splitRGB(this.background_custom_colour); | |
| 1379 | break; | |
| 1380 | case 4: | |
| 1381 | col = null; | |
| 1382 | var spacing = 3; | |
| 1383 | var line_thickness = 1; | |
| 1384 | var bg = RGB(65, 65, 65); | |
| 1385 | var colour = RGB(92, 92, 92); | |
| 1386 | gr.FillSolidRect(0, 0, this.w, this.h, bg); | |
| 1387 | for (i = 0; i < Math.ceil(this.w / spacing); i++) {
| |
| 1388 | gr.DrawLine(i * spacing, 0, i * spacing, this.h, line_thickness, colour); | |
| 1389 | } | |
| 1390 | for (i = 0; i < Math.ceil(this.h / spacing); i++) {
| |
| 1391 | gr.DrawLine(0, i * spacing, this.w, i * spacing, line_thickness, colour); | |
| 1392 | } | |
| 1393 | break; | |
| 1394 | } | |
| 1395 | if (col) gr.FillSolidRect(0, 0, this.w, this.h, col); | |
| 1396 | } else {
| |
| 1397 | gr.FillSolidRect(0, 0, this.w, this.h, this.backcolour); | |
| 1398 | } | |
| 1399 | } | |
| 1400 | ||
| 1401 | this.draw_image = function(gr, img, pos_x, pos_y, width, height, type, border, alpha) {
| |
| 1402 | if (!img) return; | |
| 1403 | gr.SetInterpolationMode(7); | |
| 1404 | switch(type) {
| |
| 1405 | case "centre": | |
| 1406 | case "top": | |
| 1407 | {
| |
| 1408 | var sr = img.Width / img.Height; | |
| 1409 | var dr = width / height; | |
| 1410 | if (sr < dr) {
| |
| 1411 | var r = img.Width / width; | |
| 1412 | var ch = height * r; | |
| 1413 | var sy = Math.round((img.Height - ch) / (type == "top" ? 1000 : 2)); | |
| 1414 | var cw = img.Width; | |
| 1415 | var sx = 0; | |
| 1416 | } else {
| |
| 1417 | var r = img.Height / height; | |
| 1418 | var cw = width * r; | |
| 1419 | var sx = Math.round((img.Width - cw) / 2); | |
| 1420 | var ch = img.Height; | |
| 1421 | var sy = 0; | |
| 1422 | } | |
| 1423 | {
| |
| 1424 | gr.DrawImage(img, pos_x, pos_y, width, height, sx + 5, sy + 5, cw - 10, ch - 10, 0, alpha || 255); | |
| 1425 | if (border) gr.DrawRect(pos_x, pos_y, width - 1, height - 1, 1, border); | |
| 1426 | } | |
| 1427 | } | |
| 1428 | break; | |
| 1429 | case "stretch": | |
| 1430 | //strech | |
| 1431 | ||
| 1432 | gr.DrawImage(img, pos_x, pos_y, width, height, 5, 5, img.Width-10, img.Height-10, 0, alpha || 255); | |
| 1433 | if (border) gr.DrawRect(pos_x, pos_y, width - 1, height - 1, 1, border); | |
| 1434 | ||
| 1435 | break; | |
| 1436 | case "adjust": | |
| 1437 | default: | |
| 1438 | //adjust | |
| 1439 | var s = Math.min(width / img.Width, height / img.Height); | |
| 1440 | var nw = Math.round(img.Width * s); | |
| 1441 | var nh = Math.round(img.Height * s); | |
| 1442 | pos_x += Math.round((width - nw) / 2); | |
| 1443 | pos_y += Math.round((height - nh) / 2); | |
| 1444 | ||
| 1445 | ||
| 1446 | gr.DrawImage(img, pos_x, pos_y, nw, nh, 5, 5, img.Width-10, img.Height-10, 0, alpha || 255); | |
| 1447 | if (border) gr.DrawRect(pos_x, pos_y, nw - 1, nh - 1, 1, border); | |
| 1448 | break; | |
| 1449 | ||
| 1450 | } | |
| 1451 | } | |
| 1452 | this.header = function(gr, text) {
| |
| 1453 | this.left_text(gr, text, this.title_font, this.textcolour_hl, 6, 6, this.w - 77, 24); | |
| 1454 | gr.DrawLine(6, 29, this.w - 6, 29, 1, this.textcolour_hl); | |
| 1455 | } | |
| 1456 | ||
| 1457 | this.centre_text = function(gr, text, font, colour, x, y, w, h) {
| |
| 1458 | gr.GdiDrawText(text, font, colour, x, y, w, h, DT_VCENTER | DT_CENTER | DT_WORDBREAK | DT_CALCRECT | DT_NOPREFIX); | |
| 1459 | } | |
| 1460 | ||
| 1461 | this.left_text = function(gr, text, font, colour, x, y, w, h) {
| |
| 1462 | gr.GdiDrawText(text, font, colour, x, y, w, h, DT_VCENTER | DT_END_ELLIPSIS | DT_CALCRECT | DT_NOPREFIX); | |
| 1463 | } | |
| 1464 | ||
| 1465 | this.right_text = function(gr, text, font, colour, x, y, w, h) {
| |
| 1466 | gr.GdiDrawText(text, font, colour, x, y, w, h, DT_VCENTER | DT_RIGHT | DT_END_ELLIPSIS | DT_CALCRECT | DT_NOPREFIX); | |
| 1467 | } | |
| 1468 | ||
| 1469 | this.format_time = function(t) {
| |
| 1470 | var h = Math.floor(t / 3600); | |
| 1471 | var m = Math.floor((t -= h * 3600) / 60); | |
| 1472 | var s = Math.floor(t -= m * 60); | |
| 1473 | return((h > 0 ? h + ":" + (m < 10 ? "0" + m : m) : m) + ":" + (s < 10 ? "0" + s : s)); | |
| 1474 | } | |
| 1475 | ||
| 1476 | this.check_version = function() {
| |
| 1477 | //not used any more but will leave intact so old scripts don't crash. | |
| 1478 | return; | |
| 1479 | } | |
| 1480 | ||
| 1481 | this.update_script = function() {
| |
| 1482 | if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
| |
| 1483 | this.xmlhttp.open("GET", this.common_url, true);
| |
| 1484 | this.xmlhttp.send(); | |
| 1485 | this.xmlhttp.onreadystatechange = function() {
| |
| 1486 | if (p.xmlhttp.readyState == 4) {
| |
| 1487 | switch(p.xmlhttp.status) {
| |
| 1488 | case 200: | |
| 1489 | var text = p.xmlhttp.responsetext; | |
| 1490 | switch (true) {
| |
| 1491 | case text.indexOf("function panel") == -1:
| |
| 1492 | p.MsgBox("Unexpected server error. Not updating.", 0, p.name);
| |
| 1493 | break; | |
| 1494 | case text.indexOf('var VERSION = "' + VERSION) == 0:
| |
| 1495 | p.MsgBox("Already using latest version.", 0, p.name);
| |
| 1496 | break; | |
| 1497 | default: | |
| 1498 | if (p.save(text, p.common_filename)) {
| |
| 1499 | if (p.MsgBox("Download successful. Restart foobar2000 now?", 4, p.name) == 6) fb.RunMainMenuCommand("File/Restart");
| |
| 1500 | } else {
| |
| 1501 | p.MsgBox("Unexpected error. Not updating.", 0, p.name);
| |
| 1502 | } | |
| 1503 | break; | |
| 1504 | } | |
| 1505 | break; | |
| 1506 | case 404: | |
| 1507 | 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);
| |
| 1508 | break; | |
| 1509 | default: | |
| 1510 | p.console(p.xmlhttp.responsetext || "HTTP error: " + p.xmlhttp.status); | |
| 1511 | break; | |
| 1512 | } | |
| 1513 | } | |
| 1514 | } | |
| 1515 | } | |
| 1516 | //remove false string from file names | |
| 1517 | this.clean_filename = function(filename) {
| |
| 1518 | return filename.replace(/[\/\\|:]/g, '-').replace(/\*/g, 'x').replace(/"/g, "''").replace(/[?<>]/g, '_'); | |
| 1519 | } | |
| 1520 | ||
| 1521 | ||
| 1522 | ||
| 1523 | this.json_parse = function(text) {
| |
| 1524 | try {
| |
| 1525 | var data = JSON.parse(text); | |
| 1526 | return data; | |
| 1527 | } catch(e) {
| |
| 1528 | this.console("JSON.parse error.");
| |
| 1529 | return false; | |
| 1530 | } | |
| 1531 | } | |
| 1532 | ||
| 1533 | this.name = name; | |
| 1534 | this.features = features; | |
| 1535 | this.dui = window.InstanceType; | |
| 1536 | this.script_path = fb.ProfilePath; | |
| 1537 | this.images_path = this.script_path + "images\\"; | |
| 1538 | this.root_url = "https://dl.dropboxusercontent.com/u/22801321/wsh/" | |
| 1539 | this.common_url = this.root_url + "marc2003/common7.js"; | |
| 1540 | this.common_filename = this.script_path + "common7.js"; | |
| 1541 | this.tooltip = window.CreateTooltip(); | |
| 1542 | this.w = 0; | |
| 1543 | this.h = 0; | |
| 1544 | this.mx = 0; | |
| 1545 | this.my = 0; | |
| 1546 | this.metadb = fb.GetFocusItem(); | |
| 1547 | this.WshShell = new ActiveXObject("WScript.Shell");
| |
| 1548 | this.fso = new ActiveXObject("Scripting.FileSystemObject");
| |
| 1549 | this.vb = new ActiveXObject("ScriptControl");
| |
| 1550 | this.vb.Language = "VBScript"; | |
| 1551 | //this.settings_folder = fb.ProfilePath + "last_fm\\"; | |
| 1552 | //if (!this.fso.FolderExists(this.settings_folder)) this.fso.CreateFolder(this.settings_folder); | |
| 1553 | ||
| 1554 | //this.data_folder = lfm_folder + "\\"; | |
| 1555 | //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; | |
| 1556 | //if (!this.fso.FolderExists(this.data_folder)) return; | |
| 1557 | this.artist = ""; | |
| 1558 | this.artist_tf = "%path%"; | |
| 1559 | this.normal_font_size = (12); | |
| 1560 | //window.GetProperty("normal_font_size", 12);
| |
| 1561 | this.list_font_size = 11; | |
| 1562 | this.up_img = gdi.Image(this.images_path + "down.png"); | |
| 1563 | this.down_img = gdi.Image(this.images_path + "down.png"); | |
| 1564 | this.metadb_func = typeof on_metadb_changed == "function"; | |
| 1565 | this.features_init(); | |
| 1566 | this.colors_changed(); | |
| 1567 | this.font_changed(); | |
| 1568 | } | |
| 1569 | ||
| 1570 | function artreader(x, y, w, h) {
| |
| 1571 | this.draw = function(gr) {
| |
| 1572 | if (!this.img) return; | |
| 1573 | p.draw_image(gr, this.img, this.x, this.y, this.w, this.h, this.type); | |
| 1574 | } | |
| 1575 | ||
| 1576 | this.metadb_changed = function() {
| |
| 1577 | if (!p.metadb) return; | |
| 1578 | this.img && this.img.Dispose(); | |
| 1579 | this.path = ""; | |
| 1580 | this.img = utils.GetAlbumArtV2(p.metadb, this.id); | |
| 1581 | window.RepaintRect(this.x, this.y, this.w, this.h); | |
| 1582 | utils.GetAlbumArtAsync(window.ID, p.metadb, this.id); | |
| 1583 | } | |
| 1584 | ||
| 1585 | this.get_album_art_done = function(ip) {
| |
| 1586 | this.path = ip; | |
| 1587 | } | |
| 1588 | ||
| 1589 | this.trace = function(x, y) {
| |
| 1590 | return (x > this.x && x < this.x + this.w && y > this.y && y < this.y + this.h); | |
| 1591 | } | |
| 1592 | ||
| 1593 | this.wheel = function(step) {
| |
| 1594 | if (!this.trace(p.mx, p.my)) return false; | |
| 1595 | this.id -= step; | |
| 1596 | if (this.id < 0) this.id = 4; | |
| 1597 | if (this.id > 4) this.id = 0; | |
| 1598 | window.SetProperty("artreader_id", this.id);
| |
| 1599 | this.metadb_changed(); | |
| 1600 | return true; | |
| 1601 | } | |
| 1602 | ||
| 1603 | this.move = function(x, y) {
| |
| 1604 | if (this.trace(x, y)) {
| |
| 1605 | if (this.img) p.tt("Original size: " + this.img.Width + "x" + this.img.Height + "px");
| |
| 1606 | return true; | |
| 1607 | } else {
| |
| 1608 | p.ttd(); | |
| 1609 | return false; | |
| 1610 | } | |
| 1611 | } | |
| 1612 | ||
| 1613 | this.lbtn_dblclk = function(x, y) {
| |
| 1614 | if (!this.trace(x, y)) return false; | |
| 1615 | if (this.img) p.run("explorer /select,\"" + this.path + "\"");
| |
| 1616 | return true; | |
| 1617 | } | |
| 1618 | ||
| 1619 | this.x = x; | |
| 1620 | this.y = y; | |
| 1621 | this.w = w; | |
| 1622 | this.h = h; | |
| 1623 | this.id = window.GetProperty("artreader_id", 0);
| |
| 1624 | this.img = null; | |
| 1625 | this.path = null; | |
| 1626 | this.type = window.GetProperty("artreader_image_type", "top");
| |
| 1627 | } | |
| 1628 | ||
| 1629 | function buttons() {
| |
| 1630 | this.draw = function(gr) {
| |
| 1631 | for (i in this.buttons) {
| |
| 1632 | this.buttons[i].draw(gr); | |
| 1633 | } | |
| 1634 | } | |
| 1635 | ||
| 1636 | this.move = function(x, y) {
| |
| 1637 | this.tmp_btn = null; | |
| 1638 | for (i in this.buttons) {
| |
| 1639 | if (this.buttons[i].trace(x, y)) this.tmp_btn = i; | |
| 1640 | } | |
| 1641 | if (this.btn == this.tmp_btn) return this.btn; | |
| 1642 | if (this.tmp_btn) this.buttons[this.tmp_btn].state("hover");
| |
| 1643 | if (this.btn) this.buttons[this.btn].state("normal");
| |
| 1644 | this.btn = this.tmp_btn; | |
| 1645 | return this.btn; | |
| 1646 | } | |
| 1647 | ||
| 1648 | this.lbtn_up = function(x, y) {
| |
| 1649 | if (!this.btn) return false; | |
| 1650 | this.buttons[this.btn].lbtn_up(x, y); | |
| 1651 | return true; | |
| 1652 | } | |
| 1653 | ||
| 1654 | this.leave = function() {
| |
| 1655 | if (this.btn) this.buttons[this.btn].state("normal");
| |
| 1656 | this.btn = null; | |
| 1657 | } | |
| 1658 | ||
| 1659 | this.buttons = []; | |
| 1660 | this.btn = null; | |
| 1661 | } | |
| 1662 | ||
| 1663 | function button(x, y, w, h, img_src, func, tiptext, themed) {
| |
| 1664 | this.draw = function (gr) {
| |
| 1665 | if (this.themed) {
| |
| 1666 | p.themed_button.SetPartAndStateId(1, this.id); | |
| 1667 | p.themed_button.DrawThemeBackground(gr, this.x, this.y, this.w, this.h); | |
| 1668 | 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"); | |
| 1669 | } else {
| |
| 1670 | this.img && p.draw_image(gr, this.img, this.x, this.y, this.w, this.h, "adjust"); | |
| 1671 | } | |
| 1672 | } | |
| 1673 | ||
| 1674 | this.trace = function(x, y) {
| |
| 1675 | return (x > this.x && x < this.x + this.w && y > this.y && y < this.y + this.h); | |
| 1676 | } | |
| 1677 | ||
| 1678 | this.lbtn_up = function () {
| |
| 1679 | this.func && this.func(x, y); | |
| 1680 | } | |
| 1681 | ||
| 1682 | this.state = function(s) {
| |
| 1683 | if (s == "hover") {
| |
| 1684 | this.img = this.img_hover; | |
| 1685 | this.id = 2; | |
| 1686 | p.tt(this.tiptext); | |
| 1687 | } else {
| |
| 1688 | this.img = this.img_normal; | |
| 1689 | this.id = 0; | |
| 1690 | p.ttd(); | |
| 1691 | } | |
| 1692 | window.RepaintRect(this.x, this.y, this.w, this.h); | |
| 1693 | } | |
| 1694 | ||
| 1695 | this.x = x; | |
| 1696 | this.y = y; | |
| 1697 | this.w = w; | |
| 1698 | this.h = h; | |
| 1699 | this.func = func; | |
| 1700 | this.tiptext = tiptext; | |
| 1701 | this.themed = themed; | |
| 1702 | this.id = 0; | |
| 1703 | this.img_normal = gdi.Image(p.images_path + img_src.normal); | |
| 1704 | this.img_hover = img_src.hover ? gdi.Image(p.images_path + img_src.hover) : this.img_normal; | |
| 1705 | this.img = this.img_normal; | |
| 1706 | } | |
| 1707 | ||
| 1708 | function cd(x, y, w, h) {
| |
| 1709 | this.draw = function(gr) {
| |
| 1710 | if (this.shadow) p.draw_image(gr, this.shadow_img, this.x, this.y, this.w, this.h, "adjust"); | |
| 1711 | p.draw_image(gr, this.case_img, this.x, this.y, this.w, this.h, "adjust"); | |
| 1712 | if (this.img) {
| |
| 1713 | this.ratio = Math.min(this.w / this.case_img.Width, this.h / this.case_img.Height); | |
| 1714 | this.nw = 488 * this.ratio; | |
| 1715 | this.nh = 476 * this.ratio; | |
| 1716 | this.nx = Math.round((this.w - (452 * this.ratio)) / 2); | |
| 1717 | this.ny = Math.round((this.h - this.nh) / 2); | |
| 1718 | p.draw_image(gr, this.img, this.nx + this.x, this.ny + this.y, this.nw, this.nh, "top"); | |
| 1719 | } | |
| 1720 | p.draw_image(gr, this.semi_img, this.x, this.y, this.w, this.h, "adjust"); | |
| 1721 | if (this.gloss) p.draw_image(gr, this.gloss_img, this.x, this.y, this.w, this.h, "adjust"); | |
| 1722 | } | |
| 1723 | ||
| 1724 | this.metadb_changed = function() {
| |
| 1725 | if (!p.metadb) return; | |
| 1726 | this.img && this.img.Dispose(); | |
| 1727 | this.path = ""; | |
| 1728 | this.img = utils.GetAlbumArtV2(p.metadb, 0); | |
| 1729 | window.Repaint(); | |
| 1730 | utils.GetAlbumArtAsync(window.ID, p.metadb, 0); | |
| 1731 | } | |
| 1732 | ||
| 1733 | this.get_album_art_done = function(ip) {;
| |
| 1734 | this.path = ip; | |
| 1735 | } | |
| 1736 | ||
| 1737 | this.trace = function(x, y) {
| |
| 1738 | return (x > this.x && x < this.x + this.w && y > this.y && y < this.y + this.h); | |
| 1739 | } | |
| 1740 | ||
| 1741 | this.move = function(x, y) {
| |
| 1742 | if (this.trace(x, y)) {
| |
| 1743 | if (this.img) p.tt("Original size: " + this.img.Width + "x" + this.img.Height + "px");
| |
| 1744 | return true; | |
| 1745 | } else {
| |
| 1746 | p.ttd(); | |
| 1747 | return false; | |
| 1748 | } | |
| 1749 | } | |
| 1750 | ||
| 1751 | this.lbtn_dblclk = function(x, y) {
| |
| 1752 | if (!this.trace(x, y)) return false; | |
| 1753 | if (this.img) p.run("explorer /select,\"" + this.path + "\"");
| |
| 1754 | return true; | |
| 1755 | } | |
| 1756 | ||
| 1757 | this.x = x; | |
| 1758 | this.y = y; | |
| 1759 | this.w = w; | |
| 1760 | this.h = h; | |
| 1761 | this.shadow_img = gdi.Image(p.images_path + "shadow.png"); | |
| 1762 | this.case_img = gdi.Image(p.images_path + "case.png"); | |
| 1763 | this.semi_img = gdi.Image(p.images_path + "semi.png"); | |
| 1764 | this.gloss_img = gdi.Image(p.images_path + "gloss.png"); | |
| 1765 | this.gloss = window.GetProperty("cd_gloss", false);
| |
| 1766 | this.shadow = window.GetProperty("cd_shadow", false);
| |
| 1767 | this.img = null; | |
| 1768 | this.path = null; | |
| 1769 | } | |
| 1770 | ||
| 1771 | function images(x, y, w, h) {
| |
| 1772 | this.playback_time = function(time) {
| |
| 1773 | 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(); | |
| 1774 | if (this.cycle > 0 && this.images.length > 1 && time % this.cycle == 0) {
| |
| 1775 | this.index++; | |
| 1776 | if (this.index == this.images.length) this.index = 0; | |
| 1777 | window.RepaintRect(this.x, this.y, this.w, this.h); | |
| 1778 | } | |
| 1779 | } | |
| 1780 | ||
| 1781 | this.draw = function (gr) {
| |
| 1782 | if (this.images.length == 0) return; | |
| 1783 | p.draw_image(gr, this.images[this.index], this.x, this.y, this.w, this.h, this.type); | |
| 1784 | } | |
| 1785 | ||
| 1786 | this.metadb_changed = function() {
| |
| 1787 | if (!p.metadb) return false; | |
| 1788 | switch(this.mode) {
| |
| 1789 | case "last.fm": | |
| 1790 | p.artist = p.eval(p.artist_tf); | |
| 1791 | if (this.artist == p.artist) return false; | |
| 1792 | this.artist = p.artist; | |
| 1793 | //this.folder = p.data_folder + p.clean_filename(p.artist); | |
| 1794 | //if (!p.fso.FolderExists(this.folder)) p.fso.CreateFolder(this.folder); | |
| 1795 | break; | |
| 1796 | case "custom": | |
| 1797 | this.temp_folder = p.eval(this.custom_folder_tf); | |
| 1798 | if (this.temp_folder == this.folder) return false; | |
| 1799 | this.folder = this.temp_folder; | |
| 1800 | break; | |
| 1801 | } | |
| 1802 | this.update(); | |
| 1803 | return true; | |
| 1804 | } | |
| 1805 | ||
| 1806 | this.trace = function(x, y) {
| |
| 1807 | return (x > this.x && x < this.x + this.w && y > this.y && y < this.y + this.h); | |
| 1808 | } | |
| 1809 | ||
| 1810 | this.wheel = function(step) {
| |
| 1811 | if (!p.metadb || this.images.length < 2 || !this.trace(p.mx, p.my) || (typeof th == "object" && th.mode == "grid" && !th.overlay)) return false; | |
| 1812 | this.index -= step; | |
| 1813 | if (this.index < 0) this.index = this.images.length - 1; | |
| 1814 | if (this.index >= this.images.length) this.index = 0; | |
| 1815 | window.RepaintRect(this.x, this.y, this.w, this.h); | |
| 1816 | return true; | |
| 1817 | } | |
| 1818 | ||
| 1819 | this.lbtn_dblclk = function(x, y) {
| |
| 1820 | if (!this.trace(x, y)) return false; | |
| 1821 | p.run("\"" + this.files[this.index] + "\"");
| |
| 1822 | return true; | |
| 1823 | } | |
| 1824 | ||
| 1825 | //LAST.FM RADIO-------------------------------------------------------------------------------------------------- | |
| 1826 | ||
| 1827 | //open simmilar artist | |
| 1828 | this.downloadLFM = function() | |
| 1829 | {
| |
| 1830 | //if (!p.fso.FolderExists(this.folder)) return; | |
| 1831 | {
| |
| 1832 | if (auto_yt=="1") | |
| 1833 | ||
| 1834 | {
| |
| 1835 | 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)
| |
| 1836 | ||
| 1837 | ||
| 1838 | { var randomnumber=Math.floor(Math.random()*18)
| |
| 1839 | var a=randomnumber; | |
| 1840 | this.working=true; | |
| 1841 | if (START_ARTIST == "" || START_ARTIST == "?") return; | |
| 1842 | //var folder = this.folder + "\\"; | |
| 1843 | if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
| |
| 1844 | this.xmlhttp.open("GET", "http://www.last.fm/music/" + encodeURIComponent(START_ARTIST) + "/+similar"+ "?page=" + a, true);
| |
| 1845 | this.xmlhttp.send(); | |
| 1846 | this.xmlhttp.onreadystatechange = function() {
| |
| 1847 | if (im.xmlhttp.readyState == 4) {
| |
| 1848 | if (im.xmlhttp.status == 200) {
| |
| 1849 | var text = im.xmlhttp.responsetext; | |
| 1850 | if (!im.doc) im.doc = new ActiveXObject("htmlfile");
| |
| 1851 | im.doc.open(); | |
| 1852 | var div = im.doc.createElement("div");
| |
| 1853 | div.innerHTML = text; | |
| 1854 | var data = div.getElementsByTagName("a");
| |
| 1855 | var urls = []; | |
| 1856 | ||
| 1857 | ||
| 1858 | ||
| 1859 | for (i = 0; i < data.length; i++) {
| |
| 1860 | 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(" wiki/edit","").replace("/ similar","").replace("?page=","'").replace("/ charts","'").replace("-","").replace("%2F%E3%82%A4%E3%83%95%E3%83%BB%E3%83%8E%E3%83%83%E3%83%88%E3%83%BB%E3%83%95%E3%82%A9%E3%83%BE3%83%BB%E3%83%A6%E3%83%BC","").replace("Ajoutez ce titre sur Deezer exclusivement sur www.hotmixradio.fr","").replace("www.Hituri.net","").replace("%E3%81%97%E3%82%83%E3%81%AB%E3%82%80%E3%81%AB%E3%82%B7%E3%82%A7%E3%82%A4%E3%82%AF%EF","").replace("%B81%E3%82%B7%E3%82%A7%E3%82%A4%E3%82%AF%EF%B81","").replace("%E4%BD%95%E3%82%88%E3%82%8A%E3%82%82%E5%83%95%E3%82%89%E3%81%97%E3%81%8F%E3%80%81%E4%BD%95%E3%82%88%E3%82%8A","").replace("%E3%82%82%E5%90%9B%E3%82%89%E3%81%97%E3%81%8F","").replace("%D0%91%D1%8D0%B5%D1%82 %D0%BF%D0%BE %D0%B3%D0%BB%D0%B0%D0%B7%D0%B0%D0%BC","").replace("%E3%83%9E%E3%82%A4%E3%83%BB%E3%83%9E3%83%87%E3%82%A3","").replace("%D0%9B%D0%B5%D1%82%D0%B5%D1%82%D1%8C","").replace("%2F%2F %D0%A1%D0%9B%D0%A3%D0%A8%D0%90%D0%AE%D0%A2","").replace("%D0%9F%D0%BE%D0%BF-%D0%A5%D0%B8%D1%82","").replace("/","").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'"));
| |
| 1861 | } | |
| 1862 | ||
| 1863 | ||
| 1864 | //select random URL | |
| 1865 | var randomnumber = Math.floor(Math.random()*(20-50)+50); | |
| 1866 | do{
| |
| 1867 | randomnumber = Math.floor(Math.random()*(20-50)+50); | |
| 1868 | } while(randomnumber%2!=1); | |
| 1869 | i=randomnumber; | |
| 1870 | ||
| 1871 | ||
| 1872 | //select all url | |
| 1873 | //for (i = 0; i < urls.length; i++) | |
| 1874 | {
| |
| 1875 | ||
| 1876 | //do something with urls[i] | |
| 1877 | //if (START_ARTIST.indexOf("*")== 0) {} else {p.console("" + urls[i]);}
| |
| 1878 | ||
| 1879 | if (urls[i] > "") | |
| 1880 | {
| |
| 1881 | ||
| 1882 | last_fm = window.SetProperty("YT Similar", urls[i]);
| |
| 1883 | last_fm = urls[i]; | |
| 1884 | window.SetProperty("YT Similar", urls[i]);
| |
| 1885 | } | |
| 1886 | else | |
| 1887 | //if (urls[i] == "" || urls[i] == "?") | |
| 1888 | {
| |
| 1889 | last_fm = window.SetProperty("YT Similar", "");
| |
| 1890 | last_fm = ""; | |
| 1891 | window.SetProperty("YT Similar", "");
| |
| 1892 | } | |
| 1893 | ||
| 1894 | } | |
| 1895 | ||
| 1896 | im.doc.close(); | |
| 1897 | im.working=false; | |
| 1898 | if (START_ARTIST.indexOf("*")== 0) {im.downloadGENRE2();}
| |
| 1899 | else | |
| 1900 | if (last_fm == "" || last_fm == "?") {im.downloadLFM();}
| |
| 1901 | else | |
| 1902 | im.downloadTRACK(); | |
| 1903 | //im.update(); | |
| 1904 | //window.NotifyOthers("images", "update");
| |
| 1905 | } else {
| |
| 1906 | if (START_ARTIST.indexOf("*")== 0) {} else {p.console("HTTP error: " + im.xmlhttp.status);}
| |
| 1907 | ||
| 1908 | if (START_ARTIST.indexOf("*")== 0) {im.downloadGENRE2();}
| |
| 1909 | else | |
| 1910 | if (im.xmlhttp.status == 404) {im.downloadLFM();}
| |
| 1911 | } | |
| 1912 | } | |
| 1913 | } | |
| 1914 | } | |
| 1915 | }} | |
| 1916 | ||
| 1917 | } | |
| 1918 | ||
| 1919 | ||
| 1920 | //Open track | |
| 1921 | this.downloadTRACK = function() | |
| 1922 | {
| |
| 1923 | //if (!p.fso.FolderExists(this.folder)) return; | |
| 1924 | //if (server==ooo) return true; | |
| 1925 | //else | |
| 1926 | {
| |
| 1927 | ||
| 1928 | ||
| 1929 | ||
| 1930 | ||
| 1931 | ||
| 1932 | {
| |
| 1933 | ||
| 1934 | ||
| 1935 | ||
| 1936 | {var randomnumber=Math.floor(Math.random()*20)
| |
| 1937 | var a=randomnumber; | |
| 1938 | this.working=true; | |
| 1939 | if (last_fm == "" || last_fm == "?") return; | |
| 1940 | //var folder = this.folder + "\\"; | |
| 1941 | if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
| |
| 1942 | this.xmlhttp.open("GET", "http://www.last.fm/music/" + encodeURIComponent(last_fm) + "/+tracks" + "?page=" + a, true);
| |
| 1943 | this.xmlhttp.send(); | |
| 1944 | this.xmlhttp.onreadystatechange = function() {
| |
| 1945 | if (im.xmlhttp.readyState == 4) {
| |
| 1946 | if (im.xmlhttp.status == 200) {
| |
| 1947 | var text = im.xmlhttp.responsetext; | |
| 1948 | if (!im.doc) im.doc = new ActiveXObject("htmlfile");
| |
| 1949 | im.doc.open(); | |
| 1950 | var div = im.doc.createElement("tr");
| |
| 1951 | div.innerHTML = text; | |
| 1952 | var data = div.getElementsByTagName("td");
| |
| 1953 | var urls = []; | |
| 1954 | ||
| 1955 | ||
| 1956 | ||
| 1957 | for (i = 0; i < data.length; i++) {
| |
| 1958 | if (data[i].title) urls.push(data[i].title.replace(/about:\//,"").replace(",","").replace("1","").replace("2","").replace("3","").replace("4","").replace("5","").replace("6","").replace("7","").replace("8","").replace("9","").replace("0","").replace("listeners","").replace("listener","").split("(")[0].split("[")[0].split(",")[0].split("{")[0].replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'"));
| |
| 1959 | } | |
| 1960 | ||
| 1961 | ||
| 1962 | //select random URL | |
| 1963 | var randomnumber = Math.floor(Math.random()*Math.max(urls.length)); | |
| 1964 | i=randomnumber; | |
| 1965 | ||
| 1966 | {
| |
| 1967 | ||
| 1968 | //do something with urls[i] | |
| 1969 | p.console("" + last_fm + " - " + urls[i]);
| |
| 1970 | ||
| 1971 | if (urls[i] > "") | |
| 1972 | {
| |
| 1973 | ||
| 1974 | ooo2 = window.SetProperty("YT Track", last_fm + " - " + urls[i]);
| |
| 1975 | ooo2 = urls[i]; | |
| 1976 | window.SetProperty("YT Track", last_fm + " - " + urls[i]);
| |
| 1977 | } | |
| 1978 | else | |
| 1979 | //if (urls[i] == "" || urls[i] == "?") | |
| 1980 | {
| |
| 1981 | ooo2 = window.SetProperty("YT Track", "");
| |
| 1982 | ooo2 = ""; | |
| 1983 | window.SetProperty("YT Track", "");
| |
| 1984 | } | |
| 1985 | } | |
| 1986 | ||
| 1987 | im.doc.close(); | |
| 1988 | im.working=false; | |
| 1989 | if (ooo2 == "" || ooo2 == "?") {im.downloadLFM();}
| |
| 1990 | else | |
| 1991 | im.downloadYT(); | |
| 1992 | //im.update(); | |
| 1993 | //window.NotifyOthers("images", "update");
| |
| 1994 | } else {
| |
| 1995 | p.console("HTTP error: " + im.xmlhttp.status);
| |
| 1996 | if (START_ARTIST.indexOf("*")== 0) {im.downloadGENRE2();}
| |
| 1997 | else | |
| 1998 | if (im.xmlhttp.status == 404) {im.downloadLFM();}
| |
| 1999 | ||
| 2000 | } | |
| 2001 | } | |
| 2002 | } | |
| 2003 | } | |
| 2004 | }}} | |
| 2005 | ||
| 2006 | ||
| 2007 | ||
| 2008 | ||
| 2009 | ||
| 2010 | //open Youtube | |
| 2011 | this.downloadYT = function() | |
| 2012 | {
| |
| 2013 | {
| |
| 2014 | ||
| 2015 | ||
| 2016 | {
| |
| 2017 | ||
| 2018 | //if (p.artist.indexOf("3dydfy://")== 0)
| |
| 2019 | ||
| 2020 | {
| |
| 2021 | this.working=true; | |
| 2022 | if (ooo2 == "" || ooo2 == "?") return; | |
| 2023 | if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
| |
| 2024 | this.xmlhttp.open("GET", "http://www.youtube.com/results?search_query=" + last_fm.replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ") +" %2D " + encodeURIComponent(ooo2).replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 "), true);
| |
| 2025 | this.xmlhttp.send(); | |
| 2026 | this.xmlhttp.onreadystatechange = function() {
| |
| 2027 | if (im.xmlhttp.readyState == 4) {
| |
| 2028 | if (im.xmlhttp.status == 200) {
| |
| 2029 | var text = im.xmlhttp.responsetext; | |
| 2030 | if (!im.doc) im.doc = new ActiveXObject("htmlfile");
| |
| 2031 | im.doc.open(); | |
| 2032 | var div = im.doc.createElement("div");
| |
| 2033 | div.innerHTML = text; | |
| 2034 | var data = div.getElementsByTagName("a");
| |
| 2035 | var urls = []; | |
| 2036 | ||
| 2037 | ||
| 2038 | ||
| 2039 | for (i = 0; i < data.length; i++) {
| |
| 2040 | if (data[i].href.indexOf("about:/watch?v=") == 0) urls.push("" + data[i].href.replace(/about:\//,"").replace("watch?",""));
| |
| 2041 | } | |
| 2042 | ||
| 2043 | //select random URL | |
| 2044 | //var randomnumber = Math.floor(Math.random()*Math.max(urls.length-1))+1; | |
| 2045 | //i=randomnumber; | |
| 2046 | i = 1; | |
| 2047 | ||
| 2048 | {
| |
| 2049 | ||
| 2050 | //do something with urls[i] | |
| 2051 | p.console("" + urls[i]);
| |
| 2052 | ||
| 2053 | if (urls[i] > "" && ooo2 > "") | |
| 2054 | {
| |
| 2055 | YT_URL = window.SetProperty("YT URL", urls[i]);
| |
| 2056 | YT_URL = urls[i]; | |
| 2057 | window.SetProperty("YT URL", urls[i]);
| |
| 2058 | ||
| 2059 | var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath; | |
| 2060 | var str = tmppath + "\\foobar2000.exe /add "; | |
| 2061 | var LFM0 = last_fm.replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ");
| |
| 2062 | var LFM1 = encodeURIComponent(LFM0).replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20");
| |
| 2063 | var go = str + "3dydfy://www.youtube.com/watch?fb2k_title=" + encodeURIComponent(ooo2) + "&" + "&fb2k_artist=" + decodeURIComponent(LFM1).replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20") + "&" + urls[i];
| |
| 2064 | p.run(go); | |
| 2065 | } | |
| 2066 | else | |
| 2067 | //if (urls[i] == "" || urls[i] == "?") | |
| 2068 | {
| |
| 2069 | YT_URL = window.SetProperty("YT URL", "");
| |
| 2070 | YT_URL = ""; | |
| 2071 | window.SetProperty("YT URL", "");
| |
| 2072 | } | |
| 2073 | ||
| 2074 | ||
| 2075 | ||
| 2076 | } | |
| 2077 | ||
| 2078 | im.doc.close(); | |
| 2079 | im.working=false; | |
| 2080 | if (YT_URL == "" || YT_URL == "?") {im.downloadLFM();}
| |
| 2081 | ||
| 2082 | } else {
| |
| 2083 | p.console("HTTP error: " + im.xmlhttp.status);
| |
| 2084 | if (START_ARTIST.indexOf("*")== 0) {im.downloadGENRE2();}
| |
| 2085 | else | |
| 2086 | if (im.xmlhttp.status == 404) {im.downloadLFM();}
| |
| 2087 | } | |
| 2088 | } | |
| 2089 | } | |
| 2090 | } | |
| 2091 | }}} | |
| 2092 | ||
| 2093 | ||
| 2094 | ||
| 2095 | //LAST.FM RADIO(One)-------------------------------------------------------------------------------------------------- | |
| 2096 | ||
| 2097 | //open simmilar artist | |
| 2098 | this.downloadLFM1 = function() | |
| 2099 | {
| |
| 2100 | ||
| 2101 | {
| |
| 2102 | ||
| 2103 | {
| |
| 2104 | //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)
| |
| 2105 | ||
| 2106 | ||
| 2107 | { var randomnumber=Math.floor(Math.random()*18)
| |
| 2108 | var a=randomnumber; | |
| 2109 | this.working=true; | |
| 2110 | if (START_ARTIST == "" || START_ARTIST == "?") return; | |
| 2111 | if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
| |
| 2112 | this.xmlhttp.open("GET", "http://www.last.fm/music/" + encodeURIComponent(START_ARTIST) + "/+similar"+ "?page=" + a, true);
| |
| 2113 | this.xmlhttp.send(); | |
| 2114 | this.xmlhttp.onreadystatechange = function() {
| |
| 2115 | if (im.xmlhttp.readyState == 4) {
| |
| 2116 | if (im.xmlhttp.status == 200) {
| |
| 2117 | var text = im.xmlhttp.responsetext; | |
| 2118 | if (!im.doc) im.doc = new ActiveXObject("htmlfile");
| |
| 2119 | im.doc.open(); | |
| 2120 | var div = im.doc.createElement("div");
| |
| 2121 | div.innerHTML = text; | |
| 2122 | var data = div.getElementsByTagName("a");
| |
| 2123 | var urls = []; | |
| 2124 | ||
| 2125 | ||
| 2126 | ||
| 2127 | for (i = 0; i < data.length; i++) {
| |
| 2128 | 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(" wiki/edit","").replace("/ similar","").replace("?page=","'").replace("/ charts","'").replace("-","").replace("%2F%E3%82%A4%E3%83%95%E3%83%BB%E3%83%8E%E3%83%83%E3%83%88%E3%83%BB%E3%83%95%E3%82%A9%E3%83%BE3%83%BB%E3%83%A6%E3%83%BC","").replace("Ajoutez ce titre sur Deezer exclusivement sur www.hotmixradio.fr","").replace("www.Hituri.net","").replace("%E3%81%97%E3%82%83%E3%81%AB%E3%82%80%E3%81%AB%E3%82%B7%E3%82%A7%E3%82%A4%E3%82%AF%EF","").replace("%B81%E3%82%B7%E3%82%A7%E3%82%A4%E3%82%AF%EF%B81","").replace("%E4%BD%95%E3%82%88%E3%82%8A%E3%82%82%E5%83%95%E3%82%89%E3%81%97%E3%81%8F%E3%80%81%E4%BD%95%E3%82%88%E3%82%8A","").replace("%E3%82%82%E5%90%9B%E3%82%89%E3%81%97%E3%81%8F","").replace("%D0%91%D1%8D0%B5%D1%82 %D0%BF%D0%BE %D0%B3%D0%BB%D0%B0%D0%B7%D0%B0%D0%BC","").replace("%E3%83%9E%E3%82%A4%E3%83%BB%E3%83%9E3%83%87%E3%82%A3","").replace("%D0%9B%D0%B5%D1%82%D0%B5%D1%82%D1%8C","").replace("%2F%2F %D0%A1%D0%9B%D0%A3%D0%A8%D0%90%D0%AE%D0%A2","").replace("%D0%9F%D0%BE%D0%BF-%D0%A5%D0%B8%D1%82","").replace("/","").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'"));
| |
| 2129 | } | |
| 2130 | ||
| 2131 | ||
| 2132 | //select random URL | |
| 2133 | var randomnumber = Math.floor(Math.random()*(20-50)+50); | |
| 2134 | do{
| |
| 2135 | randomnumber = Math.floor(Math.random()*(20-50)+50); | |
| 2136 | } while(randomnumber%2!=1); | |
| 2137 | i=randomnumber; | |
| 2138 | ||
| 2139 | //select all url | |
| 2140 | //for (i = 0; i < urls.length; i++) | |
| 2141 | {
| |
| 2142 | ||
| 2143 | //do something with urls[i] | |
| 2144 | //if (START_ARTIST.indexOf("*")== 0) {} else {p.console("" + urls[i]);}
| |
| 2145 | ||
| 2146 | if (urls[i] > "") | |
| 2147 | {
| |
| 2148 | ||
| 2149 | last_fm = window.SetProperty("YT Similar", urls[i]);
| |
| 2150 | last_fm = urls[i]; | |
| 2151 | window.SetProperty("YT Similar", urls[i]);
| |
| 2152 | } | |
| 2153 | else | |
| 2154 | //if (urls[i] == "" || urls[i] == "?") | |
| 2155 | {
| |
| 2156 | last_fm = window.SetProperty("YT Similar", "");
| |
| 2157 | last_fm = ""; | |
| 2158 | window.SetProperty("YT Similar", "");
| |
| 2159 | } | |
| 2160 | ||
| 2161 | } | |
| 2162 | ||
| 2163 | im.doc.close(); | |
| 2164 | im.working=false; | |
| 2165 | if (START_ARTIST.indexOf("*")== 0) {im.downloadGENRE2();}
| |
| 2166 | else | |
| 2167 | if (last_fm == "" || last_fm == "?") {im.downloadLFM1();}
| |
| 2168 | else | |
| 2169 | im.downloadTRACK1(); | |
| 2170 | //im.update(); | |
| 2171 | //window.NotifyOthers("images", "update");
| |
| 2172 | } else {
| |
| 2173 | if (START_ARTIST.indexOf("*")== 0) {} else {p.console("HTTP error: " + im.xmlhttp.status);}
| |
| 2174 | if (START_ARTIST.indexOf("*")== 0) {im.downloadGENRE2();}
| |
| 2175 | else | |
| 2176 | if (im.xmlhttp.status == 404) {im.downloadLFM1();}
| |
| 2177 | } | |
| 2178 | } | |
| 2179 | } | |
| 2180 | } | |
| 2181 | }} | |
| 2182 | ||
| 2183 | } | |
| 2184 | ||
| 2185 | ||
| 2186 | //Open track | |
| 2187 | this.downloadTRACK1 = function() | |
| 2188 | {
| |
| 2189 | {
| |
| 2190 | ||
| 2191 | ||
| 2192 | ||
| 2193 | ||
| 2194 | ||
| 2195 | {
| |
| 2196 | ||
| 2197 | ||
| 2198 | ||
| 2199 | {var randomnumber=Math.floor(Math.random()*20)
| |
| 2200 | var a=randomnumber; | |
| 2201 | this.working=true; | |
| 2202 | if (last_fm == "" || last_fm == "?") return; | |
| 2203 | //var folder = this.folder + "\\"; | |
| 2204 | if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
| |
| 2205 | this.xmlhttp.open("GET", "http://www.last.fm/music/" + encodeURIComponent(last_fm) + "/+tracks" + "?page=" + a, true);
| |
| 2206 | this.xmlhttp.send(); | |
| 2207 | this.xmlhttp.onreadystatechange = function() {
| |
| 2208 | if (im.xmlhttp.readyState == 4) {
| |
| 2209 | if (im.xmlhttp.status == 200) {
| |
| 2210 | var text = im.xmlhttp.responsetext; | |
| 2211 | if (!im.doc) im.doc = new ActiveXObject("htmlfile");
| |
| 2212 | im.doc.open(); | |
| 2213 | var div = im.doc.createElement("tr");
| |
| 2214 | div.innerHTML = text; | |
| 2215 | var data = div.getElementsByTagName("td");
| |
| 2216 | var urls = []; | |
| 2217 | ||
| 2218 | ||
| 2219 | ||
| 2220 | for (i = 0; i < data.length; i++) {
| |
| 2221 | if (data[i].title) urls.push(data[i].title.replace(/about:\//,"").replace(",","").replace("1","").replace("2","").replace("3","").replace("4","").replace("5","").replace("6","").replace("7","").replace("8","").replace("9","").replace("0","").replace("listeners","").replace("listener","").split("(")[0].split("[")[0].split(",")[0].split("{")[0].replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'"));
| |
| 2222 | } | |
| 2223 | ||
| 2224 | //select random URL | |
| 2225 | var randomnumber = Math.floor(Math.random()*Math.max(urls.length)); | |
| 2226 | i=randomnumber; | |
| 2227 | ||
| 2228 | {
| |
| 2229 | ||
| 2230 | //do something with urls[i] | |
| 2231 | p.console("" + last_fm + " - " + urls[i]);
| |
| 2232 | ||
| 2233 | if (urls[i] > "") | |
| 2234 | {
| |
| 2235 | ||
| 2236 | ooo2 = window.SetProperty("YT Track", last_fm + " - " + urls[i]);
| |
| 2237 | ooo2 = urls[i]; | |
| 2238 | window.SetProperty("YT Track", last_fm + " - " + urls[i]);
| |
| 2239 | } | |
| 2240 | else | |
| 2241 | //if (urls[i] == "" || urls[i] == "?") | |
| 2242 | {
| |
| 2243 | ooo2 = window.SetProperty("YT Track", "");
| |
| 2244 | ooo2 = ""; | |
| 2245 | window.SetProperty("YT Track", "");
| |
| 2246 | } | |
| 2247 | } | |
| 2248 | ||
| 2249 | im.doc.close(); | |
| 2250 | im.working=false; | |
| 2251 | if (ooo2 == "" || ooo2 == "?") {im.downloadLFM1();}
| |
| 2252 | else | |
| 2253 | im.downloadYT1(); | |
| 2254 | } else {
| |
| 2255 | p.console("HTTP error: " + im.xmlhttp.status);
| |
| 2256 | if (START_ARTIST.indexOf("*")== 0) {im.downloadGENRE2();}
| |
| 2257 | else | |
| 2258 | if (im.xmlhttp.status == 404) {im.downloadLFM1();}
| |
| 2259 | ||
| 2260 | } | |
| 2261 | } | |
| 2262 | } | |
| 2263 | } | |
| 2264 | }}} | |
| 2265 | ||
| 2266 | ||
| 2267 | ||
| 2268 | ||
| 2269 | ||
| 2270 | //open Youtube | |
| 2271 | this.downloadYT1 = function() | |
| 2272 | {
| |
| 2273 | {
| |
| 2274 | ||
| 2275 | {
| |
| 2276 | ||
| 2277 | //if (p.artist.indexOf("3dydfy://")== 0)
| |
| 2278 | ||
| 2279 | {
| |
| 2280 | this.working=true; | |
| 2281 | if (ooo2 == "" || ooo2 == "?") return; | |
| 2282 | if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
| |
| 2283 | this.xmlhttp.open("GET", "http://www.youtube.com/results?search_query=" + last_fm.replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ") +" %2D " + encodeURIComponent(ooo2).replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 "), true);
| |
| 2284 | this.xmlhttp.send(); | |
| 2285 | this.xmlhttp.onreadystatechange = function() {
| |
| 2286 | if (im.xmlhttp.readyState == 4) {
| |
| 2287 | if (im.xmlhttp.status == 200) {
| |
| 2288 | var text = im.xmlhttp.responsetext; | |
| 2289 | if (!im.doc) im.doc = new ActiveXObject("htmlfile");
| |
| 2290 | im.doc.open(); | |
| 2291 | var div = im.doc.createElement("div");
| |
| 2292 | div.innerHTML = text; | |
| 2293 | var data = div.getElementsByTagName("a");
| |
| 2294 | var urls = []; | |
| 2295 | ||
| 2296 | ||
| 2297 | ||
| 2298 | for (i = 0; i < data.length; i++) {
| |
| 2299 | if (data[i].href.indexOf("about:/watch?v=") == 0) urls.push("" + data[i].href.replace(/about:\//,"").replace("watch?",""));
| |
| 2300 | } | |
| 2301 | ||
| 2302 | //select random URL | |
| 2303 | //var randomnumber = Math.floor(Math.random()*Math.max(urls.length-1))+1; | |
| 2304 | //i=randomnumber; | |
| 2305 | i = 1; | |
| 2306 | ||
| 2307 | {
| |
| 2308 | ||
| 2309 | //do something with urls[i] | |
| 2310 | p.console("" + urls[i]);
| |
| 2311 | ||
| 2312 | if (urls[i] > "" && ooo2 > "") | |
| 2313 | {
| |
| 2314 | YT_URL = window.SetProperty("YT URL", urls[i]);
| |
| 2315 | YT_URL = urls[i]; | |
| 2316 | window.SetProperty("YT URL", urls[i]);
| |
| 2317 | ||
| 2318 | var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath; | |
| 2319 | var str = tmppath + "\\foobar2000.exe /add "; | |
| 2320 | var LFM0 = last_fm.replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ");
| |
| 2321 | var LFM1 = encodeURIComponent(LFM0).replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20");
| |
| 2322 | var go = str + "3dydfy://www.youtube.com/watch?fb2k_title=" + encodeURIComponent(ooo2) + "&" + "&fb2k_artist=" + decodeURIComponent(LFM1).replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20") + "&" + urls[i];
| |
| 2323 | p.run(go); | |
| 2324 | } | |
| 2325 | else | |
| 2326 | //if (urls[i] == "" || urls[i] == "?") | |
| 2327 | {
| |
| 2328 | YT_URL = window.SetProperty("YT URL", "");
| |
| 2329 | YT_URL = ""; | |
| 2330 | window.SetProperty("YT URL", "");
| |
| 2331 | } | |
| 2332 | ||
| 2333 | ||
| 2334 | ||
| 2335 | } | |
| 2336 | ||
| 2337 | im.doc.close(); | |
| 2338 | im.working=false; | |
| 2339 | if (YT_URL == "" || YT_URL == "?") {im.downloadLFM1();}
| |
| 2340 | ||
| 2341 | } else {
| |
| 2342 | p.console("HTTP error: " + im.xmlhttp.status);
| |
| 2343 | if (START_ARTIST.indexOf("*")== 0) {im.downloadGENRE2();}
| |
| 2344 | else | |
| 2345 | if (im.xmlhttp.status == 404) {im.downloadLFM1();}
| |
| 2346 | } | |
| 2347 | } | |
| 2348 | } | |
| 2349 | } | |
| 2350 | }}} | |
| 2351 | ||
| 2352 | ||
| 2353 | ||
| 2354 | //CHECK IF ARTIST EXIST-------------------------------------------------------------------------------------------------- | |
| 2355 | ||
| 2356 | this.downloadLFM0 = function() | |
| 2357 | ||
| 2358 | {
| |
| 2359 | this.working=true; | |
| 2360 | if (START_ARTIST == "" || START_ARTIST == "?") return; | |
| 2361 | if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
| |
| 2362 | this.xmlhttp.open("GET", "http://www.last.fm/music/" + encodeURIComponent(START_ARTIST) + "/+similar", true);
| |
| 2363 | this.xmlhttp.send(); | |
| 2364 | this.xmlhttp.onreadystatechange = function() {
| |
| 2365 | if (im.xmlhttp.readyState == 4) {
| |
| 2366 | if (im.xmlhttp.status == 200) {
| |
| 2367 | var text = im.xmlhttp.responsetext; | |
| 2368 | if (!im.doc) im.doc = new ActiveXObject("htmlfile");
| |
| 2369 | im.doc.open(); | |
| 2370 | var div = im.doc.createElement("div");
| |
| 2371 | div.innerHTML = text; | |
| 2372 | var data = div.getElementsByTagName("a");
| |
| 2373 | var urls = []; | |
| 2374 | ||
| 2375 | ||
| 2376 | ||
| 2377 | ||
| 2378 | im.doc.close(); | |
| 2379 | im.working=false; | |
| 2380 | im.downloadLFM000(); | |
| 2381 | ||
| 2382 | } else {
| |
| 2383 | if (START_ARTIST.indexOf("*")== 0) {} else {p.console("HTTP error: " + im.xmlhttp.status);}
| |
| 2384 | if (START_ARTIST.indexOf("*")== 0) {im.downloadGENRE2();}
| |
| 2385 | else | |
| 2386 | if (im.xmlhttp.status == 404) | |
| 2387 | {
| |
| 2388 | p.MsgBox("This Artist Not Found!", 0, p.name);
| |
| 2389 | } | |
| 2390 | ||
| 2391 | ||
| 2392 | } | |
| 2393 | } | |
| 2394 | } | |
| 2395 | } | |
| 2396 | ||
| 2397 | ||
| 2398 | ||
| 2399 | //START ARTIST RADIO(same artist)-------------------------------------------------------------------------------------------------- | |
| 2400 | ||
| 2401 | //open simmilar artist | |
| 2402 | this.downloadLFM000 = function() | |
| 2403 | {
| |
| 2404 | ||
| 2405 | {
| |
| 2406 | ||
| 2407 | {
| |
| 2408 | //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)
| |
| 2409 | ||
| 2410 | ||
| 2411 | { var randomnumber=Math.floor(Math.random()*18)
| |
| 2412 | var a=randomnumber; | |
| 2413 | this.working=true; | |
| 2414 | if (START_ARTIST == "" || START_ARTIST == "?") return; | |
| 2415 | if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
| |
| 2416 | this.xmlhttp.open("GET", "http://www.last.fm/music/" + encodeURIComponent(START_ARTIST) + "/+similar"+ "?page=" + a, true);
| |
| 2417 | this.xmlhttp.send(); | |
| 2418 | this.xmlhttp.onreadystatechange = function() {
| |
| 2419 | if (im.xmlhttp.readyState == 4) {
| |
| 2420 | if (im.xmlhttp.status == 200) {
| |
| 2421 | var text = im.xmlhttp.responsetext; | |
| 2422 | if (!im.doc) im.doc = new ActiveXObject("htmlfile");
| |
| 2423 | im.doc.open(); | |
| 2424 | var div = im.doc.createElement("div");
| |
| 2425 | div.innerHTML = text; | |
| 2426 | var data = div.getElementsByTagName("a");
| |
| 2427 | var urls = []; | |
| 2428 | ||
| 2429 | ||
| 2430 | ||
| 2431 | for (i = 0; i < data.length; i++) {
| |
| 2432 | 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(" wiki/edit","").replace("/ similar","").replace("?page=","'").replace("/ charts","'").replace("-","").replace("%2F%E3%82%A4%E3%83%95%E3%83%BB%E3%83%8E%E3%83%83%E3%83%88%E3%83%BB%E3%83%95%E3%82%A9%E3%83%BE3%83%BB%E3%83%A6%E3%83%BC","").replace("Ajoutez ce titre sur Deezer exclusivement sur www.hotmixradio.fr","").replace("www.Hituri.net","").replace("%E3%81%97%E3%82%83%E3%81%AB%E3%82%80%E3%81%AB%E3%82%B7%E3%82%A7%E3%82%A4%E3%82%AF%EF","").replace("%B81%E3%82%B7%E3%82%A7%E3%82%A4%E3%82%AF%EF%B81","").replace("%E4%BD%95%E3%82%88%E3%82%8A%E3%82%82%E5%83%95%E3%82%89%E3%81%97%E3%81%8F%E3%80%81%E4%BD%95%E3%82%88%E3%82%8A","").replace("%E3%82%82%E5%90%9B%E3%82%89%E3%81%97%E3%81%8F","").replace("%D0%91%D1%8D0%B5%D1%82 %D0%BF%D0%BE %D0%B3%D0%BB%D0%B0%D0%B7%D0%B0%D0%BC","").replace("%E3%83%9E%E3%82%A4%E3%83%BB%E3%83%9E3%83%87%E3%82%A3","").replace("%D0%9B%D0%B5%D1%82%D0%B5%D1%82%D1%8C","").replace("%2F%2F %D0%A1%D0%9B%D0%A3%D0%A8%D0%90%D0%AE%D0%A2","").replace("%D0%9F%D0%BE%D0%BF-%D0%A5%D0%B8%D1%82","").replace("/","").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'"));
| |
| 2433 | } | |
| 2434 | ||
| 2435 | ||
| 2436 | //select random URL | |
| 2437 | var randomnumber = Math.floor(Math.random()*(20-50)+50); | |
| 2438 | do{
| |
| 2439 | randomnumber = Math.floor(Math.random()*(20-50)+50); | |
| 2440 | } while(randomnumber%2!=1); | |
| 2441 | i=randomnumber; | |
| 2442 | ||
| 2443 | //select all url | |
| 2444 | //for (i = 0; i < urls.length; i++) | |
| 2445 | {
| |
| 2446 | ||
| 2447 | //do something with urls[i] | |
| 2448 | //if (START_ARTIST.indexOf("*")== 0) {} else {p.console("" + urls[i]);}
| |
| 2449 | ||
| 2450 | if (urls[i] > "") | |
| 2451 | {
| |
| 2452 | ||
| 2453 | last_fm = window.SetProperty("YT Similar", urls[i]);
| |
| 2454 | last_fm = urls[i]; | |
| 2455 | window.SetProperty("YT Similar", urls[i]);
| |
| 2456 | } | |
| 2457 | else | |
| 2458 | //if (urls[i] == "" || urls[i] == "?") | |
| 2459 | {
| |
| 2460 | last_fm = window.SetProperty("YT Similar", "");
| |
| 2461 | last_fm = ""; | |
| 2462 | window.SetProperty("YT Similar", "");
| |
| 2463 | } | |
| 2464 | ||
| 2465 | } | |
| 2466 | ||
| 2467 | im.doc.close(); | |
| 2468 | im.working=false; | |
| 2469 | if (START_ARTIST.indexOf("*")== 0) {im.downloadGENRE2();}
| |
| 2470 | else | |
| 2471 | if (last_fm == "" || last_fm == "?") {im.downloadLFM000();}
| |
| 2472 | else | |
| 2473 | im.downloadTRACK11(); | |
| 2474 | ||
| 2475 | } else {
| |
| 2476 | if (START_ARTIST.indexOf("*")== 0) {} else {p.console("HTTP error: " + im.xmlhttp.status);}
| |
| 2477 | if (START_ARTIST.indexOf("*")== 0) {im.downloadGENRE2();}
| |
| 2478 | else | |
| 2479 | if (im.xmlhttp.status == 404) {im.downloadLFM000();}
| |
| 2480 | ||
| 2481 | } | |
| 2482 | } | |
| 2483 | } | |
| 2484 | } | |
| 2485 | }} | |
| 2486 | ||
| 2487 | } | |
| 2488 | ||
| 2489 | ||
| 2490 | //Open track | |
| 2491 | this.downloadTRACK11 = function() | |
| 2492 | {
| |
| 2493 | {
| |
| 2494 | {
| |
| 2495 | ||
| 2496 | ||
| 2497 | {var randomnumber=Math.floor(Math.random()*20)
| |
| 2498 | var a=randomnumber; | |
| 2499 | this.working=true; | |
| 2500 | if (last_fm == "" || last_fm == "?") return; | |
| 2501 | //var folder = this.folder + "\\"; | |
| 2502 | if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
| |
| 2503 | this.xmlhttp.open("GET", "http://www.last.fm/music/" + encodeURIComponent(last_fm) + "/+tracks" + "?page=" + a, true);
| |
| 2504 | this.xmlhttp.send(); | |
| 2505 | this.xmlhttp.onreadystatechange = function() {
| |
| 2506 | if (im.xmlhttp.readyState == 4) {
| |
| 2507 | if (im.xmlhttp.status == 200) {
| |
| 2508 | var text = im.xmlhttp.responsetext; | |
| 2509 | if (!im.doc) im.doc = new ActiveXObject("htmlfile");
| |
| 2510 | im.doc.open(); | |
| 2511 | var div = im.doc.createElement("tr");
| |
| 2512 | div.innerHTML = text; | |
| 2513 | var data = div.getElementsByTagName("td");
| |
| 2514 | var urls = []; | |
| 2515 | ||
| 2516 | ||
| 2517 | ||
| 2518 | for (i = 0; i < data.length; i++) {
| |
| 2519 | if (data[i].title) urls.push(data[i].title.replace(/about:\//,"").replace(",","").replace("1","").replace("2","").replace("3","").replace("4","").replace("5","").replace("6","").replace("7","").replace("8","").replace("9","").replace("0","").replace("listeners","").replace("listener","").split("(")[0].split("[")[0].split(",")[0].split("{")[0].replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'"));
| |
| 2520 | } | |
| 2521 | ||
| 2522 | //select random URL | |
| 2523 | var randomnumber = Math.floor(Math.random()*Math.max(urls.length)); | |
| 2524 | i=randomnumber; | |
| 2525 | ||
| 2526 | {
| |
| 2527 | ||
| 2528 | //do something with urls[i] | |
| 2529 | p.console("" + last_fm + " - " + urls[i]);
| |
| 2530 | ||
| 2531 | if (urls[i] > "") | |
| 2532 | {
| |
| 2533 | ||
| 2534 | ooo2 = window.SetProperty("YT Track", last_fm + " - " + urls[i]);
| |
| 2535 | ooo2 = urls[i]; | |
| 2536 | window.SetProperty("YT Track", last_fm + " - " + urls[i]);
| |
| 2537 | } | |
| 2538 | else | |
| 2539 | //if (urls[i] == "" || urls[i] == "?") | |
| 2540 | {
| |
| 2541 | ooo2 = window.SetProperty("YT Track", "");
| |
| 2542 | ooo2 = ""; | |
| 2543 | window.SetProperty("YT Track", "");
| |
| 2544 | } | |
| 2545 | } | |
| 2546 | ||
| 2547 | im.doc.close(); | |
| 2548 | im.working=false; | |
| 2549 | if (ooo2 == "" || ooo2 == "?") {im.downloadLFM000();}
| |
| 2550 | else | |
| 2551 | im.downloadYT11(); | |
| 2552 | } else {
| |
| 2553 | p.console("HTTP error: " + im.xmlhttp.status);
| |
| 2554 | if (START_ARTIST.indexOf("*")== 0) {im.downloadGENRE2();}
| |
| 2555 | else | |
| 2556 | if (im.xmlhttp.status == 404) {im.downloadLFM000();}
| |
| 2557 | ||
| 2558 | ||
| 2559 | } | |
| 2560 | } | |
| 2561 | } | |
| 2562 | } | |
| 2563 | }}} | |
| 2564 | ||
| 2565 | ||
| 2566 | ||
| 2567 | ||
| 2568 | ||
| 2569 | //open Youtube | |
| 2570 | this.downloadYT11 = function() | |
| 2571 | {
| |
| 2572 | {
| |
| 2573 | ||
| 2574 | {
| |
| 2575 | ||
| 2576 | //if (p.artist.indexOf("3dydfy://")== 0)
| |
| 2577 | ||
| 2578 | {
| |
| 2579 | this.working=true; | |
| 2580 | if (ooo2 == "" || ooo2 == "?") return; | |
| 2581 | if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
| |
| 2582 | this.xmlhttp.open("GET", "http://www.youtube.com/results?search_query=" + last_fm.replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ") +" %2D " + encodeURIComponent(ooo2).replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 "), true);
| |
| 2583 | this.xmlhttp.send(); | |
| 2584 | this.xmlhttp.onreadystatechange = function() {
| |
| 2585 | if (im.xmlhttp.readyState == 4) {
| |
| 2586 | if (im.xmlhttp.status == 200) {
| |
| 2587 | var text = im.xmlhttp.responsetext; | |
| 2588 | if (!im.doc) im.doc = new ActiveXObject("htmlfile");
| |
| 2589 | im.doc.open(); | |
| 2590 | var div = im.doc.createElement("div");
| |
| 2591 | div.innerHTML = text; | |
| 2592 | var data = div.getElementsByTagName("a");
| |
| 2593 | var urls = []; | |
| 2594 | ||
| 2595 | ||
| 2596 | ||
| 2597 | for (i = 0; i < data.length; i++) {
| |
| 2598 | if (data[i].href.indexOf("about:/watch?v=") == 0) urls.push("" + data[i].href.replace(/about:\//,"").replace("watch?",""));
| |
| 2599 | } | |
| 2600 | ||
| 2601 | //select random URL | |
| 2602 | //var randomnumber = Math.floor(Math.random()*Math.max(urls.length-1))+1; | |
| 2603 | //i=randomnumber; | |
| 2604 | i = 1; | |
| 2605 | ||
| 2606 | {
| |
| 2607 | ||
| 2608 | //do something with urls[i] | |
| 2609 | p.console("" + urls[i]);
| |
| 2610 | ||
| 2611 | if (urls[i] > "" && ooo2 > "") | |
| 2612 | {
| |
| 2613 | YT_URL = window.SetProperty("YT URL", urls[i]);
| |
| 2614 | YT_URL = urls[i]; | |
| 2615 | window.SetProperty("YT URL", urls[i]);
| |
| 2616 | ||
| 2617 | var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath; | |
| 2618 | var str = tmppath + "\\foobar2000.exe /add "; | |
| 2619 | var LFM0 = last_fm.replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ").replace(" & ", " %26 ");
| |
| 2620 | var LFM1 = encodeURIComponent(LFM0).replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20");
| |
| 2621 | var go = str + "3dydfy://www.youtube.com/watch?fb2k_title=" + encodeURIComponent(ooo2) + "&" + "&fb2k_artist=" + decodeURIComponent(LFM1).replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20").replace(" ","%20") + "&" + urls[i];
| |
| 2622 | p.run(go); | |
| 2623 | } | |
| 2624 | else | |
| 2625 | //if (urls[i] == "" || urls[i] == "?") | |
| 2626 | {
| |
| 2627 | YT_URL = window.SetProperty("YT URL", "");
| |
| 2628 | YT_URL = ""; | |
| 2629 | window.SetProperty("YT URL", "");
| |
| 2630 | } | |
| 2631 | ||
| 2632 | ||
| 2633 | ||
| 2634 | } | |
| 2635 | im.doc.close(); | |
| 2636 | im.working=false; | |
| 2637 | if (YT_URL == "" || YT_URL == "?") {im.downloadLFM000();}
| |
| 2638 | ||
| 2639 | } else {
| |
| 2640 | p.console("HTTP error: " + im.xmlhttp.status);
| |
| 2641 | if (START_ARTIST.indexOf("*")== 0) {im.downloadGENRE2();}
| |
| 2642 | else | |
| 2643 | if (im.xmlhttp.status == 404) {im.downloadLFM000();}
| |
| 2644 | ||
| 2645 | } | |
| 2646 | } | |
| 2647 | } | |
| 2648 | } | |
| 2649 | }}} | |
| 2650 | ||
| 2651 | ||
| 2652 | ||
| 2653 | ||
| 2654 | ||
| 2655 | ||
| 2656 | ||
| 2657 | ||
| 2658 | ||
| 2659 | //Download Same Video------------------------------------------------------------------ | |
| 2660 | this.downloadART_TITLE = function() | |
| 2661 | {
| |
| 2662 | ||
| 2663 | {
| |
| 2664 | ||
| 2665 | ||
| 2666 | {
| |
| 2667 | ||
| 2668 | ||
| 2669 | ||
| 2670 | {
| |
| 2671 | this.working=true; | |
| 2672 | p.artist = p.eval("%artist% %title%");
| |
| 2673 | if (p.artist == "" || p.artist == "?") return; | |
| 2674 | var folder = this.folder + "\\"; | |
| 2675 | if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
| |
| 2676 | this.xmlhttp.open("GET", "http://www.youtube.com/results?search_query=" + encodeURIComponent(p.artist), true);
| |
| 2677 | this.xmlhttp.send(); | |
| 2678 | this.xmlhttp.onreadystatechange = function() {
| |
| 2679 | if (im.xmlhttp.readyState == 4) {
| |
| 2680 | if (im.xmlhttp.status == 200) {
| |
| 2681 | var text = im.xmlhttp.responsetext; | |
| 2682 | if (!im.doc) im.doc = new ActiveXObject("htmlfile");
| |
| 2683 | im.doc.open(); | |
| 2684 | var div = im.doc.createElement("div");
| |
| 2685 | div.innerHTML = text; | |
| 2686 | var data = div.getElementsByTagName("a");
| |
| 2687 | var urls = []; | |
| 2688 | ||
| 2689 | ||
| 2690 | ||
| 2691 | for (i = 0; i < data.length; i++) {
| |
| 2692 | if (data[i].href.indexOf("about:/watch?v=") == 0) urls.push("http://www.youtube.com/" + data[i].href.replace(/about:\//,""));
| |
| 2693 | } | |
| 2694 | ||
| 2695 | i=1; | |
| 2696 | {
| |
| 2697 | ||
| 2698 | //do something with urls[i] | |
| 2699 | p.console("" + urls[i]);
| |
| 2700 | ||
| 2701 | var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath; | |
| 2702 | var str = tmppath + "\\foobar2000.exe /add "; | |
| 2703 | var go = str + urls[i]; | |
| 2704 | p.run(go); | |
| 2705 | ||
| 2706 | } | |
| 2707 | ||
| 2708 | ||
| 2709 | ||
| 2710 | ||
| 2711 | im.doc.close(); | |
| 2712 | im.working=false; | |
| 2713 | im.update(); | |
| 2714 | window.NotifyOthers("images", "update");
| |
| 2715 | } else {
| |
| 2716 | p.console("HTTP error: " + im.xmlhttp.status);
| |
| 2717 | } | |
| 2718 | } | |
| 2719 | } | |
| 2720 | } | |
| 2721 | }}} | |
| 2722 | ||
| 2723 | ||
| 2724 | ||
| 2725 | //GENRE-------------------------------------------------------------------------------------------------- | |
| 2726 | ||
| 2727 | //open Genre | |
| 2728 | this.downloadGENRE2 = function() | |
| 2729 | {
| |
| 2730 | {
| |
| 2731 | ||
| 2732 | {
| |
| 2733 | if (START_ARTIST.indexOf("*")== 0)
| |
| 2734 | ||
| 2735 | ||
| 2736 | - | { var randomnumber=Math.floor(Math.random()*27)
|
| 2736 | + | { var randomnumber=Math.floor(Math.random()*gnr)
|
| 2737 | var a=randomnumber; | |
| 2738 | this.working=true; | |
| 2739 | if (START_ARTIST == "" || START_ARTIST == "?") return; | |
| 2740 | //var folder = this.folder + "\\"; | |
| 2741 | if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
| |
| 2742 | this.xmlhttp.open("GET", "http://www.last.fm/music/+tag/" + encodeURIComponent(START_ARTIST).replace("*","") + "?page=" + a, true);
| |
| 2743 | this.xmlhttp.send(); | |
| 2744 | this.xmlhttp.onreadystatechange = function() {
| |
| 2745 | if (im.xmlhttp.readyState == 4) {
| |
| 2746 | if (im.xmlhttp.status == 200) {
| |
| 2747 | var text = im.xmlhttp.responsetext; | |
| 2748 | if (!im.doc) im.doc = new ActiveXObject("htmlfile");
| |
| 2749 | im.doc.open(); | |
| 2750 | var div = im.doc.createElement("li");
| |
| 2751 | div.innerHTML = text; | |
| 2752 | var data = div.getElementsByTagName("a");
| |
| 2753 | var urls = []; | |
| 2754 | ||
| 2755 | ||
| 2756 | ||
| 2757 | for (i = 0; i < data.length; i++) {
| |
| 2758 | - | 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("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(" wiki/edit","").replace("/ similar","").replace("?page=","'").replace("/ charts","'").replace("-","").replace("%2F%E3%82%A4%E3%83%95%E3%83%BB%E3%83%8E%E3%83%83%E3%83%88%E3%83%BB%E3%83%95%E3%82%A9%E3%83%BE3%83%BB%E3%83%A6%E3%83%BC","").replace("Ajoutez ce titre sur Deezer exclusivement sur www.hotmixradio.fr","").replace("www.Hituri.net","").replace("%E3%81%97%E3%82%83%E3%81%AB%E3%82%80%E3%81%AB%E3%82%B7%E3%82%A7%E3%82%A4%E3%82%AF%EF","").replace("%B81%E3%82%B7%E3%82%A7%E3%82%A4%E3%82%AF%EF%B81","").replace("%E4%BD%95%E3%82%88%E3%82%8A%E3%82%82%E5%83%95%E3%82%89%E3%81%97%E3%81%8F%E3%80%81%E4%BD%95%E3%82%88%E3%82%8A","").replace("%E3%82%82%E5%90%9B%E3%82%89%E3%81%97%E3%81%8F","").replace("%D0%91%D1%8D0%B5%D1%82 %D0%BF%D0%BE %D0%B3%D0%BB%D0%B0%D0%B7%D0%B0%D0%BC","").replace("%E3%83%9E%E3%82%A4%E3%83%BB%E3%83%9E3%83%87%E3%82%A3","").replace("%D0%9B%D0%B5%D1%82%D0%B5%D1%82%D1%8C","").replace("%2F%2F %D0%A1%D0%9B%D0%A3%D0%A8%D0%90%D0%AE%D0%A2","").replace("%D0%9F%D0%BE%D0%BF-%D0%A5%D0%B8%D1%82","").replace("/","").split("tag")[0].split("hype")[0].split("events")[0]);
|
| 2758 | + | if (data[i].className.indexOf("name") == 0)
|
| 2759 | 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("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(" wiki/edit","").replace("/ similar","").replace("?page=","'").replace("/ charts","'").replace("-","").replace("%2F%E3%82%A4%E3%83%95%E3%83%BB%E3%83%8E%E3%83%83%E3%83%88%E3%83%BB%E3%83%95%E3%82%A9%E3%83%BE3%83%BB%E3%83%A6%E3%83%BC","").replace("Ajoutez ce titre sur Deezer exclusivement sur www.hotmixradio.fr","").replace("www.Hituri.net","").replace("%E3%81%97%E3%82%83%E3%81%AB%E3%82%80%E3%81%AB%E3%82%B7%E3%82%A7%E3%82%A4%E3%82%AF%EF","").replace("%B81%E3%82%B7%E3%82%A7%E3%82%A4%E3%82%AF%EF%B81","").replace("%E4%BD%95%E3%82%88%E3%82%8A%E3%82%82%E5%83%95%E3%82%89%E3%81%97%E3%81%8F%E3%80%81%E4%BD%95%E3%82%88%E3%82%8A","").replace("%E3%82%82%E5%90%9B%E3%82%89%E3%81%97%E3%81%8F","").replace("%D0%91%D1%8D0%B5%D1%82 %D0%BF%D0%BE %D0%B3%D0%BB%D0%B0%D0%B7%D0%B0%D0%BC","").replace("%E3%83%9E%E3%82%A4%E3%83%BB%E3%83%9E3%83%87%E3%82%A3","").replace("%D0%9B%D0%B5%D1%82%D0%B5%D1%82%D1%8C","").replace("%2F%2F %D0%A1%D0%9B%D0%A3%D0%A8%D0%90%D0%AE%D0%A2","").replace("%D0%9F%D0%BE%D0%BF-%D0%A5%D0%B8%D1%82","").replace("/","").split("tag")[0].split("hype")[0].split("events")[0]);
| |
| 2760 | } | |
| 2761 | ||
| 2762 | //select random URL | |
| 2763 | - | var randomnumber = Math.floor(Math.random()*(34-96)+96); |
| 2763 | + | var randomnumber = Math.floor(Math.random()*(0-9)+9); |
| 2764 | do{
| |
| 2765 | - | randomnumber = Math.floor(Math.random()*(34-96)+96); |
| 2765 | + | randomnumber = Math.floor(Math.random()*(0-9)+9); |
| 2766 | } while(randomnumber%2!=0); | |
| 2767 | ||
| 2768 | i=randomnumber; | |
| 2769 | ||
| 2770 | {
| |
| 2771 | ||
| 2772 | if (urls[i] > "") | |
| 2773 | //p.console("" + urls[i]);
| |
| 2774 | {
| |
| 2775 | ||
| 2776 | last_fm = window.SetProperty("YT Similar", urls[i]);
| |
| 2777 | last_fm = urls[i]; | |
| 2778 | window.SetProperty("YT Similar", urls[i]);
| |
| 2779 | } | |
| 2780 | else | |
| 2781 | {
| |
| 2782 | last_fm = window.SetProperty("YT Similar", "");
| |
| 2783 | last_fm = ""; | |
| 2784 | window.SetProperty("YT Similar", "");
| |
| 2785 | } | |
| 2786 | ||
| 2787 | } | |
| 2788 | ||
| 2789 | im.doc.close(); | |
| 2790 | im.working=false; | |
| 2791 | if (last_fm == "" || last_fm == "?") {im.downloadGENRE2();}
| |
| 2792 | else | |
| 2793 | im.downloadTRACK1(); | |
| 2794 | } else {
| |
| 2795 | p.console("HTTP error: " + im.xmlhttp.status);
| |
| 2796 | if (im.xmlhttp.status == 404) | |
| 2797 | {im.downloadGENRE2();}
| |
| 2798 | } | |
| 2799 | } | |
| 2800 | } | |
| 2801 | } | |
| 2802 | }} | |
| 2803 | ||
| 2804 | } | |
| 2805 | ||
| 2806 | ||
| 2807 | ||
| 2808 | this.update0 = function() {
| |
| 2809 | this.index = 0; | |
| 2810 | for (i = 0; i < this.images.length; i++) {
| |
| 2811 | try { this.images[i].Dispose(); } catch(e) {}
| |
| 2812 | } | |
| 2813 | this.folders = this.folder.split("|");
| |
| 2814 | this.files = []; | |
| 2815 | for (i = 0; i < this.folders.length; i++) {
| |
| 2816 | 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()); | |
| 2817 | } | |
| 2818 | this.images = []; | |
| 2819 | for (i = 0; i < this.files.length; i++) {
| |
| 2820 | this.images[i] = gdi.Image(this.files[i]); | |
| 2821 | } | |
| 2822 | if (typeof th == "object") {
| |
| 2823 | th.nc = true; | |
| 2824 | th.calc(); | |
| 2825 | } | |
| 2826 | window.Repaint(); | |
| 2827 | } | |
| 2828 | ||
| 2829 | ||
| 2830 | ||
| 2831 | this.update = function() {
| |
| 2832 | this.index = 0; | |
| 2833 | for (i = 0; i < this.images.length; i++) {
| |
| 2834 | try { this.images[i].Dispose(); } catch(e) {}
| |
| 2835 | } | |
| 2836 | this.folders = this.folder.split("|");
| |
| 2837 | this.files = []; | |
| 2838 | for (i = 0; i < this.folders.length; i++) {
| |
| 2839 | 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()); | |
| 2840 | } | |
| 2841 | ||
| 2842 | this.images = []; | |
| 2843 | for (i = 0; i < this.files.length; i++) {
| |
| 2844 | this.images[i] = gdi.Image(this.files[i]); | |
| 2845 | } | |
| 2846 | if (typeof th == "object") {
| |
| 2847 | th.nc = true; | |
| 2848 | th.calc(); | |
| 2849 | } | |
| 2850 | window.Repaint(); | |
| 2851 | } | |
| 2852 | ||
| 2853 | this.delete_image = function() {
| |
| 2854 | if (!this.app) this.app = new ActiveXObject("Shell.Application");
| |
| 2855 | this.app.Namespace(10).MoveHere(this.files[this.index]); | |
| 2856 | window.SetTimeout(function() {
| |
| 2857 | im.update(); | |
| 2858 | window.NotifyOthers("images", "update");
| |
| 2859 | }, 100); | |
| 2860 | } | |
| 2861 | ||
| 2862 | this.x = x; | |
| 2863 | this.y = y; | |
| 2864 | this.w = w; | |
| 2865 | this.h = h; | |
| 2866 | this.files = []; | |
| 2867 | this.images = []; | |
| 2868 | this.index = 0; | |
| 2869 | this.artist = ""; | |
| 2870 | this.folder = ""; | |
| 2871 | this.limit = 0; | |
| 2872 | //this.cycle = window.GetProperty("image_cycle", 0);
| |
| 2873 | this.mode = ("last.fm");
| |
| 2874 | //window.GetProperty("image_mode", "last.fm");
| |
| 2875 | this.type = "adjust"; | |
| 2876 | this.auto_download = "off"; | |
| 2877 | this.custom_folder_tf = "$directory_path(%path%)"; | |
| 2878 | } | |
| 2879 | ||
| 2880 | function lastfm() {
| |
| 2881 | this.notify_data = function(name, data) {
| |
| 2882 | if (name == "lastfm" && data == "update") {
| |
| 2883 | this.username = p.open(this.username_file).trim(); | |
| 2884 | this.sk = p.open(this.sk_file).trim(); | |
| 2885 | if (p.check_feature("lastfm_charts")) li.update();
| |
| 2886 | if (typeof ps == "object") {
| |
| 2887 | ps.loved_working = false; | |
| 2888 | ps.playcount_working = false; | |
| 2889 | b.update(); | |
| 2890 | on_item_focus_change(); | |
| 2891 | } | |
| 2892 | if (p.check_feature("lastfm")) {
| |
| 2893 | li.artist = ""; | |
| 2894 | on_item_focus_change(); | |
| 2895 | } | |
| 2896 | if (p.check_feature("lastfm_album")) {
| |
| 2897 | t.artist = ""; | |
| 2898 | t.album = ""; | |
| 2899 | on_item_focus_change(); | |
| 2900 | } | |
| 2901 | window.Repaint(); | |
| 2902 | } | |
| 2903 | } | |
| 2904 | ||
| 2905 | this.post = function(method, metadb) {
| |
| 2906 | if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
| |
| 2907 | switch(method) {
| |
| 2908 | case "auth.getMobileSession": | |
| 2909 | var func = function() {
| |
| 2910 | var json_data = p.json_parse(l.xmlhttp.responsetext); | |
| 2911 | if (!json_data) return; | |
| 2912 | if (json_data.error) {
| |
| 2913 | p.MsgBox(json_data.message, 0, p.name); | |
| 2914 | } else if (json_data.session) {
| |
| 2915 | p.save(json_data.session.key, l.sk_file); | |
| 2916 | window.NotifyOthers("lastfm", "update");
| |
| 2917 | l.notify_data("lastfm", "update");
| |
| 2918 | } | |
| 2919 | } | |
| 2920 | ||
| 2921 | this.authToken = hex_md5(this.username + hex_md5(this.password)); | |
| 2922 | this.api_sig = hex_md5("api_key" + this.api_key + "authToken" + this.authToken + "method" + method + "username" + this.username + this.secret);
| |
| 2923 | this.data = "method=" + method + "&api_key=" + this.api_key + "&api_sig=" + this.api_sig + "&format=json&authToken=" + this.authToken + "&username=" + this.username; | |
| 2924 | break; | |
| 2925 | case "track.love": | |
| 2926 | case "track.unlove": | |
| 2927 | var func = function() {
| |
| 2928 | var json_data = p.json_parse(l.xmlhttp.responsetext); | |
| 2929 | if (!json_data) return; | |
| 2930 | if (json_data.error) {
| |
| 2931 | p.console(json_data.message); | |
| 2932 | } else if (json_data.status && json_data.status == "ok") {
| |
| 2933 | p.console("Track " + (method == "track.love" ? "loved successfully." : "unloved successfully."));
| |
| 2934 | fb.RunContextCommandWithMetadb("Customdb Love " + (method == "track.love" ? 1 : 0), metadb, 8);
| |
| 2935 | } | |
| 2936 | } | |
| 2937 | ||
| 2938 | if (!metadb || this.username.length == 0 || this.sk.length != 32) return; | |
| 2939 | this.artist = fb.TitleFormat(p.artist_tf).EvalWithMetadb(metadb); | |
| 2940 | this.track = fb.TitleFormat("%title%").EvalWithMetadb(metadb);
| |
| 2941 | if (this.artist == "" || this.artist == "?" || this.track == "?") return; | |
| 2942 | p.console("Attempting to " + (method == "track.love" ? "love \"" : "unlove \"") + this.track + "\" by \"" + this.artist + "\"");
| |
| 2943 | p.console("Contacting Last.fm....");
| |
| 2944 | this.api_sig = hex_md5("api_key" + this.api_key + "artist" + this.artist + "method" + method + "sk" + this.sk + "track" + this.track + this.secret);
| |
| 2945 | 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); | |
| 2946 | break; | |
| 2947 | default: | |
| 2948 | return; | |
| 2949 | } | |
| 2950 | ||
| 2951 | this.xmlhttp.open("POST", "https://ws.audioscrobbler.com/2.0/", true);
| |
| 2952 | this.xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
| |
| 2953 | this.xmlhttp.setRequestHeader("User-Agent", this.user_agent);
| |
| 2954 | this.xmlhttp.send(this.data); | |
| 2955 | this.xmlhttp.onreadystatechange = function() {
| |
| 2956 | if (l.xmlhttp.readyState == 4) {
| |
| 2957 | if (l.xmlhttp.status == 200) {
| |
| 2958 | func(); | |
| 2959 | } else {
| |
| 2960 | p.console(l.xmlhttp.responsetext || "HTTP error: " + l.xmlhttp.status); | |
| 2961 | } | |
| 2962 | } | |
| 2963 | } | |
| 2964 | } | |
| 2965 | ||
| 2966 | this.update_username = function() {
| |
| 2967 | var old_username = this.username; | |
| 2968 | this.username = p.InputBox("Enter your Last.fm username.", p.name, this.username);
| |
| 2969 | if (this.username.length > 0 && this.username != old_username) p.save("", this.sk_file);
| |
| 2970 | p.save(this.username, this.username_file); | |
| 2971 | window.NotifyOthers("lastfm", "update");
| |
| 2972 | this.notify_data("lastfm", "update");
| |
| 2973 | } | |
| 2974 | ||
| 2975 | this.update_password = function() {
| |
| 2976 | this.password = p.InputBox("Enter your Last.fm password\n\nThis is only required to love/unlove tracks.", p.name, "");
| |
| 2977 | if (this.password.length > 0) {
| |
| 2978 | this.sk = ""; | |
| 2979 | p.save(this.sk, this.sk_file); | |
| 2980 | window.NotifyOthers("lastfm", "update");
| |
| 2981 | this.notify_data("lastfm", "update");
| |
| 2982 | this.post("auth.getMobileSession");
| |
| 2983 | } | |
| 2984 | } | |
| 2985 | ||
| 2986 | this.get_url = function() {
| |
| 2987 | return "http://ws.audioscrobbler.com/2.0/?format=json&api_key=" + this.api_key + "&user=" + this.username + "&username=" + this.username + "&s=" + Math.random(); | |
| 2988 | } | |
| 2989 | ||
| 2990 | this.username_error = "Use the right click menu to set your Last.fm username."; | |
| 2991 | this.password_error = "Use the right click menu to set your Last.fm password."; | |
| 2992 | this.url = "http://www.last.fm/"; | |
| 2993 | this.api_key = "56d9e050cc2d6b36102c8b4a5fe6152d"; | |
| 2994 | this.secret = "9f1f4346ce3ba206390074ff8cb4c6ce"; | |
| 2995 | this.user_agent = "foobar2000_wsh_panel_mod_scripts"; | |
| 2996 | this.username_file = p.settings_folder + "username"; | |
| 2997 | this.username = p.open(this.username_file).trim(); | |
| 2998 | this.sk_file = p.settings_folder + "sk"; | |
| 2999 | this.sk = p.open(this.sk_file).trim(); | |
| 3000 | this.auto_correct = window.GetProperty("lastfm_auto_correct", true);
| |
| 3001 | } | |
| 3002 | ||
| 3003 | function list(x, y, w, h) {
| |
| 3004 | this.size = function() {
| |
| 3005 | this.row_height = this.mode == "echonest" ? 90 : 20; | |
| 3006 | this.rows = Math.floor((this.h - (this.mode == "echonest" ? 50 : 30)) / this.row_height); | |
| 3007 | this.index = 0; | |
| 3008 | this.offset = 0; | |
| 3009 | switch(true) {
| |
| 3010 | case this.mode == "lastfm_charts": | |
| 3011 | this.text_width = Math.round(this.w / 3); | |
| 3012 | this.lastfm_charts_bar_x = this.text_width + 30; | |
| 3013 | break; | |
| 3014 | case this.mode == "musicbrainz" && this.musicbrainz_mode == "releases": | |
| 3015 | this.text_width = this.w - 120; | |
| 3016 | break; | |
| 3017 | default: | |
| 3018 | this.text_width = this.w - 50; | |
| 3019 | break; | |
| 3020 | } | |
| 3021 | this.but_x = this.x + Math.round((this.w - 15) / 2); | |
| 3022 | this.up_btn = new sb(this.but_x, this.y, 15, 15, p.up_img, "li.offset > 0", function() { li.wheel(1); });
| |
| 3023 | 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); });
| |
| 3024 | } | |
| 3025 | ||
| 3026 | this.draw = function(gr) {
| |
| 3027 | switch(this.mode) {
| |
| 3028 | case "discogs": | |
| 3029 | for (i = 0; i < Math.min(this.items, this.rows); i++) {
| |
| 3030 | 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); | |
| 3031 | 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); | |
| 3032 | } | |
| 3033 | break; | |
| 3034 | case "lastfm_charts": | |
| 3035 | var max_bar_width = (this.w - this.lastfm_charts_bar_x - 40) / this.playcounts[0]; | |
| 3036 | for (i = 0; i < Math.min(this.items, this.rows); i++) {
| |
| 3037 | 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); | |
| 3038 | var bar_width = max_bar_width * this.playcounts[i + this.offset]; | |
| 3039 | var bar_colour = p.splitRGB(this.lastfm_charts_bar_colour); | |
| 3040 | gr.FillSolidRect(this.lastfm_charts_bar_x + this.x, this.y + 16 + (i * this.row_height), bar_width, 18, bar_colour); | |
| 3041 | 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); | |
| 3042 | 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); | |
| 3043 | } | |
| 3044 | break; | |
| 3045 | case "lastfm": | |
| 3046 | for (i = 0; i < Math.min(this.items, this.rows); i++) {
| |
| 3047 | 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"); | |
| 3048 | 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"); | |
| 3049 | 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); | |
| 3050 | } | |
| 3051 | break; | |
| 3052 | case "musicbrainz": | |
| 3053 | for (i = 0; i < Math.min(this.items, this.rows); i++) {
| |
| 3054 | 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"); | |
| 3055 | if (this.musicbrainz_mode == "releases") {
| |
| 3056 | p.draw_image(gr, this.autoplaylist_img, this.x, this.y + 16 + (i * this.row_height), 16, 16, "adjust"); | |
| 3057 | 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); | |
| 3058 | 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); | |
| 3059 | } | |
| 3060 | 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); | |
| 3061 | } | |
| 3062 | break; | |
| 3063 | case "autoplaylists": | |
| 3064 | for (i = 0; i < Math.min(this.items, this.rows); i++) {
| |
| 3065 | 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); | |
| 3066 | if (!this.autoplaylists_editing && this.autoplaylists_hover && this.index == i + this.offset) {
| |
| 3067 | p.draw_image(gr, this.autoplaylists_edit_img, this.x + this.w - 40, this.y + 16 + (i * this.row_height), 16, 16, "adjust"); | |
| 3068 | p.draw_image(gr, this.autoplaylists_del_img, this.x + this.w - 20, this.y + 16 + (i * this.row_height), 16, 16, "adjust"); | |
| 3069 | } | |
| 3070 | } | |
| 3071 | break; | |
| 3072 | case "echonest": | |
| 3073 | for (i = 0; i < Math.min(this.items, this.rows); i++) {
| |
| 3074 | 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); | |
| 3075 | 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); | |
| 3076 | 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); | |
| 3077 | } | |
| 3078 | break; | |
| 3079 | } | |
| 3080 | this.up_btn.draw(gr); | |
| 3081 | this.down_btn.draw(gr); | |
| 3082 | 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); | |
| 3083 | } | |
| 3084 | ||
| 3085 | this.metadb_changed = function() {
| |
| 3086 | p.artist = p.eval(p.artist_tf); | |
| 3087 | if (this.artist == p.artist) return false; | |
| 3088 | this.artist = p.artist; | |
| 3089 | this.folder = p.data_folder + p.artist_tf; | |
| 3090 | //if (!p.fso.FolderExists(this.folder)) p.fso.CreateFolder(this.folder); | |
| 3091 | this.update(); | |
| 3092 | return true; | |
| 3093 | } | |
| 3094 | ||
| 3095 | this.trace = function(x, y) {
| |
| 3096 | return (x > this.x && x < this.x + this.w && y > this.y && y < this.y + this.h); | |
| 3097 | } | |
| 3098 | ||
| 3099 | this.wheel = function(step) {
| |
| 3100 | if (!this.trace(p.mx, p.my)) return false; | |
| 3101 | if (this.items > this.rows) {
| |
| 3102 | this.offset -= step * (this.mode == "echonest" ? 1 : 3); | |
| 3103 | if (this.offset < 0) this.offset = 0; | |
| 3104 | if (this.rows + this.offset > this.items) this.offset = this.items - this.rows; | |
| 3105 | window.RepaintRect(this.x, this.y, this.w, this.h); | |
| 3106 | } | |
| 3107 | return true; | |
| 3108 | } | |
| 3109 | ||
| 3110 | this.move = function(x, y) {
| |
| 3111 | this.index = Math.floor((y - this.y - 15) / this.row_height) + this.offset; | |
| 3112 | this.in_range = this.index >= this.offset && this.index < this.offset + Math.min(this.rows, this.items); | |
| 3113 | switch(true) {
| |
| 3114 | case !this.trace(x, y): | |
| 3115 | case this.mode == "autoplaylists" && this.autoplaylists_editing: | |
| 3116 | case this.mode == "lastfm" && l.username.length == 0: | |
| 3117 | window.SetCursor(IDC_ARROW); | |
| 3118 | this.leave(); | |
| 3119 | return false; | |
| 3120 | case this.up_btn.trace(x, y): | |
| 3121 | case this.down_btn.trace(x, y): | |
| 3122 | window.SetCursor(IDC_HAND); | |
| 3123 | break; | |
| 3124 | case !this.in_range: | |
| 3125 | window.SetCursor(IDC_ARROW); | |
| 3126 | this.leave(); | |
| 3127 | break; | |
| 3128 | case this.mode == "musicbrainz" && this.musicbrainz_mode == "releases" && x > this.x && x < this.x + 20: | |
| 3129 | case this.mode == "lastfm" && this.text_x == 20 && x > this.x && x < this.x + 20: | |
| 3130 | window.SetCursor(IDC_HAND); | |
| 3131 | switch(true) {
| |
| 3132 | case this.lastfm_mode == 0 && this.lastfm_button == "spotify": | |
| 3133 | p.tt('spotify:search:"' + this.names[this.index].replace(/\s+/g, "+") + '"');
| |
| 3134 | break; | |
| 3135 | default: | |
| 3136 | p.tt("Autoplaylist: " + this.queries[this.index]);
| |
| 3137 | break; | |
| 3138 | } | |
| 3139 | break; | |
| 3140 | case this.mode == "autoplaylists": | |
| 3141 | switch(true) {
| |
| 3142 | case x > this.x && x < this.x + Math.min(this.names_widths[this.index], this.text_width): | |
| 3143 | window.SetCursor(IDC_HAND); | |
| 3144 | p.tt('Run "' + this.names[this.index] + '"');
| |
| 3145 | break; | |
| 3146 | case x > this.x + this.w - 40 && x < this.x + this.w - 20: | |
| 3147 | window.SetCursor(IDC_HAND); | |
| 3148 | p.tt('Edit "' + this.names[this.index] + '"');
| |
| 3149 | break; | |
| 3150 | case x > this.x + this.w - 20 && x < this.x + this.w: | |
| 3151 | window.SetCursor(IDC_HAND); | |
| 3152 | p.tt('Delete "' + this.names[this.index] + '"');
| |
| 3153 | break; | |
| 3154 | default: | |
| 3155 | window.SetCursor(IDC_ARROW); | |
| 3156 | this.leave(); | |
| 3157 | break; | |
| 3158 | } | |
| 3159 | this.autoplaylists_hover = true; | |
| 3160 | window.RepaintRect(this.x + this.w - 40, this.y + 15, 40, Math.min(this.rows, this.items) * this.row_height); | |
| 3161 | break; | |
| 3162 | case this.mode == "echonest": | |
| 3163 | case x > this.x + this.text_x && x < this.x + this.text_x + Math.min(this.names_widths[this.index], this.text_width): | |
| 3164 | window.SetCursor(IDC_HAND); | |
| 3165 | p.tt(this.urls[this.index]); | |
| 3166 | break; | |
| 3167 | default: | |
| 3168 | window.SetCursor(IDC_ARROW); | |
| 3169 | p.ttd(); | |
| 3170 | break; | |
| 3171 | } | |
| 3172 | return true; | |
| 3173 | } | |
| 3174 | ||
| 3175 | this.lbtn_up = function(x, y) {
| |
| 3176 | switch(true) {
| |
| 3177 | case !this.trace(x, y): | |
| 3178 | return false; | |
| 3179 | case this.mode == "autoplaylists" && this.autoplaylists_editing: | |
| 3180 | case this.mode == "lastfm" && l.username.length == 0: | |
| 3181 | case this.up_btn.lbtn_up(x, y): | |
| 3182 | case this.down_btn.lbtn_up(x, y): | |
| 3183 | case !this.in_range: | |
| 3184 | break; | |
| 3185 | case this.mode == "musicbrainz" && this.musicbrainz_mode == "releases" && x > this.x && x < this.x + 20: | |
| 3186 | case this.mode == "lastfm" && this.text_x == 20 && x > this.x && x < this.x + 20: | |
| 3187 | switch(true) {
| |
| 3188 | case this.lastfm_mode == 0 && this.lastfm_button == "spotify": | |
| 3189 | if (p.run('spotify:search:"' + this.names[this.index].replace(/\s+/g, "+") + '"')) {
| |
| 3190 | if (fb.IsPlaying && !fb.IsPaused && this.lastfm_pause) fb.Pause(); | |
| 3191 | } else {
| |
| 3192 | p.MsgBox("Unable to launch Spotify.", 0, p.name);
| |
| 3193 | } | |
| 3194 | break; | |
| 3195 | default: | |
| 3196 | fb.CreateAutoPlaylist(fb.PlaylistCount, this.names[this.index], this.queries[this.index]); | |
| 3197 | fb.ActivePlaylist = fb.PlaylistCount - 1; | |
| 3198 | break; | |
| 3199 | } | |
| 3200 | break; | |
| 3201 | case this.mode == "autoplaylists": | |
| 3202 | switch(true) {
| |
| 3203 | case x > this.x && x < this.x + Math.min(this.names_widths[this.index], this.text_width): | |
| 3204 | this.autoplaylists_run(this.names[this.index], this.queries[this.index], this.sorts[this.index], this.forced[this.index]); | |
| 3205 | break; | |
| 3206 | case x > this.x + this.w - 40 && x < this.x + this.w - 20: | |
| 3207 | this.autoplaylists_edit(x, y); | |
| 3208 | break; | |
| 3209 | case x > this.x + this.w - 20 && x < this.x + this.w: | |
| 3210 | this.autoplaylists_delete(); | |
| 3211 | break | |
| 3212 | } | |
| 3213 | break; | |
| 3214 | case this.mode == "echonest": | |
| 3215 | case x > this.x + this.text_x && x < this.x + this.text_x + Math.min(this.names_widths[this.index], this.text_width): | |
| 3216 | p.browser(this.urls[this.index]); | |
| 3217 | break; | |
| 3218 | } | |
| 3219 | return true; | |
| 3220 | } | |
| 3221 | ||
| 3222 | this.leave = function() {
| |
| 3223 | p.ttd(); | |
| 3224 | if (this.mode != "autoplaylists") return; | |
| 3225 | this.autoplaylists_hover = false; | |
| 3226 | window.RepaintRect(this.x, this.y, this.w, this.h); | |
| 3227 | } | |
| 3228 | ||
| 3229 | this.update = function() {
| |
| 3230 | this.items = 0; | |
| 3231 | this.offset = 0; | |
| 3232 | this.index = 0; | |
| 3233 | this.names = []; | |
| 3234 | this.names_widths = []; | |
| 3235 | this.urls = []; | |
| 3236 | this.dates = []; | |
| 3237 | this.queries = []; | |
| 3238 | this.ranks = []; | |
| 3239 | this.playcounts = []; | |
| 3240 | this.sorts = []; | |
| 3241 | this.summaries = []; | |
| 3242 | this.release_types = []; | |
| 3243 | this.images = []; | |
| 3244 | this.forced = []; | |
| 3245 | this.data = []; | |
| 3246 | this.file = null; | |
| 3247 | this.date = ""; | |
| 3248 | var temp_bmp = gdi.CreateImage(1, 1); | |
| 3249 | var temp_gr = temp_bmp.GetGraphics(); | |
| 3250 | switch(this.mode) {
| |
| 3251 | case "autoplaylists": | |
| 3252 | this.text = p.open(this.filename); | |
| 3253 | this.data = this.text.split(/\r?\n/g); | |
| 3254 | this.items = this.data.length; | |
| 3255 | for (i = 0; i < this.items; i++) {
| |
| 3256 | var temp = this.data[i].split("¬");
| |
| 3257 | this.names[i] = temp[0]; | |
| 3258 | this.queries[i] = temp[1]; | |
| 3259 | this.sorts[i] = temp[2]; | |
| 3260 | this.forced[i] = temp[3]; | |
| 3261 | this.names_widths[i] = temp_gr.CalcTextWidth(this.names[i], p.list_font); | |
| 3262 | } | |
| 3263 | break; | |
| 3264 | case "lastfm": | |
| 3265 | this.text_x = 20; | |
| 3266 | this.filename = this.folder + "\\" + this.lastfm_methods[this.lastfm_mode] + ".json"; | |
| 3267 | if (p.fso.fileExists(this.filename)) {
| |
| 3268 | this.file = p.fso.Getfile(this.filename); | |
| 3269 | this.json_text = p.open(this.filename); | |
| 3270 | this.json_data = p.json_parse(this.json_text); | |
| 3271 | if (this.json_data) {
| |
| 3272 | switch(true) {
| |
| 3273 | case this.json_data.error > 0: | |
| 3274 | p.console(this.json_data.message); | |
| 3275 | break; | |
| 3276 | case this.lastfm_mode == 0 && this.json_data.similarartists && typeof this.json_data.similarartists.artist == "object": | |
| 3277 | this.data = this.json_data.similarartists.artist; | |
| 3278 | break; | |
| 3279 | case this.lastfm_mode == 1 && this.json_data.toptags && typeof this.json_data.toptags.tag == "object": | |
| 3280 | this.data = this.json_data.toptags.tag; | |
| 3281 | break; | |
| 3282 | case this.lastfm_mode == 2 && this.json_data.topfans && typeof this.json_data.topfans.user == "object": | |
| 3283 | this.text_x = 0; | |
| 3284 | this.data = this.json_data.topfans.user; | |
| 3285 | break; | |
| 3286 | case this.lastfm_mode == 3 && this.json_data.topalbums && typeof this.json_data.topalbums.album == "object": | |
| 3287 | this.data = this.json_data.topalbums.album; | |
| 3288 | break; | |
| 3289 | case this.lastfm_mode == 4 && this.json_data.toptracks && typeof this.json_data.toptracks.track == "object": | |
| 3290 | this.data = this.json_data.toptracks.track; | |
| 3291 | break; | |
| 3292 | } | |
| 3293 | this.items = this.data.length; | |
| 3294 | for (i = 0; i < this.items; i++) {
| |
| 3295 | this.names[i] = this.data[i].name; | |
| 3296 | this.urls[i] = this.data[i].url; | |
| 3297 | this.names_widths[i] = temp_gr.CalcTextWidth(this.names[i], p.list_font); | |
| 3298 | if (this.lastfm_mode == 0) this.queries[i] = "artist HAS " + this.names[i]; | |
| 3299 | if (this.lastfm_mode == 1) this.queries[i] = "genre HAS " + this.names[i]; | |
| 3300 | if (this.lastfm_mode == 3) this.queries[i] = "album HAS " + this.names[i] + " OR title HAS " + this.names[i]; | |
| 3301 | if (this.lastfm_mode == 4) this.queries[i] = "title HAS " + this.names[i]; | |
| 3302 | } | |
| 3303 | } | |
| 3304 | if (Date.parse(Date()) - Date.parse(this.file.DateLastModified) > ONE_DAY) this.get(); | |
| 3305 | } else {
| |
| 3306 | this.get(); | |
| 3307 | } | |
| 3308 | break; | |
| 3309 | case "lastfm_charts": | |
| 3310 | this.filename = this.folder + "\\" + l.username + "_" + this.lastfm_charts_modes[this.lastfm_charts_mode] + "_" + this.lastfm_charts_periods[this.lastfm_charts_period] + ".json"; | |
| 3311 | if (p.fso.fileExists(this.filename)) {
| |
| 3312 | this.file = p.fso.Getfile(this.filename); | |
| 3313 | this.json_text = p.open(this.filename); | |
| 3314 | this.json_data = p.json_parse(this.json_text); | |
| 3315 | if (this.json_data) {
| |
| 3316 | switch(true) {
| |
| 3317 | case this.json_data.error > 0: | |
| 3318 | p.console(this.json_data.message); | |
| 3319 | break; | |
| 3320 | case this.lastfm_charts_mode == 0 && this.json_data.topartists && typeof this.json_data.topartists.artist == "object": | |
| 3321 | this.data = this.json_data.topartists.artist; | |
| 3322 | break; | |
| 3323 | case this.lastfm_charts_mode == 1 && this.json_data.topalbums && typeof this.json_data.topalbums.album == "object": | |
| 3324 | this.data = this.json_data.topalbums.album; | |
| 3325 | break; | |
| 3326 | case this.lastfm_charts_mode == 2 && this.json_data.toptracks && typeof this.json_data.toptracks.track == "object": | |
| 3327 | this.data = this.json_data.toptracks.track; | |
| 3328 | break; | |
| 3329 | } | |
| 3330 | this.items = this.data.length; | |
| 3331 | for (i = 0; i < this.items; i++) {
| |
| 3332 | this.names[i] = this.lastfm_charts_mode != 0 ? this.data[i].artist.name + " - " + this.data[i].name : this.data[i].name; | |
| 3333 | this.ranks[i] = (i > 0 && this.data[i].playcount == this.data[i - 1].playcount) ? this.ranks[i - 1] : this.data[i]["@attr"].rank; | |
| 3334 | this.urls[i] = this.data[i].url; | |
| 3335 | this.names_widths[i] = temp_gr.CalcTextWidth(this.names[i], p.list_font); | |
| 3336 | this.playcounts[i] = this.data[i].playcount; | |
| 3337 | } | |
| 3338 | } | |
| 3339 | if (Date.parse(Date()) - Date.parse(this.file.DateLastModified) > ONE_DAY) this.get(); | |
| 3340 | } else {
| |
| 3341 | this.get(); | |
| 3342 | } | |
| 3343 | break; | |
| 3344 | case "discogs": | |
| 3345 | this.filename = this.folder + "\\discogs.json"; | |
| 3346 | if (p.fso.fileExists(this.filename)) {
| |
| 3347 | this.file = p.fso.Getfile(this.filename); | |
| 3348 | this.json_text = p.open(this.filename); | |
| 3349 | this.json_data = p.json_parse(this.json_text); | |
| 3350 | if (this.json_data && this.json_data.results) {
| |
| 3351 | this.data = this.json_reverse_sort(this.json_data.results, "year"); | |
| 3352 | var swap_artist = fb.TitleFormat("$swapprefix($lower(" + p.artist + ")) - ").Eval(true);
| |
| 3353 | for (i = 0; i < this.data.length; i++) {
| |
| 3354 | var temp_artist = this.data[i].title.replace(/\s{2,}/g,' ');
| |
| 3355 | if (this.discogs_match && temp_artist.toLowerCase().indexOf(swap_artist) != 0) continue; | |
| 3356 | this.dates.push(this.data[i].year || ""); | |
| 3357 | this.urls.push("http://www.discogs.com" + this.data[i].uri);
| |
| 3358 | this.names.push(temp_artist); | |
| 3359 | this.names_widths.push(temp_gr.CalcTextWidth(temp_artist, p.list_font)); | |
| 3360 | } | |
| 3361 | this.items = this.names.length; | |
| 3362 | } | |
| 3363 | if (Date.parse(Date()) - Date.parse(this.file.DateLastModified) > ONE_DAY) this.get(); | |
| 3364 | } else {
| |
| 3365 | this.get(); | |
| 3366 | } | |
| 3367 | break; | |
| 3368 | case "musicbrainz": | |
| 3369 | this.filename = this.folder + "\\musicbrainz_" + this.musicbrainz_mode + ".json"; | |
| 3370 | if (p.fso.fileExists(this.filename)) {
| |
| 3371 | this.file = p.fso.Getfile(this.filename); | |
| 3372 | this.json_text = p.open(this.filename); | |
| 3373 | this.json_data = p.json_parse(this.json_text); | |
| 3374 | if (this.json_data) {
| |
| 3375 | switch(this.musicbrainz_mode) {
| |
| 3376 | case "releases": | |
| 3377 | this.data = this.json_data["release-groups"] || []; | |
| 3378 | this.data = this.json_reverse_sort(this.data, "first-release-date"); | |
| 3379 | var primary, secondary, name; | |
| 3380 | for (i = 0; i < this.data.length; i++) {
| |
| 3381 | primary = this.data[i]["primary-type"]; | |
| 3382 | secondary = this.data[i]["secondary-types"].join("").toLowerCase();
| |
| 3383 | switch(true) {
| |
| 3384 | case !this.musicbrainz_remix && secondary.indexOf("remix") > -1:
| |
| 3385 | case !this.musicbrainz_compilation && secondary.indexOf("compilation") > -1:
| |
| 3386 | case !this.musicbrainz_live && secondary.indexOf("live") > -1:
| |
| 3387 | break; | |
| 3388 | case this.musicbrainz_single && primary == "Single": | |
| 3389 | case this.musicbrainz_ep && primary == "EP": | |
| 3390 | case this.musicbrainz_album && primary == "Album": | |
| 3391 | name = this.data[i].title; | |
| 3392 | this.dates.push(this.data[i]["first-release-date"].substring(0,4)); | |
| 3393 | this.names.push(name); | |
| 3394 | this.urls.push("http://musicbrainz.org/release-group/" + this.data[i].id);
| |
| 3395 | this.names_widths.push(temp_gr.CalcTextWidth(name, p.list_font)); | |
| 3396 | this.queries.push("album HAS " + name + " OR title HAS " + name);
| |
| 3397 | switch(true) {
| |
| 3398 | case secondary.indexOf("remix") > -1:
| |
| 3399 | this.release_types.push("Remix");
| |
| 3400 | break; | |
| 3401 | case secondary.indexOf("compilation") > -1:
| |
| 3402 | this.release_types.push("Compilation");
| |
| 3403 | break; | |
| 3404 | case secondary.indexOf("live") > -1:
| |
| 3405 | this.release_types.push("Live");
| |
| 3406 | break; | |
| 3407 | default: | |
| 3408 | this.release_types.push(primary); | |
| 3409 | break; | |
| 3410 | } | |
| 3411 | } | |
| 3412 | } | |
| 3413 | this.items = this.names.length; | |
| 3414 | break; | |
| 3415 | case "URLs": | |
| 3416 | this.data = this.json_data.relations || []; | |
| 3417 | this.items = this.data.length; | |
| 3418 | for (i = 0; i < this.items; i++) {
| |
| 3419 | this.urls[i] = this.data[i].url.resource; | |
| 3420 | this.images[i] = ""; | |
| 3421 | if (this.data[i].type == "official homepage") {
| |
| 3422 | this.images[i] = "home"; | |
| 3423 | } else {
| |
| 3424 | for (name in this.musicbrainz_images) {
| |
| 3425 | if (this.urls[i].indexOf(name) > -1) {
| |
| 3426 | this.images[i] = name; | |
| 3427 | break; | |
| 3428 | } | |
| 3429 | } | |
| 3430 | if (this.images[i].length == 0) this.images[i] = "external"; | |
| 3431 | } | |
| 3432 | this.names[i] = decodeURIComponent(this.urls[i]); | |
| 3433 | this.names_widths[i] = temp_gr.CalcTextWidth(this.names[i], p.list_font); | |
| 3434 | } | |
| 3435 | break; | |
| 3436 | } | |
| 3437 | } | |
| 3438 | if (Date.parse(Date()) - Date.parse(this.file.DateLastModified) > ONE_DAY) this.get(); | |
| 3439 | } else {
| |
| 3440 | this.get(); | |
| 3441 | } | |
| 3442 | break; | |
| 3443 | case "echonest": | |
| 3444 | this.filename = this.folder + "\\echonest_" + this.echonest_modes[this.echonest_mode] + ".json"; | |
| 3445 | if (p.fso.fileExists(this.filename)) {
| |
| 3446 | this.file = p.fso.Getfile(this.filename); | |
| 3447 | this.json_text = p.open(this.filename); | |
| 3448 | this.json_data = p.json_parse(this.json_text); | |
| 3449 | if (this.json_data && this.json_data.response && this.json_data.response.status && this.json_data.response.status.code == 0) {
| |
| 3450 | this.data = this.json_data.response[this.echonest_modes[this.echonest_mode]] || []; | |
| 3451 | this.items = this.data.length; | |
| 3452 | for (i = 0; i < this.items; i++) {
| |
| 3453 | this.names[i] = p.strip_tags(this.data[i].name); | |
| 3454 | this.urls[i] = (this.data[i].url || "").replace(/\\/g, ""); | |
| 3455 | this.temp_date = (this.data[i].date_posted || this.data[i].date_reviewed || this.data[i].date_found || "").substring(0, 10); | |
| 3456 | this.dates[i] = this.temp_date.substring(8,10) + "-" + this.temp_date.substring(5,7) + "-" + this.temp_date.substring(0,4); | |
| 3457 | this.summaries[i] = p.strip_tags(this.data[i].summary); | |
| 3458 | } | |
| 3459 | } | |
| 3460 | if (Date.parse(Date()) - Date.parse(this.file.DateLastModified) > ONE_DAY) this.get(); | |
| 3461 | } else {
| |
| 3462 | this.get(); | |
| 3463 | } | |
| 3464 | break; | |
| 3465 | } | |
| 3466 | temp_bmp.ReleaseGraphics(temp_gr); | |
| 3467 | temp_bmp.Dispose(); | |
| 3468 | temp_gr = null; | |
| 3469 | temp_bmp = null; | |
| 3470 | if (this.file) {
| |
| 3471 | var temp_date = new Date(this.file.DateLastModified); | |
| 3472 | this.date = "Updated: " + temp_date.toLocaleTimeString() + ", " + temp_date.toLocaleDateString(); | |
| 3473 | } | |
| 3474 | window.Repaint(); | |
| 3475 | } | |
| 3476 | ||
| 3477 | this.get = function() {
| |
| 3478 | var fn = this.filename; | |
| 3479 | var func = function() {
| |
| 3480 | if (!p.save(li.xmlhttp.responsetext, fn)) return; | |
| 3481 | li.update(); | |
| 3482 | } | |
| 3483 | var url = ""; | |
| 3484 | var user_agent = ""; | |
| 3485 | switch(this.mode) {
| |
| 3486 | case "discogs": | |
| 3487 | if (this.artist == "" || this.artist == "?") return; | |
| 3488 | url = "http://api.discogs.com/database/search?per_page=100&type=master&artist=" + encodeURIComponent(this.artist); | |
| 3489 | user_agent = "foobar2000_wsh_panel_mod_discogs +http://www.hydrogenaudio.org/forums/index.php?showuser=19379"; | |
| 3490 | break; | |
| 3491 | case "lastfm_charts": | |
| 3492 | if (l.username.length == 0) return(p.console(l.username_error)); | |
| 3493 | url = l.get_url() + "&method=user." + this.lastfm_charts_methods[this.lastfm_charts_mode] + "&period=" + this.lastfm_charts_periods[this.lastfm_charts_period]; | |
| 3494 | user_agent = l.user_agent; | |
| 3495 | break; | |
| 3496 | case "lastfm": | |
| 3497 | if (this.artist == "" || this.artist == "?") return; | |
| 3498 | if (l.username.length == 0) return(p.console(l.username_error)); | |
| 3499 | url = l.get_url() + "&method=" + this.lastfm_methods[this.lastfm_mode] + "&artist=" + encodeURIComponent(this.artist) + "&autocorrect=" + (l.auto_correct ? 1 : 0); | |
| 3500 | user_agent = l.user_agent; | |
| 3501 | break; | |
| 3502 | case "musicbrainz": | |
| 3503 | user_agent = "foobar2000_wsh_panel_mod_musicbrainz +http://www.hydrogenaudio.org/forums/index.php?showuser=19379"; | |
| 3504 | var fn1 = this.folder + "\\MUSICBRAINZ_ARTISTID.txt"; | |
| 3505 | this.musicbrainz_id = p.eval("$if3(%musicbrainz_artistid%,%musicbrainz artist id%,)");
| |
| 3506 | this.musicbrainz_id = this.musicbrainz_id.substring(0, 36); | |
| 3507 | if (this.musicbrainz_id.length == 0) this.musicbrainz_id = p.open(fn1); | |
| 3508 | if (this.musicbrainz_id.length == 0) {
| |
| 3509 | if (this.artist == "" || this.artist == "?") return; | |
| 3510 | url = "https://musicbrainz.org/ws/2/artist/?query=artist:" + encodeURIComponent(this.artist.toLowerCase()) + "&fmt=json"; | |
| 3511 | var func = function() {
| |
| 3512 | var json_data = p.json_parse(li.xmlhttp.responsetext); | |
| 3513 | if (!json_data) return; | |
| 3514 | var artist = li.artist.toLowerCase(); | |
| 3515 | var artists = json_data.artist || []; | |
| 3516 | for (i = 0; i < artists.length; i++) {
| |
| 3517 | if (artist == artists[i].name.toLowerCase()) {
| |
| 3518 | if (!p.save(artists[i].id, fn1)) return; | |
| 3519 | li.get(); | |
| 3520 | break; | |
| 3521 | } | |
| 3522 | } | |
| 3523 | } | |
| 3524 | } else {
| |
| 3525 | if (this.musicbrainz_mode == "releases") url = "https://musicbrainz.org/ws/2/release-group?artist=" + this.musicbrainz_id + "&limit=100&offset=0&fmt=json"; | |
| 3526 | else url = "https://musicbrainz.org/ws/2/artist/" + this.musicbrainz_id + "?inc=url-rels&fmt=json"; | |
| 3527 | } | |
| 3528 | break; | |
| 3529 | case "echonest": | |
| 3530 | if (this.artist == "" || this.artist == "?") return; | |
| 3531 | url = "http://developer.echonest.com/api/v4/artist/" + this.echonest_modes[this.echonest_mode] + "/?name=" + encodeURIComponent(this.artist) + "&api_key=EKWS4ESQLKN3G2ZWV"; | |
| 3532 | break; | |
| 3533 | } | |
| 3534 | if (url.length == 0) return; | |
| 3535 | this.xmlhttp.open("GET", url, true);
| |
| 3536 | if (user_agent.length > 0) this.xmlhttp.setRequestHeader('User-Agent', user_agent);
| |
| 3537 | this.xmlhttp.send(); | |
| 3538 | this.xmlhttp.onreadystatechange = function() {
| |
| 3539 | if (li.xmlhttp.readyState == 4) {
| |
| 3540 | if (li.xmlhttp.status == 200) {
| |
| 3541 | func(); | |
| 3542 | } else {
| |
| 3543 | p.console(li.xmlhttp.responsetext || "HTTP error: " + li.xmlhttp.status); | |
| 3544 | } | |
| 3545 | } | |
| 3546 | } | |
| 3547 | } | |
| 3548 | ||
| 3549 | this.json_reverse_sort = function(data, prop) {
| |
| 3550 | data = data.sort(function(a, b) {
| |
| 3551 | if (!a[prop] || b[prop] > a[prop]) return 1; | |
| 3552 | if (!b[prop] || b[prop] < a[prop]) return -1; | |
| 3553 | return 0; | |
| 3554 | }); | |
| 3555 | return data; | |
| 3556 | } | |
| 3557 | ||
| 3558 | this.init = function() {
| |
| 3559 | switch(true) {
| |
| 3560 | case p.check_feature("discogs"):
| |
| 3561 | this.mode = "discogs"; | |
| 3562 | this.discogs_match = window.GetProperty("discogs_match", false);
| |
| 3563 | break; | |
| 3564 | case p.check_feature("lastfm_charts"):
| |
| 3565 | this.mode = "lastfm_charts"; | |
| 3566 | this.text_x = 20; | |
| 3567 | this.lastfm_charts_modes = ["artist", "album", "track"]; | |
| 3568 | this.lastfm_charts_mode = window.GetProperty("lastfm_charts_mode", 0);
| |
| 3569 | this.lastfm_charts_methods = ["getTopArtists", "getTopAlbums", "getTopTracks"]; | |
| 3570 | this.lastfm_charts_periods_display = ["overall", "last 7 days", "1 month", "3 month", "6 month", "12 month"]; | |
| 3571 | this.lastfm_charts_periods = ["overall", "7day", "1month", "3month", "6month", "12month"]; | |
| 3572 | this.lastfm_charts_period = window.GetProperty("lastfm_charts_period", 0);
| |
| 3573 | this.lastfm_charts_bar_colour = window.GetProperty("lastfm_charts_bar_colour", "72-127-221");
| |
| 3574 | this.folder = p.data_folder + "charts"; | |
| 3575 | //if (!p.fso.FolderExists(this.folder)) p.fso.CreateFolder(this.folder); | |
| 3576 | break; | |
| 3577 | case p.check_feature("lastfm"):
| |
| 3578 | this.mode = "lastfm"; | |
| 3579 | this.lastfm_methods = ["artist.getSimilar", "artist.getTopTags", "artist.getTopFans", "artist.getTopAlbums", "artist.getTopTracks"]; | |
| 3580 | this.lastfm_modes = ["similar artists", "top tags", "top fans", "top albums", "top tracks"]; | |
| 3581 | this.lastfm_mode = window.GetProperty("lastfm_mode", 0);
| |
| 3582 | this.lastfm_button = window.GetProperty("lastfm_button", "spotify");
| |
| 3583 | this.lastfm_pause = window.GetProperty("lastfm_pause", true);
| |
| 3584 | this.lastfm_spotify_img = gdi.Image(p.images_path + "spotify.png"); | |
| 3585 | break; | |
| 3586 | case p.check_feature("musicbrainz"):
| |
| 3587 | this.mode = "musicbrainz"; | |
| 3588 | this.text_x = 20; | |
| 3589 | this.musicbrainz_images = {
| |
| 3590 | "viaf.org": gdi.Image(p.images_path + "viaf_small.png"), | |
| 3591 | "allmusic.com": gdi.Image(p.images_path + "allmusic_small.png"), | |
| 3592 | "external": gdi.Image(p.images_path + "external_small.png"), | |
| 3593 | "bbc.co.uk": gdi.Image(p.images_path + "bbc_small.png"), | |
| 3594 | "facebook.com": gdi.Image(p.images_path + "facebook_small.png"), | |
| 3595 | "home": gdi.Image(p.images_path + "home_small.png"), | |
| 3596 | "last.fm": gdi.Image(p.images_path + "lastfm_small.png"), | |
| 3597 | "twitter.com": gdi.Image(p.images_path + "twitter_small.png"), | |
| 3598 | "soundcloud.com": gdi.Image(p.images_path + "soundcloud_small.png"), | |
| 3599 | "wikipedia.org": gdi.Image(p.images_path + "wikipedia_small.png"), | |
| 3600 | "discogs.com": gdi.Image(p.images_path + "discogs_small.png"), | |
| 3601 | "myspace.com": gdi.Image(p.images_path + "myspace_small.png"), | |
| 3602 | "youtube.com": gdi.Image(p.images_path + "youtube_small.png"), | |
| 3603 | "imdb.com": gdi.Image(p.images_path + "imdb_small.png"), | |
| 3604 | "plus.google.com": gdi.Image(p.images_path + "google_plus_small.png"), | |
| 3605 | "lyrics.wikia.com": gdi.Image(p.images_path + "lyrics_wikia_small.png"), | |
| 3606 | "flickr.com": gdi.Image(p.images_path + "flickr_small.png"), | |
| 3607 | "secondhandsongs.com": gdi.Image(p.images_path + "secondhandsongs_small.png"), | |
| 3608 | "vimeo.com": gdi.Image(p.images_path + "vimeo_small.png"), | |
| 3609 | "rateyourmusic.com": gdi.Image(p.images_path + "rateyourmusic_small.png"), | |
| 3610 | "instagram.com": gdi.Image(p.images_path + "instagram_small.png"), | |
| 3611 | "tumblr.com": gdi.Image(p.images_path + "tumblr_small.png"), | |
| 3612 | "decoda.com": gdi.Image(p.images_path + "decoda_small.png"), | |
| 3613 | "wikidata.org": gdi.Image(p.images_path + "wikidata_small.png") | |
| 3614 | } | |
| 3615 | this.musicbrainz_mode = window.GetProperty("musicbrainz_mode", "releases");
| |
| 3616 | this.musicbrainz_show_release_type = window.GetProperty("musicbrainz_show_release_type", true);
| |
| 3617 | this.musicbrainz_live = window.GetProperty("musicbrainz_live", false);
| |
| 3618 | this.musicbrainz_ep = window.GetProperty("musicbrainz_ep", true);
| |
| 3619 | this.musicbrainz_single = window.GetProperty("musicbrainz_single", true);
| |
| 3620 | this.musicbrainz_album = window.GetProperty("musicbrainz_album", true);
| |
| 3621 | this.musicbrainz_remix = window.GetProperty("musicbrainz_remix", true);
| |
| 3622 | this.musicbrainz_compilation = window.GetProperty("musicbrainz_compilation", true);
| |
| 3623 | break; | |
| 3624 | case p.check_feature("echonest"):
| |
| 3625 | this.mode = "echonest"; | |
| 3626 | this.echonest_modes = ["news", "reviews", "blogs"]; | |
| 3627 | this.echonest_mode = window.GetProperty("echonest_mode", 0);
| |
| 3628 | break; | |
| 3629 | case p.check_feature("autoplaylists"):
| |
| 3630 | this.autoplaylists_add = function() {
| |
| 3631 | if (this.autoplaylists_editing) return; | |
| 3632 | this.autoplaylists_editing = true; | |
| 3633 | var new_name = p.InputBox("Enter a name for your autoplaylist", p.name, "");
| |
| 3634 | if (new_name == "") { this.autoplaylists_editing = false; return; }
| |
| 3635 | var new_query = p.InputBox("Enter your autoplaylist query", p.name, "");
| |
| 3636 | if (new_query == "") { this.autoplaylists_editing = false; return; }
| |
| 3637 | var new_sort = p.InputBox("Enter a sort pattern\n\n(optional)", p.name, "");
| |
| 3638 | var new_force = new_sort.length > 0 ? p.MsgBox("Force sort?", 4, p.name) : 7;
| |
| 3639 | this.data.push(new_name + "¬" + new_query + "¬" + new_sort + "¬" + new_force); | |
| 3640 | if (this.data.length > this.rows) this.offset = this.data.length - this.rows; | |
| 3641 | p.save(this.data.join("\n"), this.filename);
| |
| 3642 | if (this.autoplaylists_success) this.autoplaylists_run(new_name, new_query, new_sort, new_force); | |
| 3643 | window.NotifyOthers("autoplaylists", "update");
| |
| 3644 | this.update(); | |
| 3645 | this.autoplaylists_editing = false; | |
| 3646 | } | |
| 3647 | ||
| 3648 | this.autoplaylists_run = function(n, q, s, f) {
| |
| 3649 | if (this.autoplaylists_remove_duplicates) {
| |
| 3650 | i = 0; | |
| 3651 | while(i < fb.PlaylistCount) {
| |
| 3652 | if (fb.GetPlaylistName(i) == n) fb.RemovePlaylist(i); | |
| 3653 | else i++; | |
| 3654 | } | |
| 3655 | } | |
| 3656 | fb.CreateAutoPlaylist(fb.PlaylistCount, n, q, s, f == 6 ? true : false); | |
| 3657 | fb.ActivePlaylist = fb.PlaylistCount - 1; | |
| 3658 | } | |
| 3659 | ||
| 3660 | this.autoplaylists_edit = function(x, y) {
| |
| 3661 | var _menu = window.CreatePopupMenu(); | |
| 3662 | var i = this.index; | |
| 3663 | _menu.AppendMenuItem(MF_STRING, 1, "Rename..."); | |
| 3664 | _menu.AppendMenuItem(MF_STRING, 2, "Edit query..."); | |
| 3665 | _menu.AppendMenuItem(MF_STRING, 3, "Edit sort pattern..."); | |
| 3666 | _menu.AppendMenuItem(MF_STRING, 4, "Force Sort"); | |
| 3667 | _menu.CheckMenuItem(4, this.forced[i] == 6 ? true : false); | |
| 3668 | this.autoplaylists_editing = true; | |
| 3669 | this.autoplaylists_hover = false; | |
| 3670 | window.RepaintRect(this.x + this.w - 40, this.y + 15, 40, Math.min(this.rows, this.items) * this.row_height); | |
| 3671 | idx = _menu.TrackPopupMenu(x, y); | |
| 3672 | switch(idx) {
| |
| 3673 | case 0: | |
| 3674 | this.autoplaylists_editing = false; | |
| 3675 | _menu.Dispose(); | |
| 3676 | return; | |
| 3677 | case 1: | |
| 3678 | var new_name = p.InputBox("Rename your autoplaylist", p.name, this.names[i]);
| |
| 3679 | if (new_name != "") this.names[i] = new_name; | |
| 3680 | break; | |
| 3681 | case 2: | |
| 3682 | var new_query = p.InputBox("Enter your autoplaylist query", p.name, this.queries[i]);
| |
| 3683 | if (new_query != "") this.queries[i] = new_query; | |
| 3684 | break; | |
| 3685 | case 3: | |
| 3686 | var new_sort = p.InputBox("Enter a sort pattern\n\n(optional)", p.name, this.sorts[i]);
| |
| 3687 | this.sorts[i] = new_sort; | |
| 3688 | this.forced[i] = new_sort.length > 0 ? p.MsgBox("Force sort?", 4, p.name) : 7;
| |
| 3689 | break; | |
| 3690 | case 4: | |
| 3691 | this.forced[i] = this.forced[i] == 6 ? 7 : 6; | |
| 3692 | break; | |
| 3693 | } | |
| 3694 | _menu.Dispose(); | |
| 3695 | var temp = this.names[i] + "¬" + this.queries[i] + "¬" + this.sorts[i] + "¬" + this.forced[i]; | |
| 3696 | if (this.data[i] != temp) {
| |
| 3697 | this.data[i] = temp; | |
| 3698 | p.save(this.data.join("\n"), this.filename);
| |
| 3699 | if (this.autoplaylists_success) this.autoplaylists_run(this.names[i], this.queries[i], this.sorts[i], this.forced[i]); | |
| 3700 | window.NotifyOthers("autoplaylists", "update");
| |
| 3701 | this.update(); | |
| 3702 | } | |
| 3703 | this.autoplaylists_editing = false; | |
| 3704 | } | |
| 3705 | ||
| 3706 | this.autoplaylists_delete = function() {
| |
| 3707 | if (this.offset > 1) this.offset--; | |
| 3708 | this.autoplaylists_deleted_items.unshift(this.data[this.index]); | |
| 3709 | this.data.splice(this.index, 1); | |
| 3710 | p.save(this.data.join("\n"), this.filename);
| |
| 3711 | window.NotifyOthers("autoplaylists", "update");
| |
| 3712 | this.update(); | |
| 3713 | } | |
| 3714 | ||
| 3715 | this.mode = "autoplaylists"; | |
| 3716 | this.autoplaylists_del_img = gdi.Image(p.images_path + "cross.png"); | |
| 3717 | this.autoplaylists_edit_img = gdi.Image(p.images_path + "edit.png"); | |
| 3718 | this.autoplaylists_hover = false; | |
| 3719 | this.autoplaylists_editing = false; | |
| 3720 | this.autoplaylists_remove_duplicates = window.GetProperty("autoplaylists_remove_duplicates", true);
| |
| 3721 | this.autoplaylists_success = window.GetProperty("autoplaylists_success", true);
| |
| 3722 | this.autoplaylists_title = window.GetProperty("autoplaylists_title", "Autoplaylists");
| |
| 3723 | this.autoplaylists_slot = window.GetProperty("autoplaylists_slot", 1);
| |
| 3724 | this.filename = p.settings_folder + "autoplaylists" + this.autoplaylists_slot; | |
| 3725 | this.autoplaylists_deleted_items = []; | |
| 3726 | break; | |
| 3727 | } | |
| 3728 | } | |
| 3729 | ||
| 3730 | this.x = x; | |
| 3731 | this.y = y; | |
| 3732 | this.w = w; | |
| 3733 | this.h = h; | |
| 3734 | this.index = 0; | |
| 3735 | this.offset = 0; | |
| 3736 | this.items = 0; | |
| 3737 | this.text = ""; | |
| 3738 | this.artist = ""; | |
| 3739 | this.url = ""; | |
| 3740 | this.text_x = 0; | |
| 3741 | this.show_timestamp = window.GetProperty("show_timestamp", true);
| |
| 3742 | this.autoplaylist_img = gdi.Image(p.images_path + "search_small.png"); | |
| 3743 | this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
| |
| 3744 | this.init(); | |
| 3745 | } | |
| 3746 | ||
| 3747 | function playcount_sync(x, y) {
| |
| 3748 | this.playback_time = function() {
| |
| 3749 | this.time_elapsed++; | |
| 3750 | if (this.time_elapsed == 3 && this.auto_love && fb.TitleFormat(this.auto_love_tf).Eval() == 1 && this.old_userloved == 0) {
| |
| 3751 | p.console("Automatically loving this track....");
| |
| 3752 | this.love_track(); | |
| 3753 | } | |
| 3754 | if (this.time_elapsed == this.target_time) {
| |
| 3755 | if (!this.library || fb.IsMetadbInMediaLibrary(p.metadb)) this.sync_track(); | |
| 3756 | else p.console("Skipping... Track not in library.");
| |
| 3757 | } | |
| 3758 | } | |
| 3759 | ||
| 3760 | this.metadb_changed = function() {
| |
| 3761 | if (!p.metadb) return false; | |
| 3762 | this.artist = fb.TitleFormat(p.artist_tf).EvalWithMetadb(p.metadb); | |
| 3763 | this.track = fb.TitleFormat("%title%").EvalWithMetadb(p.metadb);
| |
| 3764 | this.old_userloved = fb.TitleFormat("%LASTFM_LOVED_DB%").EvalWithMetadb(p.metadb) == 1 ? 1 : 0;
| |
| 3765 | this.old_userplaycount = fb.TitleFormat("%LASTFM_PLAYCOUNT_DB%").EvalWithMetadb(p.metadb);
| |
| 3766 | this.method = this.old_userloved == 1 ? "track.unlove" : "track.love"; | |
| 3767 | this.tooltip = (this.old_userloved == 1 ? "Unlove" : "Love") + " \"" + this.track + "\" by \"" + this.artist + "\"."; | |
| 3768 | this.crc32 = fb.TitleFormat("$crc32($lower(%artist%%title%))").EvalWithMetadb(p.metadb);
| |
| 3769 | b.update(); | |
| 3770 | return true; | |
| 3771 | } | |
| 3772 | ||
| 3773 | this.playback_new_track = function() {
| |
| 3774 | this.auto_love_count = 0; | |
| 3775 | this.time_elapsed = 0; | |
| 3776 | switch(true) {
| |
| 3777 | case fb.PlaybackLength == 0: | |
| 3778 | this.target_time = 240; | |
| 3779 | break; | |
| 3780 | case fb.PlaybackLength >= 30: | |
| 3781 | this.target_time = Math.min(Math.floor(fb.PlaybackLength / 2), 240); | |
| 3782 | break; | |
| 3783 | default: | |
| 3784 | this.target_time = 5; | |
| 3785 | break; | |
| 3786 | } | |
| 3787 | on_item_focus_change(); | |
| 3788 | } | |
| 3789 | ||
| 3790 | this.playback_edited = function() {
| |
| 3791 | if (this.auto_love && fb.TitleFormat(this.auto_love_tf).Eval() == 1 && this.old_userloved == 0 && this.auto_love_count == 0) {
| |
| 3792 | this.auto_love_count = 1; | |
| 3793 | p.console("Automatically loving this track....");
| |
| 3794 | this.love_track(); | |
| 3795 | } | |
| 3796 | } | |
| 3797 | ||
| 3798 | this.tf = function(value) {
| |
| 3799 | return(value.replace(/'/g, "''").replace(/,/g, "','").replace(/\//g, "'/'").replace(/\(/g, "'('").replace(/\)/g, "')'").replace(/\[/g, "'['").replace(/\]/g, "']'"));
| |
| 3800 | } | |
| 3801 | ||
| 3802 | this.love_track = function() {
| |
| 3803 | l.post(this.method, p.metadb); | |
| 3804 | } | |
| 3805 | ||
| 3806 | this.sync_track = function() {
| |
| 3807 | switch(true) {
| |
| 3808 | case this.loved_working || this.playcount_working: | |
| 3809 | return; | |
| 3810 | case !utils.CheckComponent("foo_customdb", true):
| |
| 3811 | p.console("Not contacting Last.fm. foo_customdb is missing.");
| |
| 3812 | return; | |
| 3813 | default: | |
| 3814 | p.console("Contacting Last.fm....");
| |
| 3815 | this.get(l.get_url() + "&method=track.getinfo&artist=" + encodeURIComponent(this.artist) + "&track=" + encodeURIComponent(this.track) + "&autocorrect=" + (l.auto_correct ? 1 : 0), function() {
| |
| 3816 | ps.update_track(); | |
| 3817 | }); | |
| 3818 | } | |
| 3819 | } | |
| 3820 | ||
| 3821 | this.get = function(url, func) {
| |
| 3822 | if (l.username.length == 0) {
| |
| 3823 | this.loved_working = false; | |
| 3824 | this.playcount_working = false; | |
| 3825 | p.console(l.username_error); | |
| 3826 | return; | |
| 3827 | } | |
| 3828 | this.xmlhttp.open("GET", url, true);
| |
| 3829 | this.xmlhttp.setRequestHeader('User-Agent', l.user_agent);
| |
| 3830 | this.xmlhttp.send(); | |
| 3831 | this.xmlhttp.onreadystatechange = function() {
| |
| 3832 | if (ps.xmlhttp.readyState == 4) {
| |
| 3833 | if (ps.xmlhttp.status == 200) {
| |
| 3834 | func(); | |
| 3835 | } else {
| |
| 3836 | p.console(ps.xmlhttp.responsetext || "HTTP error: " + ps.xmlhttp.status); | |
| 3837 | } | |
| 3838 | } | |
| 3839 | } | |
| 3840 | } | |
| 3841 | ||
| 3842 | this.update_track = function() {
| |
| 3843 | this.json_data = p.json_parse(ps.xmlhttp.responsetext); | |
| 3844 | if (!this.json_data || this.json_data.error > 0 || !this.json_data.track) {
| |
| 3845 | p.console(ps.xmlhttp.responsetext); | |
| 3846 | return; | |
| 3847 | } | |
| 3848 | this.userplaycount = this.json_data.track.userplaycount > 0 ? ++this.json_data.track.userplaycount : 1; | |
| 3849 | this.userloved = this.json_data.track.userloved == 1 ? 1 : 0; | |
| 3850 | if (fb.IsPlaying && this.time_elapsed >= this.target_time && fb.PlaybackLength > 29 && fb.PlaybackLength < 10800) {
| |
| 3851 | switch(true) {
| |
| 3852 | case this.userplaycount < this.old_userplaycount: | |
| 3853 | p.console("Playcount returned from Last.fm is lower than current value. Not updating.");
| |
| 3854 | break; | |
| 3855 | case this.old_userplaycount == this.userplaycount: | |
| 3856 | p.console("No changes found. Not updating.");
| |
| 3857 | break; | |
| 3858 | default: | |
| 3859 | p.console("Last.fm responded ok. Attempting to update playcount...");
| |
| 3860 | fb.RunContextCommandWithMetadb("Customdb Delete Playcount", p.metadb, 8);
| |
| 3861 | if (this.old_userloved == 1) fb.RunContextCommandWithMetadb("Customdb Love 0", p.metadb, 8);
| |
| 3862 | var attempt = 0; | |
| 3863 | while(fb.TitleFormat("%LASTFM_PLAYCOUNT_DB%").EvalWithMetadb(p.metadb) != this.userplaycount && attempt <= 3) {
| |
| 3864 | var query1 = '\"INSERT INTO quicktag(url,subsong,fieldname,value) VALUES(\\"' + this.crc32 + '\\",\\"-1\\",\\"LASTFM_PLAYCOUNT_DB\\",\\"' + this.userplaycount + '\\")\";'; | |
| 3865 | p.WshShell.Run(p.fso.GetFile(p.script_path + "sqlite3.exe").ShortPath + " " + p.fso.GetFile(fb.ProfilePath + "customdb_sqlite.db").ShortPath + " " + query1, 0, true); | |
| 3866 | attempt++; | |
| 3867 | } | |
| 3868 | fb.RunContextCommandWithMetadb("Customdb Refresh", p.metadb, 8);
| |
| 3869 | if (fb.TitleFormat("%LASTFM_PLAYCOUNT_DB%").EvalWithMetadb(p.metadb) == this.userplaycount) p.console("Playcount updated successfully.");
| |
| 3870 | else p.console("Database error. Playcount not updated.");
| |
| 3871 | break; | |
| 3872 | } | |
| 3873 | } | |
| 3874 | if (this.old_userloved != this.userloved) fb.RunContextCommandWithMetadb("Customdb Love " + this.userloved, p.metadb, 8);
| |
| 3875 | } | |
| 3876 | ||
| 3877 | this.start_import = function() {
| |
| 3878 | if (this.show_console) fb.ShowConsole(); | |
| 3879 | this.loved_page_errors = 0; | |
| 3880 | this.playcount_page_errors = 0; | |
| 3881 | ps.pages = 0; | |
| 3882 | this.r = 1; | |
| 3883 | this.sql = "BEGIN TRANSACTION;\n"; | |
| 3884 | this.loved_working = true; | |
| 3885 | this.sync_loved(1); | |
| 3886 | } | |
| 3887 | ||
| 3888 | this.sync_loved = function(page) {
| |
| 3889 | if (!this.loved_working) return(p.console("Import aborted."));
| |
| 3890 | this.page = page; | |
| 3891 | this.get(l.get_url() + "&method=user.getlovedtracks&limit=200&page=" + this.page, function() {
| |
| 3892 | ps.update_loved(); | |
| 3893 | }); | |
| 3894 | } | |
| 3895 | ||
| 3896 | this.update_loved = function() {
| |
| 3897 | this.json_data = p.json_parse(ps.xmlhttp.responsetext); | |
| 3898 | if (this.json_data && this.json_data.error > 0) {
| |
| 3899 | this.loved_working = false; | |
| 3900 | p.MsgBox("There is a problem with the Last.fm web services. Please try again later.\n\n" + ps.xmlhttp.responsetext, 0, p.name);
| |
| 3901 | return; | |
| 3902 | } | |
| 3903 | if (this.json_data && this.json_data.lovedtracks && this.json_data.lovedtracks.track) {
| |
| 3904 | if (this.page == 1) this.pages = this.json_data.lovedtracks["@attr"].totalPages; | |
| 3905 | for (i = 0; i < this.json_data.lovedtracks.track.length; i++) {
| |
| 3906 | var data = []; | |
| 3907 | data[0] = this.json_data.lovedtracks.track[i].artist.name; | |
| 3908 | data[1] = this.json_data.lovedtracks.track[i].name; | |
| 3909 | data[2] = 1; | |
| 3910 | if (data.length == 3) {
| |
| 3911 | p.console(this.r + ": " + data[0] + " - " + data[1]); | |
| 3912 | var url = fb.TitleFormat("$crc32($lower(" + this.tf(data[0]) + this.tf(data[1]) + "))").Eval(true);
| |
| 3913 | this.sql += 'INSERT OR REPLACE INTO quicktag(url,subsong,fieldname,value) VALUES("' + url + '","-1","LASTFM_LOVED_DB","' + data[2] + '");' + "\n";
| |
| 3914 | this.r++; | |
| 3915 | } | |
| 3916 | } | |
| 3917 | p.console("Loved tracks: completed page " + this.page + " of " + this.pages);
| |
| 3918 | } else if (this.pages > 0) {
| |
| 3919 | this.loved_page_errors++; | |
| 3920 | } | |
| 3921 | if (this.page < this.pages) {
| |
| 3922 | this.page++; | |
| 3923 | this.sync_loved(this.page); | |
| 3924 | } else {
| |
| 3925 | this.loved_working = false; | |
| 3926 | if (this.full_import) {
| |
| 3927 | this.playcount_working = true; | |
| 3928 | this.pages = 0; | |
| 3929 | this.r = 1; | |
| 3930 | this.sync_playcount(1); | |
| 3931 | } else {
| |
| 3932 | try {
| |
| 3933 | this.sql += "COMMIT;" | |
| 3934 | var ts = p.fso.OpenTextFile(this.sql_file, 2, true, 0); | |
| 3935 | ts.WriteLine(this.sql); | |
| 3936 | ts.Close(); | |
| 3937 | this.finish_import(); | |
| 3938 | } catch(e) {
| |
| 3939 | } | |
| 3940 | if (this.loved_page_errors > 0) {
| |
| 3941 | p.console("Loved track page errors: " + this.loved_page_errors + " (200 records are lost for every page that fails.)");
| |
| 3942 | } else {
| |
| 3943 | p.console("There were no errors reported.");
| |
| 3944 | } | |
| 3945 | } | |
| 3946 | } | |
| 3947 | } | |
| 3948 | ||
| 3949 | this.sync_playcount = function(page) {
| |
| 3950 | if (this.playcount_working == false) return(p.console("Import aborted."));
| |
| 3951 | this.page = page; | |
| 3952 | this.get(l.get_url() + "&method=library.gettracks&limit=100&page=" + this.page, function() {
| |
| 3953 | ps.update_playcount(); | |
| 3954 | }); | |
| 3955 | } | |
| 3956 | ||
| 3957 | this.update_playcount = function() {
| |
| 3958 | this.json_data = p.json_parse(ps.xmlhttp.responsetext); | |
| 3959 | if (this.json_data && this.json_data.error > 0) {
| |
| 3960 | this.playcount_working = false; | |
| 3961 | p.MsgBox("There is a problem with the Last.fm web services. Please try again later.\n\n" + ps.xmlhttp.responsetext, 0, p.name);
| |
| 3962 | return; | |
| 3963 | } | |
| 3964 | if (this.json_data && this.json_data.tracks && this.json_data.tracks.track) {
| |
| 3965 | if (this.page == 1) this.pages = this.json_data.tracks["@attr"].totalPages | |
| 3966 | for (i = 0; i < this.json_data.tracks.track.length; i++) {
| |
| 3967 | var data = []; | |
| 3968 | data[0] = this.json_data.tracks.track[i].artist.name; | |
| 3969 | data[1] = this.json_data.tracks.track[i].name; | |
| 3970 | data[2] = this.json_data.tracks.track[i].playcount; | |
| 3971 | if (data[2] == 0) {
| |
| 3972 | this.page = this.pages; | |
| 3973 | break; | |
| 3974 | } | |
| 3975 | if (data.length == 3) {
| |
| 3976 | p.console(this.r + ": " + data[0] + " - " + data[1] + " " + data[2]); | |
| 3977 | var url = fb.TitleFormat("$crc32($lower(" + this.tf(data[0]) + this.tf(data[1]) + "))").Eval(true);
| |
| 3978 | this.sql += 'INSERT OR REPLACE INTO quicktag(url,subsong,fieldname,value) VALUES("' + url + '","-1","LASTFM_PLAYCOUNT_DB","' + data[2] + '");' + "\n";
| |
| 3979 | this.r++; | |
| 3980 | } | |
| 3981 | } | |
| 3982 | p.console("Playcount: completed page " + this.page + " of " + this.pages);
| |
| 3983 | } else if (this.pages > 0) {
| |
| 3984 | this.playcount_page_errors++; | |
| 3985 | } | |
| 3986 | if (this.page < this.pages) {
| |
| 3987 | this.page++; | |
| 3988 | this.sync_playcount(this.page); | |
| 3989 | } else {
| |
| 3990 | try {
| |
| 3991 | this.sql += "COMMIT;" | |
| 3992 | var ts = p.fso.OpenTextFile(this.sql_file, 2, true, 0); | |
| 3993 | ts.WriteLine(this.sql); | |
| 3994 | ts.Close(); | |
| 3995 | this.finish_import(); | |
| 3996 | } catch(e) {
| |
| 3997 | } | |
| 3998 | this.playcount_working = false; | |
| 3999 | if (this.loved_page_errors + this.playcount_page_errors > 0) {
| |
| 4000 | p.console("Loved track page errors: " + this.loved_page_errors + " (200 records are lost for every page that fails.)");
| |
| 4001 | p.console("Playcount page errors: " + this.playcount_page_errors + " (100 records are lost for every page that fails.)");
| |
| 4002 | } else {
| |
| 4003 | p.console("There were no errors reported.");
| |
| 4004 | } | |
| 4005 | } | |
| 4006 | } | |
| 4007 | ||
| 4008 | this.finish_import = function() {
| |
| 4009 | try {
| |
| 4010 | var cmd_file = p.fso.GetFile(p.script_path + "lastfm_sql.cmd").ShortPath; | |
| 4011 | var db_file = p.fso.GetFile(fb.ProfilePath + "customdb_sqlite.db").ShortPath; | |
| 4012 | p.run(cmd_file + " " + p.fso.GetFile(p.script_path + "sqlite3.exe").ShortPath + " " + db_file + " " + p.fso.GetFile(this.sql_file).ShortPath); | |
| 4013 | } catch(e) {
| |
| 4014 | } | |
| 4015 | } | |
| 4016 | ||
| 4017 | this.update_button = function() {
| |
| 4018 | var exclamation = this.icon == "tango" ? "exclamation.png" : "exclamation_small.png"; | |
| 4019 | var love = this.icon == "tango" ? "love.png" : "love_small.png"; | |
| 4020 | var love_h = this.icon == "tango" ? "love_h.png" : "love_h_small.png"; | |
| 4021 | this.size = this.icon == "tango" ? 32 : 20; | |
| 4022 | switch(true) {
| |
| 4023 | case l.username.length == 0: | |
| 4024 | this.n = exclamation; | |
| 4025 | this.h = exclamation; | |
| 4026 | this.tooltip = l.username_error; | |
| 4027 | this.func = null; | |
| 4028 | break; | |
| 4029 | case l.sk.length != 32: | |
| 4030 | this.n = exclamation; | |
| 4031 | this.h = exclamation; | |
| 4032 | this.tooltip = l.password_error; | |
| 4033 | this.func = null; | |
| 4034 | break; | |
| 4035 | case !p.metadb: | |
| 4036 | this.n = exclamation; | |
| 4037 | this.h = exclamation; | |
| 4038 | this.tooltip = "No selection"; | |
| 4039 | this.func = null; | |
| 4040 | break; | |
| 4041 | case !utils.CheckComponent("foo_customdb", true):
| |
| 4042 | this.n = exclamation; | |
| 4043 | this.h = exclamation; | |
| 4044 | this.tooltip = "The foo_customdb component is not installed. Please refer to the readme."; | |
| 4045 | this.func = null; | |
| 4046 | break; | |
| 4047 | default: | |
| 4048 | this.n = this.old_userloved == 1 ? love_h : love; | |
| 4049 | this.h = this.old_userloved == 1 ? love : love_h; | |
| 4050 | this.func = function() { ps.love_track(); }
| |
| 4051 | break; | |
| 4052 | } | |
| 4053 | } | |
| 4054 | ||
| 4055 | this.x = x; | |
| 4056 | this.y = y; | |
| 4057 | this.loved_working = false; | |
| 4058 | this.playcount_working = false; | |
| 4059 | this.sql_file = p.data_folder + "lastfm.sql"; | |
| 4060 | this.page = 0; | |
| 4061 | this.last_page = 0; | |
| 4062 | this.auto_love = window.GetProperty("playcount_sync_auto_love", false);
| |
| 4063 | this.auto_love_tf = window.GetProperty("playcount_sync_auto_love_tf", "");
| |
| 4064 | this.icon = window.GetProperty("playcount_sync_icon", "tango");
| |
| 4065 | this.show_console = window.GetProperty("playcount_sync_show_console", true);
| |
| 4066 | this.library = window.GetProperty("playcount_sync_library", false);
| |
| 4067 | this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
| |
| 4068 | window.SetInterval(function() {
| |
| 4069 | var temp = ps.page > 1 ? ps.page - 1 : 1; | |
| 4070 | if (ps.loved_working && ps.page == ps.last_page) {
| |
| 4071 | ps.xmlhttp.abort(); | |
| 4072 | ps.sync_loved(temp); | |
| 4073 | } else if (ps.playcount_working && ps.page == ps.last_page) {
| |
| 4074 | ps.xmlhttp.abort(); | |
| 4075 | ps.sync_playcount(temp); | |
| 4076 | } else {
| |
| 4077 | ps.last_page = ps.page; | |
| 4078 | } | |
| 4079 | }, 15000); | |
| 4080 | } | |
| 4081 | ||
| 4082 | function rating(x, y, bs) {
| |
| 4083 | this.draw = function(gr) {
| |
| 4084 | if (!p.metadb) return; | |
| 4085 | for (i = 1; i < 6; i++) {
| |
| 4086 | this.img = i > (this.hover ? this.lrating : this.rating) ? this.off_img : this.on_img; | |
| 4087 | p.draw_image(gr, this.img, this.x + this.bs * (i - 1), this.y, this.bs, this.bs, "adjust"); | |
| 4088 | } | |
| 4089 | } | |
| 4090 | ||
| 4091 | this.metadb_changed = function() {
| |
| 4092 | if (!p.metadb) return false; | |
| 4093 | this.hover = false; | |
| 4094 | this.rating = p.eval("$if2(%rating%,0)");
| |
| 4095 | this.tiptext = p.eval(this.tiptext_tf); | |
| 4096 | this.lrating = this.rating; | |
| 4097 | window.RepaintRect(this.x, this.y, this.w, this.bs); | |
| 4098 | return true; | |
| 4099 | } | |
| 4100 | ||
| 4101 | this.trace = function(x, y) {
| |
| 4102 | return x > this.x - this.bs && x < this.x + (this.bs * 5) && y > this.y && y < this.y + this.bs; | |
| 4103 | } | |
| 4104 | ||
| 4105 | this.move = function(x, y) {
| |
| 4106 | if (!this.trace(x, y)) {
| |
| 4107 | if (this.hover) this.leave(); | |
| 4108 | return false; | |
| 4109 | } | |
| 4110 | if (p.metadb) {
| |
| 4111 | if (x > this.x) p.tt(this.tiptext); | |
| 4112 | this.hover = true; | |
| 4113 | this.lrating = Math.ceil((x - this.x) / this.bs); | |
| 4114 | window.RepaintRect(this.x, this.y, this.w, this.bs); | |
| 4115 | } | |
| 4116 | return true; | |
| 4117 | } | |
| 4118 | ||
| 4119 | this.lbtn_up = function(x, y) {
| |
| 4120 | if (!this.trace(x, y)) return false; | |
| 4121 | if (this.check) {
| |
| 4122 | if (this.lrating != this.rating && this.hover == 1) fb.RunContextCommandWithMetadb("Rating/" + (this.lrating == 0 ? "<not set>" : this.lrating), p.metadb, 8);
| |
| 4123 | } else {
| |
| 4124 | p.MsgBox(this.error_text, 0, p.name); | |
| 4125 | p.browser("http://www.foobar2000.org/components/view/foo_playcount");
| |
| 4126 | } | |
| 4127 | return true; | |
| 4128 | } | |
| 4129 | ||
| 4130 | this.leave = function() {
| |
| 4131 | p.ttd(); | |
| 4132 | this.hover = false; | |
| 4133 | window.RepaintRect(this.x, this.y, this.w, this.bs); | |
| 4134 | } | |
| 4135 | ||
| 4136 | this.x = x; | |
| 4137 | this.y = y; | |
| 4138 | this.bs = bs; | |
| 4139 | this.w = this.bs * 5; | |
| 4140 | this.hover = false; | |
| 4141 | this.rating = null; | |
| 4142 | this.lrating = null; | |
| 4143 | this.img = null; | |
| 4144 | this.off_img = gdi.Image(p.images_path + "off.png"); | |
| 4145 | this.on_img = gdi.Image(p.images_path + "on.png"); | |
| 4146 | this.check = utils.CheckComponent("foo_playcount", true);
| |
| 4147 | this.error_text = "This script requires foo_playcount."; | |
| 4148 | this.tiptext_tf = this.check ? 'Rate "%title%" by "%artist%"' : this.error_text; | |
| 4149 | } | |
| 4150 | ||
| 4151 | function sb(x, y, w, h, img, isVisible, func) {
| |
| 4152 | this.x = x; | |
| 4153 | this.y = y; | |
| 4154 | this.w = w; | |
| 4155 | this.h = h; | |
| 4156 | this.img = img; | |
| 4157 | this.isVisible = new Function("return (" + isVisible + ");");
| |
| 4158 | this.func = func; | |
| 4159 | ||
| 4160 | this.draw = function(gr) {
| |
| 4161 | if (this.isVisible()) p.draw_image(gr, this.img, this.x, this.y, this.w, this.h, "adjust"); | |
| 4162 | } | |
| 4163 | ||
| 4164 | this.trace = function(x, y) {
| |
| 4165 | return(x > this.x && x < this.x + this.w && y > this.y && y < this.y + this.h && this.isVisible()); | |
| 4166 | } | |
| 4167 | ||
| 4168 | this.lbtn_up = function(x, y) {
| |
| 4169 | if (!this.trace(x, y)) return false; | |
| 4170 | this.func && this.func(x, y); | |
| 4171 | return true; | |
| 4172 | } | |
| 4173 | } | |
| 4174 | ||
| 4175 | function seekbar(x, y, w, h) {
| |
| 4176 | this.trace = function(x, y) {
| |
| 4177 | 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)); | |
| 4178 | } | |
| 4179 | ||
| 4180 | this.draw = function(gr) {
| |
| 4181 | p.draw_background(gr); | |
| 4182 | switch(this.mode) {
| |
| 4183 | case "spectrogram": | |
| 4184 | if (this.working) {
| |
| 4185 | p.draw_image(gr, this.hourglass_img, this.x, this.y + Math.round((this.h - 32) / 2), this.w, 32, "adjust"); | |
| 4186 | } else {
| |
| 4187 | p.draw_image(gr, this.img, this.x, this.y, this.w, this.h, "stretch"); | |
| 4188 | } | |
| 4189 | if (fb.IsPlaying && fb.PlaybackLength > 0) {
| |
| 4190 | this.calc_pos(); | |
| 4191 | gr.FillSolidRect(this.x + this.pos - 2, this.y, 2, this.h, p.splitRGB(this.marker)); | |
| 4192 | } | |
| 4193 | break; | |
| 4194 | case "nyan_cat": | |
| 4195 | if (fb.IsPlaying && fb.PlaybackLength > 0) {
| |
| 4196 | this.calc_pos(); | |
| 4197 | for (i = 0; i < this.offsets.length; i++) {
| |
| 4198 | gr.FillSolidRect(this.x - 48, this.y + this.offsets[i], this.pos + 2, this.heights[i], this.colours[i]); | |
| 4199 | } | |
| 4200 | p.draw_image(gr, this.cat_img[this.z], this.pos, this.y, 48, 30); | |
| 4201 | } else {
| |
| 4202 | p.draw_image(gr, this.cat_img[0], 0, this.y, 48, 30); | |
| 4203 | } | |
| 4204 | break; | |
| 4205 | } | |
| 4206 | } | |
| 4207 | ||
| 4208 | this.playback_new_track = function() {
| |
| 4209 | if (this.mode != "spectrogram") return; | |
| 4210 | var metadb = fb.GetNowPlaying(); | |
| 4211 | this.img && this.img.Dispose(); | |
| 4212 | this.img = null; | |
| 4213 | try {
| |
| 4214 | this.png_filename = spectrogram_cache + "\\" + fb.TitleFormat("$crc32(%path%)").EvalWithMetadb(metadb) + this.sox_params + ".png";
| |
| 4215 | switch(true) {
| |
| 4216 | case !metadb: | |
| 4217 | case metadb.RawPath.indexOf("file") != 0:
| |
| 4218 | p.console("Skipping... Not a valid file type.");
| |
| 4219 | break; | |
| 4220 | case fb.PlaybackLength == 0: | |
| 4221 | p.console("Skipping... Unknown length.");
| |
| 4222 | break; | |
| 4223 | case fb.TitleFormat("$if($or($strcmp(%__cue_embedded%,yes),$strcmp($right(%path%,3),cue)),cue,)").EvalWithMetadb(metadb) == "cue":
| |
| 4224 | p.console("Skipping... Cannot support cuesheets.");
| |
| 4225 | break; | |
| 4226 | case fb.TitleFormat("%subsong%").EvalWithMetadb(metadb) > 0:
| |
| 4227 | p.console("Skipping... Cannot support tracks with chapters.");
| |
| 4228 | break; | |
| 4229 | case this.library && !fb.IsMetadbInMediaLibrary(metadb): | |
| 4230 | p.console("Skipping... Track not in library.");
| |
| 4231 | break; | |
| 4232 | case p.fso.FileExists(this.png_filename): | |
| 4233 | this.img = gdi.Image(this.png_filename); | |
| 4234 | break; | |
| 4235 | default: | |
| 4236 | this.working = true | |
| 4237 | window.Repaint(); | |
| 4238 | var filename = metadb.Path; | |
| 4239 | var length = fb.TitleFormat("%length%").EvalWithMetadb(metadb);
| |
| 4240 | 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 + "\"\""; | |
| 4241 | //p.console(cmd); | |
| 4242 | try { p.WshShell.Run(cmd, 0, true); } catch(e) {}
| |
| 4243 | this.working = false; | |
| 4244 | this.img = gdi.Image(this.png_filename); | |
| 4245 | break; | |
| 4246 | } | |
| 4247 | } catch(e) {
| |
| 4248 | //p.console(e); | |
| 4249 | } | |
| 4250 | window.Repaint(); | |
| 4251 | } | |
| 4252 | ||
| 4253 | this.playback_stop = function() {
| |
| 4254 | window.Repaint(); | |
| 4255 | } | |
| 4256 | ||
| 4257 | this.playback_seek = function() {
| |
| 4258 | this.update(); | |
| 4259 | } | |
| 4260 | ||
| 4261 | this.move = function(x, y) {
| |
| 4262 | if (this.drag) this.update(); | |
| 4263 | if (this.trace(x, y)) {
| |
| 4264 | if (fb.IsPlaying && fb.PlaybackLength > 0) {
| |
| 4265 | x -= this.x; | |
| 4266 | this.drag_seek = x < 0 ? 0 : x > this.w ? 1 : x / this.w; | |
| 4267 | if (x != this.old_x || y != this.old_y) {
| |
| 4268 | p.tt(p.format_time(fb.PlaybackLength * this.drag_seek)); | |
| 4269 | this.old_x = x; | |
| 4270 | this.old_y = y; | |
| 4271 | } | |
| 4272 | } | |
| 4273 | return true; | |
| 4274 | } else {
| |
| 4275 | this.leave(); | |
| 4276 | return false; | |
| 4277 | } | |
| 4278 | } | |
| 4279 | ||
| 4280 | this.lbtn_down = function(x, y) {
| |
| 4281 | if (!this.trace(x, y)) return false; | |
| 4282 | if (fb.IsPlaying && fb.PlaybackLength > 0) this.drag = true; | |
| 4283 | return true; | |
| 4284 | } | |
| 4285 | ||
| 4286 | this.lbtn_up = function(x, y) {
| |
| 4287 | if (!this.trace(x, y)) return false; | |
| 4288 | if (this.drag) {
| |
| 4289 | this.drag = false; | |
| 4290 | fb.PlaybackTime = fb.PlaybackLength * this.drag_seek; | |
| 4291 | } | |
| 4292 | return true; | |
| 4293 | } | |
| 4294 | ||
| 4295 | this.leave = function() {
| |
| 4296 | this.drag = false; | |
| 4297 | p.ttd(); | |
| 4298 | } | |
| 4299 | ||
| 4300 | this.update = function() {
| |
| 4301 | window.RepaintRect(0, this.y, p.w, this.h); | |
| 4302 | } | |
| 4303 | ||
| 4304 | this.calc_pos = function() {
| |
| 4305 | this.pos = this.drag ? this.w * this.drag_seek : this.w * (fb.PlaybackTime / fb.PlaybackLength); | |
| 4306 | } | |
| 4307 | ||
| 4308 | this.init = function() {
| |
| 4309 | switch(true) {
| |
| 4310 | case p.check_feature("spectrogram"):
| |
| 4311 | this.clear_images = function(period) {
| |
| 4312 | var now = Date.parse(Date()); | |
| 4313 | images = utils.Glob(spectrogram_cache + "\\*.*").toArray(); | |
| 4314 | for (i = 0; i < images.length; i++) {
| |
| 4315 | if (this.png_filename == images[i]) continue; | |
| 4316 | var file = p.fso.Getfile(images[i]); | |
| 4317 | var file_date = Date.parse(file.DateLastModified); | |
| 4318 | if (now - file_date > period) {
| |
| 4319 | try {
| |
| 4320 | p.fso.DeleteFile(images[i]); | |
| 4321 | } catch(e) {
| |
| 4322 | p.console("Could not delete " + images[i]);
| |
| 4323 | } | |
| 4324 | } | |
| 4325 | } | |
| 4326 | } | |
| 4327 | ||
| 4328 | this.mode = "spectrogram"; | |
| 4329 | this.library = window.GetProperty("seekbar_library", false);
| |
| 4330 | this.marker = window.GetProperty("seekbar_marker", "240-240-240");
| |
| 4331 | this.sox_params = window.GetProperty("sox_params", "channels 1 spectrogram -Y 130").trim();
| |
| 4332 | this.working = false; | |
| 4333 | this.img = false; | |
| 4334 | this.hourglass_img = gdi.Image(p.images_path + "hourglass.png"); | |
| 4335 | //if (!p.fso.FolderExists(spectrogram_cache)) p.fso.CreateFolder(spectrogram_cache); | |
| 4336 | if (fb.IsPlaying) {
| |
| 4337 | window.SetTimeout(function() {
| |
| 4338 | s.playback_new_track(); | |
| 4339 | }, 100); | |
| 4340 | } | |
| 4341 | break; | |
| 4342 | case p.check_feature("nyan_cat"):
| |
| 4343 | this.mode = "nyan_cat"; | |
| 4344 | this.cat_img = [gdi.Image(p.images_path + "\\seekbar cat.png"), gdi.Image(p.images_path + "\\seekbar cat 2.png")]; | |
| 4345 | this.offsets = [2, 6, 10, 15, 20, 24]; | |
| 4346 | this.heights = [4, 4, 5, 5, 4, 4]; | |
| 4347 | 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)]; | |
| 4348 | break; | |
| 4349 | } | |
| 4350 | } | |
| 4351 | ||
| 4352 | this.x = x; | |
| 4353 | this.y = y; | |
| 4354 | this.w = w; | |
| 4355 | this.h = h; | |
| 4356 | this.z = 0; | |
| 4357 | this.pos = 0; | |
| 4358 | this.drag = false; | |
| 4359 | this.drag_seek = 0; | |
| 4360 | this.old_x = 0; | |
| 4361 | this.old_y = 0; | |
| 4362 | this.init(); | |
| 4363 | this.seekbar_timer = window.SetInterval(function() {
| |
| 4364 | s.z = s.z == 0 ? 1 : 0; | |
| 4365 | if (!fb.IsPlaying || fb.IsPaused || fb.PlaybackLength == 0) return; | |
| 4366 | s.update(); | |
| 4367 | }, 150); | |
| 4368 | } | |
| 4369 | ||
| 4370 | function text(x, y, w, h) {
| |
| 4371 | this.size = function() {
| |
| 4372 | this.rows = Math.floor((this.h - 36) / p.row_height); | |
| 4373 | this.but_x = this.x + Math.round((this.w - 15) / 2); | |
| 4374 | this.up_btn = new sb(this.but_x, this.y, 15, 15, p.up_img, "t.offset > 0", function() { t.wheel(1); });
| |
| 4375 | 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); });
| |
| 4376 | this.calc(); | |
| 4377 | } | |
| 4378 | ||
| 4379 | this.draw = function(gr, colour) {
| |
| 4380 | for (i = 0; i < Math.min(this.rows, this.text_rows); i++) {
| |
| 4381 | 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); | |
| 4382 | 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); | |
| 4383 | } | |
| 4384 | this.up_btn.draw(gr); | |
| 4385 | this.down_btn.draw(gr); | |
| 4386 | } | |
| 4387 | ||
| 4388 | this.metadb_changed = function() {
| |
| 4389 | if (!p.metadb) return false; | |
| 4390 | switch(this.mode) {
| |
| 4391 | case "simple_tag": | |
| 4392 | this.temp_filename = p.metadb.Path; | |
| 4393 | if (this.filename == this.temp_filename) return false; | |
| 4394 | this.filename = this.temp_filename; | |
| 4395 | this.text = p.eval(this.tag); | |
| 4396 | break; | |
| 4397 | case "simple_text": | |
| 4398 | this.temp_filename = p.eval(this.filename_tf); | |
| 4399 | if (this.filename == this.temp_filename) return false; | |
| 4400 | this.text = ""; | |
| 4401 | this.filename = this.temp_filename; | |
| 4402 | if (p.fso.FolderExists(this.filename)) {
| |
| 4403 | this.files = []; | |
| 4404 | this.files = this.files.concat(utils.Glob(this.filename + "\\*.txt").toArray(), utils.Glob(this.filename + "\\*.log").toArray()); | |
| 4405 | this.files.sort(); | |
| 4406 | this.text = p.open(this.files[0]); | |
| 4407 | } else {
| |
| 4408 | this.filenames = this.filename.split("|");
| |
| 4409 | for (i = 0; i < this.filenames.length; i++) {
| |
| 4410 | if (p.fso.fileExists(this.filenames[i])) {
| |
| 4411 | this.text = p.open(this.filenames[i]); | |
| 4412 | break; | |
| 4413 | } | |
| 4414 | } | |
| 4415 | } | |
| 4416 | this.text = this.text.replace(/\t/g, " "); | |
| 4417 | break; | |
| 4418 | case "lastfm_wiki": | |
| 4419 | p.artist = p.eval(p.artist_tf); | |
| 4420 | if (this.artist == p.artist) return false; | |
| 4421 | this.artist = p.artist; | |
| 4422 | this.folder = p.data_folder + p.artist; | |
| 4423 | if (!p.fso.FolderExists(this.folder)) p.fso.CreateFolder(this.folder); | |
| 4424 | this.filename = this.folder + "\\artist.getInfo_mod.json"; | |
| 4425 | this.text = "Nothing found."; | |
| 4426 | this.url = "http://www.last.fm/"; | |
| 4427 | if (p.fso.fileExists(this.filename)) {
| |
| 4428 | this.json_text = p.open(this.filename); | |
| 4429 | this.json_data = p.json_parse(this.json_text); | |
| 4430 | if (this.json_data && this.json_data.response && this.json_data.response.biographies) {
| |
| 4431 | this.items = this.json_data.response.biographies.length; | |
| 4432 | for (i = 0; i < this.items; i++) {
| |
| 4433 | if (this.json_data.response.biographies[i].site == this.source) {
| |
| 4434 | this.text = this.json_data.response.biographies[i].text; | |
| 4435 | this.url = this.json_data.response.biographies[i].license["attribution-url"]; | |
| 4436 | break; | |
| 4437 | } | |
| 4438 | } | |
| 4439 | if (this.source == "last.fm") this.text = this.text.replace(/\. /g, ".\n\n"); | |
| 4440 | 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"); | |
| 4441 | } | |
| 4442 | } else {
| |
| 4443 | this.get(); | |
| 4444 | } | |
| 4445 | break; | |
| 4446 | case "lastfm_album": | |
| 4447 | var temp_album = p.eval("[%album%]");
| |
| 4448 | var temp_artist = p.eval("[%album artist%]");
| |
| 4449 | if (this.album == temp_album && this.artist == temp_artist) return false; | |
| 4450 | this.artist = temp_artist; | |
| 4451 | this.album = temp_album; | |
| 4452 | this.folder = p.data_folder + p.eval("$crc32(%album artist%)");
| |
| 4453 | if (!p.fso.FolderExists(this.folder)) p.fso.CreateFolder(this.folder); | |
| 4454 | this.filename = this.folder + "\\album.getInfo_" + p.eval("$crc32(%album%)") + ".json";
| |
| 4455 | this.text = "Nothing found."; | |
| 4456 | this.url = l.url; | |
| 4457 | if (p.fso.fileExists(this.filename)) {
| |
| 4458 | this.file = p.fso.GetFile(this.filename); | |
| 4459 | this.json_text = p.open(this.filename); | |
| 4460 | this.json_data = p.json_parse(this.json_text); | |
| 4461 | if (this.json_data && this.json_data.album) {
| |
| 4462 | if (this.json_data.album.url) this.url = this.json_data.album.url; | |
| 4463 | if (this.json_data.album.wiki && this.json_data.album.wiki.content) {
| |
| 4464 | this.text = p.strip_tags(this.json_data.album.wiki.content); | |
| 4465 | 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();
| |
| 4466 | } | |
| 4467 | } | |
| 4468 | if (Date.parse(Date()) - Date.parse(this.file.DateLastModified) > ONE_DAY) this.get(); | |
| 4469 | } else {
| |
| 4470 | this.get(); | |
| 4471 | } | |
| 4472 | break; | |
| 4473 | } | |
| 4474 | this.calc(); | |
| 4475 | window.Repaint(); | |
| 4476 | return true; | |
| 4477 | } | |
| 4478 | ||
| 4479 | this.trace = function(x, y) {
| |
| 4480 | return (x > this.x && x < this.x + this.w && y > this.y && y < this.y + this.h); | |
| 4481 | } | |
| 4482 | ||
| 4483 | this.wheel = function(step) {
| |
| 4484 | if (!this.trace(p.mx, p.my)) return false; | |
| 4485 | if (this.text_rows > this.rows) {
| |
| 4486 | this.offset -= step * 3; | |
| 4487 | if (this.offset < 0) this.offset = 0; | |
| 4488 | if (this.offset + this.rows > this.text_rows) this.offset = this.text_rows - this.rows; | |
| 4489 | window.RepaintRect(this.x, this.y, this.w, this.h); | |
| 4490 | } | |
| 4491 | return true; | |
| 4492 | } | |
| 4493 | ||
| 4494 | this.move = function(x, y) {
| |
| 4495 | switch(true) {
| |
| 4496 | case !this.trace(x, y): | |
| 4497 | window.SetCursor(IDC_ARROW); | |
| 4498 | return false; | |
| 4499 | case this.up_btn.trace(x, y): | |
| 4500 | case this.down_btn.trace(x, y): | |
| 4501 | window.SetCursor(IDC_HAND); | |
| 4502 | return true; | |
| 4503 | default: | |
| 4504 | window.SetCursor(IDC_ARROW); | |
| 4505 | return false; | |
| 4506 | } | |
| 4507 | } | |
| 4508 | ||
| 4509 | this.lbtn_up = function(x, y) {
| |
| 4510 | if (!this.trace(x, y)) return false; | |
| 4511 | this.up_btn.lbtn_up(x, y); | |
| 4512 | this.down_btn.lbtn_up(x, y); | |
| 4513 | return true; | |
| 4514 | } | |
| 4515 | ||
| 4516 | this.get = function() {
| |
| 4517 | var fn = this.filename; | |
| 4518 | var func = function() {
| |
| 4519 | if (!p.save(t.xmlhttp.responsetext, fn)) return; | |
| 4520 | t.artist = ""; | |
| 4521 | t.album = ""; | |
| 4522 | on_item_focus_change(); | |
| 4523 | } | |
| 4524 | var url = ""; | |
| 4525 | var user_agent = ""; | |
| 4526 | switch(this.mode) {
| |
| 4527 | case "lastfm_album": | |
| 4528 | if (this.artist == "" || this.album == "") return; | |
| 4529 | url = l.get_url() + "&method=album.getInfo&artist=" + encodeURIComponent(this.artist) + "&album=" + encodeURIComponent(this.album); | |
| 4530 | user_agent = l.user_agent; | |
| 4531 | break; | |
| 4532 | case "lastfm_wiki": | |
| 4533 | if (this.artist == "" || this.artist == "?") return; | |
| 4534 | url = "http://developer.echonest.com/api/v4/artist/biographies?api_key=EKWS4ESQLKN3G2ZWV&format=json&name=" + encodeURIComponent(this.artist); | |
| 4535 | break; | |
| 4536 | } | |
| 4537 | if (url.length == 0) return; | |
| 4538 | this.xmlhttp.open("GET", url, true);
| |
| 4539 | if (user_agent.length > 0) this.xmlhttp.setRequestHeader('User-Agent', user_agent);
| |
| 4540 | this.xmlhttp.send(); | |
| 4541 | this.xmlhttp.onreadystatechange = function() {
| |
| 4542 | if (t.xmlhttp.readyState == 4) {
| |
| 4543 | if (t.xmlhttp.status == 200) {
| |
| 4544 | func(); | |
| 4545 | } else {
| |
| 4546 | p.console(t.xmlhttp.responsetext || "HTTP error: " + t.xmlhttp.status); | |
| 4547 | } | |
| 4548 | } | |
| 4549 | } | |
| 4550 | } | |
| 4551 | ||
| 4552 | this.calc = function() {
| |
| 4553 | this.offset = 0; | |
| 4554 | this.text_rows = 0; | |
| 4555 | if (this.w < 100 || this.text.length == 0) return; | |
| 4556 | var temp_bmp = gdi.CreateImage(1, 1); | |
| 4557 | var temp_gr = temp_bmp.GetGraphics(); | |
| 4558 | var paragraphs = this.text.split("\n");
| |
| 4559 | this.text_array = []; | |
| 4560 | for (i = 0; i < paragraphs.length; i++) {
| |
| 4561 | if (this.fixed) {
| |
| 4562 | this.text_array.push(paragraphs[i]); | |
| 4563 | } else {
| |
| 4564 | var lines = temp_gr.EstimateLineWrap(paragraphs[i], p.normal_font, this.w).toArray(); | |
| 4565 | for (j = 0; j < lines.length; j += 2) {
| |
| 4566 | this.text_array.push(lines[j].trim()); | |
| 4567 | } | |
| 4568 | } | |
| 4569 | } | |
| 4570 | this.text_rows = this.text_array.length; | |
| 4571 | temp_bmp.ReleaseGraphics(temp_gr); | |
| 4572 | temp_bmp.Dispose(); | |
| 4573 | temp_gr = null; | |
| 4574 | temp_bmp = null; | |
| 4575 | } | |
| 4576 | ||
| 4577 | this.init = function() {
| |
| 4578 | switch(true) {
| |
| 4579 | case p.check_feature("lastfm_album"):
| |
| 4580 | this.mode = "lastfm_album"; | |
| 4581 | break; | |
| 4582 | case p.check_feature("lastfm_wiki"):
| |
| 4583 | this.mode = "lastfm_wiki"; | |
| 4584 | this.source = window.GetProperty("biography_source", "last.fm");
| |
| 4585 | break; | |
| 4586 | case p.check_feature("simple_text"):
| |
| 4587 | this.mode = "simple_text"; | |
| 4588 | this.title = window.GetProperty("text_title", "$directory_path(%path%)");
| |
| 4589 | this.filename_tf = window.GetProperty("text_filename_tf", "$directory_path(%path%)");
| |
| 4590 | this.filename = ""; | |
| 4591 | this.fixed = window.GetProperty("text_fixed_font", true);
| |
| 4592 | break; | |
| 4593 | case p.check_feature("simple_tag"):
| |
| 4594 | this.mode = "simple_tag"; | |
| 4595 | this.title = window.GetProperty("text_title", "%title%");
| |
| 4596 | this.filename = ""; | |
| 4597 | this.centre = window.GetProperty("text_centre", false);
| |
| 4598 | this.tag = window.GetProperty("text_tag", "[%lyrics%]");
| |
| 4599 | break; | |
| 4600 | } | |
| 4601 | } | |
| 4602 | ||
| 4603 | this.x = x; | |
| 4604 | this.y = y; | |
| 4605 | this.w = w; | |
| 4606 | this.h = h; | |
| 4607 | this.text = ""; | |
| 4608 | this.artist = ""; | |
| 4609 | this.album = ""; | |
| 4610 | this.url = ""; | |
| 4611 | this.fixed = false; | |
| 4612 | this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
| |
| 4613 | this.init(); | |
| 4614 | this.size(); | |
| 4615 | } | |
| 4616 | ||
| 4617 | function thumbs() {
| |
| 4618 | this.trace = function(x, y) {
| |
| 4619 | return (x > this.x && x < this.x + this.w && y > this.y && y < this.y + this.h); | |
| 4620 | } | |
| 4621 | ||
| 4622 | this.draw = function(gr) {
| |
| 4623 | switch(true) {
| |
| 4624 | case im.images.length == 0: | |
| 4625 | break; | |
| 4626 | case this.mode == "off": | |
| 4627 | p.draw_image(gr, im.images[im.index], im.x, im.y, im.w, im.h, im.type); | |
| 4628 | break; | |
| 4629 | case !this.img: | |
| 4630 | break; | |
| 4631 | case this.mode == "grid": | |
| 4632 | gr.DrawImage(this.img, this.x, this.y, this.w, this.h, 0, this.offset * this.px, this.w, this.h); | |
| 4633 | if (this.overlay) {
| |
| 4634 | gr.FillSolidRect(this.x, this.y, this.w, this.h, RGBA(0, 0, 0, 126)); | |
| 4635 | p.draw_image(gr, im.images[im.index], im.x, im.y, im.w, im.h, "adjust"); | |
| 4636 | } | |
| 4637 | break; | |
| 4638 | case this.mode == "left": | |
| 4639 | case this.mode == "right": | |
| 4640 | gr.DrawImage(this.img, this.x, this.y, this.w, this.h, 0, this.offset * this.px, this.w, this.h); | |
| 4641 | p.draw_image(gr, im.images[im.index], im.x, im.y, im.w, im.h, im.type); | |
| 4642 | break; | |
| 4643 | case this.mode == "bottom": | |
| 4644 | case this.mode == "top": | |
| 4645 | gr.DrawImage(this.img, this.x, this.y, this.w, this.h, this.offset * this.px, 0, this.w, this.h); | |
| 4646 | p.draw_image(gr, im.images[im.index], im.x, im.y, im.w, im.h, im.type); | |
| 4647 | break; | |
| 4648 | } | |
| 4649 | } | |
| 4650 | ||
| 4651 | this.calc = function() {
| |
| 4652 | this.offset = 0; | |
| 4653 | switch(true) {
| |
| 4654 | case p.w < this.px || p.h < this.px || this.mode == "off": | |
| 4655 | this.nc = true; | |
| 4656 | this.img && this.img.Dispose(); | |
| 4657 | this.img = null; | |
| 4658 | im.x = 0; | |
| 4659 | im.y = 0; | |
| 4660 | im.w = p.w; | |
| 4661 | im.h = p.h; | |
| 4662 | break; | |
| 4663 | case this.mode == "grid": | |
| 4664 | this.x = 0; | |
| 4665 | this.y = 0; | |
| 4666 | this.w = p.w; | |
| 4667 | this.h = p.h; | |
| 4668 | im.x = 40; | |
| 4669 | im.y = 40; | |
| 4670 | im.w = this.w - 80; | |
| 4671 | im.h = this.h - 80; | |
| 4672 | if (!this.nc && this.columns != Math.floor(this.w / this.px)) this.nc = true; | |
| 4673 | this.overlay = false; | |
| 4674 | this.rows = Math.ceil(this.h / this.px); | |
| 4675 | this.columns = Math.floor(this.w / this.px); | |
| 4676 | this.img_rows = Math.ceil(im.images.length / this.columns); | |
| 4677 | if (this.nc && im.images.length > 0) {
| |
| 4678 | this.nc = false; | |
| 4679 | this.img && this.img.Dispose(); | |
| 4680 | this.img = null; | |
| 4681 | this.img = gdi.CreateImage(Math.min(this.columns, im.images.length) * this.px, this.img_rows * this.px); | |
| 4682 | var temp_gr = this.img.GetGraphics(); | |
| 4683 | temp_gr.SetInterpolationMode(7); | |
| 4684 | var ci = 0; | |
| 4685 | var row, col; | |
| 4686 | for (row = 0; row < this.img_rows; row++) {
| |
| 4687 | for (col = 0; col < this.columns; col++) {
| |
| 4688 | if (ci == im.images.length) continue; | |
| 4689 | p.draw_image(temp_gr, im.images[ci], col * this.px, row * this.px, this.px, this.px, "top"); | |
| 4690 | ci++; | |
| 4691 | } | |
| 4692 | } | |
| 4693 | this.img.ReleaseGraphics(temp_gr); | |
| 4694 | temp_gr = null; | |
| 4695 | } | |
| 4696 | break; | |
| 4697 | case this.mode == "left": | |
| 4698 | case this.mode == "right": | |
| 4699 | this.x = this.mode == "left" ? 0 : p.w - this.px; | |
| 4700 | this.y = 0; | |
| 4701 | this.w = this.px; | |
| 4702 | this.h = p.h; | |
| 4703 | im.x = this.mode == "right" ? 0 : this.px; | |
| 4704 | im.y = 0; | |
| 4705 | im.w = p.w - this.px; | |
| 4706 | im.h = p.h; | |
| 4707 | this.rows = Math.ceil(this.h / this.px); | |
| 4708 | if (this.nc && im.images.length > 0) {
| |
| 4709 | this.nc = false; | |
| 4710 | this.img && this.img.Dispose(); | |
| 4711 | this.img = null; | |
| 4712 | this.img = gdi.CreateImage(this.px, this.px * im.images.length); | |
| 4713 | var temp_gr = this.img.GetGraphics(); | |
| 4714 | temp_gr.SetInterpolationMode(7); | |
| 4715 | for (i = 0; i < im.images.length; i++) {
| |
| 4716 | p.draw_image(temp_gr, im.images[i], 0, i * this.px, this.px, this.px, "top"); | |
| 4717 | } | |
| 4718 | this.img.ReleaseGraphics(temp_gr); | |
| 4719 | temp_gr = null; | |
| 4720 | } | |
| 4721 | break; | |
| 4722 | case this.mode == "bottom": | |
| 4723 | case this.mode == "top": | |
| 4724 | this.x = 0; | |
| 4725 | this.y = this.mode == "top" ? 0 : p.h - this.px; | |
| 4726 | this.w = p.w; | |
| 4727 | this.h = this.px; | |
| 4728 | im.x = 0; | |
| 4729 | im.y = this.mode == "bottom" ? 0 : this.px; | |
| 4730 | im.w = p.w; | |
| 4731 | im.h = p.h - this.px; | |
| 4732 | this.columns = Math.ceil(this.w / this.px); | |
| 4733 | if (this.nc && im.images.length > 0) {
| |
| 4734 | this.nc = false; | |
| 4735 | this.img && this.img.Dispose(); | |
| 4736 | this.img = null; | |
| 4737 | this.img = gdi.CreateImage(this.px * im.images.length, this.px); | |
| 4738 | var temp_gr = this.img.GetGraphics(); | |
| 4739 | temp_gr.SetInterpolationMode(7); | |
| 4740 | for (i = 0; i < im.images.length; i++) {
| |
| 4741 | p.draw_image(temp_gr, im.images[i], i * this.px, 0, this.px, this.px, "top"); | |
| 4742 | } | |
| 4743 | this.img.ReleaseGraphics(temp_gr); | |
| 4744 | temp_gr = null; | |
| 4745 | } | |
| 4746 | break; | |
| 4747 | } | |
| 4748 | } | |
| 4749 | ||
| 4750 | this.wheel = function(step) {
| |
| 4751 | switch(true) {
| |
| 4752 | case !this.trace(p.mx, p.my): | |
| 4753 | case this.overlay: | |
| 4754 | return false; | |
| 4755 | case this.mode == "grid": | |
| 4756 | if (this.img_rows < this.rows) return true; | |
| 4757 | this.offset -= step; | |
| 4758 | if (this.offset < 0) this.offset = 0; | |
| 4759 | if (this.offset > this.img_rows - this.rows) this.offset = this.img_rows - this.rows + 1; | |
| 4760 | break; | |
| 4761 | case this.mode == "left": | |
| 4762 | case this.mode == "right": | |
| 4763 | if (im.images.length < this.rows) return true; | |
| 4764 | this.offset -= step; | |
| 4765 | if (this.offset < 0) this.offset = 0; | |
| 4766 | if (this.rows + this.offset > im.images.length) this.offset = im.images.length - this.rows + 1; | |
| 4767 | break; | |
| 4768 | case this.mode == "bottom": | |
| 4769 | case this.mode == "top": | |
| 4770 | if (im.images.length < this.columns) return true; | |
| 4771 | this.offset -= step; | |
| 4772 | if (this.offset < 0) this.offset = 0; | |
| 4773 | if (this.columns + this.offset > im.images.length) this.offset = im.images.length - this.columns + 1; | |
| 4774 | break; | |
| 4775 | } | |
| 4776 | window.RepaintRect(this.x, this.y, this.w, this.h); | |
| 4777 | return true; | |
| 4778 | } | |
| 4779 | ||
| 4780 | this.move = function(x, y) {
| |
| 4781 | switch(true) {
| |
| 4782 | case !this.trace(x, y): | |
| 4783 | window.SetCursor(IDC_ARROW); | |
| 4784 | return false; | |
| 4785 | case this.overlay: | |
| 4786 | window.SetCursor(IDC_ARROW); | |
| 4787 | return true; | |
| 4788 | case this.mode == "grid": | |
| 4789 | this.index = Math.floor((x - this.x) / this.px) + (Math.floor((y - this.y) / this.px) * this.columns) + (this.offset * this.columns); | |
| 4790 | break; | |
| 4791 | case this.mode == "left": | |
| 4792 | case this.mode == "right": | |
| 4793 | this.index = Math.floor((y - this.y) / this.px) + this.offset; | |
| 4794 | break; | |
| 4795 | case this.mode == "bottom": | |
| 4796 | case this.mode == "top": | |
| 4797 | this.index = Math.floor((x - this.x) / this.px) + this.offset; | |
| 4798 | break; | |
| 4799 | } | |
| 4800 | window.SetCursor(this.index < im.images.length ? IDC_HAND : IDC_ARROW); | |
| 4801 | return true; | |
| 4802 | } | |
| 4803 | ||
| 4804 | this.lbtn_up = function(x, y) {
| |
| 4805 | switch(true) {
| |
| 4806 | case !this.trace(x, y): | |
| 4807 | return false; | |
| 4808 | case this.mode == "grid" && this.overlay && im.trace(x, y): | |
| 4809 | this.overlay = false; | |
| 4810 | window.Repaint(); | |
| 4811 | break; | |
| 4812 | case this.mode == "grid" && this.index < im.images.length && !this.overlay: | |
| 4813 | this.overlay = true; | |
| 4814 | im.index = this.index; | |
| 4815 | window.Repaint(); | |
| 4816 | break; | |
| 4817 | case this.overlay: | |
| 4818 | break; | |
| 4819 | case this.index < im.images.length: | |
| 4820 | im.index = this.index; | |
| 4821 | window.Repaint(); | |
| 4822 | } | |
| 4823 | return true; | |
| 4824 | } | |
| 4825 | ||
| 4826 | this.lbtn_dblclk = function(x, y) {
| |
| 4827 | if (!im.trace(x, y) || th.mode == "grid") return false; | |
| 4828 | p.run("\"" + im.files[im.index] + "\"");
| |
| 4829 | return true; | |
| 4830 | } | |
| 4831 | ||
| 4832 | this.nc = false; | |
| 4833 | this.mode = "off"; | |
| 4834 | this.px = 40; | |
| 4835 | this.img = null; | |
| 4836 | } | |
| 4837 | ||
| 4838 | //json2.js | |
| 4839 | if(typeof JSON!=='object'){JSON={};}
| |
| 4840 | (function(){'use strict';function f(n){return n<10?'0'+n:n;}
| |
| 4841 | if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+
| |
| 4842 | f(this.getUTCMonth()+1)+'-'+ | |
| 4843 | f(this.getUTCDate())+'T'+ | |
| 4844 | f(this.getUTCHours())+':'+ | |
| 4845 | f(this.getUTCMinutes())+':'+ | |
| 4846 | f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}
| |
| 4847 | 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+'"';}
| |
| 4848 | 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);}
| |
| 4849 | if(typeof rep==='function'){value=rep.call(holder,key,value);}
| |
| 4850 | 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';}
| |
| 4851 | 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';}
| |
| 4852 | v=partial.length===0?'[]':gap?'[\n'+gap+partial.join(',\n'+gap)+'\n'+mind+']':'['+partial.join(',')+']';gap=mind;return v;}
| |
| 4853 | 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);}}}}
| |
| 4854 | v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}
| |
| 4855 | 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;}
| |
| 4856 | rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}
| |
| 4857 | return str('',{'':value});};}
| |
| 4858 | 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];}}}}
| |
| 4859 | return reviver.call(holder,key,value);} | |
| 4860 | text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+
| |
| 4861 | ('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}
| |
| 4862 | 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;}
| |
| 4863 | throw new SyntaxError('JSON.parse');};}}());
| |
| 4864 | ||
| 4865 | /* | |
| 4866 | * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message | |
| 4867 | * Digest Algorithm, as defined in RFC 1321. | |
| 4868 | * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009 | |
| 4869 | * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet | |
| 4870 | * Distributed under the BSD License | |
| 4871 | * See http://pajhome.org.uk/crypt/md5 for more info. | |
| 4872 | */ | |
| 4873 | var hexcase=0;function hex_md5(a){return rstr2hex(rstr_md5(str2rstr_utf8(a)))}
| |
| 4874 | function hex_hmac_md5(a,b){return rstr2hex(rstr_hmac_md5(str2rstr_utf8(a),str2rstr_utf8(b)))}
| |
| 4875 | function md5_vm_test(){return hex_md5("abc").toLowerCase()=="900150983cd24fb0d6963f7d28e17f72"}
| |
| 4876 | function rstr_md5(a){return binl2rstr(binl_md5(rstr2binl(a),a.length*8))}
| |
| 4877 | function rstr_hmac_md5(c,f){var e=rstr2binl(c);if(e.length>16){e=binl_md5(e,c.length*8)}
| |
| 4878 | var a=Array(16),d=Array(16);for(var b=0;b<16;b++){a[b]=e[b]^909522486;d[b]=e[b]^1549556828}
| |
| 4879 | var g=binl_md5(a.concat(rstr2binl(f)),512+f.length*8);return binl2rstr(binl_md5(d.concat(g),512+128))} | |
| 4880 | function rstr2hex(c){try{hexcase}catch(g){hexcase=0}
| |
| 4881 | 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)}
| |
| 4882 | return b} | |
| 4883 | 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++}
| |
| 4884 | 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))}}}}}
| |
| 4885 | return b} | |
| 4886 | function rstr2binl(b){var a=Array(b.length>>2);for(var c=0;c<a.length;c++){a[c]=0}
| |
| 4887 | for(var c=0;c<b.length*8;c+=8){a[c>>5]|=(b.charCodeAt(c/8)&255)<<(c%32)}
| |
| 4888 | return a} | |
| 4889 | function binl2rstr(b){var a="";for(var c=0;c<b.length*32;c+=8){a+=String.fromCharCode((b[c>>5]>>>(c%32))&255)}
| |
| 4890 | return a} | |
| 4891 | 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)}
| |
| 4892 | return Array(o,n,m,l)} | |
| 4893 | 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)}
| |
| 4894 | function md5_ff(g,f,k,j,e,i,h){return md5_cmn((f&k)|((~f)&j),g,f,e,i,h)}
| |
| 4895 | function md5_gg(g,f,k,j,e,i,h){return md5_cmn((f&j)|(k&(~j)),g,f,e,i,h)}
| |
| 4896 | function md5_hh(g,f,k,j,e,i,h){return md5_cmn(f^k^j,g,f,e,i,h)}
| |
| 4897 | function md5_ii(g,f,k,j,e,i,h){return md5_cmn(k^(f|(~j)),g,f,e,i,h)}
| |
| 4898 | function safe_add(a,d){var c=(a&65535)+(d&65535);var b=(a>>16)+(d>>16)+(c>>16);return(b<<16)|(c&65535)}
| |
| 4899 | function bit_rol(a,b){return(a<<b)|(a>>>(32-b))};
| |
| 4900 | ||
| 4901 | ||
| 4902 | ||
| 4903 | ||
| 4904 | ||
| 4905 | var p = new panel("Youtube Radio", ["custom_background", "remap", "metadb"]);
| |
| 4906 | var im = new images(0, 0, 0, 0); | |
| 4907 | var th = new thumbs(); | |
| 4908 | ||
| 4909 | on_item_focus_change(); | |
| 4910 | ||
| 4911 | function on_playback_time(time) {
| |
| 4912 | im.playback_time(time); | |
| 4913 | //if (ooo2 == "" || ooo2 == "?") if (time==30) im.downloadLFM1(); | |
| 4914 | } | |
| 4915 | ||
| 4916 | ||
| 4917 | function on_metadb_changed() {
| |
| 4918 | im.metadb_changed(); | |
| 4919 | } | |
| 4920 | ||
| 4921 | //Button | |
| 4922 | ||
| 4923 | var Buttons; | |
| 4924 | ||
| 4925 | var g_tooltip = window.CreateTooltip(); | |
| 4926 | var g_down = false; | |
| 4927 | ||
| 4928 | var btn_down = null; | |
| 4929 | var cur_btn = null; | |
| 4930 | ||
| 4931 | ButtonStates = {
| |
| 4932 | normal: 0, | |
| 4933 | hover: 1, | |
| 4934 | down: 2 | |
| 4935 | } | |
| 4936 | ||
| 4937 | function Button(x, y, w, h, img_src, func, tiptext) {
| |
| 4938 | this.left = x; | |
| 4939 | this.top = y; | |
| 4940 | this.w = w; | |
| 4941 | this.h = h; | |
| 4942 | this.right = x + w; | |
| 4943 | this.bottom = y + h; | |
| 4944 | this.func = func; | |
| 4945 | this.tiptext = tiptext; | |
| 4946 | this.state = ButtonStates.normal; | |
| 4947 | this.img_normal = img_src && img_src.normal ? gdi.Image(img_src.normal) : null; | |
| 4948 | this.img_hover = img_src && img_src.hover ? gdi.Image(img_src.hover) : this.img_normal; | |
| 4949 | this.img_down = img_src && img_src.down ? gdi.Image(img_src.down) : this.img_hover; | |
| 4950 | this.img = this.img_normal; | |
| 4951 | ||
| 4952 | this.alterImage = function(img_src) {
| |
| 4953 | this.img_normal = img_src && img_src.normal ? gdi.Image(img_src.normal) : null; | |
| 4954 | this.img_hover = img_src && img_src.hover ? gdi.Image(img_src.hover) : this.img_normal; | |
| 4955 | this.img_down = img_src && img_src.down ? gdi.Image(img_src.down) : this.img_hover; | |
| 4956 | ||
| 4957 | this.changeState(this.state); | |
| 4958 | } | |
| 4959 | ||
| 4960 | this.traceMouse = function (x, y) {
| |
| 4961 | var b = (this.left < x) && (x < this.right) && (this.top < y) && (y < this.bottom); | |
| 4962 | if (b) | |
| 4963 | g_down ? this.changeState(ButtonStates.down) : this.changeState(ButtonStates.hover); | |
| 4964 | else | |
| 4965 | this.changeState(ButtonStates.normal); | |
| 4966 | return b; | |
| 4967 | } | |
| 4968 | ||
| 4969 | ||
| 4970 | this.changeState = function (newstate) {
| |
| 4971 | if (newstate != this.state) | |
| 4972 | window.RepaintRect(this.left, this.top, this.w, this.h); | |
| 4973 | this.state = newstate; | |
| 4974 | switch (this.state) | |
| 4975 | {
| |
| 4976 | case ButtonStates.normal: | |
| 4977 | this.img = this.img_normal; | |
| 4978 | break; | |
| 4979 | ||
| 4980 | case ButtonStates.hover: | |
| 4981 | this.img = this.img_hover; | |
| 4982 | break; | |
| 4983 | ||
| 4984 | case ButtonStates.down: | |
| 4985 | this.img = this.img_down; | |
| 4986 | break; | |
| 4987 | ||
| 4988 | default: | |
| 4989 | this.img = null; | |
| 4990 | } | |
| 4991 | } | |
| 4992 | ||
| 4993 | this.draw = function (gr) {
| |
| 4994 | this.img && gr.DrawImage(this.img, this.left, this.top, this.w, this.h, 0, 0, this.w, this.h); | |
| 4995 | } | |
| 4996 | ||
| 4997 | this.onClick = function () {
| |
| 4998 | this.func && this.func(x,y); | |
| 4999 | } | |
| 5000 | ||
| 5001 | this.onMouseIn = function() {
| |
| 5002 | g_tooltip.Text = this.tiptext; | |
| 5003 | g_tooltip.Activate(); | |
| 5004 | } | |
| 5005 | ||
| 5006 | this.onMouseOut = function() {
| |
| 5007 | g_tooltip.Deactivate(); | |
| 5008 | } | |
| 5009 | } | |
| 5010 | ||
| 5011 | function buttonsDraw(gr) {
| |
| 5012 | for (i in Buttons) {
| |
| 5013 | Buttons[i].draw(gr); | |
| 5014 | } | |
| 5015 | } | |
| 5016 | ||
| 5017 | function buttonsTraceMouse(x, y) {
| |
| 5018 | var btn = null; | |
| 5019 | for (i in Buttons) {
| |
| 5020 | if (Buttons[i].traceMouse(x, y) && !btn) | |
| 5021 | btn = Buttons[i]; | |
| 5022 | } | |
| 5023 | ||
| 5024 | return btn; | |
| 5025 | } | |
| 5026 | ||
| 5027 | function on_mouse_move(x, y) {
| |
| 5028 | var btn = buttonsTraceMouse(x, y); | |
| 5029 | ||
| 5030 | if (btn != cur_btn) {
| |
| 5031 | cur_btn && cur_btn.onMouseOut(); | |
| 5032 | btn && btn.onMouseIn(); | |
| 5033 | } | |
| 5034 | ||
| 5035 | cur_btn = btn; | |
| 5036 | } | |
| 5037 | ||
| 5038 | function on_mouse_lbtn_down(x, y) {
| |
| 5039 | g_down = true; | |
| 5040 | btn_down = cur_btn; | |
| 5041 | ||
| 5042 | if (cur_btn) {
| |
| 5043 | cur_btn.changeState(ButtonStates.down); | |
| 5044 | } | |
| 5045 | } | |
| 5046 | ||
| 5047 | function on_mouse_lbtn_up(x, y) {
| |
| 5048 | if (cur_btn) {
| |
| 5049 | cur_btn.changeState(ButtonStates.hover); | |
| 5050 | if( btn_down == cur_btn ) | |
| 5051 | cur_btn.onClick(x, y); | |
| 5052 | } | |
| 5053 | g_down = false; | |
| 5054 | } | |
| 5055 | ||
| 5056 | function on_mouse_leave() {
| |
| 5057 | if (cur_btn) {
| |
| 5058 | cur_btn.changeState(ButtonStates.normal); | |
| 5059 | } | |
| 5060 | } | |
| 5061 | ||
| 5062 | function on_size() {
| |
| 5063 | ww = window.Width; | |
| 5064 | wh = window.Height; | |
| 5065 | window.Repaint(); | |
| 5066 | } | |
| 5067 | ||
| 5068 | function on_paint(gr) {
| |
| 5069 | /*switch(window.GetProperty("mode", 1)) {
| |
| 5070 | case 1: | |
| 5071 | //col = window.GetColorDUI(1); | |
| 5072 | break; | |
| 5073 | case 2: | |
| 5074 | col = utils.GetSysColor(4); | |
| 5075 | break; | |
| 5076 | case 3: | |
| 5077 | col = custom; | |
| 5078 | break; | |
| 5079 | }*/ | |
| 5080 | //gr.FillSolidRect(0, 0, ww, wh, col); | |
| 5081 | buttonsDraw(gr); | |
| 5082 | //gr.DrawRect(0,0, ww, wh, 1.0, -6250336); | |
| 5083 | } | |
| 5084 | ||
| 5085 | function RGB(r,g,b) {
| |
| 5086 | return (0xff000000|(r<<16)|(g<<8)|(b)); | |
| 5087 | } | |
| 5088 | ||
| 5089 | function on_colors_changed() {
| |
| 5090 | window.Repaint(); | |
| 5091 | } | |
| 5092 | ||
| 5093 | ||
| 5094 | //init Buttons | |
| 5095 | ||
| 5096 | //custom colour accessed through the context menu | |
| 5097 | var custom = RGB(255,255,255); | |
| 5098 | ||
| 5099 | //button width | |
| 5100 | var bw = 24; | |
| 5101 | //button height | |
| 5102 | var bh = 20; | |
| 5103 | ||
| 5104 | //Button position | |
| 5105 | var top_margin = -1; | |
| 5106 | var left_margin = 0; | |
| 5107 | ||
| 5108 | var image_path0 = window.GetProperty("Button Path", fb.ProfilePath + "image");
| |
| 5109 | var image_path = (image_path0 + "\\"); | |
| 5110 | ||
| 5111 | //these 2 lines of code lock the panel size. you can comment them out or change the dimensions to suit | |
| 5112 | //window.MinWidth = window.MaxWidth = 24; | |
| 5113 | //window.MinHeight = window.MaxHeight = 20; | |
| 5114 | ||
| 5115 | ||
| 5116 | ||
| 5117 | Buttons = {
| |
| 5118 | but1: new Button(left_margin,top_margin,bw,bh, {normal: image_path + "youtube0.png", hover: image_path + "youtube1.png"}, function(){
| |
| 5119 | //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)
| |
| 5120 | p.rbtn_up(24, 17); | |
| 5121 | //im.downloadONE(); | |
| 5122 | /*else | |
| 5123 | {
| |
| 5124 | p.artist = p.eval("%artist% %title%");
| |
| 5125 | p.browser("http://www.youtube.com/results?search_query=" + encodeURIComponent(p.artist) + "&ie=utf-8");
| |
| 5126 | }*/ | |
| 5127 | }, "Youtube") | |
| 5128 | ||
| 5129 | } | |
| 5130 | ||
| 5131 | //fb.RunMainMenuCommand("Library/Search");
| |
| 5132 | //fb.RunContextCommand("Open containing folder");
| |
| 5133 | ||
| 5134 | function on_mouse_rbtn_up(x, y) {
| |
| 5135 | return true; | |
| 5136 | } |