Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: WSH Panel Mod script discussion/help (Read 1391591 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

WSH Panel Mod script discussion/help

Reply #4025
it's just a blank white panel and you double click to run...
https://gist.github.com/marc2k3/b3d7b5da40af202738ad

I'm on 9926 build (Not the latest one 10041)

Code: [Select]
creating the htmlfile ActiveXObject works.
clipboardData.setData() works.
although clipboardData.getData() didn't crash the script, the text does not match what was written in the previous test.
open() works.
createElement() works.
innerHTML and innerText works.
getElementsByTagName works.
className works.
close() works.
testing complete. everything seems ok.


WSH Panel Mod script discussion/help

Reply #4026
Code: [Select]
although clipboardData.getData() didn't crash the script, the text does not match what was written in the previous test.


well that's weird. although i accounted for it, i didn't actually expect to see it happen in practice. if you use JSplaylist, can you test and see if copy/paste functionality works between input boxes? if it works, we can probably ignore that error....

as for anyone else, the above gist script is only going to be useful if you're running the latest 10041 build of windows 10 - something i can't do at the moment.

WSH Panel Mod script discussion/help

Reply #4027
Code: [Select]
fso.OpenTextFile(filename, 2, true, -1);


you probably looked at that and didn't understand what the numbers were for.... so you googled it and found out. that had to be more satisfying than me telling you even if i did you give quite a large clue.


Yes,  I didn't not exactly for what  the numbers are.  So i assumed that this is for file format.
Thanks, you give me a clue..

One more thing, because script use 'cmd' to open 'm3u' files, if i have spaces in folder path, then it won't open.
So, how to fix this? I was try to add double quotes.. Didn't work, or i put in wrong place.
My path: ''C:\user\mire\desktop\foobar xch4\file_name.m3u''

since strangeluck hasn't come back with any meaningful bug reports about scripts crashing in the latest build of windows 10, i've knocked up a little script which does some more in depth testing. first it tests the clipboard because i think that's all falstaff uses it for in JSplaylist. i then test some html stuff. since i'm on windows 7, this is what my popup window reports...

Code: [Select]
creating the htmlfile ActiveXObject works.
clipboardData.setData() works.
clipboardData.getData() works.
open() works.
createElement() works.
innerHTML and innerText works.
getElementsByTagName works.
className works.
close() works.
testing complete. everything seems ok.


it's just a blank white panel and you double click to run...

https://gist.github.com/marc2k3/b3d7b5da40af202738ad


I will test later...

WSH Panel Mod script discussion/help

Reply #4028
Code: [Select]
although clipboardData.getData() didn't crash the script, the text does not match what was written in the previous test.


well that's weird. although i accounted for it, i didn't actually expect to see it happen in practice. if you use JSplaylist, can you test and see if copy/paste functionality works between input boxes? if it works, we can probably ignore that error....

as for anyone else, the above gist script is only going to be useful if you're running the latest 10041 build of windows 10 - something i can't do at the moment.


copy/paste works fine in JSplaylist 

Although i had encountered a very frustrating issue with your similar artist script
The script download the json file first time without any errors, but in couple of seconds,
Code: [Select]
Last.fm Similar Artists: JSON.parse error.

when i looked at the downloaded folder,seems like it replaces the json file with a empty file.
Any idea what caused this??
But i cant reproduce it every time, It only happens some times, very weird error :/.
Had anyone encountered this??

WSH Panel Mod script discussion/help

Reply #4029
@mire777, you need to escape the quotes in your path. here are 2 different ways of doing it.

Code: [Select]
"\"" + fb.ProfilePath + "playlist.m3u\""


or

Code: [Select]
'"' + fb.ProfilePath + 'playlist.m3u"'


@samithaj, thanks for confirming copy/paste works in JSplaylist on windows 10. i'll update my script with the erroneous clipboard reporting.

as for the JSON.parse error, **** happens. i guess invalid responses shouldn't blindly be written to disk. simply look for all instances of p.save in the common file and find the one that is used by the last.fm script. think about how you can validate the response before saving.

WSH Panel Mod script discussion/help

Reply #4030
@mire777, you need to escape the quotes in your path. here are 2 different ways of doing it.

Code: [Select]
"\"" + fb.ProfilePath + "playlist.m3u\""

or

Code: [Select]
'"' + fb.ProfilePath + 'playlist.m3u"'

Thanks Marc , it works
Here is script if someone wants to try on windows 10..                                         

-You can love, unlove or play loved tracks as radio .
Should work as last.fm ''loved''.
Playlist are saved in foobar folder: ''playlists-YT''.



[code]
// ==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");

//Folder
fso = new ActiveXObject("Scripting.FileSystemObject");
folder = fb.ProfilePath + "playlists-YT";

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();
if (fb.ActivePlaylist == (GetPlaylistID(pls + " [Loved]"))) if (fb.PlaybackLength>=50) {LOVED();} else
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;
}

