Advertisement
Guest User

Foobar Youtube Radio 0.0.11.

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