Advertisement
Guest User

Foobar Youtube Radio 2.3

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