//Remove false string from file names   
this.clean_filename = function(filename) {
return filename.replace(/[\/\\|:]/g, '-').replace(/\*/g, 'x').replace(/"/g, "''").replace(/[?<>]/g, '_');
}

//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 + " [Tracks: "+ p.artist +"]"));
}

//Focus on playlist(Similar Tracks)
function set_focus5()
{
if (pls>"")
fb.ActivePlaylist = (GetPlaylistID(pls + " [Similar to: "+ p.artist + " - " + p.title +"]"));
}

//Focus on playlist(Loved)
function set_focus6()
{
if (pls>"")
fb.ActivePlaylist = (GetPlaylistID(pls + " [Loved]"));
}

//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 q = window.CreatePopupMenu();
    var MF_POPUP = 0x00000010;
    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();

//POPUP BUTTON
{_menu.AppendMenuItem(MF_STRING | MF_POPUP, q.ID, "Open");}

//START *POPUP
p.artist = p.eval("%artist%");
if (p.artist == "" || p.artist == "?") {q.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Radio Station by [%artist%]");}
else
{q.AppendMenuItem(MF_STRING, 1915, "Radio Station by [" + p.artist.replace(/&/g,"&&") + "]");}

p.genre = p.eval("%genre%");
if (p.genre == "" || p.genre == "?") {q.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Radio Station by [%genre%]");}
else
{q.AppendMenuItem(MF_STRING, 1921, "Radio Station by [genre: " + p.genre.replace(/&/g,"&&") + " ]");}

p.artist = p.eval("%artist%");
if (p.artist == "" || p.artist == "?") {q.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Top Tracks by " + "[%artist%]");}
else
{q.AppendMenuItem(MF_STRING, 1916, "Top Tracks by [" + p.artist.replace(/&/g,"&&") + "]");}

p.artist = p.eval("%artist%");
p.title = p.eval("%title%");
if (p.artist == "" || p.artist == "?") {q.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Similar Tracks as [%artist% - %title%]");}
else
{q.AppendMenuItem(MF_STRING, 1920, "Similar Tracks as [" + p.artist.replace(/&/g,"&&") + " - " + p.title.replace(/&/g,"&&") + "]");}
//END *POPUP

_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.AppendMenuSeparator();

_menu.AppendMenuItem(MF_STRING, 1914, "Start Radio Station");

_menu.AppendMenuSeparator();

//START LOVED
p.path = p.eval("%path%");
p.artist = p.eval("%artist%");
p.title = p.eval("%title%");
filename = folder + "\\"+ clean_filename(p.artist + " - " + p.title) + ".m3u";

if (p.path.indexOf("youtube.com")>0) {
if (fso.FileExists(filename)) {_menu.AppendMenuItem(MF_STRING, 500, "♥ Un-Love");}
else
{_menu.AppendMenuItem(MF_STRING, 501, "♥ Love Track");}
if (fb.ActivePlaylist == (GetPlaylistID(pls + " [Loved]"))) {_menu.AppendMenuItem(MF_STRING, 502, "♪ Next Loved..");}
else
{_menu.AppendMenuItem(MF_STRING, 502, "♪ Play Loved..");}
} else
{
_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "♥ Love Track");
{_menu.AppendMenuItem(MF_STRING, 502, "♪ Play Loved..");}
}
//END LOVED

_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..");}

/* //Find in Browser
_menu.AppendMenuSeparator();
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");}
_menu.AppendMenuSeparator();*/

_menu.AppendMenuItem(MF_STRING, 401, "Search For Videos...");

_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 500:
                filename = folder + "\\"+ clean_filename(p.artist + " - " + p.title) + ".m3u";
                //Delete file
                if (fso.FileExists(filename)) fso.DeleteFile(filename);
                break;
               
          case 501:
                this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
                p.path = p.eval("%path%");
                p.artist = p.eval("%artist%");
                p.title = p.eval("%title%");
               
                //Create file & folder
                filename = folder + "\\"+ clean_filename(p.artist + " - " + p.title) + ".m3u";
                if(!fso.FolderExists(folder)) fso.CreateFolder(folder);
               
                //Save file
                function save_file(x) {
                try {
                g_text = p.path;
                ts = fso.OpenTextFile(filename, 2, true, -2);
                ts.Write(g_text);
                ts.close();
                } catch(e) {
                fb.trace("Error saving text: " + e);
                }}
                save_file(filename);
            break;

          case 502:
                LOVED();
            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_focus5(); //focus on playlist
                SIMILAR_TRACKS();
                break;
           
          case 1921:
                this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
                p.genre = p.eval("%genre%");
                if (p.genre == "" || p.genre == "?") return;
                STATION = "*" + p.genre;
                window.SetProperty("YT  Station", "*" + p.genre);
                YT_PL = 1;
                window.SetProperty("YT  Playlist", "1");
                YT_AUTO = "1"
                window.SetProperty("YT  Auto", "1");
                set_focus(); //Focus on playlist
                LOAD_GENRE();
                break;
              }
              _menu.Dispose();
           }

//Features init
    this.features_init = function() {
    for (i = 0; i < this.features.length; i++) {
    switch(this.features) {
    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 == 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.href.indexOf("about:/music/") == 0) urls.push(CLEAN_ART_NAME(data.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
if (urls > "")
{
//p.console("" + urls);
SIM_ART = window.SetProperty("YT Similar", urls);
SIM_ART = urls;
window.SetProperty("YT Similar", urls);
}
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();}
                }
         }
      }
   }                           
}

