I see...
This is because youtube now use 'https' , and they make other changes in html.
I will see to use gdata instead of real youtube web page..
Here is new script:
// ==PREPROCESSOR==
// @name "Youtube Radio"
// @author "Mire777"
// @feature "v1.4"
// @feature "watch-metadb"
// ==/PREPROCESSOR==
//Properties
YT_PL = window.GetProperty("YT Playlist", "0");
YT_AUTO = window.GetProperty("YT Auto", "0");
YT_TRACK = window.GetProperty("YT Track", "");
STATION = window.GetProperty("YT Station", "");
SIM_ART = window.GetProperty("YT Similar", "");
YT_URL = window.GetProperty("YT URL", "");
art = window.GetProperty("YT Artist Variety (1-20)", "20");
sng = window.GetProperty("YT Song Hotness (1-20)", "20");
tag = window.GetProperty("YT Tag Hotness (1-100)", "27");
pls = window.GetProperty("FB Playlist", "YT Radio");
var MF_GRAYED = 0x00000001;
var MF_STRING = 0x00000000;
var IDC_ARROW = 32512;
var IDC_HAND = 32649;
function RGB(r, g, b) {
return (0xff000000 | (r << 16) | (g << 8) | (b));
}
function RGBA(r, g, b, a) {
return ((a << 24) | (r << 16) | (g << 8) | (b));
}
function on_colors_changed() {
p.colors_changed();
}
function on_selection_changed() {
p.item_focus_change();
}
function on_playlist_switch() {
set_focus0(); //Check Playlist
}
function on_playback_new_track() {
p.item_focus_change();
LOAD_ART();
}
function on_playback_dynamic_info_track() {
p.item_focus_change();
}
function on_playback_stop() {
p.item_focus_change();
}
function on_item_focus_change() {
p.item_focus_change();
}
function on_mouse_leave() {
}
function on_mouse_rbtn_up(x, y) {
p.rbtn_up(x, y);
return true;
}
//Playlist
function GetPlaylistID(Playlist_Name)
{
for (var i = 0; i < fb.PlaylistCount; i++)
{
if (fb.GetPlaylistName(i) == Playlist_Name)
{
return i;
}
}
//Create playlist if it doesn't exist
fb.CreatePlaylist(fb.PlaylistCount, Playlist_Name);
return i;
}
//Playlist(Check)
function GetPlaylistID0(Playlist_Name)
{
for (var i = 0; i < fb.PlaylistCount; i++)
if (fb.GetPlaylistName(i) == Playlist_Name)
{
return i;
}
}
//Focus on playlist(Check)
function set_focus0()
{
if (pls>"")
{
var PL_NM = (GetPlaylistID0(pls + " ["+ STATION +"]"));
if (fb.ActivePlaylist == PL_NM) {YT_PL = 1; window.SetProperty("YT Playlist", "1");}
else
{YT_PL = 0; window.SetProperty("YT Playlist", "0");}
}
}
//Focus on playlist(YT Radio)
function set_focus()
{
if (pls>"")
fb.ActivePlaylist = (GetPlaylistID(pls + " ["+ STATION +"]"));
}
//Focus on playlist(Same Video)
function set_focus2()
{
if (pls>"")
fb.ActivePlaylist = (GetPlaylistID(pls + " [Same Video]"));
}
//Focus on playlist(Search Videos)
function set_focus3()
{
if (pls>"")
fb.ActivePlaylist = (GetPlaylistID(pls + " [Search Videos]"));
}
//Focus on playlist(Popular Tracks)
function set_focus4()
{
if (pls>"")
fb.ActivePlaylist = (GetPlaylistID(pls + " [Popular tracks by: "+ p.artist +"]"));
}
//Focus on playlist(Similar Tracks)
function set_focus5()
{
if (pls>"")
fb.ActivePlaylist = (GetPlaylistID(pls + " [Similar to: "+ p.artist + " - " + p.title +"]"));
}
//Panel
function panel(name, features) {
this.item_focus_change = function() {
if (!this.metadb_func) return;
switch(this.selection_mode) {
case 0:
this.metadb = fb.GetSelection();
break;
case 1:
this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
break;
case 2:
this.metadb = fb.GetFocusItem();
break;
}
if (this.metadb) on_metadb_changed();
}
//Metadb
this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
//Size
this.size = function() {
this.w = window.Width;
this.h = window.Height;
}
//Move
this.move = function(x, y) {
this.mx = x;
this.my = y;
}
//Menu
this.rbtn_up = function(x, y) {
var _menu = window.CreatePopupMenu();
var idx;
switch(true) {
case typeof th == "object":
case typeof im == "object":
on_item_focus_change()
if (pls>"")
{
if(YT_AUTO==1) _menu.AppendMenuItem(MF_STRING, 1902, "Youtube Radio");
if(YT_AUTO==0) _menu.AppendMenuItem(MF_STRING, 1903, "Youtube Radio");
_menu.CheckMenuItem(1902, YT_AUTO?1:0);
_menu.AppendMenuSeparator();
{
if(YT_PL==1 && YT_AUTO==1 && STATION>"") {_menu.AppendMenuItem(MF_STRING, 22, "Get Next Video");}
else
{_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Get Next Video");}
_menu.AppendMenuItem(MF_STRING, 401, "Search Videos");
_menu.AppendMenuSeparator();
_menu.AppendMenuItem(MF_STRING, 1914, "Start Radio Station");
p.artist = p.eval("%artist%");
if (p.artist == "" || p.artist == "?") {_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Same Artist Station");}
else
{_menu.AppendMenuItem(MF_STRING, 1915, "Same Artist Station");}
_menu.AppendMenuSeparator();
p.artist = p.eval("%artist%");
if (p.artist == "" || p.artist == "?") {_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Open Same Video");}
else
{_menu.AppendMenuItem(MF_STRING, 403, "Open Same Video");}
/*p.artist = p.eval("%artist%");
if (p.artist == "" || p.artist == "?") {_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Find in Browser");}
else
{_menu.AppendMenuItem(MF_STRING, 404, "Find in Browser");}*/
p.artist = p.eval("%artist%");
if (p.artist == "" || p.artist == "?") {_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Popular Tracks...");}
else
{_menu.AppendMenuItem(MF_STRING, 1916, "Popular Tracks...");}
p.artist = p.eval("%artist%");
if (p.artist == "" || p.artist == "?") {_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Similar Tracks...");}
else
{_menu.AppendMenuItem(MF_STRING, 1920, "Similar Tracks...");}
_menu.AppendMenuSeparator();
_menu.AppendMenuItem(MF_STRING, 9, "Properties...");
}
}
}
if (pls=="") {_menu.AppendMenuItem(MF_STRING, 9, "Please Set: (FB Playlist)");}
if (utils.IsKeyPressed(0x10)) _menu.AppendMenuItem(MF_STRING, 10, "Configure...");
idx = _menu.TrackPopupMenu(x, y);
switch(idx) {
case 9:
window.ShowProperties();
break;
case 10:
window.ShowConfigure();
break;
case 22:
set_focus(); //Focus on playlist
LOAD_ART();
break;
case 401:
set_focus3(); //Focus on playlist
fb.RunMainMenuCommand("View/Youtube Source");
break;
case 403:
this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
set_focus2(); //Focus on playlist
LOAD_SAME();
break;
case 404:
p.artist = p.eval("%artist% %title%");
p.browser("https://www.youtube.com/results?search_query=" + encodeURIComponent(p.artist));
break;
case 1902:
YT_AUTO = 0;
window.SetProperty("YT Auto", "0");
break;
case 1903:
YT_AUTO = 1;
window.SetProperty("YT Auto", "1");
break;
case 1914:
var Start;
Start = this.InputBox("Type Artist to Start Station\n\n( *genre - will play genre station)", "Youtube Radio", "");
if (Start=="")
{
}
else
{
YT_PL = 1;
window.SetProperty("YT Playlist", "1");
YT_AUTO = "1"
window.SetProperty("YT Auto", "1");
STATION = Start;
window.SetProperty("YT Station", Start);
set_focus(); //Focus on playlist
LOAD_ART();
}
break;
case 1915:
this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
p.artist = p.eval("%artist%");
if (p.artist == "" || p.artist == "?") return;
STATION = p.artist;
window.SetProperty("YT Station", p.artist);
YT_PL = 1;
window.SetProperty("YT Playlist", "1");
YT_AUTO = "1"
window.SetProperty("YT Auto", "1");
set_focus(); //Focus on playlist
LOAD_ART();
break;
case 1916:
set_focus4(); //focus on playlist
POP_TRACKS();
break;
case 1920:
//set_focus4(); //focus on playlist
SIMILAR_TRACKS();
break;
}
_menu.Dispose();
}
//Features init
this.features_init = function() {
for (i = 0; i < this.features.length; i++) {
switch(this.features[i]) {
case "metadb":
this.selection_mode = 1;
break;
case "remap":
this.artist_tf = ("%artist%");
break;
}
}
}
this.check_feature = function(f) {
for (i = 0; i < this.features.length; i++) {
if (this.features[i] == f) return true;
}
return false;
}
//Eval
this.eval = function(tf) {
if (!this.metadb || tf == "") return "";
if (fb.IsPlaying && this.metadb.RawPath.indexOf("file://") != 0) {
return fb.TitleFormat(tf).Eval();
} else {
return fb.TitleFormat(tf).EvalWithMetadb(this.metadb);
}
}
//Console Msg
this.console = function(message) {
this.name = "Youtube Radio"
fb.trace(this.name + ": " + message);
}
//Trim
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, "");
}
//Input Box
this.InputBox = function(prompt, title, value) {
prompt = prompt.replace(/"/g, '" + Chr(34) + "').replace(/\n/g, '" + Chr(13) + "');
title = title.replace(/"/g, '" + Chr(34) + "');
value = value.replace(/"/g, '" + Chr(34) + "');
var temp_value = this.vb.eval('InputBox' + '("' + prompt + '", "' + title + '", "' + value + '")');
if (typeof temp_value == "undefined") return value;
if (temp_value.length == 254) this.MsgBox("Your entry was too long and will be truncated.\n\nSee the WSH panel mod script discussion thread on hydrogenaudio forums for help.", 0, "Youtube Radio");
return temp_value.trim();
}
//Msg Box
this.MsgBox = function(prompt, buttons, title) {
prompt = prompt.replace(/"/g, '" + Chr(34) + "').replace(/\n/g, '" + Chr(13) + "');
title = title.replace(/"/g, '" + Chr(34) + "');
return this.vb.eval('MsgBox' + '("' + prompt + '", "' + buttons + '", "' + title + '")');
}
//Browser
this.browser = function(command) {
if (!this.run(command)) this.MsgBox("Unable to launch your default browser.", 0, "Youtube Radio");
}
//Run Command
this.run = function(command) {
try {
this.WshShell.Run(command);
return true;
} catch(e) {
return false;
}
}
//futures
this.metadb_func = typeof on_metadb_changed == "function";
this.features = features;
this.dui = window.InstanceType;
this.metadb = fb.GetFocusItem();
this.WshShell = new ActiveXObject("WScript.Shell");
this.fso = new ActiveXObject("Scripting.FileSystemObject");
this.vb = new ActiveXObject("ScriptControl");
this.vb.Language = "VBScript";
this.artist_tf = "%artist%";
this.features_init();
this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
if (fb.GetFocusItem())
{this.artist = fb.TitleFormat(this.artist_tf).EvalWithMetadb(this.metadb);}
}
//YT NAMES-------------------------------------------------
//Clean Art Name
CLEAN_ART_NAME = function (t)
{ try
{
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","'");
} catch (e) {}
}
//Clean Track Name
CLEAN_TRACK_NAME = function (t)
{ try
{
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();
} catch (e) {}
}
//Clean Genre Name
CLEAN_GENRE_NAME = function (t)
{ try
{
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];
} catch (e) {}
}
//*********************YT RADIO START**********************
//SIMILAR ARTIST--------------------------------------------------
this.LOAD_ART = function()
{ if (YT_AUTO=="1")
if (YT_PL=="1")
{ var randomnumber=Math.floor(Math.random()*art)
var a=randomnumber;
if (STATION == "" || STATION == "?") return;
if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
this.xmlhttp.open("GET", "http://www.last.fm/music/" + encodeURIComponent(STATION) + "/+similar"+ "?page=" + a, true);
this.xmlhttp.send();
this.xmlhttp.onreadystatechange = function() {
if (this.xmlhttp.readyState == 4) {
if (this.xmlhttp.status == 200) {
var text = this.xmlhttp.responsetext;
if (!this.doc) this.doc = new ActiveXObject("htmlfile");
this.doc.open();
var div = this.doc.createElement("div");
div.innerHTML = text;
var data = div.getElementsByTagName("a");
var urls = [];
for (i = 0; i < data.length; i++) {
if (data[i].href.indexOf("about:/music/") == 0) urls.push(CLEAN_ART_NAME(data[i].href));
}
//select random URL
var randomnumber = Math.floor(Math.random()*(20-50)+50);
do{
randomnumber = Math.floor(Math.random()*(20-50)+50);
} while(randomnumber%2!=1);
i=randomnumber;
{
//Start with urls[i]
if (urls[i] > "")
{
//p.console("" + urls[i]);
SIM_ART = window.SetProperty("YT Similar", urls[i]);
SIM_ART = urls[i];
window.SetProperty("YT Similar", urls[i]);
}
else
{
SIM_ART = window.SetProperty("YT Similar", "");
SIM_ART = "";
window.SetProperty("YT Similar", "");
}
}
this.doc.close();
if (STATION.indexOf("*")== 0) {LOAD_GENRE();}
else
if (SIM_ART == "" || SIM_ART == "?") {LOAD_ART();}
else
LOAD_TRACK();
} else {
if (STATION.indexOf("*")== 0) {LOAD_GENRE();}
else
if (this.xmlhttp.status == 404) {p.console("HTTP error: " + this.xmlhttp.status); LOAD_ART();}
}
}
}
}
}
//TRACK----------------------------------------------------
this.LOAD_TRACK = function()
{
{var randomnumber=Math.floor(Math.random()*sng)
var a=randomnumber;
if (SIM_ART == "" || SIM_ART == "?") return;
if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
this.xmlhttp.open("GET", "http://www.last.fm/music/" + encodeURIComponent(SIM_ART) + "/+tracks" + "?page=" + a, true);
this.xmlhttp.send();
this.xmlhttp.onreadystatechange = function() {
if (this.xmlhttp.readyState == 4) {
if (this.xmlhttp.status == 200) {
var text = this.xmlhttp.responsetext;
if (!this.doc) this.doc = new ActiveXObject("htmlfile");
this.doc.open();
var div = this.doc.createElement("tr");
div.innerHTML = text;
var data = div.getElementsByTagName("td");
var urls = [];
for (i = 0; i < data.length; i++) {
if (data[i].title) urls.push(CLEAN_TRACK_NAME(data[i].title));
}
//select random URL
var randomnumber = Math.floor(Math.random()*Math.max(urls.length));
i=randomnumber;
{
//Start with urls[i]
if (urls[i] > "")
{
p.console("" + SIM_ART + " - " + urls[i]);
YT_TRACK = window.SetProperty("YT Track", urls[i]);
YT_TRACK = urls[i];
window.SetProperty("YT Track", urls[i]);
}
else
{
YT_TRACK = window.SetProperty("YT Track", "");
YT_TRACK = "";
window.SetProperty("YT Track", "");
}
}
this.doc.close();
if (YT_TRACK == "" || YT_TRACK == "?") {LOAD_ART();}
else
set_focus(); //focus on playlist
do_youtube_search1(decodeURIComponent(SIM_ART), decodeURIComponent(YT_TRACK));
} else {
p.console("HTTP error: " + this.xmlhttp.status);
if (STATION.indexOf("*")== 0) {LOAD_GENRE();}
else
if (this.xmlhttp.status == 404) {LOAD_ART();}
}
}
}
}
}
//POPULAR TRACKS----------------------------------------------------
this.POP_TRACKS = function()
{ p.artist = p.eval("%artist%");
{ if (p.artist == "" || p.artist == "?") return;
if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
this.xmlhttp.open("GET", "http://www.last.fm/music/" + encodeURIComponent(p.artist) + "/+tracks" + "?page=1", true);
this.xmlhttp.send();
this.xmlhttp.onreadystatechange = function() {
if (this.xmlhttp.readyState == 4) {
if (this.xmlhttp.status == 200) {
var text = this.xmlhttp.responsetext;
if (!this.doc) this.doc = new ActiveXObject("htmlfile");
this.doc.open();
var div = this.doc.createElement("tr");
div.innerHTML = text;
var data = div.getElementsByTagName("td");
var urls = [];
for (i = 0; i < data.length; i++) {
if (data[i].title) urls.push(CLEAN_TRACK_NAME(data[i].title));
}
//Select urls[i]
for (i = 0; i < urls.length; i++)
{
//Start with urls[i]
if (urls[i] > "")
do_youtube_search1(decodeURIComponent(p.artist), urls[i]);
}
this.doc.close();
} else {
p.console("HTTP error: " + this.xmlhttp.status);
}
}
}
}
}
//SIMILAR TRACKS----------------------------------------------------
this.SIMILAR_TRACKS = function()
{ p.artist = p.eval("%artist%");
p.title = p.eval("%title%");
{ if (p.artist == "" || p.artist == "?") return;
if (p.title == "" || p.title == "?") return;
if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
this.xmlhttp.open("GET", "http://www.last.fm/music/" + encodeURIComponent(p.artist) + "/_/" + encodeURIComponent(p.title) + "/+similar", true);
this.xmlhttp.send();
this.xmlhttp.onreadystatechange = function() {
if (this.xmlhttp.readyState == 4) {
if (this.xmlhttp.status == 200) {
var text = this.xmlhttp.responsetext;
if (!this.doc) this.doc = new ActiveXObject("htmlfile");
this.doc.open();
var div = this.doc.createElement("td");
div.innerHTML = text;
var data = div.getElementsByTagName("a");
var urls = [];
for (i = 0; i < data.length; i++) {
if (data[i].href.indexOf("/_/") >0)
urls.push((data[i].href));
}
//Select urls[i]
for (i = 0; i < 100; i++)
{
//Start with urls[i]
if (urls[i].indexOf("http:")==0) return;
if (urls[i].indexOf("/_/") >0)
title_split = urls[i].split("/_/")[1].replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ");
artist_split = urls[i].split("/_/")[0].replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("about:/music/","");
set_focus5();//set focus on playlist
do_youtube_search1(decodeURIComponent(artist_split),decodeURIComponent(title_split));
//fb.trace('::' ,artist_split + ' - '+ title_split )
}
this.doc.close();
} else {
p.console("HTTP error: " + this.xmlhttp.status);
}
}
}
}
}
//SAME VIDEO-----------------------------------------------
this.LOAD_SAME = function()
{
var artist0 = p.eval("%artist%");
var title0 = p.eval("%title%");
if(artist0 > "?" && title0 > "?") {set_focus2(); do_youtube_search1(decodeURIComponent(artist0), decodeURIComponent(title0));}
}
//GENRE----------------------------------------------------
this.LOAD_GENRE = function()
{ if (STATION.indexOf("*")== 0)
{ var randomnumber=Math.floor(Math.random()*tag)
var a=randomnumber;
if (STATION == "" || STATION == "?") return;
if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
this.xmlhttp.open("GET", "http://www.last.fm/music/+tag/" + encodeURIComponent(STATION).replace("*","") + "?page=" + a, true);
this.xmlhttp.send();
this.xmlhttp.onreadystatechange = function() {
if (this.xmlhttp.readyState == 4) {
if (this.xmlhttp.status == 200) {
var text = this.xmlhttp.responsetext;
if (!this.doc) this.doc = new ActiveXObject("htmlfile");
this.doc.open();
var div = this.doc.createElement("li");
div.innerHTML = text;
var data = div.getElementsByTagName("a");
var urls = [];
for (i = 0; i < data.length; i++) {
if (data[i].className.indexOf("name") == 0)
if (data[i].href.indexOf("about:/music/") == 0) urls.push(CLEAN_GENRE_NAME(data[i].href));
}
//select random URL
var randomnumber = Math.floor(Math.random()*(0-9)+9);
do{
randomnumber = Math.floor(Math.random()*(0-9)+9);
} while(randomnumber%2!=0);
i=randomnumber;
{
//Start with urls[i]
if (urls[i] > "")
{
//p.console("" + urls[i]);
SIM_ART = window.SetProperty("YT Similar", urls[i]);
SIM_ART = urls[i];
window.SetProperty("YT Similar", urls[i]);
}
else
{
SIM_ART = window.SetProperty("YT Similar", "");
SIM_ART = "";
window.SetProperty("YT Similar", "");
}
}
this.doc.close();
if (SIM_ART == "" || SIM_ART == "?") {LOAD_GENRE();}
else
LOAD_TRACK();
} else {
p.console("HTTP error: " + this.xmlhttp.status);
if (this.xmlhttp.status == 404) {LOAD_GENRE();}
}
}
}
}
}
//LOAD YOUTUBE VIDEO---------------------------------------
strip_title = function (t1, t2)
{
try
{
if (t1 == t2)
return t1;
if (t1.match(RegExp(t2 + "( and | & )", "i")))
return t1;
var a = "(by the |by: |by |of |the |feat. |ft. |)";
var b = "( feat.| ft.|)";
var t3 = "";
if (!t2.match(/^the /i))
{
t3 = t1.replace(RegExp("[^a-z\\d_)\\]\"]*(" + a + t2 + b + ")[^a-z\\d_(\\[\"]*","gi")," - ").replace(/^[^a-z()\[\]\d\"]*|[^a-z()\[\]\d\"]*$/gi, "");
}
else
{
var t4 = t2.replace(/^the /i, "")
t3 = t1.replace(RegExp("[^a-z\\d_)\\]\"]*(" + a + t4 + b + ")[^a-z\\d_(\\[\"]*","gi")," - ").replace(/^[^a-z()\[\]\d\"]*|[^a-z()\[\]\d\"]*$/gi, "");
}
return t3.match(/\S/) ? t3 : t1;
}
catch (e)
{
return t1;
}
}
convert = function(min)
{
var parts = min.split(':'),
minutes = +parts[0],
seconds = +parts[1];
return minutes * 60 + seconds;
}
strip = function (t)
{
try
{
t = t.replace(/[\.,\!\?\:;'"\-_]/g,"").toLowerCase();
return t;
} catch (e)
{}
}
clean = function (t)
{
try
{
return t.replace(/'/g, "’").toLowerCase();
} catch (e) {}
}
youtube_search = function (state_change_callback, p_on_search_finished_callback)
{
this.xmlhttp = null;
this.http_callback_funct = null;
this.ready_state_change_callback = state_change_callback;
this.search_done = false;
this.on_search_finished_callback = p_on_search_finished_callback;
this.yt_link;
this.search_artist;
this.search_title;
this.metadata;
this.on_state_change = function ()
{
if (this.xmlhttp != null && this.xmlhttp.readyState == 4 && this.xmlhttp.status == 200 && this.http_callback_funct != null)
this.http_callback_funct();
}
this.StartSearch = function (p_artist, p_title, p_extra_metadata)
{
this.search_artist = p_artist;
this.search_title = p_title;
this.metadata = p_extra_metadata;
this.http_callback_funct = null;
this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
var URL = "https://www.youtube.com/results?search_query=" + encodeURIComponent(p_artist + " " + p_title);
this.http_callback_funct = this.AnalyseSearch;
this.xmlhttp.open("GET", URL);
this.xmlhttp.onreadystatechange = this.ready_state_change_callback;
this.xmlhttp.send();
}
this.AnalyseSearch = function ()
{
var text = this.xmlhttp.responsetext;
var doc = new ActiveXObject("htmlfile");
doc.open();
var div = doc.createElement("div");
div.innerHTML = text;
var data = div.getElementsByTagName("a");
var url = "";
var first_match;
re_test:
for (var i = 0; i < data.length; i++)
{
if (data[i].href.indexOf("about:/watch?v=") == 0)
{
i++; //link
//Find Title[NEW]
{
var st = text.indexOf( data[i].href.replace("about:/watch?", "") );
var str = "a class=\"yt-uix-tile-link yt-ui-ellipsis yt-ui-ellipsis-2 yt-uix-sessionlink spf-link\">";
st = text.indexOf(str, st) + str.length;
var et = text.indexOf("</a>", st);
var youtube_title = text.substr(st, et - st);
var Y_Title = youtube_title.replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&").replace("'", "'").replace(""", "''").replace("&", "&");
//p.console("Title: " + Y_Title);
}
//Find Title[OLD]
//Y_Title = data[i].title;
//p.console("Title: " + Y_Title);
//Find minutes
var s = text.indexOf( data[i].href.replace("about:/watch?", "") );
var str = "<span class=\"video-time\">";
s = text.indexOf(str, s) + str.length;
var e = text.indexOf("</span>", s);
var length = text.substr(s, e - s);
length = convert(length);
length = length ? length : "";
if (!first_match)
{
// title stripped of artist name if same as search_artist
var stripped_title = strip_title(Y_Title, this.search_artist);
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?", "");
}
//3dydfy
if (!this.IsGoodMatch(Y_Title))
continue;
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?", "");
break;
}
}
if (!url.length)
url = first_match;
this.yt_link = url;
doc.close();
this.on_search_finished_callback(url, this.search_artist, this.search_title);
}
this.IsGoodMatch = function (video_name)
{
var clean_vid_name = clean(strip(video_name));
var clean_artist = clean(strip(this.search_artist));
var clean_title = clean(strip(this.search_title));
if (clean_vid_name.indexOf(clean_artist) != -1 && clean_vid_name.indexOf(clean_title) != -1 && clean_vid_name.indexOf("full album") == -1)
{
//p.console("GOOD MATCH");
return true;
}
else
{
//p.console("BAD MATCH");
return false;
}
}
}
//Call Search
do_youtube_search1 = function (p_artist, p_title)
{
var yt_search1 = new youtube_search(function ()
{
yt_search1.on_state_change();
}, on_youtube_search1_done);
yt_search1.StartSearch(p_artist, p_title);
}
on_youtube_search1_done = function (link, p_artist, p_title)
{
var url2="";
url2 = link;
if (!url2)
{p.console("Track Or Artist - Not Exist!"); LOAD_ART();}
if (link && link.length)
{
p.console("" + "\"" + link + "\"");
YT_URL = window.SetProperty("YT URL", link);
var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath;
var str = tmppath + "\\foobar2000.exe /add ";
var go = str + link;
p.run(go);
}
}
//**************************(END)**************************
this.artist = "";
//Set Panels
function pan1() { }
function pan2(x, y, w, h) { }
//---------------------------------------------------------
//Begin--->
var p = new panel("Youtube Radio", ["remap", "metadb"]);
var im = new pan2(0, 0, 0, 0);
var th = new pan1();
on_item_focus_change();
{
}
function on_metadb_changed() {
}
//Buttons---------------------------------------------------
var Buttons;
var g_tooltip = window.CreateTooltip();
var g_down = false;
var btn_down = null;
var cur_btn = null;
ButtonStates = {
normal: 0,
hover: 1,
down: 2
}
function Button(x, y, w, h, img_src, func, tiptext) {
this.left = x;
this.top = y;
this.w = w;
this.h = h;
this.right = x + w;
this.bottom = y + h;
this.func = func;
this.tiptext = tiptext;
this.state = ButtonStates.normal;
this.img_normal = img_src && img_src.normal ? gdi.Image(img_src.normal) : null;
this.img_hover = img_src && img_src.hover ? gdi.Image(img_src.hover) : this.img_normal;
this.img_down = img_src && img_src.down ? gdi.Image(img_src.down) : this.img_hover;
this.img = this.img_normal;
this.alterImage = function(img_src) {
this.img_normal = img_src && img_src.normal ? gdi.Image(img_src.normal) : null;
this.img_hover = img_src && img_src.hover ? gdi.Image(img_src.hover) : this.img_normal;
this.img_down = img_src && img_src.down ? gdi.Image(img_src.down) : this.img_hover;
this.changeState(this.state);
}
this.traceMouse = function (x, y) {
var b = (this.left < x) && (x < this.right) && (this.top < y) && (y < this.bottom);
if (b)
g_down ? this.changeState(ButtonStates.down) : this.changeState(ButtonStates.hover);
else
this.changeState(ButtonStates.normal);
return b;
}
this.changeState = function (newstate) {
if (newstate != this.state)
window.RepaintRect(this.left, this.top, this.w, this.h);
this.state = newstate;
switch (this.state)
{
case ButtonStates.normal:
this.img = this.img_normal;
break;
case ButtonStates.hover:
this.img = this.img_hover;
break;
case ButtonStates.down:
this.img = this.img_down;
break;
default:
this.img = null;
}
}
this.draw = function (gr) {
this.img && gr.DrawImage(this.img, this.left, this.top, this.w, this.h, 0, 0, this.w, this.h);
}
this.onClick = function () {
this.func && this.func(x,y);
}
this.onMouseIn = function() {
g_tooltip.Text = this.tiptext;
g_tooltip.Activate();
}
this.onMouseOut = function() {
g_tooltip.Deactivate();
}
}
function buttonsDraw(gr) {
for (i in Buttons) {
Buttons[i].draw(gr);
}
}
function buttonsTraceMouse(x, y) {
var btn = null;
for (i in Buttons) {
if (Buttons[i].traceMouse(x, y) && !btn)
btn = Buttons[i];
}
return btn;
}
function on_mouse_move(x, y) {
var btn = buttonsTraceMouse(x, y);
if (btn != cur_btn) {
cur_btn && cur_btn.onMouseOut();
btn && btn.onMouseIn();
}
cur_btn = btn;
}
function on_mouse_lbtn_down(x, y) {
g_down = true;
btn_down = cur_btn;
if (cur_btn) {
cur_btn.changeState(ButtonStates.down);
}
}
function on_mouse_lbtn_up(x, y) {
if (cur_btn) {
cur_btn.changeState(ButtonStates.hover);
if( btn_down == cur_btn )
cur_btn.onClick(x, y);
}
g_down = false;
}
function on_mouse_leave() {
if (cur_btn) {
cur_btn.changeState(ButtonStates.normal);
}
}
function on_size() {
ww = window.Width;
wh = window.Height;
window.Repaint();
}
//Background
this.dui = window.InstanceType;
function on_paint(gr) {
if (this.dui) {
col = window.GetColorDUI(1);
gr.FillSolidRect(0, 0, ww, wh, col);
}
else
{
col = window.GetColorCUI(3);
}
buttonsDraw(gr);
}
function RGB(r,g,b) {
return (0xff000000|(r<<16)|(g<<8)|(b));
}
function on_colors_changed() {
window.Repaint();
}
//Init Buttons--------------------------------------------
//Custom colour
var custom = RGB(255,255,255);
//Button width
var bw = 24;
//Button height
var bh = 20;
//Button position
var top_margin = 0;
var left_margin = 0;
var image_path0 = window.GetProperty("Button Path", fb.ProfilePath + "image");
var image_path = (image_path0 + "\\");
//These 2 lines of code lock the panel size.
//window.MinWidth = window.MaxWidth = 24;
//window.MinHeight = window.MaxHeight = 20;
Buttons = {
but1: new Button(left_margin,top_margin,bw,bh, {normal: image_path + "youtube0.png", hover: image_path + "youtube1.png"}, function(){
p.rbtn_up(24, 17);
}, "Youtube")
}
function on_mouse_rbtn_up(x, y) {
return true;
}