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 | //Properties | |
| 9 | auto_yt = window.GetProperty("YT Radio", "0");
| |
| 10 | ooo2 = window.GetProperty("YT Track", "");
| |
| 11 | START_ARTIST = window.GetProperty("YT Station", "");
| |
| 12 | last_fm = window.GetProperty("YT Similar", "");
| |
| 13 | YT_URL = window.GetProperty("YT URL", "");
| |
| 14 | art = window.GetProperty("YT Artist Variety (1-20)", "20");
| |
| 15 | sng = window.GetProperty("YT Song Hotness (1-20)", "20");
| |
| 16 | gnr = window.GetProperty("YT Tag Hotness (27-100)", "27");
| |
| 17 | pls = window.GetProperty("FB Playlist", "YT Radio");
| |
| 18 | ||
| 19 | var MF_GRAYED = 0x00000001; | |
| 20 | var MF_STRING = 0x00000000; | |
| 21 | var IDC_ARROW = 32512; | |
| 22 | var IDC_HAND = 32649; | |
| 23 | ||
| 24 | function RGB(r, g, b) {
| |
| 25 | return (0xff000000 | (r << 16) | (g << 8) | (b)); | |
| 26 | } | |
| 27 | ||
| 28 | function RGBA(r, g, b, a) {
| |
| 29 | return ((a << 24) | (r << 16) | (g << 8) | (b)); | |
| 30 | } | |
| 31 | ||
| 32 | function on_colors_changed() {
| |
| 33 | p.colors_changed(); | |
| 34 | } | |
| 35 | ||
| 36 | function on_selection_changed() {
| |
| 37 | p.item_focus_change(); | |
| 38 | } | |
| 39 | ||
| 40 | function on_playlist_switch() {
| |
| 41 | p.item_focus_change(); | |
| 42 | set_focus0(); | |
| 43 | } | |
| 44 | ||
| 45 | function on_playback_new_track() {
| |
| 46 | p.item_focus_change(); | |
| 47 | downloadLFM(); | |
| 48 | } | |
| 49 | ||
| 50 | function on_playback_dynamic_info_track() {
| |
| 51 | p.item_focus_change(); | |
| 52 | } | |
| 53 | ||
| 54 | function on_playback_stop() {
| |
| 55 | p.item_focus_change(); | |
| 56 | } | |
| 57 | ||
| 58 | function on_item_focus_change() {
| |
| 59 | p.item_focus_change(); | |
| 60 | } | |
| 61 | ||
| 62 | function on_mouse_leave() {
| |
| 63 | ||
| 64 | } | |
| 65 | ||
| 66 | function on_mouse_rbtn_up(x, y) {
| |
| 67 | p.rbtn_up(x, y); | |
| 68 | return true; | |
| 69 | } | |
| 70 | ||
| 71 | //Playlist | |
| 72 | function GetPlaylistID(Playlist_Name) | |
| 73 | {
| |
| 74 | for (var i = 0; i < fb.PlaylistCount; i++) | |
| 75 | {
| |
| 76 | if (fb.GetPlaylistName(i) == Playlist_Name) | |
| 77 | ||
| 78 | {
| |
| 79 | return i; | |
| 80 | } | |
| 81 | } | |
| 82 | // create playlist if it doesn't exist | |
| 83 | fb.CreatePlaylist(fb.PlaylistCount, Playlist_Name); | |
| 84 | return i; | |
| 85 | } | |
| 86 | - | //Focus on playlist |
| 86 | + | |
| 87 | //Playlist(Check) | |
| 88 | function GetPlaylistID0(Playlist_Name) | |
| 89 | {
| |
| 90 | for (var i = 0; i < fb.PlaylistCount; i++) | |
| 91 | ||
| 92 | if (fb.GetPlaylistName(i) == Playlist_Name) | |
| 93 | ||
| 94 | {
| |
| 95 | return i; | |
| 96 | } | |
| 97 | ||
| 98 | } | |
| 99 | ||
| 100 | ||
| 101 | //Focus on playlist(Check) | |
| 102 | function set_focus0() | |
| 103 | { if (pls>"")
| |
| 104 | {
| |
| 105 | var PL_NM = (GetPlaylistID0(pls + " ["+ START_ARTIST +"]")); | |
| 106 | if (fb.ActivePlaylist == PL_NM) {auto_yt = 1; window.SetProperty("YT Radio", "1");}
| |
| 107 | else | |
| 108 | {auto_yt = 0; window.SetProperty("YT Radio", "0");}
| |
| 109 | } | |
| 110 | } | |
| 111 | ||
| 112 | //Focus on playlist(YT Radio) | |
| 113 | function set_focus() | |
| 114 | { if (pls>"")
| |
| 115 | fb.ActivePlaylist = (GetPlaylistID(pls + " ["+ START_ARTIST +"]")); | |
| 116 | } | |
| 117 | ||
| 118 | //Focus on playlist(Same Video) | |
| 119 | function set_focus2() | |
| 120 | { if (pls>"")
| |
| 121 | fb.ActivePlaylist = (GetPlaylistID(pls + " [Same Video]")); | |
| 122 | } | |
| 123 | ||
| 124 | ||
| 125 | //Focus on playlist(Search Videos) | |
| 126 | function set_focus3() | |
| 127 | { if (pls>"")
| |
| 128 | fb.ActivePlaylist = (GetPlaylistID(pls + " [Search Videos]")); | |
| 129 | } | |
| 130 | ||
| 131 | //Panel | |
| 132 | function panel(name, features) {
| |
| 133 | this.item_focus_change = function() {
| |
| 134 | if (!this.metadb_func) return; | |
| 135 | switch(this.selection_mode) {
| |
| 136 | case 0: | |
| 137 | this.metadb = fb.GetSelection(); | |
| 138 | break; | |
| 139 | case 1: | |
| 140 | this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem(); | |
| 141 | break; | |
| 142 | case 2: | |
| 143 | this.metadb = fb.GetFocusItem(); | |
| 144 | - | if (auto_yt=="1") _menu.AppendMenuItem(MF_STRING, 22, "Get Next Video"); |
| 144 | + | |
| 145 | } | |
| 146 | - | if (auto_yt=="0") _menu.AppendMenuItem(MF_STRING, 21, "Get Next Video"); |
| 146 | + | |
| 147 | } | |
| 148 | ||
| 149 | //Metadb | |
| 150 | this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem(); | |
| 151 | ||
| 152 | ||
| 153 | //Size | |
| 154 | this.size = function() {
| |
| 155 | this.w = window.Width; | |
| 156 | this.h = window.Height; | |
| 157 | } | |
| 158 | - | _menu.AppendMenuItem(MF_STRING, 403, "Open Same Video"); |
| 158 | + | |
| 159 | //Move | |
| 160 | this.move = function(x, y) {
| |
| 161 | this.mx = x; | |
| 162 | this.my = y; | |
| 163 | } | |
| 164 | ||
| 165 | //Menu | |
| 166 | this.rbtn_up = function(x, y) {
| |
| 167 | var _menu = window.CreatePopupMenu(); | |
| 168 | var idx; | |
| 169 | switch(true) {
| |
| 170 | ||
| 171 | ||
| 172 | case typeof th == "object": | |
| 173 | case typeof im == "object": | |
| 174 | {
| |
| 175 | ||
| 176 | if(auto_yt==1) _menu.AppendMenuItem(MF_STRING, 1902, "Youtube Radio"); | |
| 177 | if(auto_yt==0) _menu.AppendMenuItem(MF_STRING, 1903, "Youtube Radio"); | |
| 178 | _menu.CheckMenuItem(1902, auto_yt?1:0); | |
| 179 | - | case 21: |
| 179 | + | |
| 180 | _menu.AppendMenuSeparator(); | |
| 181 | ||
| 182 | {
| |
| 183 | _menu.AppendMenuItem(MF_STRING, 22, "Get Next Video"); | |
| 184 | _menu.AppendMenuItem(MF_STRING, 401, "Search Videos"); | |
| 185 | _menu.AppendMenuSeparator(); | |
| 186 | ||
| 187 | _menu.AppendMenuItem(MF_STRING, 1914, "Start Radio Station"); | |
| 188 | p.artist = p.eval("%artist%");
| |
| 189 | if (p.artist == "" || p.artist == "?") {_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Same Artist Station");}
| |
| 190 | else | |
| 191 | {_menu.AppendMenuItem(MF_STRING, 1915, "Same Artist Station");}
| |
| 192 | ||
| 193 | _menu.AppendMenuSeparator(); | |
| 194 | ||
| 195 | p.artist = p.eval("%artist%");
| |
| 196 | p.title = p.eval("%title%");
| |
| 197 | if (p.artist == "" || p.artist == "?" || p.title == "" || p.title == "?") {_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Open Same Video");}
| |
| 198 | else | |
| 199 | {_menu.AppendMenuItem(MF_STRING, 403, "Open Same Video");}
| |
| 200 | ||
| 201 | _menu.AppendMenuItem(MF_STRING, 404, "Find in Browser"); | |
| 202 | ||
| 203 | ||
| 204 | _menu.AppendMenuSeparator(); | |
| 205 | } | |
| 206 | - | case 1914: |
| 206 | + | |
| 207 | ||
| 208 | - | START_ARTIST = this.InputBox("Type Artist to Start Station\n\n( *genre - will play genre station)", this.name, START_ARTIST);
|
| 208 | + | |
| 209 | - | window.SetProperty("YT Station", START_ARTIST);
|
| 209 | + | |
| 210 | - | if (START_ARTIST==Start) |
| 210 | + | |
| 211 | ||
| 212 | if (utils.IsKeyPressed(0x10)) _menu.AppendMenuItem(MF_STRING, 10, "Configure..."); | |
| 213 | idx = _menu.TrackPopupMenu(x, y); | |
| 214 | switch(idx) {
| |
| 215 | case 9: | |
| 216 | window.ShowProperties(); | |
| 217 | break; | |
| 218 | case 10: | |
| 219 | window.ShowConfigure(); | |
| 220 | break; | |
| 221 | case 22: | |
| 222 | set_focus(); | |
| 223 | downloadLFM1(); | |
| 224 | break; | |
| 225 | case 401: | |
| 226 | set_focus3(); //Focus on playlist | |
| 227 | fb.RunMainMenuCommand("View/Youtube Source");
| |
| 228 | break; | |
| 229 | case 403: | |
| 230 | this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem(); | |
| 231 | - | /*if (START_ARTIST==Start) |
| 231 | + | |
| 232 | downloadART_TITLE(); | |
| 233 | break; | |
| 234 | case 404: | |
| 235 | - | {*/
|
| 235 | + | |
| 236 | p.browser("http://www.youtube.com/results?search_query=" + encodeURIComponent(p.artist));
| |
| 237 | - | //} |
| 237 | + | |
| 238 | case 1902: | |
| 239 | auto_yt = 0; | |
| 240 | window.SetProperty("YT Radio", "0");
| |
| 241 | break; | |
| 242 | ||
| 243 | case 1903: | |
| 244 | auto_yt = 1; | |
| 245 | window.SetProperty("YT Radio", "1");
| |
| 246 | break; | |
| 247 | ||
| 248 | case 1914: | |
| 249 | var Start; | |
| 250 | Start = this.InputBox("Type Artist to Start Station\n\n( *genre - will play genre station)", "Youtube Radio", "");
| |
| 251 | if (Start=="") | |
| 252 | {
| |
| 253 | } | |
| 254 | else | |
| 255 | {
| |
| 256 | auto_yt = 1; | |
| 257 | window.SetProperty("YT Radio", "1");
| |
| 258 | START_ARTIST = Start; | |
| 259 | window.SetProperty("YT Station", Start);
| |
| 260 | set_focus(); | |
| 261 | downloadLFM0(); | |
| 262 | } | |
| 263 | break; | |
| 264 | ||
| 265 | case 1915: | |
| 266 | this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem(); | |
| 267 | Start = START_ARTIST; | |
| 268 | p.artist = p.eval("%artist%");
| |
| 269 | if (p.artist == "" || p.artist == "?") return; | |
| 270 | START_ARTIST = p.artist; | |
| 271 | window.SetProperty("YT Station", p.artist);
| |
| 272 | auto_yt = 1; | |
| 273 | window.SetProperty("YT Radio", "1");
| |
| 274 | on_item_focus_change(); | |
| 275 | set_focus(); | |
| 276 | downloadLFM0(); | |
| 277 | ||
| 278 | break; | |
| 279 | ||
| 280 | ||
| 281 | } | |
| 282 | _menu.Dispose(); | |
| 283 | ||
| 284 | } | |
| 285 | ||
| 286 | //Features init | |
| 287 | this.features_init = function() {
| |
| 288 | for (i = 0; i < this.features.length; i++) {
| |
| 289 | - | //title = title.replace(/"/g, '" + Chr(34) + "'); |
| 289 | + | |
| 290 | case "metadb": | |
| 291 | this.selection_mode = 1; | |
| 292 | break; | |
| 293 | - | 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);
|
| 293 | + | |
| 294 | this.artist_tf = window.GetProperty("YT Search", "%path%");
| |
| 295 | break; | |
| 296 | } | |
| 297 | } | |
| 298 | } | |
| 299 | ||
| 300 | this.check_feature = function(f) {
| |
| 301 | for (i = 0; i < this.features.length; i++) {
| |
| 302 | if (this.features[i] == f) return true; | |
| 303 | } | |
| 304 | return false; | |
| 305 | } | |
| 306 | - | if (!this.run(command)) this.MsgBox("Unable to launch your default browser.", 0, this.name);
|
| 306 | + | |
| 307 | this.eval = function(tf) {
| |
| 308 | if (!this.metadb || tf == "") return ""; | |
| 309 | if (fb.IsPlaying && this.metadb.RawPath.indexOf("file://") != 0) {
| |
| 310 | return fb.TitleFormat(tf).Eval(); | |
| 311 | } else {
| |
| 312 | return fb.TitleFormat(tf).EvalWithMetadb(this.metadb); | |
| 313 | } | |
| 314 | } | |
| 315 | ||
| 316 | //Console Msg | |
| 317 | this.console = function(message) {
| |
| 318 | this.name = "Youtube Radio" | |
| 319 | fb.trace(this.name + ": " + message); | |
| 320 | } | |
| 321 | ||
| 322 | //Input Box | |
| 323 | String.prototype.trim = function() {
| |
| 324 | return this.replace(/^\s+|\s+$/g, ""); | |
| 325 | } | |
| 326 | ||
| 327 | this.InputBox = function(prompt, title, value) {
| |
| 328 | prompt = prompt.replace(/"/g, '" + Chr(34) + "').replace(/\n/g, '" + Chr(13) + "'); | |
| 329 | title = title.replace(/"/g, '" + Chr(34) + "'); | |
| 330 | value = value.replace(/"/g, '" + Chr(34) + "'); | |
| 331 | var temp_value = this.vb.eval('InputBox' + '("' + prompt + '", "' + title + '", "' + value + '")');
| |
| 332 | if (typeof temp_value == "undefined") return value; | |
| 333 | 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, "Youtube Radio");
| |
| 334 | return temp_value.trim(); | |
| 335 | } | |
| 336 | ||
| 337 | //Msg Box | |
| 338 | this.MsgBox = function(prompt, buttons, title) {
| |
| 339 | prompt = prompt.replace(/"/g, '" + Chr(34) + "').replace(/\n/g, '" + Chr(13) + "'); | |
| 340 | title = title.replace(/"/g, '" + Chr(34) + "'); | |
| 341 | return this.vb.eval('MsgBox' + '("' + prompt + '", "' + buttons + '", "' + title + '")');
| |
| 342 | } | |
| 343 | ||
| 344 | //Browser | |
| 345 | this.browser = function(command) {
| |
| 346 | if (!this.run(command)) this.MsgBox("Unable to launch your default browser.", 0, "Youtube Radio");
| |
| 347 | } | |
| 348 | ||
| 349 | //Run Command | |
| 350 | this.run = function(command) {
| |
| 351 | try {
| |
| 352 | this.WshShell.Run(command); | |
| 353 | return true; | |
| 354 | } catch(e) {
| |
| 355 | return false; | |
| 356 | } | |
| 357 | } | |
| 358 | ||
| 359 | ||
| 360 | ||
| 361 | //futures | |
| 362 | this.metadb_func = typeof on_metadb_changed == "function"; | |
| 363 | this.features = features; | |
| 364 | this.dui = window.InstanceType; | |
| 365 | this.metadb = fb.GetFocusItem(); | |
| 366 | this.WshShell = new ActiveXObject("WScript.Shell");
| |
| 367 | this.fso = new ActiveXObject("Scripting.FileSystemObject");
| |
| 368 | this.vb = new ActiveXObject("ScriptControl");
| |
| 369 | this.vb.Language = "VBScript"; | |
| 370 | this.artist_tf = "%path%"; | |
| 371 | this.features_init(); | |
| 372 | this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem(); | |
| 373 | if (fb.GetFocusItem()) | |
| 374 | {this.artist = fb.TitleFormat(this.artist_tf).EvalWithMetadb(this.metadb);}
| |
| 375 | ||
| 376 | ||
| 377 | ||
| 378 | } | |
| 379 | //YT NAMES------------------------------------------------- | |
| 380 | ||
| 381 | //Clean Art Name | |
| 382 | - | //if (!p.fso.FolderExists(this.folder)) return; |
| 382 | + | |
| 383 | CLEAN_ART_NAME = function (t) | |
| 384 | {
| |
| 385 | try | |
| 386 | {
| |
| 387 | return t.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","'");
| |
| 388 | } catch (e) {}
| |
| 389 | } | |
| 390 | ||
| 391 | ||
| 392 | //Clean Track Name | |
| 393 | ||
| 394 | CLEAN_TRACK_NAME = function (t) | |
| 395 | {
| |
| 396 | try | |
| 397 | {
| |
| 398 | return t.replace(/about:\//,"").trim().split(" (")[0].replace(" (","").split(" [")[0].replace(" [","").split(" {")[0].replace(" {","").split(", ")[0].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","'").replace(" 01-","").replace(" 02-","").replace(" 03-","").replace(" 04-","").replace(" 05-","").replace(" 06-","").replace(" 07-","").replace(" 08-","").replace(" 09-","").replace("09 ","").replace("08 ","").replace("07 ","").replace("06 ","").replace("05 ","").replace("04 ","").replace("03 ","").replace("02 ","").replace("01 ","").replace("00 ","").replace("01 ","").replace("02 ","").replace("03 ","").replace("04 ","").replace("05 ","").replace("06 ","").replace("07 ","").replace("08 ","").replace("09 ","").replace("00 ","").replace(".mp","").replace(" - Remastered ","").replace(" - Remastered","").replace("- "," ").replace(decodeURIComponent(last_fm) + " -"," ").replace(decodeURIComponent(last_fm) + " - "," ").replace(" - Live ","").replace(" - Live","").replace(" Pt.1","").replace(" - Demo;2 Digital Remaster 66 ","").replace(" - Demo;2 Digital Remaster","").replace(" - Demo;","").replace(" - Demo","").replace("Digital Remaster","").replace("Original- ","").replace("Original- ","").replace("Original-","").replace(" - Vocal Version","").replace(" Mega-Mix","").replace("Mega-Mix","").replace(" - Original Mix","").replace(" Pop Radio Edit","").replace(" Radio Edit","").replace(" - Single Version","").replace(" - Edited Version","").replace("- ","").replace("- ","").replace("- ","").replace("- ","").replace("- ","").replace("- ","").replace("- ","").replace("- ","").replace("- ","").replace("- ","").replace(" - Extended Version","").replace(" -Remaster","").replace("`","'").replace(". "," ").replace(" Version","").replace(" edit","").replace(" - Edit","").replace(" Simple Mix","").replace(" Almighty Mix","").replace(" - Vocal","").replace(" Vocal","").replace(" Remix","").replace(" Extended Version","").replace(" - Explicit Version","").replace("- Explicit Version","").replace(" Explicit Version","").replace("Explicit Version","").replace(" Anthology", "").replace("The " + decodeURIComponent(last_fm), " ").replace(" - Survival Remix","").replace(" Radio Mix","").replace(" Survival Remix","").replace("Survival Remix","").replace(decodeURIComponent(last_fm) + "-"," ").replace(decodeURIComponent(last_fm)," ").replace(" Club Mix","").replace("_"," ").replace("_"," ").replace("_"," ").replace("_"," ").replace("_"," ").replace("_"," ").replace("_"," ").replace("_"," ").replace("_"," ").replace("_"," ").replace(" wwwi.info","").replace(" Edit","").replace("live","").replace("Single","").replace("vk.com/xclusives zone ","").replace(" Acoustic","").replace("Remix","").replace("Part&","").replace(" +","").replace(" % ","").replace(" % ","").replace(" % ","").replace(" % ","").replace(" % ","").replace(" % ","").replace(" % ","").replace(" % ","").replace(" % ","").replace(" % ","").replace(" % ","").replace(" % ","").replace(" % ","").replace(" Live;0 2","").replace(" Live;0 2","").replace("Live;0 2","").replace(' /"/"',"").replace(" -0","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace(" Alternate Mix","").replace("Live","").replace(" Alternate Mix","").replace("Alternate Mix","").replace("-0","").replace(" remastered","").replace(" // СЛУШАЮТ:","").replace("www.KLAUSOM.lt","").replace("-;-Bit Digital Remaster","").replace(" :","").replace("-1 Remaster","").replace(" Genuine Album","").replace(" www.rsmp.com","").replace(" www.rsmp.com","").replace("www.rsmp.com","").replace("Instrumental","").replace(" Instrumental","").replace("www.SongsLover.pk","").replace(" Genuine Album","").replace("Album","").replace("Remaster","").replace("Lyrics","").replace("w/lyrics","").replace(" -","").replace(" Radio","").replace("0%","").replace("remaster","").replace(" Lyrics","").split(" | '' |")[0].replace(" | '' |","").split(" |")[0].replace(" |","").split("|")[0].replace("|","").split("| On:")[0].replace("| On:","").split(" feat")[0].replace(" feat","").split(" ft.")[0].replace(" ft.","").split(" Feat.")[0].replace(" Feat","").split("Greatest Hits Megamix")[0].replace("Greatest Hits Megamix","").split("Lyrics")[0].replace("Lyrics","").split("Lyric")[0].replace("Lyric","").split("www.")[0].replace("www.","").split(";Feat")[0].replace(";Feat","").trim();
| |
| 399 | } catch (e) {}
| |
| 400 | } | |
| 401 | ||
| 402 | ||
| 403 | ||
| 404 | ||
| 405 | //Clean Genre Name | |
| 406 | ||
| 407 | CLEAN_GENRE_NAME = function (t) | |
| 408 | {
| |
| 409 | try | |
| 410 | {
| |
| 411 | return t.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];
| |
| 412 | } catch (e) {}
| |
| 413 | } | |
| 414 | ||
| 415 | ||
| 416 | ||
| 417 | //YT RADIO START-------------------------------------------- | |
| 418 | ||
| 419 | //open simmilar artist | |
| 420 | this.downloadLFM = function() | |
| 421 | {
| |
| 422 | {
| |
| 423 | if (auto_yt=="1") | |
| 424 | ||
| 425 | {
| |
| 426 | p.artist = p.eval("%path%");
| |
| 427 | 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)
| |
| 428 | ||
| 429 | ||
| 430 | { var randomnumber=Math.floor(Math.random()*art)
| |
| 431 | var a=randomnumber; | |
| 432 | this.working=true; | |
| 433 | if (START_ARTIST == "" || START_ARTIST == "?") return; | |
| 434 | if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
| |
| 435 | this.xmlhttp.open("GET", "http://www.last.fm/music/" + encodeURIComponent(START_ARTIST) + "/+similar"+ "?page=" + a, true);
| |
| 436 | this.xmlhttp.send(); | |
| 437 | this.xmlhttp.onreadystatechange = function() {
| |
| 438 | if (this.xmlhttp.readyState == 4) {
| |
| 439 | if (this.xmlhttp.status == 200) {
| |
| 440 | var text = this.xmlhttp.responsetext; | |
| 441 | if (!this.doc) this.doc = new ActiveXObject("htmlfile");
| |
| 442 | this.doc.open(); | |
| 443 | var div = this.doc.createElement("div");
| |
| 444 | div.innerHTML = text; | |
| 445 | var data = div.getElementsByTagName("a");
| |
| 446 | var urls = []; | |
| 447 | ||
| 448 | ||
| 449 | ||
| 450 | for (i = 0; i < data.length; i++) {
| |
| 451 | if (data[i].href.indexOf("about:/music/") == 0) urls.push(CLEAN_ART_NAME(data[i].href));
| |
| 452 | } | |
| 453 | ||
| 454 | ||
| 455 | //select random URL | |
| 456 | var randomnumber = Math.floor(Math.random()*(20-50)+50); | |
| 457 | do{
| |
| 458 | randomnumber = Math.floor(Math.random()*(20-50)+50); | |
| 459 | } while(randomnumber%2!=1); | |
| 460 | i=randomnumber; | |
| 461 | ||
| 462 | {
| |
| 463 | ||
| 464 | //do something with urls[i] | |
| 465 | ||
| 466 | if (urls[i] > "") | |
| 467 | {
| |
| 468 | ||
| 469 | last_fm = window.SetProperty("YT Similar", urls[i]);
| |
| 470 | last_fm = urls[i]; | |
| 471 | window.SetProperty("YT Similar", urls[i]);
| |
| 472 | } | |
| 473 | else | |
| 474 | //if (urls[i] == "" || urls[i] == "?") | |
| 475 | {
| |
| 476 | last_fm = window.SetProperty("YT Similar", "");
| |
| 477 | last_fm = ""; | |
| 478 | window.SetProperty("YT Similar", "");
| |
| 479 | } | |
| 480 | ||
| 481 | } | |
| 482 | ||
| 483 | this.doc.close(); | |
| 484 | this.working=false; | |
| 485 | if (START_ARTIST.indexOf("*")== 0) {downloadGENRE2();}
| |
| 486 | else | |
| 487 | if (last_fm == "" || last_fm == "?") {downloadLFM();}
| |
| 488 | else | |
| 489 | downloadTRACK(); | |
| 490 | } else {
| |
| 491 | if (START_ARTIST.indexOf("*")== 0) {} else {p.console("HTTP error: " + this.xmlhttp.status);}
| |
| 492 | ||
| 493 | if (START_ARTIST.indexOf("*")== 0) {downloadGENRE2();}
| |
| 494 | else | |
| 495 | if (this.xmlhttp.status == 404) {downloadLFM();}
| |
| 496 | } | |
| 497 | } | |
| 498 | } | |
| 499 | } | |
| 500 | }} | |
| 501 | ||
| 502 | } | |
| 503 | ||
| 504 | ||
| 505 | //Open track | |
| 506 | this.downloadTRACK = function() | |
| 507 | {
| |
| 508 | {
| |
| 509 | ||
| 510 | {
| |
| 511 | ||
| 512 | ||
| 513 | {var randomnumber=Math.floor(Math.random()*sng)
| |
| 514 | var a=randomnumber; | |
| 515 | this.working=true; | |
| 516 | if (last_fm == "" || last_fm == "?") return; | |
| 517 | if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
| |
| 518 | this.xmlhttp.open("GET", "http://www.last.fm/music/" + encodeURIComponent(last_fm) + "/+tracks" + "?page=" + a, true);
| |
| 519 | this.xmlhttp.send(); | |
| 520 | this.xmlhttp.onreadystatechange = function() {
| |
| 521 | if (this.xmlhttp.readyState == 4) {
| |
| 522 | if (this.xmlhttp.status == 200) {
| |
| 523 | var text = this.xmlhttp.responsetext; | |
| 524 | if (!this.doc) this.doc = new ActiveXObject("htmlfile");
| |
| 525 | this.doc.open(); | |
| 526 | var div = this.doc.createElement("tr");
| |
| 527 | div.innerHTML = text; | |
| 528 | var data = div.getElementsByTagName("td");
| |
| 529 | var urls = []; | |
| 530 | ||
| 531 | ||
| 532 | ||
| 533 | for (i = 0; i < data.length; i++) {
| |
| 534 | if (data[i].title) urls.push(CLEAN_TRACK_NAME(data[i].title)); | |
| 535 | } | |
| 536 | ||
| 537 | //select random URL | |
| 538 | var randomnumber = Math.floor(Math.random()*Math.max(urls.length)); | |
| 539 | i=randomnumber; | |
| 540 | ||
| 541 | {
| |
| 542 | ||
| 543 | //do something with urls[i] | |
| 544 | if (urls[i] > "") | |
| 545 | ||
| 546 | {
| |
| 547 | ||
| 548 | p.console("" + last_fm + " - " + urls[i]);
| |
| 549 | ||
| 550 | ooo2 = window.SetProperty("YT Track", urls[i]);
| |
| 551 | - | //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)
|
| 551 | + | |
| 552 | window.SetProperty("YT Track", urls[i]);
| |
| 553 | } | |
| 554 | else | |
| 555 | //if (urls[i] == "" || urls[i] == "?") | |
| 556 | {
| |
| 557 | ooo2 = window.SetProperty("YT Track", "");
| |
| 558 | ooo2 = ""; | |
| 559 | window.SetProperty("YT Track", "");
| |
| 560 | } | |
| 561 | } | |
| 562 | ||
| 563 | this.doc.close(); | |
| 564 | this.working=false; | |
| 565 | if (ooo2 == "" || ooo2 == "?") {downloadLFM();}
| |
| 566 | else | |
| 567 | set_focus(); //focus on playlist | |
| 568 | do_youtube_search1(decodeURIComponent(last_fm), decodeURIComponent(ooo2)); | |
| 569 | } else {
| |
| 570 | p.console("HTTP error: " + this.xmlhttp.status);
| |
| 571 | if (START_ARTIST.indexOf("*")== 0) {downloadGENRE2();}
| |
| 572 | else | |
| 573 | if (this.xmlhttp.status == 404) {downloadLFM();}
| |
| 574 | ||
| 575 | } | |
| 576 | } | |
| 577 | } | |
| 578 | } | |
| 579 | }}} | |
| 580 | ||
| 581 | ||
| 582 | //YT RADIO(One)-------------------------------------------- | |
| 583 | ||
| 584 | //open simmilar artist | |
| 585 | this.downloadLFM1 = function() | |
| 586 | {
| |
| 587 | ||
| 588 | {
| |
| 589 | ||
| 590 | {
| |
| 591 | ||
| 592 | ||
| 593 | { var randomnumber=Math.floor(Math.random()*art)
| |
| 594 | var a=randomnumber; | |
| 595 | this.working=true; | |
| 596 | if (START_ARTIST == "" || START_ARTIST == "?") return; | |
| 597 | if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
| |
| 598 | this.xmlhttp.open("GET", "http://www.last.fm/music/" + encodeURIComponent(START_ARTIST) + "/+similar"+ "?page=" + a, true);
| |
| 599 | this.xmlhttp.send(); | |
| 600 | this.xmlhttp.onreadystatechange = function() {
| |
| 601 | if (this.xmlhttp.readyState == 4) {
| |
| 602 | if (this.xmlhttp.status == 200) {
| |
| 603 | var text = this.xmlhttp.responsetext; | |
| 604 | if (!this.doc) this.doc = new ActiveXObject("htmlfile");
| |
| 605 | this.doc.open(); | |
| 606 | var div = this.doc.createElement("div");
| |
| 607 | div.innerHTML = text; | |
| 608 | var data = div.getElementsByTagName("a");
| |
| 609 | var urls = []; | |
| 610 | ||
| 611 | ||
| 612 | ||
| 613 | for (i = 0; i < data.length; i++) {
| |
| 614 | if (data[i].href.indexOf("about:/music/") == 0) urls.push(CLEAN_ART_NAME(data[i].href));
| |
| 615 | } | |
| 616 | ||
| 617 | ||
| 618 | ||
| 619 | //select random URL | |
| 620 | var randomnumber = Math.floor(Math.random()*(20-50)+50); | |
| 621 | do{
| |
| 622 | randomnumber = Math.floor(Math.random()*(20-50)+50); | |
| 623 | } while(randomnumber%2!=1); | |
| 624 | i=randomnumber; | |
| 625 | ||
| 626 | {
| |
| 627 | ||
| 628 | //do something with urls[i] | |
| 629 | if (urls[i] > "") | |
| 630 | {
| |
| 631 | ||
| 632 | last_fm = window.SetProperty("YT Similar", urls[i]);
| |
| 633 | last_fm = urls[i]; | |
| 634 | window.SetProperty("YT Similar", urls[i]);
| |
| 635 | } | |
| 636 | else | |
| 637 | //if (urls[i] == "" || urls[i] == "?") | |
| 638 | {
| |
| 639 | last_fm = window.SetProperty("YT Similar", "");
| |
| 640 | last_fm = ""; | |
| 641 | window.SetProperty("YT Similar", "");
| |
| 642 | } | |
| 643 | ||
| 644 | } | |
| 645 | ||
| 646 | this.doc.close(); | |
| 647 | this.working=false; | |
| 648 | if (START_ARTIST.indexOf("*")== 0) {downloadGENRE2();}
| |
| 649 | else | |
| 650 | if (last_fm == "" || last_fm == "?") {downloadLFM1();}
| |
| 651 | else | |
| 652 | downloadTRACK1(); | |
| 653 | } else {
| |
| 654 | if (START_ARTIST.indexOf("*")== 0) {} else {p.console("HTTP error: " + this.xmlhttp.status);}
| |
| 655 | if (START_ARTIST.indexOf("*")== 0) {downloadGENRE2();}
| |
| 656 | else | |
| 657 | if (this.xmlhttp.status == 404) {downloadLFM1();}
| |
| 658 | } | |
| 659 | } | |
| 660 | } | |
| 661 | } | |
| 662 | }} | |
| 663 | ||
| 664 | } | |
| 665 | ||
| 666 | ||
| 667 | //Open track | |
| 668 | this.downloadTRACK1 = function() | |
| 669 | {
| |
| 670 | {
| |
| 671 | ||
| 672 | {
| |
| 673 | ||
| 674 | {var randomnumber=Math.floor(Math.random()*sng)
| |
| 675 | var a=randomnumber; | |
| 676 | this.working=true; | |
| 677 | if (last_fm == "" || last_fm == "?") return; | |
| 678 | if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
| |
| 679 | this.xmlhttp.open("GET", "http://www.last.fm/music/" + encodeURIComponent(last_fm) + "/+tracks" + "?page=" + a, true);
| |
| 680 | this.xmlhttp.send(); | |
| 681 | this.xmlhttp.onreadystatechange = function() {
| |
| 682 | if (this.xmlhttp.readyState == 4) {
| |
| 683 | if (this.xmlhttp.status == 200) {
| |
| 684 | var text = this.xmlhttp.responsetext; | |
| 685 | if (!this.doc) this.doc = new ActiveXObject("htmlfile");
| |
| 686 | this.doc.open(); | |
| 687 | var div = this.doc.createElement("tr");
| |
| 688 | div.innerHTML = text; | |
| 689 | var data = div.getElementsByTagName("td");
| |
| 690 | var urls = []; | |
| 691 | ||
| 692 | ||
| 693 | ||
| 694 | for (i = 0; i < data.length; i++) {
| |
| 695 | if (data[i].title) urls.push(CLEAN_TRACK_NAME(data[i].title)); | |
| 696 | } | |
| 697 | ||
| 698 | //select random URL | |
| 699 | var randomnumber = Math.floor(Math.random()*Math.max(urls.length)); | |
| 700 | i=randomnumber; | |
| 701 | ||
| 702 | {
| |
| 703 | ||
| 704 | //do something with urls[i] | |
| 705 | if (urls[i] > "") | |
| 706 | ||
| 707 | {
| |
| 708 | ||
| 709 | p.console("" + last_fm + " - " + urls[i]);
| |
| 710 | ||
| 711 | ooo2 = window.SetProperty("YT Track", urls[i]);
| |
| 712 | ooo2 = urls[i]; | |
| 713 | window.SetProperty("YT Track", urls[i]);
| |
| 714 | } | |
| 715 | else | |
| 716 | //if (urls[i] == "" || urls[i] == "?") | |
| 717 | {
| |
| 718 | ooo2 = window.SetProperty("YT Track", "");
| |
| 719 | ooo2 = ""; | |
| 720 | window.SetProperty("YT Track", "");
| |
| 721 | } | |
| 722 | } | |
| 723 | ||
| 724 | this.doc.close(); | |
| 725 | this.working=false; | |
| 726 | if (ooo2 == "" || ooo2 == "?") {downloadLFM1();}
| |
| 727 | else | |
| 728 | set_focus(); //focus on playlist | |
| 729 | do_youtube_search1(decodeURIComponent(last_fm), decodeURIComponent(ooo2)); | |
| 730 | } else {
| |
| 731 | p.console("HTTP error: " + this.xmlhttp.status);
| |
| 732 | if (START_ARTIST.indexOf("*")== 0) {downloadGENRE2();}
| |
| 733 | else | |
| 734 | if (this.xmlhttp.status == 404) {downloadLFM1();}
| |
| 735 | ||
| 736 | } | |
| 737 | } | |
| 738 | } | |
| 739 | } | |
| 740 | }}} | |
| 741 | ||
| 742 | ||
| 743 | ||
| 744 | //CHECK IF ARTIST EXIST------------------------------------ | |
| 745 | ||
| 746 | this.downloadLFM0 = function() | |
| 747 | ||
| 748 | {
| |
| 749 | this.working=true; | |
| 750 | if (START_ARTIST == "" || START_ARTIST == "?") return; | |
| 751 | if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
| |
| 752 | this.xmlhttp.open("GET", "http://www.last.fm/music/" + encodeURIComponent(START_ARTIST) + "/+similar", true);
| |
| 753 | this.xmlhttp.send(); | |
| 754 | this.xmlhttp.onreadystatechange = function() {
| |
| 755 | if (this.xmlhttp.readyState == 4) {
| |
| 756 | if (this.xmlhttp.status == 200) {
| |
| 757 | var text = this.xmlhttp.responsetext; | |
| 758 | - | //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)
|
| 758 | + | |
| 759 | this.doc.open(); | |
| 760 | var div = this.doc.createElement("div");
| |
| 761 | div.innerHTML = text; | |
| 762 | var data = div.getElementsByTagName("a");
| |
| 763 | var urls = []; | |
| 764 | ||
| 765 | ||
| 766 | ||
| 767 | ||
| 768 | this.doc.close(); | |
| 769 | this.working=false; | |
| 770 | downloadLFM000(); | |
| 771 | ||
| 772 | } else {
| |
| 773 | if (START_ARTIST.indexOf("*")== 0) {} else {p.console("HTTP error: " + this.xmlhttp.status);}
| |
| 774 | if (START_ARTIST.indexOf("*")== 0) {downloadGENRE2();}
| |
| 775 | else | |
| 776 | if (this.xmlhttp.status == 404) | |
| 777 | {
| |
| 778 | p.MsgBox("This Artist Not Found!", 0, p.name);
| |
| 779 | } | |
| 780 | ||
| 781 | ||
| 782 | } | |
| 783 | } | |
| 784 | } | |
| 785 | } | |
| 786 | ||
| 787 | ||
| 788 | ||
| 789 | //START ARTIST RADIO(same artist)-------------------------- | |
| 790 | ||
| 791 | //open simmilar artist | |
| 792 | this.downloadLFM000 = function() | |
| 793 | {
| |
| 794 | ||
| 795 | {
| |
| 796 | ||
| 797 | {
| |
| 798 | ||
| 799 | { var randomnumber=Math.floor(Math.random()*art)
| |
| 800 | var a=randomnumber; | |
| 801 | this.working=true; | |
| 802 | if (START_ARTIST == "" || START_ARTIST == "?") return; | |
| 803 | if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
| |
| 804 | this.xmlhttp.open("GET", "http://www.last.fm/music/" + encodeURIComponent(START_ARTIST) + "/+similar"+ "?page=" + a, true);
| |
| 805 | this.xmlhttp.send(); | |
| 806 | this.xmlhttp.onreadystatechange = function() {
| |
| 807 | if (this.xmlhttp.readyState == 4) {
| |
| 808 | if (this.xmlhttp.status == 200) {
| |
| 809 | var text = this.xmlhttp.responsetext; | |
| 810 | if (!this.doc) this.doc = new ActiveXObject("htmlfile");
| |
| 811 | this.doc.open(); | |
| 812 | var div = this.doc.createElement("div");
| |
| 813 | div.innerHTML = text; | |
| 814 | var data = div.getElementsByTagName("a");
| |
| 815 | var urls = []; | |
| 816 | ||
| 817 | ||
| 818 | ||
| 819 | for (i = 0; i < data.length; i++) {
| |
| 820 | if (data[i].href.indexOf("about:/music/") == 0) urls.push(CLEAN_ART_NAME(data[i].href));
| |
| 821 | } | |
| 822 | ||
| 823 | ||
| 824 | ||
| 825 | //select random URL | |
| 826 | var randomnumber = Math.floor(Math.random()*(20-50)+50); | |
| 827 | do{
| |
| 828 | randomnumber = Math.floor(Math.random()*(20-50)+50); | |
| 829 | } while(randomnumber%2!=1); | |
| 830 | i=randomnumber; | |
| 831 | ||
| 832 | ||
| 833 | {
| |
| 834 | ||
| 835 | //do something with urls[i] | |
| 836 | if (urls[i] > "") | |
| 837 | {
| |
| 838 | ||
| 839 | last_fm = window.SetProperty("YT Similar", urls[i]);
| |
| 840 | last_fm = urls[i]; | |
| 841 | window.SetProperty("YT Similar", urls[i]);
| |
| 842 | } | |
| 843 | else | |
| 844 | //if (urls[i] == "" || urls[i] == "?") | |
| 845 | {
| |
| 846 | last_fm = window.SetProperty("YT Similar", "");
| |
| 847 | last_fm = ""; | |
| 848 | window.SetProperty("YT Similar", "");
| |
| 849 | } | |
| 850 | ||
| 851 | } | |
| 852 | ||
| 853 | this.doc.close(); | |
| 854 | this.working=false; | |
| 855 | if (START_ARTIST.indexOf("*")== 0) {downloadGENRE2();}
| |
| 856 | else | |
| 857 | if (last_fm == "" || last_fm == "?") {downloadLFM000();}
| |
| 858 | else | |
| 859 | downloadTRACK11(); | |
| 860 | ||
| 861 | } else {
| |
| 862 | if (START_ARTIST.indexOf("*")== 0) {} else {p.console("HTTP error: " + this.xmlhttp.status);}
| |
| 863 | if (START_ARTIST.indexOf("*")== 0) {downloadGENRE2();}
| |
| 864 | else | |
| 865 | if (this.xmlhttp.status == 404) {downloadLFM000();}
| |
| 866 | ||
| 867 | } | |
| 868 | } | |
| 869 | } | |
| 870 | } | |
| 871 | }} | |
| 872 | ||
| 873 | } | |
| 874 | ||
| 875 | ||
| 876 | //Open track | |
| 877 | this.downloadTRACK11 = function() | |
| 878 | {
| |
| 879 | {
| |
| 880 | {
| |
| 881 | ||
| 882 | ||
| 883 | {var randomnumber=Math.floor(Math.random()*sng)
| |
| 884 | var a=randomnumber; | |
| 885 | this.working=true; | |
| 886 | if (last_fm == "" || last_fm == "?") return; | |
| 887 | if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
| |
| 888 | this.xmlhttp.open("GET", "http://www.last.fm/music/" + encodeURIComponent(last_fm) + "/+tracks" + "?page=" + a, true);
| |
| 889 | this.xmlhttp.send(); | |
| 890 | this.xmlhttp.onreadystatechange = function() {
| |
| 891 | if (this.xmlhttp.readyState == 4) {
| |
| 892 | if (this.xmlhttp.status == 200) {
| |
| 893 | var text = this.xmlhttp.responsetext; | |
| 894 | if (!this.doc) this.doc = new ActiveXObject("htmlfile");
| |
| 895 | this.doc.open(); | |
| 896 | var div = this.doc.createElement("tr");
| |
| 897 | div.innerHTML = text; | |
| 898 | var data = div.getElementsByTagName("td");
| |
| 899 | var urls = []; | |
| 900 | ||
| 901 | ||
| 902 | ||
| 903 | for (i = 0; i < data.length; i++) {
| |
| 904 | if (data[i].title) urls.push(CLEAN_TRACK_NAME(data[i].title)); | |
| 905 | } | |
| 906 | ||
| 907 | //select random URL | |
| 908 | var randomnumber = Math.floor(Math.random()*Math.max(urls.length)); | |
| 909 | i=randomnumber; | |
| 910 | ||
| 911 | {
| |
| 912 | ||
| 913 | //do something with urls[i] | |
| 914 | if (urls[i] > "") | |
| 915 | ||
| 916 | {
| |
| 917 | ||
| 918 | p.console("" + last_fm + " - " + urls[i]);
| |
| 919 | ||
| 920 | ooo2 = window.SetProperty("YT Track", urls[i]);
| |
| 921 | ooo2 = urls[i]; | |
| 922 | window.SetProperty("YT Track", urls[i]);
| |
| 923 | } | |
| 924 | else | |
| 925 | //if (urls[i] == "" || urls[i] == "?") | |
| 926 | {
| |
| 927 | ooo2 = window.SetProperty("YT Track", "");
| |
| 928 | ooo2 = ""; | |
| 929 | window.SetProperty("YT Track", "");
| |
| 930 | } | |
| 931 | } | |
| 932 | ||
| 933 | this.doc.close(); | |
| 934 | this.working=false; | |
| 935 | if (ooo2 == "" || ooo2 == "?") {downloadLFM000();}
| |
| 936 | else | |
| 937 | set_focus(); //focus on playlist | |
| 938 | do_youtube_search1(decodeURIComponent(last_fm), decodeURIComponent(ooo2)); | |
| 939 | } else {
| |
| 940 | p.console("HTTP error: " + this.xmlhttp.status);
| |
| 941 | if (START_ARTIST.indexOf("*")== 0) {downloadGENRE2();}
| |
| 942 | else | |
| 943 | if (this.xmlhttp.status == 404) {downloadLFM000();}
| |
| 944 | ||
| 945 | ||
| 946 | } | |
| 947 | } | |
| 948 | } | |
| 949 | } | |
| 950 | }}} | |
| 951 | ||
| 952 | ||
| 953 | //DOWNLOAD YOUTUBE VIDEO----------------------------------- | |
| 954 | strip_title = function (t1, t2) | |
| 955 | {
| |
| 956 | try | |
| 957 | {
| |
| 958 | if (t1 == t2) | |
| 959 | return t1; | |
| 960 | if (t1.match(RegExp(t2 + "( and | & )", "i"))) | |
| 961 | return t1; | |
| 962 | var a = "(by the |by: |by |of |the |feat. |ft. |)"; | |
| 963 | var b = "( feat.| ft.|)"; | |
| 964 | var t3 = ""; | |
| 965 | if (!t2.match(/^the /i)) | |
| 966 | {
| |
| 967 | t3 = t1.replace(RegExp("[^a-z\\d_)\\]\"]*(" + a + t2 + b + ")[^a-z\\d_(\\[\"]*","gi")," - ").replace(/^[^a-z()\[\]\d\"]*|[^a-z()\[\]\d\"]*$/gi, "");
| |
| 968 | } | |
| 969 | else | |
| 970 | {
| |
| 971 | var t4 = t2.replace(/^the /i, "") | |
| 972 | t3 = t1.replace(RegExp("[^a-z\\d_)\\]\"]*(" + a + t4 + b + ")[^a-z\\d_(\\[\"]*","gi")," - ").replace(/^[^a-z()\[\]\d\"]*|[^a-z()\[\]\d\"]*$/gi, "");
| |
| 973 | } | |
| 974 | return t3.match(/\S/) ? t3 : t1; | |
| 975 | } | |
| 976 | catch (e) | |
| 977 | {
| |
| 978 | return t1; | |
| 979 | } | |
| 980 | } | |
| 981 | ||
| 982 | ||
| 983 | convert = function(min) | |
| 984 | {
| |
| 985 | var parts = min.split(':'),
| |
| 986 | minutes = +parts[0], | |
| 987 | seconds = +parts[1]; | |
| 988 | return minutes * 60 + seconds; | |
| 989 | } | |
| 990 | ||
| 991 | ||
| 992 | ||
| 993 | strip = function (t) | |
| 994 | {
| |
| 995 | try | |
| 996 | {
| |
| 997 | t = t.replace(/[\.,\!\?\:;'"\-_]/g,"").toLowerCase(); | |
| 998 | return t; | |
| 999 | } catch (e) | |
| 1000 | {}
| |
| 1001 | } | |
| 1002 | ||
| 1003 | clean = function (t) | |
| 1004 | {
| |
| 1005 | try | |
| 1006 | {
| |
| 1007 | return t.replace(/'/g, "’").toLowerCase(); | |
| 1008 | } catch (e) {}
| |
| 1009 | } | |
| 1010 | ||
| 1011 | ||
| 1012 | ||
| 1013 | ||
| 1014 | youtube_search = function (state_change_callback, p_on_search_finished_callback) | |
| 1015 | {
| |
| 1016 | this.xmlhttp = null; | |
| 1017 | this.http_callback_funct = null; | |
| 1018 | this.ready_state_change_callback = state_change_callback; | |
| 1019 | this.search_done = false; | |
| 1020 | this.on_search_finished_callback = p_on_search_finished_callback; | |
| 1021 | this.yt_link; | |
| 1022 | this.search_artist; | |
| 1023 | this.search_title; | |
| 1024 | this.metadata; | |
| 1025 | ||
| 1026 | this.on_state_change = function () | |
| 1027 | {
| |
| 1028 | if (this.xmlhttp != null && this.xmlhttp.readyState == 4 && this.xmlhttp.status == 200 && this.http_callback_funct != null) | |
| 1029 | this.http_callback_funct(); | |
| 1030 | } | |
| 1031 | ||
| 1032 | this.StartSearch = function (p_artist, p_title, p_extra_metadata) | |
| 1033 | {
| |
| 1034 | this.search_artist = p_artist; | |
| 1035 | this.search_title = p_title; | |
| 1036 | this.metadata = p_extra_metadata; | |
| 1037 | this.http_callback_funct = null; | |
| 1038 | this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
| |
| 1039 | ||
| 1040 | var URL = "http://www.youtube.com/results?search_query=" + encodeURIComponent(p_artist + " " + p_title); | |
| 1041 | ||
| 1042 | this.http_callback_funct = this.AnalyseSearch; | |
| 1043 | this.xmlhttp.open("GET", URL);
| |
| 1044 | this.xmlhttp.onreadystatechange = this.ready_state_change_callback; | |
| 1045 | this.xmlhttp.send(); | |
| 1046 | } | |
| 1047 | ||
| 1048 | this.AnalyseSearch = function () | |
| 1049 | {
| |
| 1050 | var text = this.xmlhttp.responsetext; | |
| 1051 | var doc = new ActiveXObject("htmlfile");
| |
| 1052 | doc.open(); | |
| 1053 | var div = doc.createElement("div");
| |
| 1054 | div.innerHTML = text; | |
| 1055 | var data = div.getElementsByTagName("a");
| |
| 1056 | var url = ""; | |
| 1057 | var first_match; | |
| 1058 | ||
| 1059 | re_test: | |
| 1060 | ||
| 1061 | for (var i = 0; i < data.length; i++) | |
| 1062 | {
| |
| 1063 | if (data[i].href.indexOf("about:/watch?v=") == 0)
| |
| 1064 | {
| |
| 1065 | i++; //the title is on the second link | |
| 1066 | ||
| 1067 | //check if track exist? | |
| 1068 | //if((data[i].title.toLowerCase()).indexOf(decodeURIComponent(last_fm.toLowerCase()).split(" ")[0]) > 0)
| |
| 1069 | //if((data[i].title.toLowerCase()).indexOf(decodeURIComponent(ooo2.toLowerCase()).split(" ")[0]) > 0)
| |
| 1070 | //if((data[i].title.toLowerCase()).indexOf(decodeURIComponent(ooo2.toLowerCase()).split(" ")[1]) > 0)
| |
| 1071 | //if((data[i].title.toLowerCase()).indexOf(decodeURIComponent(ooo2.toLowerCase()).split(" ")[2]) > 0)
| |
| 1072 | ||
| 1073 | ||
| 1074 | var s = text.indexOf( data[i].href.replace("about:/watch?", "") );
| |
| 1075 | var str = "<span class=\"video-time\">"; | |
| 1076 | s = text.indexOf(str, s) + str.length; | |
| 1077 | var e = text.indexOf("</span>", s);
| |
| 1078 | var length = text.substr(s, e - s); | |
| 1079 | length = convert(length); | |
| 1080 | length = length ? length : ""; | |
| 1081 | if (!first_match) | |
| 1082 | {
| |
| 1083 | // title stripped of artist name if same as search_artist | |
| 1084 | var stripped_title = strip_title(data[i].title, this.search_artist); | |
| 1085 | first_match = "3dydfy://www.youtube.com/watch?" + (this.metadata ? this.metadata + "&" : "") + "fb2k_title=" + encodeURIComponent(stripped_title) + "&3dydfy_alt_length=" + encodeURIComponent(length) + "&fb2k_artist=" + encodeURIComponent(this.search_artist) + "&" + data[i].href.replace("about:/watch?", "");
| |
| 1086 | } | |
| 1087 | //3dydfy | |
| 1088 | if (!this.IsGoodMatch(data[i].title)) | |
| 1089 | continue; | |
| 1090 | ||
| 1091 | url = "3dydfy://www.youtube.com/watch?" + (this.metadata ? this.metadata + "&" : "") + "fb2k_title=" + encodeURIComponent(this.search_title) + "&3dydfy_alt_length=" + encodeURIComponent(length) + "&fb2k_artist=" + encodeURIComponent(this.search_artist) + "&" + data[i].href.replace("about:/watch?", "");
| |
| 1092 | - | { //Set Playlist
|
| 1092 | + | |
| 1093 | - | set_focus(); |
| 1093 | + | |
| 1094 | } | |
| 1095 | - | //Start Search |
| 1095 | + | |
| 1096 | ||
| 1097 | ||
| 1098 | if (!url.length) | |
| 1099 | url = first_match; | |
| 1100 | ||
| 1101 | this.yt_link = url; | |
| 1102 | ||
| 1103 | doc.close(); | |
| 1104 | ||
| 1105 | this.on_search_finished_callback(url, this.search_artist, this.search_title); | |
| 1106 | } | |
| 1107 | ||
| 1108 | ||
| 1109 | this.IsGoodMatch = function (video_name) | |
| 1110 | {
| |
| 1111 | var clean_vid_name = clean(strip(video_name)); | |
| 1112 | var clean_artist = clean(strip(this.search_artist)); | |
| 1113 | var clean_title = clean(strip(this.search_title)); | |
| 1114 | ||
| 1115 | if (clean_vid_name.indexOf(clean_artist) != -1 && clean_vid_name.indexOf(clean_title) != -1 && clean_vid_name.indexOf("full album") == -1)
| |
| 1116 | {
| |
| 1117 | //p.console("GOOD MATCH");
| |
| 1118 | return true; | |
| 1119 | } | |
| 1120 | - | //if (link == "" || link == "?") {downloadLFM1();}
|
| 1120 | + | |
| 1121 | {
| |
| 1122 | //p.console("BAD MATCH");
| |
| 1123 | return false; | |
| 1124 | } | |
| 1125 | } | |
| 1126 | ||
| 1127 | } | |
| 1128 | ||
| 1129 | //Call Search | |
| 1130 | do_youtube_search1 = function (p_artist, p_title) | |
| 1131 | {
| |
| 1132 | var yt_search1 = new youtube_search(function () | |
| 1133 | {
| |
| 1134 | - | do_youtube_search1(decodeURIComponent(artist0), decodeURIComponent(title0)); |
| 1134 | + | |
| 1135 | }, on_youtube_search1_done); | |
| 1136 | yt_search1.StartSearch(p_artist, p_title); | |
| 1137 | } | |
| 1138 | ||
| 1139 | on_youtube_search1_done = function (link, p_artist, p_title) | |
| 1140 | {
| |
| 1141 | var url2=""; | |
| 1142 | url2 = link; | |
| 1143 | if (!url2) | |
| 1144 | {p.console("Track Or Artist - Not Exist!"); downloadLFM1();}
| |
| 1145 | ||
| 1146 | if (link && link.length) | |
| 1147 | {
| |
| 1148 | ||
| 1149 | p.console("" + "\"" + link + "\"");
| |
| 1150 | YT_URL = window.SetProperty("YT URL", link);
| |
| 1151 | var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath; | |
| 1152 | var str = tmppath + "\\foobar2000.exe /add "; | |
| 1153 | var go = str + link; | |
| 1154 | p.run(go); | |
| 1155 | } | |
| 1156 | } | |
| 1157 | //END------------------------------------------------------ | |
| 1158 | ||
| 1159 | ||
| 1160 | ||
| 1161 | //Download Same Video-------------------------------------- | |
| 1162 | this.downloadART_TITLE = function() | |
| 1163 | {
| |
| 1164 | var artist0 = p.eval("%artist%");
| |
| 1165 | var title0 = p.eval("%title%");
| |
| 1166 | if(artist0 > "?" && title0 > "?") {set_focus2(); do_youtube_search1(decodeURIComponent(artist0), decodeURIComponent(title0));}
| |
| 1167 | } | |
| 1168 | ||
| 1169 | //GENRE---------------------------------------------------- | |
| 1170 | ||
| 1171 | //open Genre | |
| 1172 | this.downloadGENRE2 = function() | |
| 1173 | {
| |
| 1174 | {
| |
| 1175 | ||
| 1176 | {
| |
| 1177 | if (START_ARTIST.indexOf("*")== 0)
| |
| 1178 | ||
| 1179 | ||
| 1180 | { var randomnumber=Math.floor(Math.random()*gnr)
| |
| 1181 | var a=randomnumber; | |
| 1182 | this.working=true; | |
| 1183 | if (START_ARTIST == "" || START_ARTIST == "?") return; | |
| 1184 | //var folder = this.folder + "\\"; | |
| 1185 | if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
| |
| 1186 | this.xmlhttp.open("GET", "http://www.last.fm/music/+tag/" + encodeURIComponent(START_ARTIST).replace("*","") + "?page=" + a, true);
| |
| 1187 | this.xmlhttp.send(); | |
| 1188 | this.xmlhttp.onreadystatechange = function() {
| |
| 1189 | if (this.xmlhttp.readyState == 4) {
| |
| 1190 | if (this.xmlhttp.status == 200) {
| |
| 1191 | var text = this.xmlhttp.responsetext; | |
| 1192 | if (!this.doc) this.doc = new ActiveXObject("htmlfile");
| |
| 1193 | this.doc.open(); | |
| 1194 | var div = this.doc.createElement("li");
| |
| 1195 | div.innerHTML = text; | |
| 1196 | var data = div.getElementsByTagName("a");
| |
| 1197 | var urls = []; | |
| 1198 | ||
| 1199 | ||
| 1200 | ||
| 1201 | for (i = 0; i < data.length; i++) {
| |
| 1202 | if (data[i].className.indexOf("name") == 0)
| |
| 1203 | if (data[i].href.indexOf("about:/music/") == 0) urls.push(CLEAN_GENRE_NAME(data[i].href));
| |
| 1204 | } | |
| 1205 | ||
| 1206 | //select random URL | |
| 1207 | var randomnumber = Math.floor(Math.random()*(0-9)+9); | |
| 1208 | do{
| |
| 1209 | randomnumber = Math.floor(Math.random()*(0-9)+9); | |
| 1210 | } while(randomnumber%2!=0); | |
| 1211 | ||
| 1212 | i=randomnumber; | |
| 1213 | ||
| 1214 | {
| |
| 1215 | ||
| 1216 | if (urls[i] > "") | |
| 1217 | //p.console("" + urls[i]);
| |
| 1218 | {
| |
| 1219 | ||
| 1220 | last_fm = window.SetProperty("YT Similar", urls[i]);
| |
| 1221 | last_fm = urls[i]; | |
| 1222 | window.SetProperty("YT Similar", urls[i]);
| |
| 1223 | } | |
| 1224 | else | |
| 1225 | {
| |
| 1226 | last_fm = window.SetProperty("YT Similar", "");
| |
| 1227 | last_fm = ""; | |
| 1228 | window.SetProperty("YT Similar", "");
| |
| 1229 | } | |
| 1230 | ||
| 1231 | } | |
| 1232 | ||
| 1233 | this.doc.close(); | |
| 1234 | this.working=false; | |
| 1235 | if (last_fm == "" || last_fm == "?") {downloadGENRE2();}
| |
| 1236 | else | |
| 1237 | downloadTRACK1(); | |
| 1238 | } else {
| |
| 1239 | p.console("HTTP error: " + this.xmlhttp.status);
| |
| 1240 | if (this.xmlhttp.status == 404) | |
| 1241 | {downloadGENRE2();}
| |
| 1242 | } | |
| 1243 | } | |
| 1244 | } | |
| 1245 | } | |
| 1246 | }} | |
| 1247 | ||
| 1248 | } | |
| 1249 | ||
| 1250 | ||
| 1251 | this.artist = ""; | |
| 1252 | function pan1() { }
| |
| 1253 | function pan2(x, y, w, h) { }
| |
| 1254 | ||
| 1255 | ||
| 1256 | //Begin---------------------------------------------------- | |
| 1257 | var p = new panel("Youtube Radio", ["remap", "metadb"]);
| |
| 1258 | var im = new pan2(0, 0, 0, 0); | |
| 1259 | var th = new pan1(); | |
| 1260 | ||
| 1261 | on_item_focus_change(); | |
| 1262 | {
| |
| 1263 | } | |
| 1264 | ||
| 1265 | function on_metadb_changed() {
| |
| 1266 | } | |
| 1267 | ||
| 1268 | //Button--------------------------------------------------- | |
| 1269 | ||
| 1270 | var Buttons; | |
| 1271 | ||
| 1272 | var g_tooltip = window.CreateTooltip(); | |
| 1273 | var g_down = false; | |
| 1274 | ||
| 1275 | var btn_down = null; | |
| 1276 | var cur_btn = null; | |
| 1277 | ||
| 1278 | ButtonStates = {
| |
| 1279 | normal: 0, | |
| 1280 | hover: 1, | |
| 1281 | down: 2 | |
| 1282 | } | |
| 1283 | ||
| 1284 | function Button(x, y, w, h, img_src, func, tiptext) {
| |
| 1285 | this.left = x; | |
| 1286 | this.top = y; | |
| 1287 | this.w = w; | |
| 1288 | this.h = h; | |
| 1289 | this.right = x + w; | |
| 1290 | this.bottom = y + h; | |
| 1291 | this.func = func; | |
| 1292 | this.tiptext = tiptext; | |
| 1293 | this.state = ButtonStates.normal; | |
| 1294 | this.img_normal = img_src && img_src.normal ? gdi.Image(img_src.normal) : null; | |
| 1295 | this.img_hover = img_src && img_src.hover ? gdi.Image(img_src.hover) : this.img_normal; | |
| 1296 | this.img_down = img_src && img_src.down ? gdi.Image(img_src.down) : this.img_hover; | |
| 1297 | this.img = this.img_normal; | |
| 1298 | ||
| 1299 | this.alterImage = function(img_src) {
| |
| 1300 | this.img_normal = img_src && img_src.normal ? gdi.Image(img_src.normal) : null; | |
| 1301 | this.img_hover = img_src && img_src.hover ? gdi.Image(img_src.hover) : this.img_normal; | |
| 1302 | this.img_down = img_src && img_src.down ? gdi.Image(img_src.down) : this.img_hover; | |
| 1303 | ||
| 1304 | this.changeState(this.state); | |
| 1305 | } | |
| 1306 | ||
| 1307 | this.traceMouse = function (x, y) {
| |
| 1308 | var b = (this.left < x) && (x < this.right) && (this.top < y) && (y < this.bottom); | |
| 1309 | if (b) | |
| 1310 | g_down ? this.changeState(ButtonStates.down) : this.changeState(ButtonStates.hover); | |
| 1311 | else | |
| 1312 | this.changeState(ButtonStates.normal); | |
| 1313 | return b; | |
| 1314 | } | |
| 1315 | ||
| 1316 | ||
| 1317 | this.changeState = function (newstate) {
| |
| 1318 | if (newstate != this.state) | |
| 1319 | window.RepaintRect(this.left, this.top, this.w, this.h); | |
| 1320 | this.state = newstate; | |
| 1321 | switch (this.state) | |
| 1322 | {
| |
| 1323 | case ButtonStates.normal: | |
| 1324 | this.img = this.img_normal; | |
| 1325 | break; | |
| 1326 | ||
| 1327 | case ButtonStates.hover: | |
| 1328 | this.img = this.img_hover; | |
| 1329 | break; | |
| 1330 | ||
| 1331 | case ButtonStates.down: | |
| 1332 | this.img = this.img_down; | |
| 1333 | break; | |
| 1334 | ||
| 1335 | default: | |
| 1336 | this.img = null; | |
| 1337 | } | |
| 1338 | } | |
| 1339 | ||
| 1340 | this.draw = function (gr) {
| |
| 1341 | this.img && gr.DrawImage(this.img, this.left, this.top, this.w, this.h, 0, 0, this.w, this.h); | |
| 1342 | } | |
| 1343 | ||
| 1344 | this.onClick = function () {
| |
| 1345 | this.func && this.func(x,y); | |
| 1346 | } | |
| 1347 | ||
| 1348 | this.onMouseIn = function() {
| |
| 1349 | g_tooltip.Text = this.tiptext; | |
| 1350 | g_tooltip.Activate(); | |
| 1351 | } | |
| 1352 | ||
| 1353 | this.onMouseOut = function() {
| |
| 1354 | g_tooltip.Deactivate(); | |
| 1355 | } | |
| 1356 | } | |
| 1357 | ||
| 1358 | function buttonsDraw(gr) {
| |
| 1359 | for (i in Buttons) {
| |
| 1360 | Buttons[i].draw(gr); | |
| 1361 | } | |
| 1362 | } | |
| 1363 | ||
| 1364 | function buttonsTraceMouse(x, y) {
| |
| 1365 | var btn = null; | |
| 1366 | for (i in Buttons) {
| |
| 1367 | if (Buttons[i].traceMouse(x, y) && !btn) | |
| 1368 | btn = Buttons[i]; | |
| 1369 | } | |
| 1370 | ||
| 1371 | return btn; | |
| 1372 | } | |
| 1373 | ||
| 1374 | function on_mouse_move(x, y) {
| |
| 1375 | var btn = buttonsTraceMouse(x, y); | |
| 1376 | ||
| 1377 | if (btn != cur_btn) {
| |
| 1378 | cur_btn && cur_btn.onMouseOut(); | |
| 1379 | btn && btn.onMouseIn(); | |
| 1380 | } | |
| 1381 | ||
| 1382 | cur_btn = btn; | |
| 1383 | } | |
| 1384 | ||
| 1385 | function on_mouse_lbtn_down(x, y) {
| |
| 1386 | g_down = true; | |
| 1387 | btn_down = cur_btn; | |
| 1388 | ||
| 1389 | if (cur_btn) {
| |
| 1390 | cur_btn.changeState(ButtonStates.down); | |
| 1391 | } | |
| 1392 | } | |
| 1393 | ||
| 1394 | function on_mouse_lbtn_up(x, y) {
| |
| 1395 | if (cur_btn) {
| |
| 1396 | cur_btn.changeState(ButtonStates.hover); | |
| 1397 | if( btn_down == cur_btn ) | |
| 1398 | cur_btn.onClick(x, y); | |
| 1399 | } | |
| 1400 | g_down = false; | |
| 1401 | } | |
| 1402 | ||
| 1403 | function on_mouse_leave() {
| |
| 1404 | if (cur_btn) {
| |
| 1405 | cur_btn.changeState(ButtonStates.normal); | |
| 1406 | } | |
| 1407 | } | |
| 1408 | ||
| 1409 | function on_size() {
| |
| 1410 | ww = window.Width; | |
| 1411 | wh = window.Height; | |
| 1412 | window.Repaint(); | |
| 1413 | } | |
| 1414 | ||
| 1415 | //Background | |
| 1416 | this.dui = window.InstanceType; | |
| 1417 | function on_paint(gr) {
| |
| 1418 | ||
| 1419 | if (this.dui) {
| |
| 1420 | col = window.GetColorDUI(1); | |
| 1421 | gr.FillSolidRect(0, 0, ww, wh, col); | |
| 1422 | } | |
| 1423 | else | |
| 1424 | {
| |
| 1425 | col = window.GetColorCUI(3); | |
| 1426 | } | |
| 1427 | ||
| 1428 | buttonsDraw(gr); | |
| 1429 | ||
| 1430 | } | |
| 1431 | ||
| 1432 | function RGB(r,g,b) {
| |
| 1433 | return (0xff000000|(r<<16)|(g<<8)|(b)); | |
| 1434 | } | |
| 1435 | ||
| 1436 | function on_colors_changed() {
| |
| 1437 | window.Repaint(); | |
| 1438 | } | |
| 1439 | ||
| 1440 | //init Buttons-------------------------------------------- | |
| 1441 | ||
| 1442 | //custom colour | |
| 1443 | var custom = RGB(255,255,255); | |
| 1444 | ||
| 1445 | //button width | |
| 1446 | var bw = 24; | |
| 1447 | ||
| 1448 | //button height | |
| 1449 | var bh = 20; | |
| 1450 | ||
| 1451 | //Button position | |
| 1452 | var top_margin = -1; | |
| 1453 | var left_margin = 0; | |
| 1454 | ||
| 1455 | var image_path0 = window.GetProperty("Button Path", fb.ProfilePath + "image");
| |
| 1456 | var image_path = (image_path0 + "\\"); | |
| 1457 | ||
| 1458 | //these 2 lines of code lock the panel size. | |
| 1459 | //window.MinWidth = window.MaxWidth = 24; | |
| 1460 | //window.MinHeight = window.MaxHeight = 20; | |
| 1461 | ||
| 1462 | ||
| 1463 | Buttons = {
| |
| 1464 | but1: new Button(left_margin,top_margin,bw,bh, {normal: image_path + "youtube0.png", hover: image_path + "youtube1.png"}, function(){
| |
| 1465 | p.rbtn_up(24, 17); | |
| 1466 | //downloadONE(); | |
| 1467 | }, "Youtube") | |
| 1468 | ||
| 1469 | } | |
| 1470 | ||
| 1471 | function on_mouse_rbtn_up(x, y) {
| |
| 1472 | return true; | |
| 1473 | } |