//LOAD 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.title) urls.push(CLEAN_TRACK_NAME(data.title));
}

//select random URL
var randomnumber = Math.floor(Math.random()*Math.max(urls.length));
i=randomnumber;

{

//Start with urls
if (urls > "")
{
p.console("" + SIM_ART + " - " + urls);

YT_TRACK = window.SetProperty("YT Track", urls);
YT_TRACK = urls;
window.SetProperty("YT Track", urls);
}
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.title) urls.push(CLEAN_TRACK_NAME(data.title));
}

//Select urls
for (i = 0; i < urls.length; i++)

{
//Start with urls
if (urls > "")
do_youtube_search1(decodeURIComponent(p.artist), urls);
}
        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.href.indexOf("/_/")>0)

urls.push((data.href));
}

//Select urls
for (i = 0; i < 100; i++)

{
//Start with urls
if (urls.indexOf("http:")==0) return;
if (urls.indexOf("/_/") >0)
title_split = urls.split("/_/")[1].replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ");
artist_split = urls.split("/_/")[0].replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("about:/music/","").replace("noredirect/","");
set_focus5();//set focus on playlist
do_youtube_search1(decodeURIComponent(artist_split),decodeURIComponent(title_split));

}
this.doc.close();
} else {
p.console("HTTP error: " + this.xmlhttp.status);
}
}
}
}
}

//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.className.indexOf("name") == 0)
    if (data.href.indexOf("about:/music/") == 0) urls.push(CLEAN_GENRE_NAME(data.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
if (urls > "")
{
//p.console("" + urls);
SIM_ART = window.SetProperty("YT Similar", urls);
SIM_ART = urls;
window.SetProperty("YT Similar", urls);
}
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();}
                }
         }
      }
   }
}
//LOVED----------------------------------------------------
this.LOVED = function()
{
                //list files
                var arr = utils.Glob(folder + "\\*.*").toArray();
                var a = [];

                for (i = 0; i < arr.length; i++) {
                if (arr) a.push(arr); 
                    }
                //select random file
                var randomnumber = Math.floor(Math.random()*Math.max(arr.length));
                i=randomnumber;
               
                file_path = arr;
                var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath;
                var str = tmppath + "\\foobar2000.exe /add ";
                var go = str + '"' + file_path + '"';
               
                //load file
                set_focus6(); //Focus on playlist
                var tm = window.SetTimeout(function() {
                p.run(go);
                p.console(file_path);
                window.ClearTimeout™; tm = false;
                }, 50);   
}

//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));}
}

//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.href.indexOf("about:/watch?v=") == 0)
          {
                i++; //link

            //Find Title[OLD]
            /*{
            var st = text.indexOf( data.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("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&");
            //p.console("Title: " + Y_Title);
            }*/
           
            //Find Title[NEW]
            Y_Title = data.title;
            Remove_duration = Y_Title.substring(Y_Title.lastIndexOf(" - ")+1);
            Y_Title = data.title.replace(Remove_duration, "").trim();
            //p.console("Title: " + Y_Title);
               
            //Find minutes
            var s = text.indexOf( data.href.replace("about:/watch?", "") );
            var str = "<span class=

WSH Panel Mod script discussion/help

Reply #4031
Hi,
Is there a bug ... similar-artists and Lastfm-chart give blank page ???
thanks for your help .

WSH Panel Mod script discussion/help

Reply #4032
get your own last.fm api key here: http://www.last.fm/api/account/create
make up any old name and copy the api key to the clipboard.

now right click your last.fm panels, configure and look for the code where it says

Code: [Select]
var l = new lastfm();


enter this line directly after it

Code: [Select]
l.api_key = "abc123";


obviously your own api key needs to go inside the double quotes.

some people have directed others to add their secret from the api account as well. you don't need to do this for the similar artists/charts scripts. it's only required if you use playcount sync to love/unlove tracks. you simply add another line directly after the one above.

Code: [Select]
l.secret = "abc123";


if you do this, make sure you enter your password again so it's authorised with your new api key.

WSH Panel Mod script discussion/help

Reply #4033
@ Marc2003
Thanks a lot , you are really the best !

WSH Panel Mod script discussion/help

Reply #4034
Hey everyone,



I'm working on a new design for foobar, inspired by turntables. I've already made this panel, using stack splitter. It works pretty well. But playback order can't be refreshed in real time. So when changing it from the menu, the panel doesn't refresh itself. I think I have no choice but switching to WSH, and rewrite everything. Moreover I would be able to add a volume knob and other features. However, it's not as simple as Panel Stack/CUI for me, since I never wrote anything into it. I read a lot of scripts that I found to understand how it works, sometimes I also edited them. But starting from zero... the mountain is just too high. So I was wandering, if anybody had links to a wiki, or anything to learn ? Or if someone would show me how to make, for example, a button ?

Thank you very much. This is my first post, I'm happy to get in touch with the foobar community.

WSH Panel Mod script discussion/help

Reply #4035
Ok I install windows 10 build 10041 .
This is report of running Marc script:

Code: [Select]
creating the htmlfile ActiveXObject works.
clipboardData.setData() works.
clipboardData.getData() works.
open() works.
createElement() works.
innerHTML and innerText works.
getElementsByTagName works.
className works.
close() works.
testing complete. everything seems ok.


I just put my old portable config with bio photography, bio text, new youtube radio.
Everything seems to work fine, I don't have any error.

Surprisingly for me, Windows 10 works incredibly fast, and you don't have to install any drivers 
I am satisfied with this version..
Just don't know should I use windows 10 as my main OS right now, because I don't know if tehnical preview will be updated to the full version later, or I must be on windows 8.1?

WSH Panel Mod script discussion/help

Reply #4036
Uh, seems that I found problem> ''HTTP error: 0 '' on bio script , mean that it loose internet connection.
After I restart foobar script works fine ,for a while then I again have this error.
Also this: ''Error: WSH Panel Mod (Biography Text by Mire777): Microsoft JScript runtime error:
'id' is null or not an object'' > I assume this is also because windows or foobar loose connection..
Anyway, can't be bothered with that. I will use windows 8 for now..

WSH Panel Mod script discussion/help

Reply #4037
@mire777, thanks for checking windows 10.

@Celeste, have you looked at the buttons/playback order examples bundled with the component? unfortunately, i don't know of any guides to help people start making stuff from scratch. it just takes time and (a lot of) patience to try and pick apart other people's work.

WSH Panel Mod script discussion/help

Reply #4038
@mire777, thanks for checking windows 10.


Unfortunately I have same problem in windows 8.1.
Maybe something block foobar scripts? Windows defender?

WSH Panel Mod script discussion/help

Reply #4039
http error code 0 can be caused by lots of things and is pretty hard to troubleshoot. here are just a few causes i've stumbled across by chance

website redirects. i only noticed this when dropbox changed the content hosting URL and it broke my script updates.
conflicting cookies. if you browse a website in IE and it leaves some cookies, it can affect scripts configured to use the same site. one such example is my thumbs script. when i first made it, it was configured to use www.last.fm - if the user had visited any regional last.fm site like lastfm.de then it broke my script giving status code 0.
and sometimes it just can be random.

maybe using wireshark to analyse the server responses would help. hopefully you'll get something more useful than just an error code.

WSH Panel Mod script discussion/help

Reply #4040
Thank you marc2003, I found good informations in the WSH folder, and with patience I managed to draw a volume knob.

Does someone know how to draw rotated shapes ? I'd like to put a thin line on my knob (it's currently a dot), so I need to draw a rotated rectangle.

WSH Panel Mod script discussion/help

Reply #4041
http error code 0 can be caused by lots of things and is pretty hard to troubleshoot. here are just a few causes i've stumbled across by chance

website redirects. i only noticed this when dropbox changed the content hosting URL and it broke my script updates.
conflicting cookies. if you browse a website in IE and it leaves some cookies, it can affect scripts configured to use the same site. one such example is my thumbs script. when i first made it, it was configured to use www.last.fm - if the user had visited any regional last.fm site like lastfm.de then it broke my script giving status code 0.
and sometimes it just can be random.

maybe using wireshark to analyse the server responses would help. hopefully you'll get something more useful than just an error code.


I found what cause this error.
This is because 'foo_youtube.dll'.
If you have enabled 'playback video' , foo_youtube.dll  loads second track 10sec before previous ends, in that way foo_youtube tryin to fix ('no video error').
Probably this leaves some cookies or affect, not only to 'Foobar Radio', but all scritps that use IE.
Quick fix is to just turn off 'playback video' in preferences. You can listen sound.
How to fix this with script, or is it possible, don't know..

WSH Panel Mod script discussion/help

Reply #4042
@mjm716, close foobar2000 and then save this in your marc2003 folder.

https://dl.dropboxusercontent.com/u/2280132...temp/common8.js


I just registered in order to get this script.

Marc2003 I admire your work and you use it frequently. The script has stopped working, I've read that you have stopped supporting your scripts, I understand and respect that. But is there any chance that you can re-upload latest common8.js? Or anyone who has this latest version can upload this script?

I use love button and playcount synch pretty actively and can't seem to find any working download link for the latest common8.js. Your re-upload will be appracieted and could help other people looking for it.

WSH Panel Mod script discussion/help

Reply #4043
A copy of "common8.js" can be found pasted online here: http://pastebin.com/raw.php?i=Z9Ucp1hP

For your reference ..............

here is lines 1 to 22 from the pastebin text:
Code: [Select]
var VERSION = "8.2015-01-24.01";

/*
(c) 2010-2015 marc2003
Please do not distribute modified versions of this file with your own scripts or themes.
You should be able to customise pretty much anything you want by editing the script
in your panel, not in this file. Leaving this intact and in its correct location
means you/other people can get bug fixes by using the "Update script" option on the
right click menu. If you need any help with customising then just come and ask on
hydrogenaudio.

http://www.hydrogenaud.io/forums/index.php?showtopic=77883
*/

var DT_LEFT = 0x00000000;
var DT_CENTER = 0x00000001;
var DT_RIGHT = 0x00000002;
var DT_VCENTER = 0x00000004;
var DT_WORDBREAK = 0x00000010;
var DT_CALCRECT = 0x00000400;
var DT_NOPREFIX = 0x00000800;
var DT_END_ELLIPSIS = 0x00008000;

and here is lines 1438 to 1466 from the pastebin text:
Code: [Select]
    var i;
    this.name = name;
    this.features = features || [];
    this.is_dui = window.InstanceType;
    this.script_path = fb.ProfilePath + "marc2003\\";
    this.ip = this.script_path + "images8\\";
    this.common_js_url = "https://dl.dropboxusercontent.com/u/22801321/wsh/marc2003/common8.js";
    this.common_js_file = this.script_path + "common8.js";
    this.tooltip = window.CreateTooltip();
    this.w = 0;
    this.h = 0;
    this.mx = 0;
    this.my = 0;
    this.metadb = fb.GetFocusItem();
    this.data_folder = fb.ProfilePath + "wsh_data\\";
    this.artists_folder = this.data_folder + "artists\\"
    this.settings_folder = fb.ProfilePath + "wsh_settings\\";
    this.artist = "";
    this.artist_tf = "%artist%";
    this.normal_font_size = window.GetProperty("2k3.normal_font_size", 14);
    this.list_font_size = window.GetProperty("2k3.list_font_size", 11);
    this.up_img = gdi.Image(this.ip + "buttons\\up.png");
    this.down_img = gdi.Image(this.ip + "buttons\\down.png");
    this.selection_mode = 1;
    this.metadb_func = typeof on_metadb_changed == "function";
    this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    this.features_init();
    this.colours_changed();
    this.font_changed();

WSH Panel Mod script discussion/help

Reply #4044
^that does nothing to solve the problem. even the last public version from this month doesn't work for playcount sync.

i've already posted how people can fix their own scripts. http://www.hydrogenaud.io/forums/index.php...st&p=893121

WSH Panel Mod script discussion/help

Reply #4045
Here is fix for ''http error 0'' on windows 8.1 and windows 10.
YouTube Radio:

[code]
// ==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");

//Folder
fso = new ActiveXObject("Scripting.FileSystemObject");
folder = fb.ProfilePath + "playlists-YT";

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();
if (fb.ActivePlaylist == (GetPlaylistID(pls + " [Loved]"))) if (fb.PlaybackLength>=10) {LOVED();} else
p.item_focus_change();
if (fb.PlaybackLength>=10) {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;
}

//Remove false string from file names   
this.clean_filename = function(filename) {
return filename.replace(/[\/\\|:]/g, '-').replace(/\*/g, 'x').replace(/"/g, "''").replace(/[?<>]/g, '_');
}

//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 + " [Tracks: "+ p.artist +"]"));
}

//Focus on playlist(Similar Tracks)
function set_focus5()
{
if (pls>"")
fb.ActivePlaylist = (GetPlaylistID(pls + " [Similar to: "+ p.artist + " - " + p.title +"]"));
}

//Focus on playlist(Loved)
function set_focus6()
{
if (pls>"")
fb.ActivePlaylist = (GetPlaylistID(pls + " [Loved]"));
}

//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 q = window.CreatePopupMenu();
    var MF_POPUP = 0x00000010;
    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();

//POPUP BUTTON
{_menu.AppendMenuItem(MF_STRING | MF_POPUP, q.ID, "Open");}

//START *POPUP
p.artist = p.eval("%artist%");
if (p.artist == "" || p.artist == "?") {q.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Radio Station by [%artist%]");}
else
{q.AppendMenuItem(MF_STRING, 1915, "Radio Station by [" + p.artist.replace(/&/g,"&&") + "]");}

p.genre = p.eval("%genre%");
if (p.genre == "" || p.genre == "?") {q.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Radio Station by [%genre%]");}
else
{q.AppendMenuItem(MF_STRING, 1921, "Radio Station by [genre: " + p.genre.replace(/&/g,"&&") + " ]");}

p.artist = p.eval("%artist%");
if (p.artist == "" || p.artist == "?") {q.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Top Tracks by " + "[%artist%]");}
else
{q.AppendMenuItem(MF_STRING, 1916, "Top Tracks by [" + p.artist.replace(/&/g,"&&") + "]");}

p.artist = p.eval("%artist%");
p.title = p.eval("%title%");
if (p.artist == "" || p.artist == "?") {q.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Similar Tracks as [%artist% - %title%]");}
else
{q.AppendMenuItem(MF_STRING, 1920, "Similar Tracks as [" + p.artist.replace(/&/g,"&&") + " - " + p.title.replace(/&/g,"&&") + "]");}
//END *POPUP

_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.AppendMenuSeparator();

_menu.AppendMenuItem(MF_STRING, 1914, "Start Radio Station");

_menu.AppendMenuSeparator();

//START LOVED
p.path = p.eval("%path%");
p.artist = p.eval("%artist%");
p.title = p.eval("%title%");
filename = folder + "\\"+ clean_filename(p.artist + " - " + p.title) + ".m3u";

if (p.path.indexOf("youtube.com")>0) {
if (fso.FileExists(filename)) {_menu.AppendMenuItem(MF_STRING, 500, "♥ Un-Love");}
else
{_menu.AppendMenuItem(MF_STRING, 501, "♥ Love Track");}
if (fb.ActivePlaylist == (GetPlaylistID(pls + " [Loved]"))) {_menu.AppendMenuItem(MF_STRING, 502, "♪ Next Loved..");}
else
{_menu.AppendMenuItem(MF_STRING, 502, "♪ Play Loved..");}
} else
{
_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "♥ Love Track");
{_menu.AppendMenuItem(MF_STRING, 502, "♪ Play Loved..");}
}
//END LOVED

_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..");}

/* //Find in Browser
_menu.AppendMenuSeparator();
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");}
_menu.AppendMenuSeparator();*/

_menu.AppendMenuItem(MF_STRING, 401, "Search For Videos...");

_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 500:
                filename = folder + "\\"+ clean_filename(p.artist + " - " + p.title) + ".m3u";
                //Delete file
                if (fso.FileExists(filename)) fso.DeleteFile(filename);
                break;
               
          case 501:
                this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
                p.path = p.eval("%path%");
                p.artist = p.eval("%artist%");
                p.title = p.eval("%title%");
               
                //Create file & folder
                filename = folder + "\\"+ clean_filename(p.artist + " - " + p.title) + ".m3u";
                if(!fso.FolderExists(folder)) fso.CreateFolder(folder);
               
                //Save file
                function save_file(x) {
                try {
                g_text = p.path;
                ts = fso.OpenTextFile(filename, 2, true, -2);
                ts.Write(g_text);
                ts.close();
                } catch(e) {
                fb.trace("Error saving text: " + e);
                }}
                save_file(filename);
            break;

          case 502:
                LOVED();
            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_focus5(); //focus on playlist
                SIMILAR_TRACKS();
                break;
           
          case 1921:
                this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
                p.genre = p.eval("%genre%");
                if (p.genre == "" || p.genre == "?") return;
                STATION = "*" + p.genre;
                window.SetProperty("YT  Station", "*" + p.genre);
                YT_PL = 1;
                window.SetProperty("YT  Playlist", "1");
                YT_AUTO = "1"
                window.SetProperty("YT  Auto", "1");
                set_focus(); //Focus on playlist
                LOAD_GENRE();
                break;
              }
              _menu.Dispose();
           }

//Features init
    this.features_init = function() {
    for (i = 0; i < this.features.length; i++) {
    switch(this.features) {
    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 == 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.href.indexOf("about:/music/") == 0) urls.push(CLEAN_ART_NAME(data.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
if (urls > "")
{
//p.console("" + urls);
SIM_ART = window.SetProperty("YT Similar", urls);
SIM_ART = urls;
window.SetProperty("YT Similar", urls);
}
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();}
                }
         }
      }
   }                           
}

//LOAD 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.title) urls.push(CLEAN_TRACK_NAME(data.title));
}

//select random URL
var randomnumber = Math.floor(Math.random()*Math.max(urls.length));
i=randomnumber;

{

//Start with urls
if (urls > "")
{
p.console("" + SIM_ART + " - " + urls);

YT_TRACK = window.SetProperty("YT Track", urls);
YT_TRACK = urls;
window.SetProperty("YT Track", urls);
}
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.title) urls.push(CLEAN_TRACK_NAME(data.title));
}

//Select urls
for (i = 0; i < urls.length; i++)

{
//Start with urls
if (urls > "")
do_youtube_search1(decodeURIComponent(p.artist), urls);
}
        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.href.indexOf("/_/")>0)

urls.push((data.href));
}

//Select urls
for (i = 0; i < 100; i++)

{
//Start with urls
if (urls.indexOf("http:")==0) return;
if (urls.indexOf("/_/") >0)
title_split = urls.split("/_/")[1].replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ");
artist_split = urls.split("/_/")[0].replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("about:/music/","").replace("noredirect/","");
set_focus5();//set focus on playlist
do_youtube_search1(decodeURIComponent(artist_split),decodeURIComponent(title_split));

}
this.doc.close();
} else {
p.console("HTTP error: " + this.xmlhttp.status);
}
}
}
}
}

//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.className.indexOf("name") == 0)
    if (data.href.indexOf("about:/music/") == 0) urls.push(CLEAN_GENRE_NAME(data.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
if (urls > "")
{
//p.console("" + urls);
SIM_ART = window.SetProperty("YT Similar", urls);
SIM_ART = urls;
window.SetProperty("YT Similar", urls);
}
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();}
                }
         }
      }
   }
}
//LOVED----------------------------------------------------
this.LOVED = function()
{
                //list files
                var arr = utils.Glob(folder + "\\*.*").toArray();
                var a = [];

                for (i = 0; i < arr.length; i++) {
                if (arr) a.push(arr); 
                    }
                //select random file
                var randomnumber = Math.floor(Math.random()*Math.max(arr.length));
                i=randomnumber;
               
                file_path = arr;
                var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath;
                var str = tmppath + "\\foobar2000.exe /add ";
                var go = str + '"' + file_path + '"';
               
                //load file
                set_focus6(); //Focus on playlist
                var tm = window.SetTimeout(function() {
                p.run(go);
                p.console(file_path);
                window.ClearTimeout™; tm = false;
                }, 50);   
}

//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));}
}

//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.href.indexOf("about:/watch?v=") == 0)
          {
                i++; //link

            //Find Title[OLD]
            /*{
            var st = text.indexOf( data.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("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&").replace("'", "'").replace("&quot;", "''").replace("&amp;", "&");
            //p.console("Title: " + Y_Title);
            }*/
           
            //Find Title[NEW]
            Y_Title = data.title;
            Remove_duration = Y_Title.substring(Y_Title.lastIndexOf(" - ")+1);
            Y_Title = data.title.replace(Remove_duration, "").trim();
            //p.console("Title: " + Y_Title);
               
            //Find minutes
            var s = text.indexOf( data.href.replace("about:/watch?", "") );
            var str = "<span class=\"video-time\" aria-hidden=\"true\">";
            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)

            {                 
            //Artist title stripped if same as search_artist
            var stripped_title = strip_title(Y_Title, this.search_artist);
            fir

WSH Panel Mod script discussion/help

Reply #4046
A copy of "common8.js" can be found pasted online here: http://pastebin.com/raw.php?i=Z9Ucp1hP


I've just updated my script, thanks for the share!

^that does nothing to solve the problem. even the last public version from this month doesn't work for playcount sync.

i've already posted how people can fix their own scripts. http://www.hydrogenaud.io/forums/index.php...st&p=893121


I don't know how I missed it. I got it working again, thank you marc2003. I felt like a man without balls without this script working in my foobar, now I'm a completed person.

WSH Panel Mod script discussion/help

Reply #4047
Submitting a panel that gets current album art from last.fm, which I use mainly for streams.

Extract rar to your profile folder.
In a new panel import lastfm_trackinfo_cover.txt
Right click panel and in properties add your last.fm api key.

http://goo.gl/r3kAOp




WSH Panel Mod script discussion/help

Reply #4048
i've made an update to br3tt's excellent JSplaylist.

https://github.com/marc2k3/jsplaylist-mod/r...es/tag/1.3.2mod

Quote
This mod updates JSplaylist to use a new method in my custom component so undo/redo
commands work from the Edit menu and keyboard shortcuts after adding/removing/reordering files.

This requires WSH panel mod v1.5.10 or above:

https://github.com/marc2k3/foo_uie_wsh_panel_mod/releases

All credit to br3tt for his original script which can be found here:

http://br3tt.deviantart.com/art/JSPlaylist-509803158

Installation instructions are the same as the original and can be found inside the wsh_br3tt folder.


my main changes can be viewed in this commit if br3tt/anyone wants to abuse me.

https://github.com/marc2k3/jsplaylist-mod/c...7345dc67c09f906

edit: although i forgot to mention it in the readme, this actually modifies 2 files in the wsh_br3tt folder and i've renamed them so you can extract them without touching the original files.

edit2: @falstaff, the reason i did this myself is because a) i'm impatient and b) i wasn't sure if you would be interested in implementing changes that required my unofficial component. if you want to use these changes or fix what you think i've broken then just let me know.

WSH Panel Mod script discussion/help

Reply #4049
Nice !!! Is it possible to have the "View/Show now playing" menu entry working?