Hydrogenaudio Forums

Hosted Forums => foobar2000 => 3rd Party Plugins - (fb2k) => Topic started by: mire777 on 2014-03-23 20:10:43

Title: Foobar Youtube Radio
Post by: mire777 on 2014-03-23 20:10:43
This is my first attempt to make Youtube Radio (based on youtube recommendation). It uses foo_youtube (http://www.hydrogenaudio.org/forums/index.php?showtopic=104379)
(Script is only for testing, you should be careful, for me works fine, but who knows, so backup your foobar before you go..).
*Thanks to Marc..

(http://s16.postimg.org/7x4h530bp/Capture.png)

How this work:

When you play video from youtube, it search recommended video from this page(example): http://www.youtube.com/watch?v=oYwL-FzFDKQ (http://www.youtube.com/watch?v=oYwL-FzFDKQ)
Then select random video from this list(on right), and send one(recommended) video to your playlist.
When first track is finished, foobar open new clip(this recommended video), trigger new, and so on..
You can specify in which playlist 'recommended videos' to be send. You can do this in: ''preferences>shell integration>always send new files to playlist''
If this field is uncheck, all files will be send in your active playlist.

You have option to:
-turn [on/off] ''Youtube Radio''(if you set 'off' you can manualy click on button and select: ''Get Next Video'' or ''Get All Videos'').

''Get All Videos''- will send all recommended videos to your playlist.
''Get Next Video'' - will send one random video to your playlist.
''Search Video'' - will open ''youtube source window'' where you can search for videos..


How to install:
You should first install Wsh plugin 1.5.6. ,
then download youtube buttons: https://www.mediafire.com/?x4n40mh48lpn183 (https://www.mediafire.com/?x4n40mh48lpn183)
put 'image' folder in foobar profile folder.
After that open new wsh panel and paste this script: http://pastebin.com/xadsrCdB (http://pastebin.com/xadsrCdB)

I would like to know if this is useful for you, i found many new artist with this script...
Title: Foobar Youtube Radio
Post by: musikomaniak on 2014-03-23 21:57:34
I had a complete crash of Foobar. Just after click on "Next videos", foobar freezed, mouse blocked and I had to restart Windows (7).
Opening foobar, all configuration was lost. Opening again, everything came back!
It happened on portable foobar.


It doesn't happen to me. What video you last played, when you click ''get next''?
This can be caused by url. Or for some reason foobar can't open that clip, and it stuck..

You can open: 3dydfy://www.youtube.com/ , 3dydfy://youtube.com/ , www.youtube.com/ , youtube.com/ , http://www.youtube.com/ (http://www.youtube.com/) .

Foo_youtube, changes some url's when adding clips, so this can be reason.
When script looks in the url and cant open, it stuck..

I don't remember which video was on. I had made a search, using your script, then I listened to one and clicked to next and...crash! All logs and history have disappeared.
I just made a search again and anything went ok.

I did not understand what happens when YouTube radio is checked.
Title: Foobar Youtube Radio
Post by: mire777 on 2014-03-24 08:54:27
I had a complete crash of Foobar. Just after click on "Next videos", foobar freezed, mouse blocked and I had to restart Windows (7).
Opening foobar, all configuration was lost. Opening again, everything came back!
It happened on portable foobar.


It doesn't happen to me. What video you last played, when you click ''get next''?
This can be caused by url. Or for some reason foobar can't open that clip, and it stuck..

You can open: 3dydfy://www.youtube.com/ , 3dydfy://youtube.com/ , www.youtube.com/ , youtube.com/ , http://www.youtube.com/ (http://www.youtube.com/) .

Foo_youtube, changes some url's when adding clips, so this can be reason.
When script looks in the url and cant open, it stuck..

I don't remember which video was on. I had made a search, using your script, then I listened to one and clicked to next and...crash! All logs and history have disappeared.
I just made a search again and anything went ok.

I did not understand what happens when YouTube radio is checked.


I repeat all you done, search for video, open in playlist>click 'Get Next'.. All ok.
If i don't know what happen in that point, then i can't fix this.
You should have saved ''crash report'' somewhere in foobar folder...
In console script saves message what video is open: Youtube Radio: <video url>.
Title: Foobar Youtube Radio
Post by: musikomaniak on 2014-03-24 09:32:58
I repeat all you done, search for video, open in playlist>click 'Get Next'.. All ok.
If i don't know what happen in that point, then i can't fix this.
You should have saved ''crash report'' somewhere in foobar folder...
In console script saves message what video is open: Youtube Radio: <video url>.


I'll do next time. I hope, never
Title: Foobar Youtube Radio
Post by: Robertina on 2014-03-24 12:35:28
FWIW: crash reports are stored automatically into a fb2k subdirectory.

You wouldn't have to wait for a program crash's reoccurring if you want to analyze the past one.
Title: Foobar Youtube Radio
Post by: mire777 on 2014-03-24 13:37:34
New version 0.0.3. Now you have possibility to stop when clicking on ''Get All Videos''. Just click: ''Abort''.
It adds 20 - 100 tracks in playlist, so be patient until it finish.
http://pastebin.com/ZMZgDU0v (http://pastebin.com/ZMZgDU0v)
Title: Foobar Youtube Radio
Post by: musikomaniak on 2014-03-24 14:40:47
I'll try your new version.
10 minutes ago I had the message "Aw, crashed :-(" while installing the script on my Foobar installed in program files.
Code: [Select]
Scripting Engine Initialization Failed (Youtube Radio by Mire777, CODE: 0x80020101)

Code: [Select]
Error: WSH Panel Mod (Youtube Radio by Mire777): Erreur d'exécution Microsoft JScript:
Un composant ActiveX ne peut pas créer un objet
File: <main>
Ln: 1483, Col: 13
<source text only available at compile time>
Error: WSH Panel Mod (Youtube Radio by Mire777): Erreur d'exécution Microsoft JScript:
Un composant ActiveX ne peut pas créer un objet
File: <main>
Ln: 1483, Col: 13
<source text only available at compile time>
Podcatcher: Auto-archiving old un-downloaded casts.


EDIT
Same error with last script
Code: [Select]
Error: WSH Panel Mod (Youtube Radio by Mire777): Erreur d'exécution Microsoft JScript:
Un composant ActiveX ne peut pas créer un objet
File: <main>
Ln: 1483, Col: 13
<source text only available at compile time>
Title: Foobar Youtube Radio
Post by: musikomaniak on 2014-03-24 16:12:42
I found where the error came! Safe Mode was checked!
Title: Foobar Youtube Radio
Post by: mire777 on 2014-03-24 16:42:26
I found where the error came! Safe Mode was checked!


Yes, uncheck safe mode.
Title: Foobar Youtube Radio
Post by: musikomaniak on 2014-03-24 17:13:13
Here it is  I discover a lot of music!
(http://i.imgur.com/h75xywS.png)

When I make a search, all the Youtube videos present in my Youtube Tab disappear. How would it possible to keep them? I mean video previously added using Add YouTube URL's
Title: Foobar Youtube Radio
Post by: mire777 on 2014-03-24 17:51:19
Here it is  I discover a lot of music!
..

Don't know what you exactly mean. You must configure search tab well, right click>hold ctrl key>add to current playlist and play.
If you don't select this, then all your playlist entry will be deleted, when adding new file..
Title: Foobar Youtube Radio
Post by: musikomaniak on 2014-03-24 19:42:33
Don't know what you exactly mean. You must configure search tab well, right click>hold ctrl key>add to current playlist and play.
If you don't select this, then all your playlist entry will be deleted, when adding new file..


I did not about right click>hold ctrl key. Thanks
I suppose everybody knows!
I did so, but the video go always to default tab, so I drag it on Youtube tab.
Title: Foobar Youtube Radio
Post by: mire777 on 2014-03-24 20:31:04
Don't know what you exactly mean. You must configure search tab well, right click>hold ctrl key>add to current playlist and play.
If you don't select this, then all your playlist entry will be deleted, when adding new file..


I did not about right click>hold ctrl key. Thanks
I suppose everybody knows!
I did so, but the video go always to default tab, so I drag it on Youtube tab.


If you talk about script, then.. preferences>shell integration>always send new files to playlist.
Enter your playlist there.. Or Uncheck that, so script will use your active playlist..
If ''youtube tab'' is active all files from 'script search' go there..
For other don't now..
Title: Foobar Youtube Radio
Post by: musikomaniak on 2014-03-28 12:19:07
Mire777, if you have time, could you make your YT images for white background?
I'm using it on a new skin (Lure) with white backround.
Title: Foobar Youtube Radio
Post by: mire777 on 2014-03-28 17:42:24
Mire777, if you have time, could you make your YT images for white background?
I'm using it on a new skin (Lure) with white backround.



Well.. Don't know what you like? Something like this? :

(http://s23.postimg.org/v8t7ts03b/youtube0.png)

(http://s17.postimg.org/6l05clxgr/youtube02.png)

(http://s27.postimg.org/jyw7zs6i7/youtube02.png)
Title: Foobar Youtube Radio
Post by: musikomaniak on 2014-03-28 19:13:15
Yes. Thank you
I cannot try now because I did not become more clever from last days. I made something wrong adding the script in the wrong place, so I loosed the volume image existing! I'm installing again the new skin...

Fortunately on the stable foobar I have a bigger Youtube image with colours.
Title: Foobar Youtube Radio
Post by: WilB on 2014-03-29 11:26:23
I have now been using the script for about a week and find it useful and that it mostly works well. I suppose the search algorithm may be improved, e.g. sometimes it gets mostly stuck on finding tracks by the same artist or rotating a few and sometimes returns full albums rather than individual tracks - I was thinking in terms of the variety that foo_lastfm_radio used to offer. In fact I originally thought you were going to use lastfm recommendations.
Title: Foobar Youtube Radio
Post by: mire777 on 2014-03-29 20:21:06
I have now been using the script for about a week and find it useful and that it mostly works well. I suppose the search algorithm may be improved, e.g. sometimes it gets mostly stuck on finding tracks by the same artist or rotating a few and sometimes returns full albums rather than individual tracks - I was thinking in terms of the variety that foo_lastfm_radio used to offer. In fact I originally thought you were going to use lastfm recommendations.


Well, i've already made last.fm radio(separately from this script), and it works..
But this is not perfect..

I'v previously wanted to have last.fm recommendation metod in youtube radio.
But there are certain problems with that.
Last.fm site doesn't have 'static html' response(as i previously think), when my script open last.fm radio page, i don't have nothing i can use as recommendation.
I don't have even a <title>.

If u want to have recommendation from there, you must have open browser, log in there, and start radio, then script can use recommendation.
This is how works..
Last.fm radio must stay open in browser for that..
But there you also have problem, you can't get next track, untill previous track is not finished.
Also if you have last.fm scrobbler, you must turn it off or set that looks only for tracks in library..

I applied this to youtube radio (merge 2 script), tested and this work, but, as i said this is not perfect..

Alternative metod is to use this page as recommendation: http://www.last.fm/music/Madonna/_/Like+a+Prayer/+similar (http://www.last.fm/music/Madonna/_/Like+a+Prayer/+similar)
When YT tracks is open in foobar it look's for simmilar songs..
Problem is that YT clips doesn't always have tags in format: %artist% - %title%. Somethimes it doesnt have nothing. In that case this can't be used..
And radio will stop..

For now, my idea is that you have box, vere you type: %artist% - %title% , then script can play simmilar tracks based on what you gave as start point.
Then looks at this page: http://www.last.fm/music/Madonna/_/Like+a+Prayer/+similar (http://www.last.fm/music/Madonna/_/Like+a+Prayer/+similar) , select random tracks from there: .. open new, and so on..
But this isn't youtube radio, rather this is some hibrid..

The fact is that YouTube recommendation method is not perfect(this is what my script use), and i must find something other..
Think to apply this youtube radio I'v already made, but..

If you have any suggestions they are welcome..
Title: Foobar Youtube Radio
Post by: WilB on 2014-03-30 00:09:10
One possibility that came to mind is echonest. It looks like you can get lists of similar artists and their songs according to hotness. There is also API: Similar artist radio – generate a playlist of songs by similar artists. These would need to be set up so that they return all music, i.e. not restricted to music in media library. So a list or playlist or something could be generated, then pick artist-title from that, with bias towards more popular songs if wish, for youtube searching. I presume this could be done in wsh panel mod since other echonest searches can be. There is already an echonest plug-in, http://www.hydrogenaudio.org/forums/index....st&p=855224 (http://www.hydrogenaudio.org/forums/index.php?s=&showtopic=104228&view=findpost&p=855224), but I think this is restricted to generating playlists of music in media library like softplaylists does with lastfm.

HTH or at least provides something to think about.
Title: Foobar Youtube Radio
Post by: mire777 on 2014-03-30 04:21:10
One possibility that came to mind is echonest. It looks like you can get lists of similar artists and their songs according to hotness. There is also API: Similar artist radio – generate a playlist of songs by similar artists. These would need to be set up so that they return all music, i.e. not restricted to music in media library. So a list or playlist or something could be generated, then pick artist-title from that, with bias towards more popular songs if wish, for youtube searching. I presume this could be done in wsh panel mod since other echonest searches can be. There is already an echonest plug-in, http://www.hydrogenaudio.org/forums/index....st&p=855224 (http://www.hydrogenaudio.org/forums/index.php?s=&showtopic=104228&view=findpost&p=855224), but I think this is restricted to generating playlists of music in media library like softplaylists does with lastfm.

HTH or at least provides something to think about.


I will try echonest..
But think that i can do this with last.fm..
Make some search box, where you type artist.
Ex. ''Florence + the Machine'' > http://www.last.fm/music/Florence+%252B+the+Machine/+similar (http://www.last.fm/music/Florence+%252B+the+Machine/+similar)
Then pick some random artist from there, and search for tracks > http://www.last.fm/music/Ellie+Goulding/+tracks (http://www.last.fm/music/Ellie+Goulding/+tracks)
Pick random track > search youtube video, and open in foobar..

Stay on that page, or:

Open another page > http://www.last.fm/music/Ellie+Goulding/+similar (http://www.last.fm/music/Ellie+Goulding/+similar)
Pick random artist, and search for tracks > http://www.last.fm/music/Lorde/+tracks (http://www.last.fm/music/Lorde/+tracks)
Pick random track > search youtube video, and open in foobar..

Only thing, don't know if this will work as last.fm radio..
And it's little tricky to open multiple pages in same time.

Anyway i will do something with this..
Title: Foobar Youtube Radio
Post by: mire777 on 2014-03-30 07:30:21
New version: http://pastebin.com/LwdynFk8 (http://pastebin.com/LwdynFk8)

Added menu option:

-Open Artist+Title (good if you want to start radio from selected 'artist' in playlist)
-Open In Browser (will search 'artist+title' in browser on youtube)
Title: Foobar Youtube Radio
Post by: mire777 on 2014-03-31 22:56:23
I Made quick test to implement last.fm recommendation in 'youtube'.
For now everything works fine. Seems it works identical as last.fm radio on web.
Except one.. It's little slower, because script opens 3 web pages(these pages can't be open in same time)..
So next track is available after 30sec playing first track.

It uses metod i described in previous post..
You type artist and script play simmilar artist and songs..
It use random metod.

------------------------------------------------------------------
I have some erors too(if someone can help me)...

Html is in format:

Code: [Select]
<div>
      <a href: ''/music/madonna''


But also have some unaceptable strings:
example:

Code: [Select]
<div>
      <a href: ''/music/http://www.cbs.interactive.com''

or:

<div>
       <li>
           <a href: ''/music/ramones/+images(+videos, +events, +wiki... etc..)


I have replace these strings with ('' ''). But in that case, i recieve:

/music/

Whitch refers me to nothing, and as result i have HTTP: error 404.(not found).
When script not found next track, it plays previous again. This is problem.

I use '/music/' to identify which tags to read, i can not know whether after this is be something that is not artist.
These tags must be skipped completly, from read, to avoid 404..
I apreciate if someone can help, and has solution for this, to skip these tags completly..


Pages i use are:
http://www.last.fm/music/Ramones/+similar (http://www.last.fm/music/Ramones/+similar)
http://www.last.fm/music/Ramones/+tracks (http://www.last.fm/music/Ramones/+tracks)


*Edit:
Going more deeply seems that these tags are before ''artist'' tags, so i assume i can ignore them with specify random numbers from max-min.
Title: Foobar Youtube Radio
Post by: WilB on 2014-04-01 17:10:24
It seems you solved your issue above.

But I was wondering why you don't use the Similar Artist Radio functionality of echonest? It already seems to return what you want, e.g. see here http://developer.echonest.com/raw_tutorial...api/static.html (http://developer.echonest.com/raw_tutorial...api/static.html) and here http://developer.echonest.com/raw_tutorial...pi/dynamic.html (http://developer.echonest.com/raw_tutorials/playlist_api/dynamic.html). I tested it and it works in wsh panel mod. It will be considerably faster than how you are trying to do it with much the same result. All you need to do is to process the json array, and search youtube for the resulting artist – title combinations. Job done! I think your script already has the json_parse functions in it.

HTH
Title: Foobar Youtube Radio
Post by: musikomaniak on 2014-04-01 19:40:22
For me its works ok. I do not use Last.fm and cannot tell you more about technical details.
When I click on open 'Artist + Title', the same video appears (normal ?)

I don't know why on a portable install with a skin from russian foobar in search I cannot type two words. The space bar does not work. For example 'english song'. But it's not really a problem. I don't speak russian and cannot ask them
Title: Foobar Youtube Radio
Post by: mire777 on 2014-04-01 22:53:15
It seems you solved your issue above.

But I was wondering why you don't use the Similar Artist Radio functionality of echonest? It already seems to return what you want, e.g. see here http://developer.echonest.com/raw_tutorial...api/static.html (http://developer.echonest.com/raw_tutorial...api/static.html) and here http://developer.echonest.com/raw_tutorial...pi/dynamic.html (http://developer.echonest.com/raw_tutorials/playlist_api/dynamic.html). I tested it and it works in wsh panel mod. It will be considerably faster than how you are trying to do it with much the same result. All you need to do is to process the json array, and search youtube for the resulting artist – title combinations. Job done! I think your script already has the json_parse functions in it.

HTH


Don't know about echonest? I was trying this demo: http://static.echonest.com/demo/dynamic/dynamic.html (http://static.echonest.com/demo/dynamic/dynamic.html)

Type 'madonna' there, and it returns me the same artist again and again. Last.fm doesn't do this.
It going more deeply. It has 17 pages of diferent artist, maybe more..
Same artist never repeat, or at least, this happen very rarely..

I never try echonest api, this code you see is previously left from (marc2003 script- modified by me),  i used this as a start.
So if i want to do this, then i must to learn first how to use json.
With html is easy..


If you have working code, then all you have to do is to merge these 2 scripts, and your done.
I can do this if you have script..

But my experiance with this demo is bad.
If this work like this, then even youtube recommendation is much better than this..

------------------------------------------------------------------------------------------------
Musikomaniak:

'Open Artist+Title' > will open the same video in your playlist.
If you ex. have song in mp3 format in normal playlist, you can click on this and you will receive video > from where you can start radio for that artist.
It is better than type in search box for same artist..
Or if you listen radio stream, you can also click on this, and you will receive video for that song, which you can downlad later as mp3 
This is because it is added.
Title: Foobar Youtube Radio
Post by: WilB on 2014-04-01 23:32:17
Oh well if you think there's too much duplication then it's not a good way. But I tried this:
url = "http://developer.echonest.com/api/v4/playlist/static?api_key=ENTERHERE&artist=madonna&type=artist-radio&results=100" Out of 100 tracks there were 13 by Madonna, may be a similar ratio to what foo_lastfm_radio used to give.
Title: Foobar Youtube Radio
Post by: mire777 on 2014-04-01 23:40:01
Oh well if you think there's too much duplication then it's not a good way. But I tried this:
url = "http://developer.echonest.com/api/v4/playlist/static?api_key=ENTERHERE&artist=madonna&type=artist-radio&results=100" Out of 100 tracks there were 13 by Madonna:


I think it's not good way. I can't open this now, because i'm on work, so i dont have my api here with me.
Problem is not to open this in wsh , but how to use json or xtml?
I never try this.

One thing, does playlist change on every call, or remains the same?
I think, see how much duplicates you have, and does new artist appear?
For static u use playlist is limited up to 100.
Last.fm has at least 204 artist.


Edit:

You must use dynamic to have unlimited acces playlist, on echonest..
Maybe this: http://developer.echonest.com/api/v4/playl...pe=artist-radio (http://developer.echonest.com/api/v4/playlist/dynamic/create?api_key=FILDTEOIK2HBORODV&artist=weezer&type=artist-radio)
Title: Foobar Youtube Radio
Post by: mire777 on 2014-04-02 00:46:17
Ok i open this with my api: http://developer.echonest.com/api/v4/playl...amp;results=100 (http://developer.echonest.com/api/v4/playlist/static?api_key=YOUR_API&artist=madonna&type=artist-radio&results=100)

I see it rotating same artist again and again, as i see in demo..
All is the same..
Title: Foobar Youtube Radio
Post by: WilB on 2014-04-02 18:52:23
I don't seem to see it like that.

Yes demo always gives as first artist one you type, but the list that follows has different artists.

May be we are aiming for different things.

Any way I did get it working with echonest as the source, as you did not seem keen on this method.

It uses one call to echonest for 100 tracks and a youtube search on track change.

You can see the results I get from the results of two searches for madonna similar artists radio below.

It seems reasonably similar to how I remember foo_lastfm_radio.

It will be interesting to compare it with your way.

You can also apparently change the variety of artists and song_hotness returned, but I haven't tried that.
Code: [Select]
RESULT 1 echonest madonna similar artists radio
  Madonna Don't Tell Me,Céline Dion Because You Loved Me,Gloria Estefan Mi Tierra,P!nk Try,Emma Bunton A World Without You,Cyndi Lauper Time After Time,Kelly Osbourne Come Dig Me Out,Annie Lennox A Whiter Shade Of Pale,Madonna Sorry,Darren Hayes Explode,Sophie Ellis-Bextor Get Over You,Gwen Stefani Cool,Tiffany I Think We're Alone Now (Re-Recorded / Remastered),Rihanna Pour It Up (Explicit),Dannii Minogue You Won't Forget About Me,Janet Jackson That's The Way Love Goes,Madonna Die Another Day,Cher Woman's World,Spice Girls Who Do You Think You Are,Kim Wilde You Came (2006 - Album Version),Kelly Osbourne Shut Up,Cyndi Lauper True Colors,Melanie C Never Be The Same Again,Kylie Minogue If Only,Madonna Girl Gone Wild,Rachel Stevens I Said Never Again (But Here We Are),Taylor Dayne I'll Always Love You,Natalie Imbruglia Wrong Impression,Darren Hayes Black Out The Sun,Spice Girls Spice Up Your Life,Emma Bunton What Took You So Long,Martika Cross My Heart,Madonna Open Your Heart,Christina Aguilera Beautiful,Britney Spears Work B**ch,Paula Abdul Knocked Out (Single Version),Gwen Stefani Rich Girl,Martika Flow With the Go,Spice Girls Goodbye,Sophie Ellis-Bextor Catch You,Madonna Papa Don't Preach,Kylie Minogue Kiss Me Once,Cyndi Lauper She Bop,Melanie C Northern Star,Jennifer Lopez On The Floor,Rihanna We Found Love,Dannii Minogue All I Wanna Do,Robbie Williams Go Gentle,Madonna Frozen,Paula Abdul Vibeology,Kylie Minogue Get Outta My Way,Spice Girls Holler (Album Version),Kelly Osbourne Contradiction,Michael Jackson Thriller,Paula Abdul Forever Your Girl (Single Version),Madonna Like A Virgin,Darren Hayes I Miss You,Britney Spears Toxic,Kim Wilde Kids In America,Emma Bunton What I Am,Kelly Osbourne Uh-Oh,Madonna Like A Prayer,Roxette The Look,Cathy Dennis Touch Me (All Night Long),Geri Halliwell It's Raining Men,Emma Bunton High On Love,Cyndi Lauper Girls Just Want To Have Fun,Lady Gaga Applause,Melanie C Think About It,Madonna 4 Minutes,Darren Hayes Stupid Mistake,Sophie Ellis-Bextor Runaway Daydreamer,Gwen Stefani The Sweet Escape,Kylie Minogue Into The Blue,Rihanna What Now,Kelly Osbourne One Word,Taylor Dayne Tell It To My Heart,Madonna Take A Bow,Spice Girls 2 Become 1 (Single Version),Martika Toy Soldiers (Single Version),Belinda Carlisle Leave A Light On,Cyndi Lauper I Drove All Night,Melanie C Weak,Cher Strong Enough,Madonna Music,Christina Aguilera Your Body,Belinda Carlisle I Get Weak,Taylor Dayne Love Will Lead You Back,Cher Believe,Spice Girls Too Much,Emma Bunton Downtown (Single Version),Martika Love...Thy Will Be Done (Single Version),Madonna Live To Tell,Christina Aguilera Fighter,Paula Abdul Cold Hearted,Gwen Stefani Hollaback Girl,Robyn Dancing On My Own,Kylie Minogue Fine,Spice Girls Stop,Sophie Ellis-Bextor Young Blood
 
  RESULT 2 echonest madonna similar artists radio
  Madonna Like A Prayer,Gwen Stefani Cool,Cyndi Lauper She Bop,Cher You Haven't Seen The Last Of Me,Taylor Dayne Don't Rush Me,Tiffany Here In My Heart,All Saints Never Ever,Britney Spears Gimme More,Madonna Hung Up,Jennifer Lopez I Luh Ya Papi,Céline Dion It's All Coming Back To Me Now,Lady Gaga G.U.Y.,Robyn Cobrastyle,Kylie Minogue Sexy Love,Roxette It Must Have Been Love,Janet Jackson What Have You Done For Me Lately,Madonna True Blue,Cher I Hope You Find It,Kim Wilde Cambodia,Natasha Bedingfield These Words,Kylie Minogue Kiss Me Once,Anastácia Paid My Dues,Cathy Dennis Touch Me (All Night Long),Gloria Estefan Mi Tierra,Madonna La Isla Bonita,Melanie C First Day Of My Life,Cyndi Lauper True Colors,Christina Aguilera Genie In A Bottle,Taylor Dayne I'll Be Your Shelter,Natalie Imbruglia Torn,Lady Gaga Poker Face,P!nk Raise Your Glass,Madonna Material Girl,Robyn Call Your Girlfriend,Cher Take It Like A Man,Sophie Ellis-Bextor Runaway Daydreamer,P!nk Try,Gwen Stefani Luxurious,Annie Lennox Why,Céline Dion I'm Alive,Madonna Take A Bow,Kylie Minogue Love At First Sight,Ashlee Simpson L.O.V.E.,Janet Jackson That's The Way Love Goes,Britney Spears Criminal,Lady Gaga Bad Romance,Melanie C I Turn To You,Gwen Stefani What You Waiting For?,Kim Wilde Kids In America,Madonna Don't Tell Me,Robyn Konichiwa Bitches,Cher Woman's World,Britney Spears Oops!...I Did It Again,Dannii Minogue I Begin To Wonder,Roxette Listen To Your Heart,Taylor Dayne Love Will Lead You Back,Madonna Sorry,Britney Spears Perfume,Kylie Minogue Into The Blue,Cyndi Lauper The Goonies 'R' Good Enough,Martika Toy Soldiers (Single Version),Madonna 4 Minutes,Cher Gypsies, Tramps And Thieves,Kelly Osbourne One Word,Taylor Dayne Tell It To My Heart,Gwen Stefani Early Winter,Sophie Ellis-Bextor Young Blood,Britney Spears Circus,Madonna Live To Tell,Jennifer Lopez On The Floor,Christina Aguilera Beautiful,Céline Dion That's The Way It Is,Lady Gaga Do What U Want,Robyn Be Mine!,Kylie Minogue Sexercize,Roxette The Look,Cyndi Lauper I Drove All Night,Madonna Ray Of Light,Cher The Shoop Shoop Song (It's In His Kiss),Darren Hayes Bloodstained Heart,Janet Jackson If,Kylie Minogue I Was Gonna Cancel,t.A.T.u. All The Things She Said,Kim Wilde You Keep Me Hangin' On,Madonna Die Another Day,Cyndi Lauper All Through The Night,Christina Aguilera Hurt,Taylor Dayne Can't Get Enough Of Your Love,Melanie C Never Be The Same Again,P!nk Just Give Me a Reason,Madonna Holiday,Robyn Dancing On My Own,Natalie Imbruglia Wrong Impression,Darren Hayes Black Out The Sun,P!nk So What
 
Title: Foobar Youtube Radio
Post by: marc2003 on 2014-04-02 23:09:37
use this to get upto 100 videos for a given artist. not all are youtube so you'll need to check the urls.

http://developer.echonest.com/docs/v4/artist.html#video (http://developer.echonest.com/docs/v4/artist.html#video)

use this to get 100 similar artists to your search term. with the bucket parameter set to video, you can get upto 15 videos per artist. that's potentially 1500 links in a single page request. ok, not all will be youtube but i bet the majority are.

http://developer.echonest.com/docs/v4/artist.html#similar (http://developer.echonest.com/docs/v4/artist.html#similar)

Title: Foobar Youtube Radio
Post by: mire777 on 2014-04-03 11:54:09
I don't seem to see it like that.

Yes demo always gives as first artist one you type, but the list that follows has different artists.

May be we are aiming for different things.

Any way I did get it working with echonest as the source, as you did not seem keen on this method.

It uses one call to echonest for 100 tracks and a youtube search on track change.

You can see the results I get from the results of two searches for madonna similar artists radio below.

It seems reasonably similar to how I remember foo_lastfm_radio.

It will be interesting to compare it with your way.

You can also apparently change the variety of artists and song_hotness returned, but I haven't tried that.



This is my 100 response for madonna from last.fm:

------------------------------
Toni Braxton - Yesterday
The Sound of Arrows - Longest Ever Daydream
Madonna - Spanish Eyes
Madonna R&D - Nothing fails (Re-Invention Studio)
Heidi Montag - Party Is Wherever I Am
Kylie Minogue - Into The Blue
Ellie Goulding - Lights (Remix)
Madonna - I'm So Stupid
Madonna & Antonio Banderas - Buenos Aires
Kylie Minogue - Wouldn't Change a Thing
Christina Aguilera - Come On Over Baby
Madonna R&D - Falling Free (Orbit Remix)
Little Boots - Symmetry
Cher - You Know It
Laura Branigan - Looking Out For Number One
Jennifer Lopez - Get Right
Gwen Stefani - New
Infernal - Under the Hellsing
Cyndi Lauper - High And Mighty (Tom Novy Mix)
P!nk - Leave Me Alone (I'm Lonely)
Loreen - We Got The Power (Klass Fm)
The Saturdays - Notorious (All Fired Up Tour Live 2011)
Spice Girls - 2 Become 1 (Album Version)
Madonna - Intervention
Alicia Keys - Girl On Fire Inferno
P!nk - Perfect
Adele - Daydreamer Live At Hotel Cafe
Taylor Dayne - The Door to Your Heart
Madonna - Girl Gone Wild (Dada Life Remix)
Lady Gaga - Do What U Want - DJ White Shadow Remix
Daniela Mercury - Pensar Em Voce
Melanie C - Something's Gonna Happen
The Pussycat Dolls - I Hate This Part (Digital Dog Edit)
Sophie Ellis-Bextor - Bittersweet (with The Freemasons)
Kelis - Bossy (Alan Braxe & Fred Falke Earth Out Remix)
Gwen Stefani - The Sweet Escape ft. Akon
P!nk - It's All Your Fault
Grace Jones - Annihilated Rhythm
Janet Jackson - Work
Atomic Kitten - Someone Like Me (Rockamerica Remix)
Jessica Simpson - Where You Are Going (Feat. Nick Lachey)
Ashlee Simpson - Love Makes The World Go 'Round
Charli XCX - Super Love
Madonna - Ray Of Light
Paloma Faith - Picking Up The Pieces
Marta SAnchez - Desconocida
Blondie - War Child
Aaliyah - We need a resolution
Sandra - Everlasting Love
Avril Lavigne - rock n roll
A*Teens - A Teens Mamma Mia
Belinda Carlisle - Fool For Love - 2009 Digital Remaster
Blondie - Atomic
Alcazar - Not a Sinner, nor a Saint
Melanie C - You'll Get Yours
Donna Summer - If You Got It Flaunt It
Lorena Simpson - Brand New Day
Annie - Bongo Song (Zongamin)
Fergie - A little party never killed nobody
Vanessa da Mata - Ai, Ai, Ai
David Guetta - I Junt Wanna F. (David Guetta And Afrojack, Timbaland, Dev)
Mariah Carey - I'll Be There
Mariah Carey - Can't Let Go
Kylie Minogue - Get Outta My Way
Janet Jackson - I Get Lonely
Ashlee Simpson - L.O.V.E. (Remix)
RuPaul - Diesel Pancake Makeup (Interlude)
Cyndi Lauper - Hymn to love (bonus)
Iggy Azalea - 1 800 Bone
Jennifer Hudson - Think Like A Man (Feat. Rick Ross)
The Pussycat Dolls - Jai Ho (DJ Fisun extended mix)
Nelly Furtado - Waiting For The Night
Florrie - You Wanna Start Something
Frankmusik - 09 Brake Lights
Stacey Q - The Model
Mirwais - Production
Mika - Everybody's Talkin
Sophie Ellis-Bextor - Bittersweet
Jennifer Lopez - I'm Real
The Pussycat Dolls - Don't Cha ft. Busta Rhymes
Kid Abelha - Na Rua, Na Chuva Na Fazenda
Madonna - Turn Up The Radio (Offer Nissim Remix)
Lady Gaga - Speechless
Nicole Scherzinger - Right There ft. 50 Cent
Diana Vickers - Smoke
Destiny's Child - Cant Help Myself
Deee-Lite - Picnic in the Summertime
Alicia Keys - Go Ahead
Loreen - My Heart Is Refusing Me
Jennifer Lopez - Jenny From The Block
Madonna - Forbidden Love
Ke$ha - Boots & Boys
Robyn - Call Your Girlfriend
Gloria Estefan - No Me Dejes de Querer
Paulina Rubio - Ni Una Sola Palabra
Goldfrapp - Believer
Marina & the Diamonds - Primadonna
Sarah Brightman - Alone Again Or
Deborah Harry - The Jam Was Moving
Nicki Minaj - Click Clack
Lena Katina - Lost in this dance
Melanie C - When You're Gone (Electric)
Kelly Clarkson - Miss Independent
Gaby Amarantos - Chuva
The Sound of Arrows - Wonders (VISITOR Remix)
Garbage - Milk
Laura Pausini - Inolvidable
Havana Brown - Flashing Lights
Cazwell - Tonight (Craig C's Master Blaster)
Frankmusik - 1A
Annie Lennox - Waiting on broken glass
Ciara - Love Sex Magic
Selena Gomez - Come & Get It
Lindsay Lohan - Confessions Of A Broken Heart
Madonna - What It Feels Like for a Girl
Ariana Grande - Almost Is Never Enough Ft. Nathan Sykes
Vanessa da Mata - Cuide-se Bem
Grace Jones - Pull Up To The Bumper
Havana Brown - Big Banana
Whigfield - Saturday Night
Infernal - Keen On Disco
Sarah Brightman - Who Wants To Live Forever
Sky Ferreira - One - Bar9 Remix
Nicole Scherzinger - Rio
Rouge - Ragatanga
--------------------------

Seems that madonna is not good example(in both cases), as it not have so much artist.
It probably depends on the station you chose.
When i open ''Carrie Lucas'' station, artist doesn't repeat. I listen 6 hours that station, and i found many artist i didn't know.
Maybe both methods are the same..

If you already get it working with echonest, and it works well, then you can paste your script here.
There is no need for me to make something else.
I thought to keep both methods, from(last.fm or echonest) and youtube.
Title: Foobar Youtube Radio
Post by: WilB on 2014-04-03 18:36:22
@marc2003 – thanks for the tips. As you suggested, 100 similar artists to search term can be obtained from echonest by doing an artist/similar search, and with the bucket parameter set to video, upto 15 videos per artist can be obtained that amounts to 1500 in total. I have this working. The advantage is that it directly gives the youtube link so there is just a single internet search. The disadvantage seems to be that always the same 15 tracks are returned for any one artist (and not necessarily the best tracks) – at least that what my tests have shown so far. I don't know if this can be changed.

So although I have an open mind, the similar artists radio method seems better even though it involves extra internet searches. I haven't tried your other suggestion since searches for a given artist are already handled by the foo_youtube plug-in.

@mire777 – I will let you have a script in due course.
Title: Foobar Youtube Radio
Post by: mire777 on 2014-04-04 13:57:43
@WilB

If you want to compare, these 2 metods..
This is pretty dirty script with last.fm.
You can test..
Just select: 'Start Radio' and type artist.

http://pastebin.com/h4RsU7Py (http://pastebin.com/h4RsU7Py)

It has problem, sometimes if artist doesn't have tracks, radio will stop. Or you will receive ''undefined' video.
In that case click ''Get Next Video''.
Title: Foobar Youtube Radio
Post by: mire777 on 2014-04-09 11:40:27
New version 'Youtube Radio 0.0.5.'
It now use last.fm 'recomendation' metod, to play your personal ''artist'' radio station.

It first search for similar artist on last.fm> then open track page> find track on youtube > and play in foobar.
For all this it use random metod, in that way track doesn't repeat.
It works in same way as last.fm radio on their website.(i think)
I'm very happy with this version..


(http://s28.postimg.org/8mnzm6mhp/Capture.png)


To start radio, you just select: ''Start Artist Radio'' > this will open dialog box where you type desired ''artist''.
Then radio will open (1) video in playlist, and when you click ''play''> it automatically opens new track.

You can:

Turn radio[on/off].


- Get Next Video

- Search Videos >(this will open 'youtube source window' with ''search'' )

- Start Artist Radio >(will open dialog box where you type ''artist'' station)

- Same artist radio >(will start ''artist radio'' for same 'artist' you selected in playlist)

- Open Same Video >(will open 'same video' you play or focus on it- from your playlist in foobar' [useful if you play radio stream and want's to download track])

- Find in Browser >(will search for same video in browser)


Link for download: http://pastebin.com/BTapaijn (http://pastebin.com/BTapaijn)
Title: Foobar Youtube Radio
Post by: musikomaniak on 2014-04-09 13:01:47
I don't really know if I'm happy...
While listening to singer Adele, I clicked on "Same artist radio" and it found:
Of monsters and men
Cazuza
and others!
Title: Foobar Youtube Radio
Post by: mire777 on 2014-04-09 17:45:49
I don't really know if I'm happy...
While listening to singer Adele, I clicked on "Same artist radio" and it found:
Of monsters and men
Cazuza
and others!


Well, this is how it work, it find similar artist and songs, based on this what you listen. This also does previous script but this is more efective. If you don't like what you hear, you can click 'get next'. Or change station. Example enter artist: Cher.
You dont have to click: ''Same Artist'' again, you click 'Get Next'.
Give this time to find good station you like...
It works exactly like last.fm radio on their site...
Title: Foobar Youtube Radio
Post by: musikomaniak on 2014-04-09 18:02:55
It did not find similar artists. The click is named : "Same artist"
Sorry, I prefere the previous version, very simple and working ok for me. (I do not use last.fm)
Surely you will continue to work to make the best one with many other functions.
Will it possible to choose a basic version?
Title: Foobar Youtube Radio
Post by: mire777 on 2014-04-09 18:34:52
You can use then previous vesion. But this is better. I can ofer both metod in one script. but.. You dont use: ,same artist' to find new one. Script do this on ,get next' or while you playing. It is strange that you didnt find similar artist and songs. Because this metod is more efective than previous
Title: Foobar Youtube Radio
Post by: mire777 on 2014-04-12 09:37:27
New version, ,,Foobar Youtube Radio 0.0.6.'' : http://pastebin.com/QdjNhAaN (http://pastebin.com/QdjNhAaN)

Changes:
In previous ver. if 'artist' has less than 50 songs on page, it use random num. to find track(num. from 0 to 50).
So if artist has 15 song, and 'selected' random number is greater, example: 30 , it can't find track.
Then this artist is skipped, and script go to next...
In that case, in console you will see: ''undefined''.

Now script first check how many track's on page that artist have. And use that number as maximum.
If it have 2 songs, script will find that 2 songs and play them as usual.
So ''undefinied'' should not repeat anymore.
You will receive: ''undefined'' only if artist doesn't have track at all(in that case artist will be skipped).
Because of this change, script now should work faster..

Next addition will be: ''genre''.
Title: Foobar Youtube Radio
Post by: mire777 on 2014-04-25 12:55:18
New version: Foobar Youtube Radio 0.0.7.
http://pastebin.com/G76MuFjS (http://pastebin.com/G76MuFjS)

Changes:
-Added Genre.
-Little changes in menu.

For now genre work using this page: http://www.last.fm/music/+tag/metal (http://www.last.fm/music/+tag/metal)
Access to page is limited to 27, which is the total of 1600 artist per genre.
Actualy number for genre artist is 1.000 artist, but it plays 'genre+similar'.
So it have more artist..

For genre you type: *pop, *rock, *soul, *jazz, *blues, *rnb, *heavy metal, *disco, *discoteque, *disco, *dance, *house, *techno... Or similar..
Be sure that genre exist on last.fm.
Title: Foobar Youtube Radio
Post by: eahm on 2014-04-25 15:40:02
Sorry not much of a programmer here... is that the code for the DLL? How do I test the component? Thanks.
Title: Foobar Youtube Radio
Post by: musikomaniak on 2014-04-25 17:56:03
Sorry not much of a programmer here... is that the code for the DLL? How do I test the component? Thanks.

You can find instructions in first post :
Quote
How to install:
You should first install Wsh plugin 1.5.6. ,
then download youtube buttons: https://www.mediafire.com/?x4n40mh48lpn183 (https://www.mediafire.com/?x4n40mh48lpn183)
put 'image' folder in foobar profile folder.
After that open new wsh panel and paste this script: http://pastebin.com/xadsrCdB (http://pastebin.com/xadsrCdB)
Title: Foobar Youtube Radio
Post by: WilB on 2014-04-25 18:02:24
I will let you have a script in due course.


@mire777 As promised my take on this is now available here (http://www.hydrogenaudio.org/forums/index.php?s=&showtopic=105522&view=findpost&p=864128). The radio mode is driven by echonest, but it also has an album mode driven by various sources. See the link for screenshots and more information.
Title: Foobar Youtube Radio
Post by: mire777 on 2014-04-26 01:06:10
I will let you have a script in due course.


@mire777 As promised my take on this is now available here (http://www.hydrogenaudio.org/forums/index.php?s=&showtopic=105522&view=findpost&p=864128). The radio mode is driven by echonest, but it also has an album mode driven by various sources. See the link for screenshots and more information.


Thanks, i did quick test, and i can say it works great. I test 'similar artist', and my conclusion is that both metod's works in same way.
Probably echonest use last.fm for search..
I like your 'album manager', would like that this be shown in popup menu, but not in panel itself.
Also i like button  .
Anyway it looks great, i give this a try.

Sorry not much of a programmer here... is that the code for the DLL? How do I test the component? Thanks.


It use 2 components, install this:
-WSH panel mode: https://code.google.com/p/foo-wsh-panel-mod/downloads/list (https://code.google.com/p/foo-wsh-panel-mod/downloads/list)
-Foo_youtube: http://www.hydrogenaudio.org/forums/index....4379&st=175 (http://www.hydrogenaudio.org/forums/index.php?showtopic=104379&st=175)

Then uncheck ''safe mode'' from foobar preferences - for wsh panel.
Download youtube buttons: http://www.mediafire.com/download/x4n40mh48lpn183/image.rar (http://www.mediafire.com/download/x4n40mh48lpn183/image.rar)
Put folder 'image' in foobar main(profile) folder.
Then make new panel, right click> wsh panel mod.
Paste this script: http://pastebin.com/G76MuFjS (http://pastebin.com/G76MuFjS)

Or you can try this from WilB. >link (http://www.hydrogenaudio.org/forums/index.php?showtopic=105522&st=0&p=864128&#entry864128)
Title: Foobar Youtube Radio
Post by: mire777 on 2014-04-27 20:21:52
New version: Foobar Youtube Radio 0.0.8.
http://pastebin.com/uxGmjCyK (http://pastebin.com/uxGmjCyK)

Changes:
-Fixed small bugs from previous ver..

I think that script is now complete.
Just to clean code, and fix some things with genre.

If you have some suggestions or idea, what to add next, will be glad to hear you..
I'm out of ideas now
Title: Foobar Youtube Radio
Post by: mire777 on 2014-04-29 10:04:46
New version: Foobar Youtube Radio 0.0.9.
http://pastebin.com/PMgQDDiE (http://pastebin.com/PMgQDDiE)

Changes:
Added track naming.
-requirements - latest- foo_youtube.dll


Foo_youtube renames video in format %artist% - %title%.
But sometimes, youtube tracks has different name format (in that case tracks can't be tagged),
Now tracks are renamed according to the search details from last.fm.
Every video will be properly tagged in format: %artist% - %title% (and you will always have biography and lyrics) , even if youtube has different or incorrect name for video, script will use last.fm info to tag tracks.
Title: Foobar Youtube Radio
Post by: mire777 on 2014-05-02 14:02:49
New version: Foobar Youtube Radio 0.0.10.
http://pastebin.com/7wrCtfgD (http://pastebin.com/7wrCtfgD)

Changes:
-Fixed genre

Thanks Marc2003 for helping to fix this.

*Youtube Radio now will play real genre(support all last.fm genres).
  You can set hotness for 'genre' up to 100. In ''properties>YT Tag''.
  Default is 27- which will play most popular artist.

Title: Foobar Youtube Radio
Post by: WilB on 2014-05-02 17:08:38
New version: Foobar Youtube Radio 0.0.9. Changes: Added track naming.


Yes the track naming, originally in YouTube Track Manager, is a nice addition. You have The vern and I and especially The vern to thank for persuading 3dyd to add it and of course a big thanks to 3dyd for implementing it. It seems to work fine in Foobar Youtube Radio.

I had a go at using last.fm as a radio source because, in particular, I wanted the last.fm tag/top tracks api methods and because the api methods ought to be faster than the trawling through last.fm web pages method. As you have not used the api methods, and didn't seem to want to do it that way, I went ahead. Having done the last.fm tag/top tracks method it was easy to extend it to other types.

YouTube Track Manager now offers a radio mode with last.fm as the source with artist, genre, similar artists and tags radio. In tag mode any last.fm tag or top tag can be used to search for a selection of tracks. This works with genres, e.g. rock, or years e.g. 2013, and other tag types. These implementations use the last.fm api.  The last.fm mode offers artist variety and song hotness support analogous to that originally found in YouTube Track Manager with echonest as the source.

Echonest is still present as a radio source. The two sources complement each other and I would not say that one is better than the other. There are differences between the two especially in regard to the artists present/absent in similar artists mode, presumably reflecting differences in the data sources. Two radio sources are also advantageous if one server is slow or not available.

The menu in YouTube Track Manager is improved with song hotness and artist variety now on the menu rather than just being configurable in properties. Additionally, in button mode the name of the current radio station is present. Both button and panel modes along with the album manager are still present. There are quite a lot of new additions, so please report any bugs.

Download and screenshots: New version  YouTube Track Manager 0.3 beta (http://www.hydrogenaudio.org/forums/index.php?s=&showtopic=105522&view=findpost&p=864797)

Title: Foobar Youtube Radio
Post by: mire777 on 2014-05-02 23:57:25
Yes the track naming, originally in YouTube Track Manager, is a nice addition. You have The vern and I and especially The vern to thank for persuading 3dyd to add it and of course a big thanks to 3dyd for implementing it. It seems to work fine in Foobar Youtube Radio.


Yes i noted that you use 'track naming' in your script, i also want to thank You, Vern and 3dyd for implementing this.
I also add this in mine script, think that 'youtube radio' now works in same way as last.fm radio, when naming tracks.

I had a go at using last.fm as a radio source because, in particular, I wanted the last.fm tag/top tracks api methods and because the api methods ought to be faster than the trawling through last.fm web pages method. As you have not used the api methods, and didn't seem to want to do it that way, I went ahead. Having done the last.fm tag/top tracks method it was easy to extend it to other types.


I think that i will not use API, because all things that they offer trough API service, already exist on web pages.
API today works, but what will be in a few years, nobody knows..
We were witnesses that last.fm 'turn off' some API metods,when they want- and if they want, they even didnt inform developers about this.
This is problem with ''foo_uie_biography'' , ''foo_lastfm_radio'' and other.., these components doesn't work now because API.
I think that last.fm API is not stable..
I'm suspicious about echonest API too..
Maybe in future echonest will, require payment, for what they offer.
So i decided to use html instead of API.
At least html might be available always, and you didnt have limit.

*I think that both metods should be available html and API metod for 'Foobar Youtube Radio'. So if one doesn't work for some years, other will.
I want to change main post, to place both script mine and yours there, if you agree. But didn't know how to do that.
I write moderator. But not recieved answer yet.

About speed, my script is a little slower, but i didnt care about this, as i see, it's fast enough.
Next track is always  loaded after 5-11sec.

Echonest is still present as a radio source. The two sources complement each other and I would not say that one is better than the other. There are differences between the two especially in regard to the artists present/absent in similar artists mode, presumably reflecting differences in the data sources. Two radio sources are also advantageous if one server is slow or not available.


I didn't test your new version yet, but as i see from previous, there are differences in both metods, as you sad: 'present/absent' some artist.
I think that last.fm offers more variety for similar artist. So i think that this mode is better.

*What should be done next, is to suppress add-processing window to apear..

One question, did you have, Youtube_Track_Manager version for WSH 1.4.2. , because i use that ver?
I was modified previous ver. for my WSH but now i must to do this again for latest.
Title: Foobar Youtube Radio
Post by: musikomaniak on 2014-05-03 07:34:26
With Youtube track manager : "Search for similar artist / Open artist and similar artists" search results are quite good. Best than with "same artist station" of Youtube Radio.
My idiot question of the day: why do you call it "Youtube RADIO"?
For me radio is ...a radio station. I'm confused in my playlists of web/stream radios and youtube radios.
Title: Foobar Youtube Radio
Post by: mire777 on 2014-05-03 09:33:43
With Youtube track manager : "Search for similar artist / Open artist and similar artists" search results are quite good. Best than with "same artist station" of Youtube Radio.
My idiot question of the day: why do you call it "Youtube RADIO"?
For me radio is ...a radio station. I'm confused in my playlists of web/stream radios and youtube radios.


Well your problem is only that you don't like menu.
Both script works in same way, i think that now with latest: 'Youtube Track Manager' , there are no differences for 'similar artist' and 'genre'.
You can rename in menu "same artist station" with "Search for similar artist" or whatever you like, on line: 592,593.
I can also add ex.> ''Open Madona and similar artist..'' , as it is done in 'YT Track Manager'.

Only difference is that Wilb script has Album Manager, which can also be added(but i will not do this, because Wilb already did that).


Question: Why do you call it "Youtube Radio"?
Well, because it is Radio, not something else.
It's based on ''Last.fm Youtube Radio'' , and it works in same way.
So this should be called: 'last.fm Radio' or 'Youtube Radio'.
You can rename this, with your own name, - call it whatever you like..
Title: Foobar Youtube Radio
Post by: WilB on 2014-05-03 12:15:54
@mire777
Yeah, I know all about the removal of api services, especially the full biography from lastfm. But at least for now the api's work with YouTube Track Manager and there is a choice of two. There is always the option of using html if they cease to work.

Echonest is now owned by Spotify. Following the aquisition by Spotify, Napster & Rdio removed their support. So I guess much of the echonest data now no doubt comes from Spotify users. Echonest say nothing is going to change with regard to availability of the api but we will have to wait and see.

The html method is not immune from failing either. I get biographies and album reviews from allmusic by an html method, and every time allmusic change the format of the web page the script breaks and has to be changed... But for now we have a choice of a number of working methods for you tube track management. I am happy for YouTube Track Manager to be on the first post of the page if the mods allow the change. To make YouTube Track Manager compatible with wsh panel mod 1.4.2 I think the changes are much the same as before - although there are more AppendTo menu items that would need to be changed to the old style - but YouTube Track Manager is still in beta and so there may be bug fixes to come.
Title: Foobar Youtube Radio
Post by: musikomaniak on 2014-05-03 15:31:19
@Mire777, I made search tests with the same artist, with different results. Your script is on my installed foobar and WilB's script is on a portable version.

Anyway, there are not many people posting here.

About radio...my confusion could be because I don't use last.fm. Its'not a problem

I could rename, but I'll have to remember to rename again everytime you update
Title: Foobar Youtube Radio
Post by: mire777 on 2014-05-04 07:16:46
@Mire777, I made search tests with the same artist, with different results. Your script is on my installed foobar and WilB's script is on a portable version.

Anyway, there are not many people posting here.

About radio...my confusion could be because I don't use last.fm. Its'not a problem

I could rename, but I'll have to remember to rename again everytime you update


Yes, i've noticed that not many people posting here.
So, I'w invite people to comment, and leave their suggestions.

-Question is how would you call this script?

@WilB i didn't receive response from the moderator i wrote.
So i will contact another to see is possible to change main post, and leave there both script.
I'll write you in pm about this..
Title: Foobar Youtube Radio
Post by: WilB on 2014-05-04 12:28:29
Deezer, Echonest, Jango, last.fm and Rhapsody all seem to use radio
Pandora, Rdio and Slacker seem to call them stations
Spotify seems to use artist radio

So I don't currently have anything better to suggest since use of the terms radio or station are pretty standard ways used to describe artist and similar artist and genre type music playback by a number of well-known sources. Even though it is a little confusing compared with traditional radio. So I guess "radio" now has a new meaning...
Title: Foobar Youtube Radio
Post by: mire777 on 2014-05-04 14:42:55
Deezer, Echonest, Jango, last.fm and Rhapsody all seem to use radio
Pandora, Rdio and Slacker seem to call them stations
Spotify seems to use artist radio

So I don't currently have anything better to suggest since use of the terms radio or station are pretty standard ways used to describe artist and similar artist and genre type music playback by a number of well-known sources. Even though it is a little confusing compared with traditional radio. So I guess "radio" now has a new meaning...


Yes i agree..
All this (Deezer, Echonest, Jango, Pandora) are ''radio'', but your own personal radio, where you can chose what to listen by: genre,artist or some way of recommendation.
Today, you have your personal 'radio', and this is future in real meaning word - 'radio'.

Seems that YouTube also trying to become 'Radio'. It have biography, similar artist, recommendation metod, genre, playlists, lyrics.. etc..
All goes in that way that youtube become radio..
In a few years, they probably will.

So great is that we already now have 'Youtube Radio' in foobar.
Any other name for this - will be inapropriate.
Title: Foobar Youtube Radio
Post by: WilB on 2014-05-04 16:31:37
"Seems that YouTube also trying to become 'Radio'"...... It seems its almost here already. Last.fm stopped there normal radio streaming service a few days ago in the face of competition. There new radio streaming player is in beta and plays music from youtube. Quote from last.fm: "On 26 March 2014, Last.fm announced they would be discontinuing their streaming radio service on 28 April. In a statement, the site said the decision was made in order to "focus on improving scrobbling and recommendations"." Further quote from another source: "Last.fm said it will continue to deliver personalized music to its listeners ... The difference is the music will not come from its own servers. Instead, music will be piped in from YouTube and VEVO onto the new player.The company, owned by CBS Interactive, struck a similar deal late January to plug into Spotify as a source. These two arrangements allow Last.fm to avoid paying music licensing fees while still delivering streaming music to its users."
Title: Foobar Youtube Radio
Post by: musikomaniak on 2014-05-04 21:20:11
For me, simple lady not very intelligent, radio means web radio /streaming radio. I choose radios for classical music, jazz, pop or news.
About Youtube Radio, for me it would be easier to call it Youtube music.
Today, I'm trying to have a new skin and make test on a foobar portable version where I have only the foo_Youtube component. It is more easy, no need for panels, buttons and scripts to find artists songs, concerts... 
Surely I miss important things.
Title: Foobar Youtube Radio
Post by: mire777 on 2014-05-08 23:58:56
For me, simple lady not very intelligent, radio means web radio /streaming radio. I choose radios for classical music, jazz, pop or news.
About Youtube Radio, for me it would be easier to call it Youtube music.
Today, I'm trying to have a new skin and make test on a foobar portable version where I have only the foo_Youtube component. It is more easy, no need for panels, buttons and scripts to find artists songs, concerts... 
Surely I miss important things.

Well with foo_youtube only, you cant find similar artist, you cant have recommendation what to listen.. So i prefer Youtube Radio. It works perfect. My playlist is always updated with new top artist and songs.. No need to go on web, and search what is new in music industry, or to type and search which new artist or songs exists. My script will inform me if something new appear... This is better way, i have all in one...
Title: Foobar Youtube Radio
Post by: mire777 on 2014-05-20 10:18:12
New version: Foobar Youtube Radio 0.0.11.
http://pastebin.com/qU8chyzn (http://pastebin.com/qU8chyzn)

Changes:

-Add track length (because of changes in foo_youtube.dll , track length now must be added trough parameter: ''3dydfy_alt_length'')
-Improved ''track naming'' (thanks WilB for implement this)
-Add support for DUI background (I missed to add this in previous version)
-'Add location' will no longer appear.

Thanks 3dyd for add ''skip analysis at clip info'' which helping to supress 'add locations' box.
Thanks WilB for improved 'track naming' which i used in this script.
Title: Foobar Youtube Radio
Post by: mire777 on 2014-05-20 15:03:50
Sooner than later..
There are new version: Foobar Youtube Radio 0.0.12.
http://pastebin.com/fMFB1GAU (http://pastebin.com/fMFB1GAU)


Changes:

Added - ''Artist Variety (1-20)"
Added - ''Song  Hotness (1-20)"
Added - ''Tag  Hotness (27-100)"


Example:
Artist Variety (20)
Song  Hotness (1-3)
*Will play top songs from last.fm (for me works best).
You can also decrease Artist Variety - to play top artist.
Title: Foobar Youtube Radio
Post by: mire777 on 2014-05-30 18:43:26
New version: Foobar Youtube Radio 0.0.14.
http://pastebin.com/Q0r2cGBe (http://pastebin.com/Q0r2cGBe)

-Fixed minor bugs.
-Added custom playlist names.

When you open Radio, every playlist will be saved in format: ''YT Radio [%artist%]'' or ''YT Radio [%genre%]''.
You can change first part of name in properties: FB Playlist.
Every station will be saved in playlist, for later listening.

Example:

Station: 'Rachel Stevens' - will be open in playlist as: ''YT Radio [Rachel Stevens]''.
Title: Foobar Youtube Radio
Post by: mire777 on 2014-06-08 15:04:41
New version: Foobar Youtube Radio 0.0.15.
http://pastebin.com/6TFfjSTB (http://pastebin.com/6TFfjSTB)

Changes:

-From now, Youtube Radio is only 'on' if Radio playlist is used, you must uncheck 'Youtube Radio' to have this playlist behave like an ordinary playlist.
In any other playlist than Youtube Radio, radio mode is automatically turned 'off'.

-'Search Video' will automatically open new playlist called> 'YT Radio [Search Videos]' , where you can add your search videos.

-'Open Same Video' will open new playlist called> 'YT Radio [Same Video]'.

Title: Foobar Youtube Radio
Post by: mire777 on 2014-06-13 12:09:05
New version: Foobar Youtube Radio 0.0.16.
http://pastebin.com/8Gj5gFLr (http://pastebin.com/8Gj5gFLr)

-Fixed minor bugs.
-Improved speed.

There probably will not be next version for now, except if something changes in foo_youtube component..
Or -if people have some requests..
For now this is final version..
Enjoy...

Title: Foobar Youtube Radio
Post by: musikomaniak on 2014-06-13 14:28:57
Thanks mire777
Title: Foobar Youtube Radio
Post by: mire777 on 2014-07-06 13:30:59
This is quick update for Youtube Radio:
YouTube has changed html tag for ''title'', because of this change in previous version there is absence of title names.

New version:
Youtube Radio 0.0.17. (http://pastebin.com/qkxggr8e)

Title: Foobar Youtube Radio
Post by: mire777 on 2014-07-06 17:43:38
Foobar Youtube Radio 0.0.18.
http://pastebin.com/UCLwVx86 (http://pastebin.com/UCLwVx86)

'Track Naming' is fixed.
-Little fix in menu.

Now everything should work as expected..
Title: Foobar Youtube Radio
Post by: mire777 on 2014-07-07 14:40:58
Foobar Youtube Radio 0.0.19.
http://pastebin.com/hrD2eicv (http://pastebin.com/hrD2eicv)

Changes:
-Added 'Popular Tracks'.
For each artist in playlist, you can receive top tracks from last.fm.
Tracks are loaded in Playlist: YT Radio [Tracks: %artist%]

(http://s13.postimg.org/cgmiam7p3/Capture.png)
Title: Foobar Youtube Radio
Post by: mire777 on 2014-07-28 16:30:56
Foobar Youtube Radio 0.0.21.

Changes:
-Fixed minor bugs.

Link for download and instruction how to install , here: mire777.deviantart.com (http://mire777.deviantart.com/art/Foobar-Youtube-Radio-447296512)
All future updates will go through deviantart..
Title: Foobar Youtube Radio
Post by: samithaj on 2014-10-04 08:34:23
It possible to save this tracks offline listen later like in a  cache
Title: Foobar Youtube Radio
Post by: mire777 on 2014-10-06 00:37:48
It possible to save this tracks offline listen later like in a  cache


You can download all tracks by clicking ''convert''. You can also download ''lame''(for converter) - and save all tracks as mp3. If this is what you need...
You can also automate this proces if you want to download all songs you listen in one folder, but i think that this is not good idea..
There might be songs you love and other you do not love.. So better is that you do: ''right click>convert'' only for songs you love.
Title: Foobar Youtube Radio
Post by: samithaj on 2014-10-07 15:54:41
It possible to save this tracks offline listen later like in a  cache


You can download all tracks by clicking ''convert''. You can also download ''lame''(for converter) - and save all tracks as mp3. If this is what you need...
You can also automate this proces if you want to download all songs you listen in one folder, but i think that this is not good idea..
There might be songs you love and other you do not love.. So better is that you do: ''right click>convert'' only for songs you love.

How to automate??
Title: Foobar Youtube Radio
Post by: mire777 on 2014-10-07 17:42:56
How to automate??


First go to playlist, right click on track>convert>...
Make new preset with name ''Record'' enter 'path' where you want to save tracks..

Then:
Hold Shift>left click on YT button>configure
On line 45 you have this:

Code: [Select]
function on_playback_new_track() {
p.item_focus_change();
LOAD_ART();
}


Replace this line with this:

Code: [Select]
function on_playback_new_track() {
if (fb.ActivePlaylist==(GetPlaylistID(pls + " ["+ STATION +"]"))) {fb.RunContextCommand("Convert/Record");}
p.item_focus_change();
LOAD_ART();
}


Now when you play YT Radio, foobar will save all tracks in user defined folder.
To turn this off, comment out this line with ''//'':

Code: [Select]
function on_playback_new_track() {
//if (fb.ActivePlaylist==(GetPlaylistID(pls + " ["+ STATION +"]"))) {fb.RunContextCommand("Convert/Record");}
p.item_focus_change();
LOAD_ART();
}
Title: Foobar Youtube Radio
Post by: mire777 on 2014-10-26 08:42:27
New version (Foobar Youtube Radio 2.0)
-Updated title handling due to Youtube changes...

Link for download (http://mire777.deviantart.com/art/Foobar-Youtube-Radio-447296512?ga_submit_new=10%253A1414312241&ga_type=edit&ga_changes=1)
Title: Foobar Youtube Radio
Post by: samithaj on 2014-11-15 13:35:04
How to automate??


First go to playlist, right click on track>convert>...
Make new preset with name ''Record'' enter 'path' where you want to save tracks..

Then:
Hold Shift>left click on YT button>configure
On line 45 you have this:

Code: [Select]
function on_playback_new_track() {
p.item_focus_change();
LOAD_ART();
}


Replace this line with this:

Code: [Select]
function on_playback_new_track() {
if (fb.ActivePlaylist==(GetPlaylistID(pls + " ["+ STATION +"]"))) {fb.RunContextCommand("Convert/Record");}
p.item_focus_change();
LOAD_ART();
}


Now when you play YT Radio, foobar will save all tracks in user defined folder.
To turn this off, comment out this line with ''//'':

Code: [Select]
function on_playback_new_track() {
//if (fb.ActivePlaylist==(GetPlaylistID(pls + " ["+ STATION +"]"))) {fb.RunContextCommand("Convert/Record");}
p.item_focus_change();
LOAD_ART();
}


Thanks mate!
Can you add a feature like lastfm similer tracks??
Title: Foobar Youtube Radio
Post by: mire777 on 2014-11-15 15:03:59
Thanks mate!
Can you add a feature like lastfm similer tracks??


Don't know what you mean? Something like option in menu?
Script already use 'similar artist' metod when you start play -script select one 'track' from 'similar artist' and send it to playlist..
Title: Foobar Youtube Radio
Post by: samithaj on 2014-11-15 18:34:36
Thanks mate!
Can you add a feature like lastfm similer tracks??


Don't know what you mean? Something like option in menu?
Script already use 'similar artist' metod when you start play -script select one 'track' from 'similar artist' and send it to playlist..

I mean tracks you can get with this function
http://www.last.fm/api/show/track.getSimilar (http://www.last.fm/api/show/track.getSimilar)
It'll be very useful to find new tracks
Title: Foobar Youtube Radio
Post by: mire777 on 2014-11-15 19:31:40
I mean tracks you can get with this function
http://www.last.fm/api/show/track.getSimilar (http://www.last.fm/api/show/track.getSimilar)
It'll be very useful to find new tracks


Yes i can do that..
I can add menu option to load 'similar tracks' on track focus.
There are already 'popular tracks' for selected artist.

So ok, i'l do that later, when i have time..
Title: Foobar Youtube Radio
Post by: mire777 on 2014-11-15 23:51:44
@samithaj

Here's new script with ''Similar Tracks''.

[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");

var MF_GRAYED = 0x00000001;
var MF_STRING = 0x00000000;
var IDC_ARROW = 32512;
var IDC_HAND = 32649;

function RGB(r, g, b) {
return (0xff000000 | (r << 16) | (g << 8) | (b));
}

function RGBA(r, g, b, a) {
return ((a << 24) | (r << 16) | (g << 8) | (b));
}

function on_colors_changed() {
p.colors_changed();
}

function on_selection_changed() {
p.item_focus_change();
}

function on_playlist_switch() {
set_focus0(); //Check Playlist
}

function on_playback_new_track() {
p.item_focus_change();
LOAD_ART();
}

function on_playback_dynamic_info_track() {
p.item_focus_change();
}

function on_playback_stop() {
p.item_focus_change();
}

function on_item_focus_change() {
p.item_focus_change();
}

function on_mouse_leave() {
}

function on_mouse_rbtn_up(x, y) {
p.rbtn_up(x, y);
return true;
}

//Playlist
function GetPlaylistID(Playlist_Name)
{
for (var i = 0; i < fb.PlaylistCount; i++)
{
if (fb.GetPlaylistName(i) == Playlist_Name)
{
return i;
}
}

//Create playlist if it doesn't exist
fb.CreatePlaylist(fb.PlaylistCount, Playlist_Name);
return i;
}

//Playlist(Check)
function GetPlaylistID0(Playlist_Name)
{
for (var i = 0; i < fb.PlaylistCount; i++)
if (fb.GetPlaylistName(i) == Playlist_Name)
{
return i;
}
}

//Focus on playlist(Check)
function set_focus0()

if (pls>"")
{
var PL_NM = (GetPlaylistID0(pls + " ["+ STATION +"]"));
if (fb.ActivePlaylist == PL_NM) {YT_PL = 1; window.SetProperty("YT  Playlist", "1");}
else
{YT_PL = 0; window.SetProperty("YT  Playlist", "0");}
}
}

//Focus on playlist(YT Radio)
function set_focus()

if (pls>"")
fb.ActivePlaylist = (GetPlaylistID(pls + " ["+ STATION +"]"));
}

//Focus on playlist(Same Video)
function set_focus2()

if (pls>"")
fb.ActivePlaylist = (GetPlaylistID(pls + " [Same Video]"));
}

//Focus on playlist(Search Videos)
function set_focus3()

if (pls>"")
fb.ActivePlaylist = (GetPlaylistID(pls + " [Search Videos]"));
}

//Focus on playlist(Popular Tracks)
function set_focus4()

if (pls>"")
fb.ActivePlaylist = (GetPlaylistID(pls + " [Popular tracks by: "+ p.artist +"]"));
}

//Focus on playlist(Similar Tracks)
function set_focus5()

if (pls>"")
fb.ActivePlaylist = (GetPlaylistID(pls + " [Similar to: "+ p.artist + " - " + p.title +"]"));
}

//Panel
    function panel(name, features) {
      this.item_focus_change = function() {
        if (!this.metadb_func) return;
        switch(this.selection_mode) {
        case 0:
        this.metadb = fb.GetSelection();
        break;
        case 1:
        this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
        break;
        case 2:
        this.metadb = fb.GetFocusItem();
        break;
      }
      if (this.metadb) on_metadb_changed();
   }

//Metadb
this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();

//Size   
    this.size = function() {
    this.w = window.Width;
    this.h = window.Height;
}

//Move   
    this.move = function(x, y) {
    this.mx = x;
    this.my = y;
}

//Menu   
    this.rbtn_up = function(x, y) {
    var _menu = window.CreatePopupMenu();
    var idx;
    switch(true) {
            case typeof th == "object":
            case typeof im == "object":

on_item_focus_change()           
if (pls>"")
{               
if(YT_AUTO==1) _menu.AppendMenuItem(MF_STRING, 1902, "Youtube Radio");
if(YT_AUTO==0) _menu.AppendMenuItem(MF_STRING, 1903, "Youtube Radio");
_menu.CheckMenuItem(1902, YT_AUTO?1:0);

_menu.AppendMenuSeparator();
{
if(YT_PL==1 && YT_AUTO==1 && STATION>"") {_menu.AppendMenuItem(MF_STRING, 22, "Get Next Video");}
else
{_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Get Next Video");}

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

_menu.AppendMenuSeparator();

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

p.artist = p.eval("%artist%");
if (p.artist == "" || p.artist == "?") {_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Same Artist Station");}
else
{_menu.AppendMenuItem(MF_STRING, 1915, "Same Artist Station");}

_menu.AppendMenuSeparator();

p.artist = p.eval("%artist%");
if (p.artist == "" || p.artist == "?") {_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Open Same Video");}
else
{_menu.AppendMenuItem(MF_STRING, 403, "Open Same Video");}

/*p.artist = p.eval("%artist%");
if (p.artist == "" || p.artist == "?") {_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Find in Browser");}
else
{_menu.AppendMenuItem(MF_STRING, 404, "Find in Browser");}*/

p.artist = p.eval("%artist%");
if (p.artist == "" || p.artist == "?") {_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Popular Tracks...");}
else
{_menu.AppendMenuItem(MF_STRING, 1916, "Popular Tracks...");}


p.artist = p.eval("%artist%");
if (p.artist == "" || p.artist == "?") {_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Similar Tracks...");}
else
{_menu.AppendMenuItem(MF_STRING, 1920, "Similar Tracks...");}

_menu.AppendMenuSeparator();

_menu.AppendMenuItem(MF_STRING, 9, "Properties...");
}            
}
}
if (pls=="") {_menu.AppendMenuItem(MF_STRING, 9, "Please Set: (FB Playlist)");}
if (utils.IsKeyPressed(0x10)) _menu.AppendMenuItem(MF_STRING, 10, "Configure...");
      
        idx = _menu.TrackPopupMenu(x, y);
        switch(idx) {
         
          case 9:
            window.ShowProperties();
            break;
               
          case 10:
            window.ShowConfigure();
            break;
               
          case 22:
                set_focus(); //Focus on playlist
            LOAD_ART();
            break;
               
          case 401:
                set_focus3(); //Focus on playlist
            fb.RunMainMenuCommand("View/Youtube Source");
            break;
               
          case 403:
                this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
                set_focus2(); //Focus on playlist
                LOAD_SAME();
            break;
         
          case 404:
                p.artist = p.eval("%artist% %title%");
                p.browser("http://www.youtube.com/results?search_query=" + encodeURIComponent(p.artist));
                break;
         
          case 1902:
                YT_AUTO = 0;
                window.SetProperty("YT  Auto", "0");
                break;
     
          case 1903:
                YT_AUTO = 1;
                window.SetProperty("YT  Auto", "1");
                break;
         
          case 1914:
                var Start;
                Start = this.InputBox("Type Artist to Start Station\n\n( *genre - will play genre station)", "Youtube Radio", "");
                if (Start=="")
                {
                }
                else
                {
                YT_PL = 1;
                window.SetProperty("YT  Playlist", "1");
                YT_AUTO = "1"
                window.SetProperty("YT  Auto", "1");
                STATION = Start;
                window.SetProperty("YT  Station", Start);
                set_focus(); //Focus on playlist
                LOAD_ART();
                }
                break;
           
          case 1915:
                this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
                p.artist = p.eval("%artist%");
                if (p.artist == "" || p.artist == "?") return;
                STATION = p.artist;
                window.SetProperty("YT  Station", p.artist);
                YT_PL = 1;
                window.SetProperty("YT  Playlist", "1");
                YT_AUTO = "1"
                window.SetProperty("YT  Auto", "1");
                set_focus(); //Focus on playlist
                LOAD_ART();
                break;
       
          case 1916:
                set_focus4(); //focus on playlist
                POP_TRACKS();
                break;
               
          case 1920:
                //set_focus4(); //focus on playlist
                SIMILAR_TRACKS();
                break;
               
               
               
              }
              _menu.Dispose();
           }

//Features init
    this.features_init = function() {
    for (i = 0; i < this.features.length; i++) {
    switch(this.features) {
    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();}
                }
         }
      }
   }                           
}

//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/","");
set_focus5();//set focus on playlist
do_youtube_search1(decodeURIComponent(artist_split),title_split);
//fb.trace('::' ,artist_split + ' - '+ title_split  )
}
        this.doc.close();
        } else {
        p.console("HTTP error: " + this.xmlhttp.status);
                }
         }
      }
   }
}

//SAME VIDEO-----------------------------------------------
this.LOAD_SAME = function()
    {
      var artist0 = p.eval("%artist%");
      var title0 = p.eval("%title%");
      if(artist0 > "?" && title0 > "?") {set_focus2(); do_youtube_search1(decodeURIComponent(artist0), decodeURIComponent(title0));}
}

//GENRE----------------------------------------------------
this.LOAD_GENRE = function()
{    if (STATION.indexOf("*")== 0)
 
    { var randomnumber=Math.floor(Math.random()*tag)
      var a=randomnumber;
        if (STATION == "" || STATION == "?") return;
      if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      this.xmlhttp.open("GET", "http://www.last.fm/music/+tag/" + encodeURIComponent(STATION).replace("*","") + "?page=" + a, true);
      this.xmlhttp.send();
      this.xmlhttp.onreadystatechange = function() {
        if (this.xmlhttp.readyState == 4) {
        if (this.xmlhttp.status == 200) {
        var text = this.xmlhttp.responsetext;
        if (!this.doc) this.doc = new ActiveXObject("htmlfile");
        this.doc.open();
        var div = this.doc.createElement("li");
        div.innerHTML = text;
        var data = div.getElementsByTagName("a");
        var urls = [];
   
for (i = 0; i < data.length; i++) {
    if (data.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();}
                }
         }
      }
   }
}

//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 = "http://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

//check if track exist?               
//if((data.title.toLowerCase()).indexOf(decodeURIComponent(SIM_ART.toLowerCase()).split(" ")[0]) > 0)
//if((data.title.toLowerCase()).indexOf(decodeURIComponent(YT_TRACK.toLowerCase()).split(" ")[0]) > 0)
//if((data.title.toLowerCase()).indexOf(decodeURIComponent(YT_TRACK.toLowerCase()).split(" ")[1]) > 0)
//if((data.title.toLowerCase()).indexOf(decodeURIComponent(YT_TRACK.toLowerCase()).split(" ")[2]) > 0)

            //Find Title[OLD]
            /*{
            var st = text.indexOf( data.href.replace("about:/watch?", "") );
            var str = "dir=\"ltr\">";
            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;
            //p.console("Title: " + Y_Title);
               
            //Find minutes
            var s = text.indexOf( data.href.replace("about:/watch?", "") );
            var str = "<span class=\"video-time\">";
            s = text.indexOf(str, s) + str.length;
            var e = text.indexOf("</span>", s);
            var length = text.substr(s, e - s);
            length = convert(length);
            length = length ? length : "";
            if (!first_match)

            {                 
            // title stripped of artist name if same as search_artist
            var stripped_title = strip_title(Y_Title, this.search_artist);
            first_match = "3dydfy://www.youtube.com/watch?" + (this.metadata ? this.metadata + "&" : "") + "fb2k_title=" + encodeURIComponent(stripped_title) + "&3dydfy_alt_length=" + encodeURIComponent(length) + "&fb2k_artist=" + encodeURIComponent(this.search_artist) + "&" + data.href.replace("about:/watch?", "");
            }
            //3dydfy
            if (!this.IsGoodMatch(Y_Title))
            continue;

            url = "3dydfy://www.youtube.com/watch?" + (this.metadata ? this.metadata + "&" : "") + "fb2k_title=" + encodeURIComponent(this.search_title) + "&3dydfy_alt_length=" + encodeURIComponent(length) + "&fb2k_artist=" + encodeURIComponent(this.search_artist) + "&" + data.href.replace("about:/watch?", "");
            break;
            }
        }

        if (!url.length)
        url = first_match;

        this.yt_link = url;

        doc.close();

        this.on_search_finished_callback(url, this.search_artist, this.search_title);
        }

        this.IsGoodMatch = function (video_name)
        {
        var clean_vid_name = clean(strip(video_name));
        var clean_artist = clean(strip(this.search_artist));
        var clean_title = clean(strip(this.search_title));

        if (clean_vid_name.indexOf(clean_artist) != -1 && clean_vid_name.indexOf(clean_title) != -1 && clean_vid_name.indexOf("full album") == -1)
        {
            //p.console("GOOD MATCH");
            return true;
        }
        else
        {
            //p.console("BAD MATCH");
            return false;
        }
    }

}

//Call Search
do_youtube_search1 = function (p_artist, p_title)
    {
    var yt_search1 = new youtube_search(function ()
    {
    yt_search1.on_state_change();
    }, on_youtube_search1_done);
    yt_search1.StartSearch(p_artist, p_title);
    }

on_youtube_search1_done = function (link, p_artist, p_title)
{
var url2="";
url2 = link;
if (!url2)
{p.console("Track Or Artist - Not Exist!"); LOAD_ART();}

if (link && link.length)
{
           
p.console("" + "\"" + link + "\"");
YT_URL = window.SetProperty("YT URL", link);
var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath;
var str = tmppath + "\\foobar2000.exe /add ";
var go = str + link;
p.run(go);
}
    }
//**************************(END)**************************
this.artist = "";

//Set Panels
function pan1() { }
function pan2(x, y, w, h) { }
//---------------------------------------------------------

//Begin--->
var p = new panel("Youtube Radio", ["remap", "metadb"]);
var im = new pan2(0, 0, 0, 0);
var th = new pan1();

on_item_focus_change();
{
}

function on_metadb_changed() {
}

//Buttons---------------------------------------------------

var Buttons;

var g_tooltip = window.CreateTooltip();
var g_down = false;

var btn_down = null;
var cur_btn = null;

ButtonStates = {
   normal: 0,
   hover: 1,
   down: 2
}

function Button(x, y, w, h, img_src, func, tiptext)  {
   this.left = x;
   this.top = y;
   this.w = w;
   this.h = h;
   this.right = x + w;
   this.bottom = y + h;
   this.func = func;
   this.tiptext = tiptext;
   this.state = ButtonStates.normal;
   this.img_normal = img_src && img_src.normal ? gdi.Image(img_src.normal) : null;
   this.img_hover = img_src && img_src.hover ? gdi.Image(img_src.hover) : this.img_normal;
   this.img_down = img_src && img_src.down ? gdi.Image(img_src.down) : this.img_hover;
   this.img = this.img_normal;
   
   this.alterImage = function(img_src) {
    this.img_normal = img_src && img_src.normal ? gdi.Image(img_src.normal) : null;
    this.img_hover = img_src && img_src.hover ? gdi.Image(img_src.hover) : this.img_normal;
    this.img_down = img_src && img_src.down ? gdi.Image(img_src.down) : this.img_hover;
      
    this.changeState(this.state);
   }
   
   this.traceMouse = function (x, y) {
    var b = (this.left < x) && (x < this.right) && (this.top < y) && (y < this.bottom);
    if (b)
    g_down ? this.changeState(ButtonStates.down) : this.changeState(ButtonStates.hover);
    else
    this.changeState(ButtonStates.normal);
    return b;
   }
   
   
   this.changeState = function (newstate) {
    if (newstate != this.state)
    window.RepaintRect(this.left, this.top, this.w, this.h);
    this.state = newstate;
    switch (this.state)
    {
    case ButtonStates.normal:
    this.img = this.img_normal;
    break;
         
    case ButtonStates.hover:
    this.img = this.img_hover;
    break;
         
    case ButtonStates.down:
    this.img = this.img_down;
    break;
         
    default:
    this.img = null;
      }
   }
   
   this.draw = function (gr) {
    this.img && gr.DrawImage(this.img, thi
Title: Foobar Youtube Radio
Post by: samithaj on 2014-12-04 11:35:56
Thank you mire777 for taking your time to do this.It's really use full !!!
Title: Foobar Youtube Radio
Post by: samithaj on 2014-12-04 11:49:32
I noted it now that your script isn't working. your old script is not working too.
Title: Foobar Youtube Radio
Post by: mire777 on 2014-12-04 17:14:46
I see...
This is because youtube now use 'https' , and they make other changes in html.
I will see to use gdata instead of real youtube web page..
Here is new script:

Code: [Select]
// ==PREPROCESSOR==
// @name "Youtube Radio"
// @author "Mire777"
// @feature "v1.4"
// @feature "watch-metadb"
// ==/PREPROCESSOR==

//Properties
YT_PL = window.GetProperty("YT Playlist", "0");
YT_AUTO = window.GetProperty("YT Auto", "0");
YT_TRACK = window.GetProperty("YT Track", "");
STATION = window.GetProperty("YT Station", "");
SIM_ART = window.GetProperty("YT Similar", "");
YT_URL = window.GetProperty("YT URL", "");
art = window.GetProperty("YT Artist Variety (1-20)", "20");
sng = window.GetProperty("YT Song Hotness (1-20)", "20");
tag = window.GetProperty("YT Tag Hotness (1-100)", "27");
pls = window.GetProperty("FB Playlist", "YT Radio");

var MF_GRAYED = 0x00000001;
var MF_STRING = 0x00000000;
var IDC_ARROW = 32512;
var IDC_HAND = 32649;

function RGB(r, g, b) {
return (0xff000000 | (r << 16) | (g << 8) | (b));
}

function RGBA(r, g, b, a) {
return ((a << 24) | (r << 16) | (g << 8) | (b));
}

function on_colors_changed() {
p.colors_changed();
}

function on_selection_changed() {
p.item_focus_change();
}

function on_playlist_switch() {
set_focus0(); //Check Playlist
}

function on_playback_new_track() {
p.item_focus_change();
LOAD_ART();
}

function on_playback_dynamic_info_track() {
p.item_focus_change();
}

function on_playback_stop() {
p.item_focus_change();
}

function on_item_focus_change() {
p.item_focus_change();
}

function on_mouse_leave() {
}

function on_mouse_rbtn_up(x, y) {
p.rbtn_up(x, y);
return true;
}

//Playlist
function GetPlaylistID(Playlist_Name)
{
for (var i = 0; i < fb.PlaylistCount; i++)
{
if (fb.GetPlaylistName(i) == Playlist_Name)
{
return i;
}
}

//Create playlist if it doesn't exist
fb.CreatePlaylist(fb.PlaylistCount, Playlist_Name);
return i;
}

//Playlist(Check)
function GetPlaylistID0(Playlist_Name)
{
for (var i = 0; i < fb.PlaylistCount; i++)
if (fb.GetPlaylistName(i) == Playlist_Name)
{
return i;
}
}

//Focus on playlist(Check)
function set_focus0()
{
if (pls>"")
{
var PL_NM = (GetPlaylistID0(pls + " ["+ STATION +"]"));
if (fb.ActivePlaylist == PL_NM) {YT_PL = 1; window.SetProperty("YT Playlist", "1");}
else
{YT_PL = 0; window.SetProperty("YT Playlist", "0");}
}
}

//Focus on playlist(YT Radio)
function set_focus()
{
if (pls>"")
fb.ActivePlaylist = (GetPlaylistID(pls + " ["+ STATION +"]"));
}

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

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

//Focus on playlist(Popular Tracks)
function set_focus4()
{
if (pls>"")
fb.ActivePlaylist = (GetPlaylistID(pls + " [Popular tracks by: "+ p.artist +"]"));
}

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

//Panel
function panel(name, features) {
this.item_focus_change = function() {
if (!this.metadb_func) return;
switch(this.selection_mode) {
case 0:
this.metadb = fb.GetSelection();
break;
case 1:
this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
break;
case 2:
this.metadb = fb.GetFocusItem();
break;
}
if (this.metadb) on_metadb_changed();
}

//Metadb
this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();

//Size
this.size = function() {
this.w = window.Width;
this.h = window.Height;
}

//Move
this.move = function(x, y) {
this.mx = x;
this.my = y;
}

//Menu
this.rbtn_up = function(x, y) {
var _menu = window.CreatePopupMenu();
var idx;
switch(true) {
case typeof th == "object":
case typeof im == "object":

on_item_focus_change()
if (pls>"")
{
if(YT_AUTO==1) _menu.AppendMenuItem(MF_STRING, 1902, "Youtube Radio");
if(YT_AUTO==0) _menu.AppendMenuItem(MF_STRING, 1903, "Youtube Radio");
_menu.CheckMenuItem(1902, YT_AUTO?1:0);

_menu.AppendMenuSeparator();
{
if(YT_PL==1 && YT_AUTO==1 && STATION>"") {_menu.AppendMenuItem(MF_STRING, 22, "Get Next Video");}
else
{_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Get Next Video");}

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

_menu.AppendMenuSeparator();

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

p.artist = p.eval("%artist%");
if (p.artist == "" || p.artist == "?") {_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Same Artist Station");}
else
{_menu.AppendMenuItem(MF_STRING, 1915, "Same Artist Station");}

_menu.AppendMenuSeparator();

p.artist = p.eval("%artist%");
if (p.artist == "" || p.artist == "?") {_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Open Same Video");}
else
{_menu.AppendMenuItem(MF_STRING, 403, "Open Same Video");}

/*p.artist = p.eval("%artist%");
if (p.artist == "" || p.artist == "?") {_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Find in Browser");}
else
{_menu.AppendMenuItem(MF_STRING, 404, "Find in Browser");}*/

p.artist = p.eval("%artist%");
if (p.artist == "" || p.artist == "?") {_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Popular Tracks...");}
else
{_menu.AppendMenuItem(MF_STRING, 1916, "Popular Tracks...");}


p.artist = p.eval("%artist%");
if (p.artist == "" || p.artist == "?") {_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Similar Tracks...");}
else
{_menu.AppendMenuItem(MF_STRING, 1920, "Similar Tracks...");}

_menu.AppendMenuSeparator();

_menu.AppendMenuItem(MF_STRING, 9, "Properties...");
}
}
}
if (pls=="") {_menu.AppendMenuItem(MF_STRING, 9, "Please Set: (FB Playlist)");}
if (utils.IsKeyPressed(0x10)) _menu.AppendMenuItem(MF_STRING, 10, "Configure...");

idx = _menu.TrackPopupMenu(x, y);
switch(idx) {

case 9:
window.ShowProperties();
break;

case 10:
window.ShowConfigure();
break;

case 22:
set_focus(); //Focus on playlist
LOAD_ART();
break;

case 401:
set_focus3(); //Focus on playlist
fb.RunMainMenuCommand("View/Youtube Source");
break;

case 403:
this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
set_focus2(); //Focus on playlist
LOAD_SAME();
break;

case 404:
p.artist = p.eval("%artist% %title%");
p.browser("https://www.youtube.com/results?search_query=" + encodeURIComponent(p.artist));
break;

case 1902:
YT_AUTO = 0;
window.SetProperty("YT Auto", "0");
break;

case 1903:
YT_AUTO = 1;
window.SetProperty("YT Auto", "1");
break;

case 1914:
var Start;
Start = this.InputBox("Type Artist to Start Station\n\n( *genre - will play genre station)", "Youtube Radio", "");
if (Start=="")
{
}
else
{
YT_PL = 1;
window.SetProperty("YT Playlist", "1");
YT_AUTO = "1"
window.SetProperty("YT Auto", "1");
STATION = Start;
window.SetProperty("YT Station", Start);
set_focus(); //Focus on playlist
LOAD_ART();
}
break;

case 1915:
this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
p.artist = p.eval("%artist%");
if (p.artist == "" || p.artist == "?") return;
STATION = p.artist;
window.SetProperty("YT Station", p.artist);
YT_PL = 1;
window.SetProperty("YT Playlist", "1");
YT_AUTO = "1"
window.SetProperty("YT Auto", "1");
set_focus(); //Focus on playlist
LOAD_ART();
break;

case 1916:
set_focus4(); //focus on playlist
POP_TRACKS();
break;

case 1920:
//set_focus4(); //focus on playlist
SIMILAR_TRACKS();
break;



}
_menu.Dispose();
}

//Features init
this.features_init = function() {
for (i = 0; i < this.features.length; i++) {
switch(this.features[i]) {
case "metadb":
this.selection_mode = 1;
break;
case "remap":
this.artist_tf = ("%artist%");
break;
}
}
}

this.check_feature = function(f) {
for (i = 0; i < this.features.length; i++) {
if (this.features[i] == f) return true;
}
return false;
}

//Eval
this.eval = function(tf) {
if (!this.metadb || tf == "") return "";
if (fb.IsPlaying && this.metadb.RawPath.indexOf("file://") != 0) {
return fb.TitleFormat(tf).Eval();
} else {
return fb.TitleFormat(tf).EvalWithMetadb(this.metadb);
}
}

//Console Msg
this.console = function(message) {
this.name = "Youtube Radio"
fb.trace(this.name + ": " + message);
}

//Trim
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, "");
}

//Input Box
this.InputBox = function(prompt, title, value) {
prompt = prompt.replace(/"/g, '" + Chr(34) + "').replace(/\n/g, '" + Chr(13) + "');
title = title.replace(/"/g, '" + Chr(34) + "');
value = value.replace(/"/g, '" + Chr(34) + "');
var temp_value = this.vb.eval('InputBox' + '("' + prompt + '", "' + title + '", "' + value + '")');
if (typeof temp_value == "undefined") return value;
if (temp_value.length == 254) this.MsgBox("Your entry was too long and will be truncated.\n\nSee the WSH panel mod script discussion thread on hydrogenaudio forums for help.", 0, "Youtube Radio");
return temp_value.trim();
}

//Msg Box
this.MsgBox = function(prompt, buttons, title) {
prompt = prompt.replace(/"/g, '" + Chr(34) + "').replace(/\n/g, '" + Chr(13) + "');
title = title.replace(/"/g, '" + Chr(34) + "');
return this.vb.eval('MsgBox' + '("' + prompt + '", "' + buttons + '", "' + title + '")');
}

//Browser
this.browser = function(command) {
if (!this.run(command)) this.MsgBox("Unable to launch your default browser.", 0, "Youtube Radio");
}

//Run Command
this.run = function(command) {
try {
this.WshShell.Run(command);
return true;
} catch(e) {
return false;
}
}

//futures
this.metadb_func = typeof on_metadb_changed == "function";
this.features = features;
this.dui = window.InstanceType;
this.metadb = fb.GetFocusItem();
this.WshShell = new ActiveXObject("WScript.Shell");
this.fso = new ActiveXObject("Scripting.FileSystemObject");
this.vb = new ActiveXObject("ScriptControl");
this.vb.Language = "VBScript";
this.artist_tf = "%artist%";
this.features_init();
this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
if (fb.GetFocusItem())
{this.artist = fb.TitleFormat(this.artist_tf).EvalWithMetadb(this.metadb);}

}

//YT NAMES-------------------------------------------------

//Clean Art Name
CLEAN_ART_NAME = function (t)
{ try
{
return t.replace(/about:\//,"").replace("music/","").replace("/_/"," - ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("free-music-downloads","").replace("/+similar?page=2","").replace("/+events","").replace("/+wiki","").replace("-+","").replace("/+albums","").replace("/+tags","").replace("/+images","").replace("/journal","").replace("/charts","").replace("/images","").replace("/listeners","").replace("/similar?page=17","").replace("/news","").replace("/groups","").replace("/albums","").replace("/videos","").replace("/tracks","").replace("/similar","").replace("/tags","").replace("noredirect/","").replace("listeners/+tracks","").replace("videos/+tracks","").replace("/+videos/","").replace("?page=1","").replace("?page=8","").replace("?page=5","").replace("?page=7","").replace("?page=9","").replace("?page=8","").replace(" wiki/edit","").replace("/ similar","").replace("?page=","'").replace("/ charts","'").replace("-","").replace("%2F%E3%82%A4%E3%83%95%E3%83%BB%E3%83%8E%E3%83%83%E3%83%88%E3%83%BB%E3%83%95%E3%82%A9%E3%83%BE3%83%BB%E3%83%A6%E3%83%BC","").replace("Ajoutez ce titre sur Deezer exclusivement sur www.hotmixradio.fr","").replace("www.Hituri.net","").replace("%E3%81%97%E3%82%83%E3%81%AB%E3%82%80%E3%81%AB%E3%82%B7%E3%82%A7%E3%82%A4%E3%82%AF%EF","").replace("%B81%E3%82%B7%E3%82%A7%E3%82%A4%E3%82%AF%EF%B81","").replace("%E4%BD%95%E3%82%88%E3%82%8A%E3%82%82%E5%83%95%E3%82%89%E3%81%97%E3%81%8F%E3%80%81%E4%BD%95%E3%82%88%E3%82%8A","").replace("%E3%82%82%E5%90%9B%E3%82%89%E3%81%97%E3%81%8F","").replace("%D0%91%D1%8D0%B5%D1%82 %D0%BF%D0%BE %D0%B3%D0%BB%D0%B0%D0%B7%D0%B0%D0%BC","").replace("%E3%83%9E%E3%82%A4%E3%83%BB%E3%83%9E3%83%87%E3%82%A3","").replace("%D0%9B%D0%B5%D1%82%D0%B5%D1%82%D1%8C","").replace("%2F%2F %D0%A1%D0%9B%D0%A3%D0%A8%D0%90%D0%AE%D0%A2","").replace("%D0%9F%D0%BE%D0%BF-%D0%A5%D0%B8%D1%82","").replace("/","").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'");
} catch (e) {}
}

//Clean Track Name
CLEAN_TRACK_NAME = function (t)
{ try
{
return t.replace(/about:\//,"").trim().split(" (")[0].replace(" (","").split(" [")[0].replace(" [","").split(" {")[0].replace(" {","").split(", ")[0].replace(", ","").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace("%27","'").replace(" 01-","").replace(" 02-","").replace(" 03-","").replace(" 04-","").replace(" 05-","").replace(" 06-","").replace(" 07-","").replace(" 08-","").replace(" 09-","").replace("09 ","").replace("08 ","").replace("07 ","").replace("06 ","").replace("05 ","").replace("04 ","").replace("03 ","").replace("02 ","").replace("01 ","").replace("00 ","").replace("01 ","").replace("02 ","").replace("03 ","").replace("04 ","").replace("05 ","").replace("06 ","").replace("07 ","").replace("08 ","").replace("09 ","").replace("00 ","").replace(".mp","").replace(" - Remastered ","").replace(" - Remastered","").replace("- "," ").replace(decodeURIComponent(SIM_ART) + " -"," ").replace(decodeURIComponent(SIM_ART) + " - "," ").replace(" - Live ","").replace(" - Live","").replace(" Pt.1","").replace(" - Demo;2 Digital Remaster 66 ","").replace(" - Demo;2 Digital Remaster","").replace(" - Demo;","").replace(" - Demo","").replace("Digital Remaster","").replace("Original- ","").replace("Original- ","").replace("Original-","").replace(" - Vocal Version","").replace(" Mega-Mix","").replace("Mega-Mix","").replace(" - Original Mix","").replace(" Pop Radio Edit","").replace(" Radio Edit","").replace(" - Single Version","").replace(" - Edited Version","").replace("- ","").replace("- ","").replace("- ","").replace("- ","").replace("- ","").replace("- ","").replace("- ","").replace("- ","").replace("- ","").replace("- ","").replace(" - Extended Version","").replace(" -Remaster","").replace("`","'").replace(". "," ").replace(" Version","").replace(" edit","").replace(" - Edit","").replace(" Simple Mix","").replace(" Almighty Mix","").replace(" - Vocal","").replace(" Vocal","").replace(" Remix","").replace(" Extended Version","").replace(" - Explicit Version","").replace("- Explicit Version","").replace(" Explicit Version","").replace("Explicit Version","").replace(" Anthology", "").replace("The " + decodeURIComponent(SIM_ART), " ").replace(" - Survival Remix","").replace(" Radio Mix","").replace(" Survival Remix","").replace("Survival Remix","").replace(decodeURIComponent(SIM_ART) + "-"," ").replace(decodeURIComponent(SIM_ART)," ").replace(" Club Mix","").replace("_"," ").replace("_"," ").replace("_"," ").replace("_"," ").replace("_"," ").replace("_"," ").replace("_"," ").replace("_"," ").replace("_"," ").replace("_"," ").replace(" wwwi.info","").replace(" Edit","").replace("live","").replace("Single","").replace("vk.com/xclusives zone ","").replace(" Acoustic","").replace("Remix","").replace("Part&","").replace(" +","").replace(" % ","").replace(" % ","").replace(" % ","").replace(" % ","").replace(" % ","").replace(" % ","").replace(" % ","").replace(" % ","").replace(" % ","").replace(" % ","").replace(" % ","").replace(" % ","").replace(" % ","").replace(" Live;0 2","").replace(" Live;0 2","").replace("Live;0 2","").replace(' /"/"',"").replace(" -0","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace("%","").replace(" Alternate Mix","").replace("Live","").replace(" Alternate Mix","").replace("Alternate Mix","").replace("-0","").replace(" remastered","").replace(" // СЛУШАЮТ:","").replace("www.KLAUSOM.lt","").replace("-;-Bit Digital Remaster","").replace(" :","").replace("-1 Remaster","").replace(" Genuine Album","").replace(" www.rsmp.com","").replace(" www.rsmp.com","").replace("www.rsmp.com","").replace("Instrumental","").replace(" Instrumental","").replace("www.SongsLover.pk","").replace(" Genuine Album","").replace("Album","").replace("Remaster","").replace("Lyrics","").replace("w/lyrics","").replace(" -","").replace(" Radio","").replace("0%","").replace("remaster","").replace(" Lyrics","").split(" | '' |")[0].replace(" | '' |","").split(" |")[0].replace(" |","").split("|")[0].replace("|","").split("| On:")[0].replace("| On:","").split(" feat")[0].replace(" feat","").split(" ft.")[0].replace(" ft.","").split(" Feat.")[0].replace(" Feat","").split("Greatest Hits Megamix")[0].replace("Greatest Hits Megamix","").split("Lyrics")[0].replace("Lyrics","").split("Lyric")[0].replace("Lyric","").split("www.")[0].replace("www.","").split(";Feat")[0].replace(";Feat","").trim();
} catch (e) {}
}

//Clean Genre Name
CLEAN_GENRE_NAME = function (t)
{ try
{
return t.replace(/about:\//,"").replace("music/","").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("free-music-downloads","").replace("/+similar?page=2","").replace("/+events","").replace("/+wiki","").replace("-+","").replace("/+albums","").replace("/+tags","").replace("/+images","").replace("/journal","").replace("/charts","").replace("/images","").replace("/listeners","").replace("/similar?page=17","").replace("/news","").replace("/groups","").replace("/albums","").replace("/videos","").replace("/tracks","").replace("/similar","").replace("/tags","").replace("noredirect/","").replace("listeners/+tracks","").replace("videos/+tracks","").replace("/+videos/","").replace("?page=1","").replace("?page=8","").replace("?page=5","").replace("?page=7","").replace("?page=9","").replace("?page=8","").replace(" wiki/edit","").replace("/ similar","").replace("?page=","'").replace("/ charts","'").replace("-","").replace("%2F%E3%82%A4%E3%83%95%E3%83%BB%E3%83%8E%E3%83%83%E3%83%88%E3%83%BB%E3%83%95%E3%82%A9%E3%83%BE3%83%BB%E3%83%A6%E3%83%BC","").replace("Ajoutez ce titre sur Deezer exclusivement sur www.hotmixradio.fr","").replace("www.Hituri.net","").replace("%E3%81%97%E3%82%83%E3%81%AB%E3%82%80%E3%81%AB%E3%82%B7%E3%82%A7%E3%82%A4%E3%82%AF%EF","").replace("%B81%E3%82%B7%E3%82%A7%E3%82%A4%E3%82%AF%EF%B81","").replace("%E4%BD%95%E3%82%88%E3%82%8A%E3%82%82%E5%83%95%E3%82%89%E3%81%97%E3%81%8F%E3%80%81%E4%BD%95%E3%82%88%E3%82%8A","").replace("%E3%82%82%E5%90%9B%E3%82%89%E3%81%97%E3%81%8F","").replace("%D0%91%D1%8D0%B5%D1%82 %D0%BF%D0%BE %D0%B3%D0%BB%D0%B0%D0%B7%D0%B0%D0%BC","").replace("%E3%83%9E%E3%82%A4%E3%83%BB%E3%83%9E3%83%87%E3%82%A3","").replace("%D0%9B%D0%B5%D1%82%D0%B5%D1%82%D1%8C","").replace("%2F%2F %D0%A1%D0%9B%D0%A3%D0%A8%D0%90%D0%AE%D0%A2","").replace("%D0%9F%D0%BE%D0%BF-%D0%A5%D0%B8%D1%82","").replace("/","").split("tag")[0].split("hype")[0].split("events")[0];
} catch (e) {}
}

//*********************YT RADIO START**********************

//SIMILAR ARTIST--------------------------------------------------
this.LOAD_ART = function()
{ if (YT_AUTO=="1")
if (YT_PL=="1")

{ var randomnumber=Math.floor(Math.random()*art)
var a=randomnumber;
if (STATION == "" || STATION == "?") return;
if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
this.xmlhttp.open("GET", "http://www.last.fm/music/" + encodeURIComponent(STATION) + "/+similar"+ "?page=" + a, true);
this.xmlhttp.send();
this.xmlhttp.onreadystatechange = function() {
if (this.xmlhttp.readyState == 4) {
if (this.xmlhttp.status == 200) {
var text = this.xmlhttp.responsetext;
if (!this.doc) this.doc = new ActiveXObject("htmlfile");
this.doc.open();
var div = this.doc.createElement("div");
div.innerHTML = text;
var data = div.getElementsByTagName("a");
var urls = [];

for (i = 0; i < data.length; i++) {
if (data[i].href.indexOf("about:/music/") == 0) urls.push(CLEAN_ART_NAME(data[i].href));
}

//select random URL
var randomnumber = Math.floor(Math.random()*(20-50)+50);
do{
randomnumber = Math.floor(Math.random()*(20-50)+50);
} while(randomnumber%2!=1);
i=randomnumber;

{

//Start with urls[i]
if (urls[i] > "")
{
//p.console("" + urls[i]);
SIM_ART = window.SetProperty("YT Similar", urls[i]);
SIM_ART = urls[i];
window.SetProperty("YT Similar", urls[i]);
}
else
{
SIM_ART = window.SetProperty("YT Similar", "");
SIM_ART = "";
window.SetProperty("YT Similar", "");
}
}

this.doc.close();
if (STATION.indexOf("*")== 0) {LOAD_GENRE();}
else
if (SIM_ART == "" || SIM_ART == "?") {LOAD_ART();}
else
LOAD_TRACK();
} else {
if (STATION.indexOf("*")== 0) {LOAD_GENRE();}
else
if (this.xmlhttp.status == 404) {p.console("HTTP error: " + this.xmlhttp.status); LOAD_ART();}
}
}
}
}
}

//TRACK----------------------------------------------------
this.LOAD_TRACK = function()
{

{var randomnumber=Math.floor(Math.random()*sng)
var a=randomnumber;
if (SIM_ART == "" || SIM_ART == "?") return;
if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
this.xmlhttp.open("GET", "http://www.last.fm/music/" + encodeURIComponent(SIM_ART) + "/+tracks" + "?page=" + a, true);
this.xmlhttp.send();
this.xmlhttp.onreadystatechange = function() {
if (this.xmlhttp.readyState == 4) {
if (this.xmlhttp.status == 200) {
var text = this.xmlhttp.responsetext;
if (!this.doc) this.doc = new ActiveXObject("htmlfile");
this.doc.open();
var div = this.doc.createElement("tr");
div.innerHTML = text;
var data = div.getElementsByTagName("td");
var urls = [];

for (i = 0; i < data.length; i++) {
if (data[i].title) urls.push(CLEAN_TRACK_NAME(data[i].title));
}

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

{

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

YT_TRACK = window.SetProperty("YT Track", urls[i]);
YT_TRACK = urls[i];
window.SetProperty("YT Track", urls[i]);
}
else
{
YT_TRACK = window.SetProperty("YT Track", "");
YT_TRACK = "";
window.SetProperty("YT Track", "");
}
}

this.doc.close();
if (YT_TRACK == "" || YT_TRACK == "?") {LOAD_ART();}
else
set_focus(); //focus on playlist
do_youtube_search1(decodeURIComponent(SIM_ART), decodeURIComponent(YT_TRACK));
} else {
p.console("HTTP error: " + this.xmlhttp.status);
if (STATION.indexOf("*")== 0) {LOAD_GENRE();}
else
if (this.xmlhttp.status == 404) {LOAD_ART();}
}
}
}
}
}

//POPULAR TRACKS----------------------------------------------------
this.POP_TRACKS = function()
{ p.artist = p.eval("%artist%");

{ if (p.artist == "" || p.artist == "?") return;
if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
this.xmlhttp.open("GET", "http://www.last.fm/music/" + encodeURIComponent(p.artist) + "/+tracks" + "?page=1", true);
this.xmlhttp.send();
this.xmlhttp.onreadystatechange = function() {
if (this.xmlhttp.readyState == 4) {
if (this.xmlhttp.status == 200) {
var text = this.xmlhttp.responsetext;
if (!this.doc) this.doc = new ActiveXObject("htmlfile");
this.doc.open();
var div = this.doc.createElement("tr");
div.innerHTML = text;
var data = div.getElementsByTagName("td");
var urls = [];

for (i = 0; i < data.length; i++) {
if (data[i].title) urls.push(CLEAN_TRACK_NAME(data[i].title));
}

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

{
//Start with urls[i]
if (urls[i] > "")
do_youtube_search1(decodeURIComponent(p.artist), urls[i]);
}
this.doc.close();
} else {
p.console("HTTP error: " + this.xmlhttp.status);
}
}
}
}
}


//SIMILAR TRACKS----------------------------------------------------
this.SIMILAR_TRACKS = function()
{ p.artist = p.eval("%artist%");
p.title = p.eval("%title%");

{ if (p.artist == "" || p.artist == "?") return;
if (p.title == "" || p.title == "?") return;
if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
this.xmlhttp.open("GET", "http://www.last.fm/music/" + encodeURIComponent(p.artist) + "/_/" + encodeURIComponent(p.title) + "/+similar", true);
this.xmlhttp.send();
this.xmlhttp.onreadystatechange = function() {
if (this.xmlhttp.readyState == 4) {
if (this.xmlhttp.status == 200) {
var text = this.xmlhttp.responsetext;
if (!this.doc) this.doc = new ActiveXObject("htmlfile");
this.doc.open();
var div = this.doc.createElement("td");
div.innerHTML = text;
var data = div.getElementsByTagName("a");
var urls = [];

for (i = 0; i < data.length; i++) {

if (data[i].href.indexOf("/_/") >0)

urls.push((data[i].href));
}

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

{
//Start with urls[i]
if (urls[i].indexOf("http:")==0) return;
if (urls[i].indexOf("/_/") >0)
title_split = urls[i].split("/_/")[1].replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ");
artist_split = urls[i].split("/_/")[0].replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("+"," ").replace("about:/music/","");
set_focus5();//set focus on playlist
do_youtube_search1(decodeURIComponent(artist_split),decodeURIComponent(title_split));
//fb.trace('::' ,artist_split + ' - '+ title_split )
}
this.doc.close();
} else {
p.console("HTTP error: " + this.xmlhttp.status);
}
}
}
}
}

//SAME VIDEO-----------------------------------------------
this.LOAD_SAME = function()
{
var artist0 = p.eval("%artist%");
var title0 = p.eval("%title%");
if(artist0 > "?" && title0 > "?") {set_focus2(); do_youtube_search1(decodeURIComponent(artist0), decodeURIComponent(title0));}
}

//GENRE----------------------------------------------------
this.LOAD_GENRE = function()
{ if (STATION.indexOf("*")== 0)

{ var randomnumber=Math.floor(Math.random()*tag)
var a=randomnumber;
if (STATION == "" || STATION == "?") return;
if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
this.xmlhttp.open("GET", "http://www.last.fm/music/+tag/" + encodeURIComponent(STATION).replace("*","") + "?page=" + a, true);
this.xmlhttp.send();
this.xmlhttp.onreadystatechange = function() {
if (this.xmlhttp.readyState == 4) {
if (this.xmlhttp.status == 200) {
var text = this.xmlhttp.responsetext;
if (!this.doc) this.doc = new ActiveXObject("htmlfile");
this.doc.open();
var div = this.doc.createElement("li");
div.innerHTML = text;
var data = div.getElementsByTagName("a");
var urls = [];

for (i = 0; i < data.length; i++) {
if (data[i].className.indexOf("name") == 0)
if (data[i].href.indexOf("about:/music/") == 0) urls.push(CLEAN_GENRE_NAME(data[i].href));
}

//select random URL
var randomnumber = Math.floor(Math.random()*(0-9)+9);
do{
randomnumber = Math.floor(Math.random()*(0-9)+9);
} while(randomnumber%2!=0);

i=randomnumber;

{

//Start with urls[i]
if (urls[i] > "")
{
//p.console("" + urls[i]);
SIM_ART = window.SetProperty("YT Similar", urls[i]);
SIM_ART = urls[i];
window.SetProperty("YT Similar", urls[i]);
}
else
{
SIM_ART = window.SetProperty("YT Similar", "");
SIM_ART = "";
window.SetProperty("YT Similar", "");
}
}
this.doc.close();
if (SIM_ART == "" || SIM_ART == "?") {LOAD_GENRE();}
else
LOAD_TRACK();
} else {
p.console("HTTP error: " + this.xmlhttp.status);
if (this.xmlhttp.status == 404) {LOAD_GENRE();}
}
}
}
}
}

//LOAD YOUTUBE VIDEO---------------------------------------
strip_title = function (t1, t2)
{
try
{
if (t1 == t2)
return t1;
if (t1.match(RegExp(t2 + "( and | & )", "i")))
return t1;
var a = "(by the |by: |by |of |the |feat. |ft. |)";
var b = "( feat.| ft.|)";
var t3 = "";
if (!t2.match(/^the /i))
{
t3 = t1.replace(RegExp("[^a-z\\d_)\\]\"]*(" + a + t2 + b + ")[^a-z\\d_(\\[\"]*","gi")," - ").replace(/^[^a-z()\[\]\d\"]*|[^a-z()\[\]\d\"]*$/gi, "");
}
else
{
var t4 = t2.replace(/^the /i, "")
t3 = t1.replace(RegExp("[^a-z\\d_)\\]\"]*(" + a + t4 + b + ")[^a-z\\d_(\\[\"]*","gi")," - ").replace(/^[^a-z()\[\]\d\"]*|[^a-z()\[\]\d\"]*$/gi, "");
}
return t3.match(/\S/) ? t3 : t1;
}
catch (e)
{
return t1;
}
}

convert = function(min)
{
var parts = min.split(':'),
minutes = +parts[0],
seconds = +parts[1];
return minutes * 60 + seconds;
}

strip = function (t)
{
try
{
t = t.replace(/[\.,\!\?\:;'"\-_]/g,"").toLowerCase();
return t;
} catch (e)
{}
}

clean = function (t)
{
try
{
return t.replace(/'/g, "’").toLowerCase();
} catch (e) {}
}

youtube_search = function (state_change_callback, p_on_search_finished_callback)
{
this.xmlhttp = null;
this.http_callback_funct = null;
this.ready_state_change_callback = state_change_callback;
this.search_done = false;
this.on_search_finished_callback = p_on_search_finished_callback;
this.yt_link;
this.search_artist;
this.search_title;
this.metadata;

this.on_state_change = function ()
{
if (this.xmlhttp != null && this.xmlhttp.readyState == 4 && this.xmlhttp.status == 200 && this.http_callback_funct != null)
this.http_callback_funct();
}

this.StartSearch = function (p_artist, p_title, p_extra_metadata)
{
this.search_artist = p_artist;
this.search_title = p_title;
this.metadata = p_extra_metadata;
this.http_callback_funct = null;
this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

var URL = "https://www.youtube.com/results?search_query=" + encodeURIComponent(p_artist + " " + p_title);

this.http_callback_funct = this.AnalyseSearch;
this.xmlhttp.open("GET", URL);
this.xmlhttp.onreadystatechange = this.ready_state_change_callback;
this.xmlhttp.send();
}

this.AnalyseSearch = function ()
{
var text = this.xmlhttp.responsetext;
var doc = new ActiveXObject("htmlfile");
doc.open();
var div = doc.createElement("div");
div.innerHTML = text;
var data = div.getElementsByTagName("a");
var url = "";
var first_match;

re_test:

for (var i = 0; i < data.length; i++)
{
if (data[i].href.indexOf("about:/watch?v=") == 0)
{
i++; //link

//Find Title[NEW]
{
var st = text.indexOf( data[i].href.replace("about:/watch?", "") );
var str = "a class=\"yt-uix-tile-link yt-ui-ellipsis yt-ui-ellipsis-2 yt-uix-sessionlink spf-link\">";
st = text.indexOf(str, st) + str.length;
var et = text.indexOf("</a>", st);
var youtube_title = text.substr(st, et - st);
var Y_Title = youtube_title.replace("'", "'").replace("&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[OLD]
//Y_Title = data[i].title;
//p.console("Title: " + Y_Title);

//Find minutes
var s = text.indexOf( data[i].href.replace("about:/watch?", "") );
var str = "<span class=\"video-time\">";
s = text.indexOf(str, s) + str.length;
var e = text.indexOf("</span>", s);
var length = text.substr(s, e - s);
length = convert(length);
length = length ? length : "";
if (!first_match)

{
// title stripped of artist name if same as search_artist
var stripped_title = strip_title(Y_Title, this.search_artist);
first_match = "3dydfy://www.youtube.com/watch?" + (this.metadata ? this.metadata + "&" : "") + "fb2k_title=" + encodeURIComponent(stripped_title) + "&3dydfy_alt_length=" + encodeURIComponent(length) + "&fb2k_artist=" + encodeURIComponent(this.search_artist) + "&" + data[i].href.replace("about:/watch?", "");
}
//3dydfy
if (!this.IsGoodMatch(Y_Title))
continue;

url = "3dydfy://www.youtube.com/watch?" + (this.metadata ? this.metadata + "&" : "") + "fb2k_title=" + encodeURIComponent(this.search_title) + "&3dydfy_alt_length=" + encodeURIComponent(length) + "&fb2k_artist=" + encodeURIComponent(this.search_artist) + "&" + data[i].href.replace("about:/watch?", "");
break;
}
}

if (!url.length)
url = first_match;

this.yt_link = url;

doc.close();

this.on_search_finished_callback(url, this.search_artist, this.search_title);
}

this.IsGoodMatch = function (video_name)
{
var clean_vid_name = clean(strip(video_name));
var clean_artist = clean(strip(this.search_artist));
var clean_title = clean(strip(this.search_title));

if (clean_vid_name.indexOf(clean_artist) != -1 && clean_vid_name.indexOf(clean_title) != -1 && clean_vid_name.indexOf("full album") == -1)
{
//p.console("GOOD MATCH");
return true;
}
else
{
//p.console("BAD MATCH");
return false;
}
}

}

//Call Search
do_youtube_search1 = function (p_artist, p_title)
{
var yt_search1 = new youtube_search(function ()
{
yt_search1.on_state_change();
}, on_youtube_search1_done);
yt_search1.StartSearch(p_artist, p_title);
}

on_youtube_search1_done = function (link, p_artist, p_title)
{
var url2="";
url2 = link;
if (!url2)
{p.console("Track Or Artist - Not Exist!"); LOAD_ART();}

if (link && link.length)
{

p.console("" + "\"" + link + "\"");
YT_URL = window.SetProperty("YT URL", link);
var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath;
var str = tmppath + "\\foobar2000.exe /add ";
var go = str + link;
p.run(go);
}
}
//**************************(END)**************************
this.artist = "";

//Set Panels
function pan1() { }
function pan2(x, y, w, h) { }
//---------------------------------------------------------

//Begin--->
var p = new panel("Youtube Radio", ["remap", "metadb"]);
var im = new pan2(0, 0, 0, 0);
var th = new pan1();

on_item_focus_change();
{
}

function on_metadb_changed() {
}

//Buttons---------------------------------------------------

var Buttons;

var g_tooltip = window.CreateTooltip();
var g_down = false;

var btn_down = null;
var cur_btn = null;

ButtonStates = {
normal: 0,
hover: 1,
down: 2
}

function Button(x, y, w, h, img_src, func, tiptext) {
this.left = x;
this.top = y;
this.w = w;
this.h = h;
this.right = x + w;
this.bottom = y + h;
this.func = func;
this.tiptext = tiptext;
this.state = ButtonStates.normal;
this.img_normal = img_src && img_src.normal ? gdi.Image(img_src.normal) : null;
this.img_hover = img_src && img_src.hover ? gdi.Image(img_src.hover) : this.img_normal;
this.img_down = img_src && img_src.down ? gdi.Image(img_src.down) : this.img_hover;
this.img = this.img_normal;

this.alterImage = function(img_src) {
this.img_normal = img_src && img_src.normal ? gdi.Image(img_src.normal) : null;
this.img_hover = img_src && img_src.hover ? gdi.Image(img_src.hover) : this.img_normal;
this.img_down = img_src && img_src.down ? gdi.Image(img_src.down) : this.img_hover;

this.changeState(this.state);
}

this.traceMouse = function (x, y) {
var b = (this.left < x) && (x < this.right) && (this.top < y) && (y < this.bottom);
if (b)
g_down ? this.changeState(ButtonStates.down) : this.changeState(ButtonStates.hover);
else
this.changeState(ButtonStates.normal);
return b;
}


this.changeState = function (newstate) {
if (newstate != this.state)
window.RepaintRect(this.left, this.top, this.w, this.h);
this.state = newstate;
switch (this.state)
{
case ButtonStates.normal:
this.img = this.img_normal;
break;

case ButtonStates.hover:
this.img = this.img_hover;
break;

case ButtonStates.down:
this.img = this.img_down;
break;

default:
this.img = null;
}
}

this.draw = function (gr) {
this.img && gr.DrawImage(this.img, this.left, this.top, this.w, this.h, 0, 0, this.w, this.h);
}

this.onClick = function () {
this.func && this.func(x,y);
}

this.onMouseIn = function() {
g_tooltip.Text = this.tiptext;
g_tooltip.Activate();
}

this.onMouseOut = function() {
g_tooltip.Deactivate();
}
}

function buttonsDraw(gr) {
for (i in Buttons) {
Buttons[i].draw(gr);
}
}

function buttonsTraceMouse(x, y) {
var btn = null;
for (i in Buttons) {
if (Buttons[i].traceMouse(x, y) && !btn)
btn = Buttons[i];
}

return btn;
}

function on_mouse_move(x, y) {
var btn = buttonsTraceMouse(x, y);

if (btn != cur_btn) {
cur_btn && cur_btn.onMouseOut();
btn && btn.onMouseIn();
}

cur_btn = btn;
}

function on_mouse_lbtn_down(x, y) {
g_down = true;
btn_down = cur_btn;

if (cur_btn) {
cur_btn.changeState(ButtonStates.down);
}
}

function on_mouse_lbtn_up(x, y) {
if (cur_btn) {
cur_btn.changeState(ButtonStates.hover);
if( btn_down == cur_btn )
cur_btn.onClick(x, y);
}
g_down = false;
}

function on_mouse_leave() {
if (cur_btn) {
cur_btn.changeState(ButtonStates.normal);
}
}

function on_size() {
ww = window.Width;
wh = window.Height;
window.Repaint();
}

//Background
this.dui = window.InstanceType;
function on_paint(gr) {

if (this.dui) {
col = window.GetColorDUI(1);
gr.FillSolidRect(0, 0, ww, wh, col);
}
else
{
col = window.GetColorCUI(3);
}

buttonsDraw(gr);

}

function RGB(r,g,b) {
return (0xff000000|(r<<16)|(g<<8)|(b));
}

function on_colors_changed() {
window.Repaint();
}

//Init Buttons--------------------------------------------

//Custom colour
var custom = RGB(255,255,255);

//Button width
var bw = 24;

//Button height
var bh = 20;

//Button position
var top_margin = 0;
var left_margin = 0;

var image_path0 = window.GetProperty("Button Path", fb.ProfilePath + "image");
var image_path = (image_path0 + "\\");

//These 2 lines of code lock the panel size.
//window.MinWidth = window.MaxWidth = 24;
//window.MinHeight = window.MaxHeight = 20;


Buttons = {
but1: new Button(left_margin,top_margin,bw,bh, {normal: image_path + "youtube0.png", hover: image_path + "youtube1.png"}, function(){
p.rbtn_up(24, 17);
}, "Youtube")

}

function on_mouse_rbtn_up(x, y) {
return true;
}
Title: Foobar Youtube Radio
Post by: samithaj on 2014-12-05 06:45:42
Thank you! It's working now.
Title: Foobar Youtube Radio
Post by: mire777 on 2015-03-14 13:08:45
New version Foobar Youtube Radio 2.3.
Download Link> (http://pastebin.com/5CNtd3Ba)
deviantart >mire777 (http://mire777.deviantart.com/art/Foobar-Youtube-Radio-447296512?ga_submit_new=10%253A1426337994&ga_type=edit&ga_changes=1)

Changes:
-''Open Radio Station by [%genre%]'' from menu, if %genre% exist.
-Cosmetic changes.
-Bug fixes.

(http://orig12.deviantart.net/1e77/f/2015/073/b/d/foobar_youtube_radio_by_mire777-d7eb474.png)
Title: Foobar Youtube Radio
Post by: mire777 on 2015-03-15 10:07:16
If someone download new version in past hours, there's a problem with track naming(not accurate) -because of youtube changes.
Fixed-> Download (http://pastebin.com/NeNwX0Xv)
Title: Foobar Youtube Radio
Post by: mire777 on 2015-03-25 12:33:09
Here is new version: Foobar Youtube Radio 2.4.

(http://i.imgur.com/iSq51vr.png)

Download> (http://pastebin.com/UDmF2PYh)

Changelog:

-Added 'Loved Videos'
Option to 'love' , 'unlove' or 'play loved' videos as radio.
Should work in same way as last.fm 'loved'.
Files are saved in 'foobar2000\playlists-YT' in '*.m3u' format.
(Thanks to Marc2003)

-Fixed 'http error: 0' on windows 8.1 and windows 10, which happens if 'video playback' is turned on.
Title: Foobar Youtube Radio
Post by: marc2003 on 2015-03-25 13:35:30
so you have to go to deviantart. from there you have to go to mediafire to get the images. and then you have to go to pastebin to get the script. why? 
Title: Foobar Youtube Radio
Post by: mire777 on 2015-03-25 15:01:44
so you have to go to deviantart. from there you have to go to mediafire to get the images. and then you have to go to pastebin to get the script. why? 


I want to use deviantart for all, but i can't change main file on deviantart, because then i must delete deviation and make new one.
So, i can only use mediafire for all..
Ok, here is new link: Link> (http://www.mediafire.com/download/6yjwamx4c81tu10/Foobar+Youtube+Radio.rar)

Instruction:

Put 'buttons-yt' folder in foobar profile folder.
After that open new wsh panel and paste script from 'YT.txt'
Title: Foobar Youtube Radio
Post by: marc2003 on 2015-03-25 15:12:07
I want to use deviantart for all, but i can't change main file on deviantart, because then i must delete deviation and make new one.


that is not the case. most theme/script authors on DA are always publishing updates while keeping their original deviation intact. you only have to look at falstaff/br3tt's work over the years.

anyway, thanks for putting all the files together.
Title: Foobar Youtube Radio
Post by: mire777 on 2015-03-25 21:05:33
that is not the case. most theme/script authors on DA are always publishing updates while keeping their original deviation intact. you only have to look at falstaff/br3tt's work over the years.

anyway, thanks for putting all the files together.


Problem is when you want to replace main file,if it is different from previous, than you can't change it.
My main file is 'image', i can't change it to something other.
But thank you for mentioned this, all files are together now.

In posted script above i left 'YT [loved]' playlist always on, i think this is not good.
So my final update: Link>> (http://www.mediafire.com/download/pb55k2rd83zzaaw/Foobar_Youtube_Radio.rar)
Title: Foobar Youtube Radio
Post by: marc2003 on 2015-03-25 22:39:47
Problem is when you want to replace main file,if it is different from previous, than you can't change it.
My main file is 'image', i can't change it to something other.


*sigh* if you don't know how to use a website feature then just be humble and and admit it. there is no shame. here's me admitting just yesterday that i didn't know how to use github properly...

it may have been possible to apply your patch using git but i honestly have no idea how so i made the changes locally and pushed it.


The easy way would have been to click the "Merge" button on the pull request page on github.




Title: Foobar Youtube Radio
Post by: mire777 on 2015-03-25 23:43:25
*sigh* if you don't know how to use a website feature then just be humble and and admit it. there is no shame. here's me admitting just yesterday that i didn't know how to use github properly...

it may have been possible to apply your patch using git but i honestly have no idea how so i made the changes locally and pushed it.


The easy way would have been to click the "Merge" button on the pull request page on github.



Well, maybe i really don't know  , since i'm not there all time.
Ok.  If someone can explain me how to change 'main file' , form '*.png' to '*rar'' on deviantart that would be great?
I have no idea how to do that?
Title: Foobar Youtube Radio
Post by: marc2003 on 2015-03-26 00:13:51
i can't remember what the exact options are but obviously you can have 2 files. every single archive download on DA is accompanied with a preview image which you can see when browsing. both the "preview" image and archive can be replaced any number of times. you can even edit the deviation name which changes the URL but DA keeps a history so all links to previous names will all re-direct to the same deviation with the latest name. as for how, there must be some help/labels in the edit dialog?? i don't have an account so can't check.

also, might i suggest using zip instead of rar. everybody has that built into windows without the need for 3rd party program required just to open the file.
Title: Foobar Youtube Radio
Post by: mire777 on 2015-03-26 17:35:52
i can't remember what the exact options are but obviously you can have 2 files. every single archive download on DA is accompanied with a preview image which you can see when browsing. both the "preview" image and archive can be replaced any number of times. you can even edit the deviation name which changes the URL but DA keeps a history so all links to previous names will all re-direct to the same deviation with the latest name. as for how, there must be some help/labels in the edit dialog?? i don't have an account so can't check.

also, might i suggest using zip instead of rar. everybody has that built into windows without the need for 3rd party program required just to open the file.


I tried everything to change main file, isn't possible. My category is 'desktop screenshots', and i have only 1 file which is 'image'.
I even try to change category, and add ''*.zip'' file, but i receive error> ''This file type is not allowed'', ''new file must be of the same type..''.
I chose 'desktop screenshots' on first, because i thought that i be able to change later, but i cant..
Anyway, here is zip file: Link> (http://www.mediafire.com/download/j6b1bq3f9yhts34/Foobar+Youtube+Radio.zip)
Title: Foobar Youtube Radio
Post by: marc2003 on 2015-03-26 17:44:22
My category is 'desktop screenshots'


ah, that would explain it then. when i mentioned falstaff earlier and from my own experience when i had account, foobar2000 is sub-category under customisation/themes. all these allow you to upload archives for people to download in addition to an image.

obviously you can't do anything with your existing deviation but if you ever post a new one, post in the right section and you can serve your files straight from there.
Title: Foobar Youtube Radio
Post by: luucasalves on 2015-04-27 09:09:51
i can't remember what the exact options are but obviously you can have 2 files. every single archive download on DA is accompanied with a preview image which you can see when browsing. both the "preview" image and archive can be replaced any number of times. you can even edit the deviation name which changes the URL but DA keeps a history so all links to previous names will all re-direct to the same deviation with the latest name. as for how, there must be some help/labels in the edit dialog?? i don't have an account so can't check.

also, might i suggest using zip instead of rar. everybody has that built into windows without the need for 3rd party program required just to open the file.


I tried everything to change main file, isn't possible. My category is 'desktop screenshots', and i have only 1 file which is 'image'.
I even try to change category, and add ''*.zip'' file, but i receive error> ''This file type is not allowed'', ''new file must be of the same type..''.
I chose 'desktop screenshots' on first, because i thought that i be able to change later, but i cant..
Anyway, here is zip file: Link> (http://www.mediafire.com/download/j6b1bq3f9yhts34/Foobar+Youtube+Radio.zip)



hi. i follow the tutorial, but dont work for me, nothing happen, any icon from yt nothing.. foo_youtube is working.... please help me
Title: Foobar Youtube Radio
Post by: mire777 on 2015-04-27 11:21:09
hi. i follow the tutorial, but dont work for me, nothing happen, any icon from yt nothing.. foo_youtube is working.... please help me


After you install WSH plugin 1.5.6. , then put 'buttons-yt' folder in foobar profile folder. This is main foobar folder where is ''foobar2000.exe''.
Then open new wsh panel and paste script from: 'YT.txt'.
Title: Foobar Youtube Radio
Post by: luucasalves on 2015-04-27 17:45:21
hi. i follow the tutorial, but dont work for me, nothing happen, any icon from yt nothing.. foo_youtube is working.... please help me


After you install WSH plugin 1.5.6. , then put 'buttons-yt' folder in foobar profile folder. This is main foobar folder where is ''foobar2000.exe''.
Then open new wsh panel and paste script from: 'YT.txt'.


hi, thanks for reply..  i think maybe my skins dont let show it? look at image

(http://puu.sh/hsPeR/e556a9b514.png)

(http://puu.sh/hsPho/59b937f4bc.png)

(http://puu.sh/hsP2t/cea9ca14f1.png)
(http://puu.sh/hsP8m/18f78cb4b1.png)


(http://puu.sh/hsPa9/b69be6a3fc.png)
(http://puu.sh/hsPcn/be778d3f6a.jpg)
Title: Foobar Youtube Radio
Post by: mire777 on 2015-04-28 05:25:15
hi, thanks for reply..  i think maybe my skins dont let show it? look at image

I'm sure that this is because of skin.
When you use CUI, and if new panel is not configured well, this is problem for most component you want to add...

Just try this in DUI, be shure that you check ''portable mod'' during installation..
Install clean foobar on deskop(do everything as you do on image), if script works, then just send me your skin, i will try to set all for you..
Title: Foobar Youtube Radio
Post by: luucasalves on 2015-04-28 06:11:51
hi, thanks for reply..  i think maybe my skins dont let show it? look at image

I'm sure that this is because of skin.
When you use CUI, and if new panel is not configured well, this is problem for most component you want to add...

Just try this in DUI, be shure that you check ''portable mod'' during installation..
Install clean foobar on deskop(do everything as you do on image), if script works, then just send me your skin, i will try to set all for you..


omgg work so good i love u ill change that skinn. you got any skin?
Title: Foobar Youtube Radio
Post by: mire777 on 2015-04-29 20:32:36
omgg work so good i love u ill change that skinn. you got any skin?


You can find great skins on deviantart.com (http://www.deviantart.com/browse/all/?section=&global=1&q=foobar+skin&offset=15) , i was used this from few posts above, it's skin from falstaff(br3tt), but now im use DUI foobar, here is my config:

(http://i.imgur.com/Dbit7EV.png)
Title: Foobar Youtube Radio
Post by: mire777 on 2015-06-05 22:02:41
Youtube Radio, new version:  Link>> (http://www.mediafire.com/download/67f820sreiuhybp/Foobar_Youtube_Radio.zip)

Due to changes in foo_youtube component, ''love'', ''unlove video'' not working anymore. Now fixed..

Title: Foobar Youtube Radio
Post by: vanhoivanbinh on 2015-07-08 06:34:08
I really like this component
Now I can listen to Youtube directly on FOOBAR2000

Dear Mire777
How can I add my own last.fm radio station on FOOBAR???
Or add some other last.fm radio station on this plugin???

Thank you very much for your help!!!
Title: Foobar Youtube Radio
Post by: mire777 on 2015-07-09 10:20:09
I really like this component
Now I can listen to Youtube directly on FOOBAR2000

Dear Mire777
How can I add my own last.fm radio station on FOOBAR???
Or add some other last.fm radio station on this plugin???

Thank you very much for your help!!!


With my script, you can play:

-artist radio
-genre radio
-top tracks from chosen artist
-similar artist track
-Loved tracks [(don't work with last.fm)]

If this is what you need, download script from here: Link>> (http://mire777.deviantart.com/art/Foobar-Youtube-Radio-447296512?ga_submit_new=10%253A1426337994&ga_type=edit&ga_changes=1)
You have instructions on site..

In short:

First install WSH plugin 1.5.6. : WSH 1.5.6 (https://code.google.com/p/foo-wsh-panel-mod/downloads/list)
Then download 'zip' file: Foobar Youtube Radio.zip (http://www.mediafire.com/download/67f820sreiuhybp/Foobar+Youtube+Radio.zip)

Put 'buttons-yt' folder in foobar profile folder.
After that open new wsh panel and paste script from: 'YT.txt'
Title: Foobar Youtube Radio
Post by: mire777 on 2015-10-07 00:12:19
Script was updated, link> (http://www.mediafire.com/download/67f820sreiuhybp/Foobar+Youtube+Radio.zip)
-Now using last.fm API.
-Fixed small bugs..
Title: Foobar Youtube Radio
Post by: widerock on 2015-10-07 02:03:19
Script was updated, link> (http://www.mediafire.com/download/67f820sreiuhybp/Foobar+Youtube+Radio.zip)
-Now using last.fm API.
-Fixed small bugs..


I've got this error message.

WSH Panel Mod (Youtube Radio by Mire777): Microsoft JScript Runtime Error:
Procedure call or argument is not valid
File: <main>
Line: 214, Col: 2
<source text only available at compile time>

I'm using WSH Panel Mod 1.5.11 due to the other scripts for my foobar.
Is there any simple method to fix this error without downgrading WSH Panel Mod?
Title: Foobar Youtube Radio
Post by: mire777 on 2015-10-07 14:20:59
I've got this error message.

WSH Panel Mod (Youtube Radio by Mire777): Microsoft JScript Runtime Error:
Procedure call or argument is not valid
File: <main>
Line: 214, Col: 2
<source text only available at compile time>

I'm using WSH Panel Mod 1.5.11 due to the other scripts for my foobar.
Is there any simple method to fix this error without downgrading WSH Panel Mod?

I haven't converted AppendMenuItem() to the new AppendTo() method, because i have some scripts that need to work in older WSH, changing this is not really necessary, as the old method continues to work in WSH 1.5.6.

As people now use Marc WSH 1.5.10-11, i will convert this in next release.
Here is modified script for you and others who use WSH 1.5.10-11:

''shift>left click>configure'' , replace script with this:

Code: [Select]
// ==PREPROCESSOR==
// @name "Youtube Radio"
// @author "Mire777"
// @feature "v1.4"
// @feature "watch-metadb"
// ==/PREPROCESSOR==

//Properties
//Api(1):d9f567e4a618a37dac934274e14b82b0
//Api(2):f21088bf9097b49ad4e7f487abab981e
API = window.GetProperty("Last.fm Api", "f21088bf9097b49ad4e7f487abab981e");
YT_PLS_FOCUS = window.GetProperty("YT  Playlist", "0");
YT_AUTO = window.GetProperty("YT  Auto", "0");
YT_TRACK = window.GetProperty("YT Track", "");
YT_STATION = window.GetProperty("YT  Station", "");
YT_SIM_ART = window.GetProperty("YT Similar", "");
YT_URL = window.GetProperty("YT URL", "");
art_hot = window.GetProperty("YT  Artist Hotness (1-250)", "250");
gnr_hot = window.GetProperty("YT  Genre Hotness (1-500)", "250")
sng_hot = window.GetProperty("YT  Song Hotness  (1-500)", "100");
yt_pls = window.GetProperty("Playlist", "YT Radio");

//Folder(loved)
fso = new ActiveXObject("Scripting.FileSystemObject");
folder_loved = fb.ProfilePath + "yt_playlists";

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

function on_playback_starting() {
p.item_focus_change();
//Check Playlist Loved
var PLOVED = GetPlaylistID0(yt_pls + " [Loved]");
if (fb.ActivePlaylist == PLOVED) {LOVED();} else
p.item_focus_change();
{LOAD_SIMILAR();}
}

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 (yt_pls>"")
{
var PL_NM = (GetPlaylistID0(yt_pls + " ["+ YT_STATION +"]"));
if (fb.ActivePlaylist == PL_NM) {YT_PLS_FOCUS = 1; window.SetProperty("YT  Playlist", "1");}
else
{YT_PLS_FOCUS = 0; window.SetProperty("YT  Playlist", "0");}
}
}

//Focus On Playlist(YT Radio)
function set_focus()

if (yt_pls>"")
fb.ActivePlaylist = (GetPlaylistID(yt_pls + " ["+ YT_STATION +"]"));
}

//Focus On Playlist(Same Video)
function set_focus2()

if (yt_pls>"")
fb.ActivePlaylist = (GetPlaylistID(yt_pls + " [Same Video]"));
}

//Focus On Playlist(Search Videos)
function set_focus3()

if (yt_pls>"")
fb.ActivePlaylist = (GetPlaylistID(yt_pls + " [Search Videos]"));
}

//Focus On Playlist(Top Tracks)
function set_focus4()

if (yt_pls>"")
fb.ActivePlaylist = (GetPlaylistID(yt_pls + " [Tracks: "+ p.artist +"]"));
}

//Focus On Playlist(Loved)
function set_focus6()
{
if (yt_pls>"")
fb.ActivePlaylist = (GetPlaylistID(yt_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 (yt_pls>"")
{
if(YT_AUTO==1) _menu.AppendMenuItem(MF_STRING, 9, "Youtube Radio");
if(YT_AUTO==0) _menu.AppendMenuItem(MF_STRING, 10, "Youtube Radio");
_menu.CheckMenuItem(9, YT_AUTO?1:0);

_menu.AppendMenuSeparator();

//POPUP BUTTON
{q.AppendTo(_menu, MF_STRING, "Open");}

//START *POP-UP*
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, 12, "Radio Station by [" + p.artist.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, 14, "Top Tracks by [" + p.artist.replace(/&/g,"&&") + "]");}
//END *POP-UP*

_menu.AppendMenuSeparator();

{
if(YT_PLS_FOCUS==1 && YT_AUTO==1 && YT_STATION>"") {_menu.AppendMenuItem(MF_STRING, 3, "Get Next Video");}
else
{_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Get Next Video");}

_menu.AppendMenuSeparator();

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

_menu.AppendMenuSeparator();

//START *LOVED*
//Eval
p.path = p.eval("%path%");
p.artist = p.eval("%artist%");
p.title = p.eval("%title%");

//Filename
filename = folder_loved + "\\"+ clean_filename(p.artist + " - " + p.title) + ".m3u";

//Check Files
var arr = utils.Glob(folder_loved + "\\*.*").toArray();
var a = [];
for (i = 0; i < arr.length; i++) {
if (arr[i]) a.push(arr[i]); 
}

var PLOVED = (GetPlaylistID0(yt_pls + " [Loved]")); //Check Playlist Loved

if (p.path.indexOf("youtube.com")>0 && fb.ActivePlaylist == PLOVED)
{
if (fso.FileExists(filename)) {_menu.AppendMenuItem(MF_STRING, 6, "♥ Un-Love");} else {_menu.AppendMenuItem(MF_STRING, 7, "♥ Love Video");}
if (arr=="" || arr=="?") {_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "♪ Play Loved..");}
else
if (arr>"" || arr>"?") {_menu.AppendMenuItem(MF_STRING, 8, "♪ Next Loved..");}
}

else

if (p.path.indexOf("youtube.com")>0)
{
if (fso.FileExists(filename)) {_menu.AppendMenuItem(MF_STRING, 6, "♥ Un-Love");} else {_menu.AppendMenuItem(MF_STRING, 7, "♥ Love Video");}
if (arr=="" || arr=="?") {_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "♪ Play Loved..");}
if (arr>"" || arr>"?") {_menu.AppendMenuItem(MF_STRING, 8, "♪ Play Loved..");}
}

else

{
{_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "♥ Love Video");}
if (arr=="" || arr=="?") {_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "♪ Play Loved..");}
if (arr>"" || arr>"?") {_menu.AppendMenuItem(MF_STRING, 8, "♪ 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, 5, "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, 16, "Find in Browser");}
_menu.AppendMenuSeparator();*/

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

_menu.AppendMenuSeparator();

_menu.AppendMenuItem(MF_STRING, 1, "Properties...");
}}}

if (yt_pls=="") {_menu.AppendMenuItem(MF_STRING, 1, "Please Set: (FB Playlist)");}
if (utils.IsKeyPressed(0x10)) _menu.AppendMenuItem(MF_STRING, 2, "Configure...");

        idx = _menu.TrackPopupMenu(x, y);
        switch(idx) {
         
          case 1:
window.ShowProperties();
break;
               
          case 2:
window.ShowConfigure();
break;
               
          case 3:
                set_focus(); //Focus On Playlist
LOAD_SIMILAR();
break;
               
          case 4:
                set_focus3(); //Focus on playlist
fb.RunMainMenuCommand("View/Youtube Search");
break;
               
          case 5:
                this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
                set_focus2(); //Focus On Playlist
                LOAD_SAME();
break;
           
          case 6:
                filename = folder_loved + "\\"+ clean_filename(p.artist + " - " + p.title) + ".m3u";
                //Delete File
                if (fso.FileExists(filename)) fso.DeleteFile(filename);
                break;
               
          case 7:
                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_loved + "\\"+ clean_filename(p.artist + " - " + p.title) + ".m3u";
                if(!fso.FolderExists(folder_loved)) fso.CreateFolder(folder_loved);
               
                //Save File
                function save_file(x) {
                try {
                g_text = "3dydfy://" + 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 8:
                LOVED();
break;
               
          case 9:
                YT_AUTO = 0;
                window.SetProperty("YT  Auto", "0");
                break;
     
          case 10:
                YT_AUTO = 1;
                window.SetProperty("YT  Auto", "1");
                break;
         
          case 11:
                var Start;
                Start = this.InputBox("Type Artist to Start Station\n\n( *genre - will play genre station)", "Youtube Radio", "");
                if (Start=="")
                {
                }
                else
                {
                YT_PLS_FOCUS = 1;
                window.SetProperty("YT  Playlist", "1");
                YT_AUTO = "1"
                window.SetProperty("YT  Auto", "1");
                YT_STATION = Start;
                window.SetProperty("YT  Station", Start);
                set_focus(); //Focus on playlist
                LOAD_SIMILAR();
                }
                break;
           
          case 12:
                this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
                p.artist = p.eval("%artist%");
                if (p.artist == "" || p.artist == "?") return;
                YT_STATION = p.artist;
                window.SetProperty("YT  Station", p.artist);
                YT_PLS_FOCUS = 1;
                window.SetProperty("YT  Playlist", "1");
                YT_AUTO = "1"
                window.SetProperty("YT  Auto", "1");
                set_focus(); //Focus On Playlist
                LOAD_SIMILAR();
                break;
       
          case 14:
                set_focus4(); //Focus On Playlist
                LOAD_TOP_TRACKS();
                break;
       
          /*case 16:
                p.artist = p.eval("%artist% %title%");
                p.browser("https://www.youtube.com/results?search_query=" + encodeURIComponent(p.artist));
                break;*/   
              }
        _menu.Dispose();
        }

//Features Init
    this.features_init = function() {
    for (i = 0; i < this.features.length; i++) {
    switch(this.features[i]) {
    case "metadb":
    this.selection_mode = 1;
    break;
    case "remap":
    this.artist_tf = ("%artist%");
    break;
}
}
}

    this.check_feature = function(f) {
    for (i = 0; i < this.features.length; i++) {
    if (this.features[i] == f) return true;
    }
    return false;
    }

//Eval
this.eval = function(tf) {
    if (!this.metadb || tf == "") return "";
    /*if (fb.IsPlaying && this.metadb.RawPath.indexOf("file://") != 0) {
    return fb.TitleFormat(tf).Eval();
    } else {*/
    return fb.TitleFormat(tf).EvalWithMetadb(this.metadb);
    //}
}

//Console Msg
    this.console = function(message) {
    this.name = "Youtube Radio"
    fb.trace(this.name + ": " + message);
    }

//Trim
    String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g, "");
    }   

//Input Box   
this.InputBox = function(prompt, title, value) {
    prompt = prompt.replace(/"/g, '" + Chr(34) + "').replace(/\n/g, '" + Chr(13) + "');
    title = title.replace(/"/g, '" + Chr(34) + "');
    value = value.replace(/"/g, '" + Chr(34) + "');
    var temp_value = this.vb.eval('InputBox' + '("' + prompt + '", "' + title + '", "' + value + '")');
    if (typeof temp_value == "undefined") return value;
    if (temp_value.length == 254) this.MsgBox("Your entry was too long and will be truncated.\n\nSee the WSH panel mod script discussion thread on hydrogenaudio forums for help.", 0, "Youtube Radio");
    return temp_value.trim();
}

//Msg Box
this.MsgBox = function(prompt, buttons, title) {
    prompt = prompt.replace(/"/g, '" + Chr(34) + "').replace(/\n/g, '" + Chr(13) + "');
    title = title.replace(/"/g, '" + Chr(34) + "');
    return this.vb.eval('MsgBox' + '("' + prompt + '", "' + buttons + '", "' + title + '")');
}

//Browser
this.browser = function(command) {
    if (!this.run(command)) this.MsgBox("Unable to launch your default browser.", 0, "Youtube Radio");
}

//Run Command
this.run = function(command) {
    try {
    this.WshShell.Run(command);
    return true;
    } catch(e) {
    return false;
    }
}

//Futures
    this.metadb_func = typeof on_metadb_changed == "function";
this.features = features;
this.dui = window.InstanceType;
this.metadb = fb.GetFocusItem();
this.WshShell = new ActiveXObject("WScript.Shell");
this.fso = new ActiveXObject("Scripting.FileSystemObject");
this.vb = new ActiveXObject("ScriptControl");
this.vb.Language = "VBScript";
this.artist_tf = "%artist%";
this.features_init();
    this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
    if (fb.GetFocusItem())
    {this.artist = fb.TitleFormat(this.artist_tf).EvalWithMetadb(this.metadb);}

}

//Clean Track Name
CLEAN_TRACK_NAME = function (t)
{ try
  {
    return t.split(/\(/g)[0].split(/\[/g)[0].split(/{/g)[0].split(/ Feat./g)[0].split(/ Feat/g)[0].split(/ feat/g)[0].split(/ - /g)[0].trim();
  } catch (e) {}
}

//*********************YT RADIO START**********************

var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

//LOAD SIMILAR ARTIST--------------------------------------------
this.LOAD_SIMILAR = function()
{   
if (YT_AUTO=="1")
if (YT_PLS_FOCUS=="1")
if (YT_STATION.indexOf("*")== 0) {LOAD_GENRE()} else
if (xmlhttp != null)
{
url = "http://ws.audioscrobbler.com/2.0/?method=artist.getSimilar&artist=" + encodeURIComponent(YT_STATION) + "&api_key=" + API + "&format=json&limit=" + art_hot + "&autocorrect=1";

xmlhttp.open("GET",url,true);
xmlhttp.setRequestHeader('User-Agent', "foobar2000_script");
xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4) {
        if (xmlhttp.status == 200) {
        data = xmlhttp.ResponseText;
   
try {
json_data = JSON.parse(data);

//Check Length
ln = json_data.similarartists.artist;
ln = ln.length;

//Select Random Similar Artist
randomnumber = Math.floor(Math.random()*(1-ln)+ln);
var i = randomnumber;
random_sim_art = json_data.similarartists.artist[i].name.replace(/&amp;/g, " \& ");

//Save Similar Artist
YT_SIM_ART = window.SetProperty("YT Similar", random_sim_art);
YT_SIM_ART = random_sim_art;
window.SetProperty("YT Similar", random_sim_art);

        xmlhttp.close;
        LOAD_TRACK();

} catch (err) {xmlhttp.close; p.console("Station doesn't exist!");}       
   
} else
          if (xmlhttp.status == 404) {p.console("HTTP error: " + xmlhttp.status);}
          }}
         
}try {xmlhttp.send();} catch (err) {xmlhttp.close;}
}

//LOAD TRACK----------------------------------------------------
this.LOAD_TRACK = function()
{
if (YT_AUTO=="1")
if (YT_PLS_FOCUS=="1")
if (xmlhttp != null)
{
url = "http://ws.audioscrobbler.com/2.0/?method=artist.getTopTracks&artist=" + encodeURIComponent(YT_SIM_ART) + "&api_key=" + API + "&format=json&limit=" + sng_hot + "&autocorrect=1";

xmlhttp.open("GET",url,true);
xmlhttp.setRequestHeader('User-Agent', "foobar2000_script");
xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4) {
        if (xmlhttp.status == 200) {
        data = xmlhttp.ResponseText;
     
try {
json_data = JSON.parse(data);

//Check Length
ln = json_data.toptracks.track;
ln = ln.length;

//Select Random Track
randomnumber = Math.floor(Math.random()*(1-ln)+ln);
var i = randomnumber;
random_track = json_data.toptracks.track[i].name.replace(/&amp;/g, " \& ");;
random_track = CLEAN_TRACK_NAME(random_track); //Clean Track Name
p.console("" + YT_SIM_ART + " - " + random_track);

//Save Random Track
YT_TRACK = window.SetProperty("YT Track", random_track);
YT_TRACK = random_track;
window.SetProperty("YT Track", random_track);
       
        xmlhttp.close;
        set_focus(); //Focus On Playlist
        do_youtube_search1(decodeURIComponent(YT_SIM_ART), decodeURIComponent(YT_TRACK));
       
} catch (err) {xmlhttp.close; p.console("Artist doesn't have tracks!"); if (YT_STATION.indexOf("*")== 0) {LOAD_GENRE();} else {LOAD_SIMILAR();}}       
       
} else
        if (xmlhttp.status == 404) {p.console("HTTP error: " + xmlhttp.status);}
        }}

}try {xmlhttp.send();} catch (err) {xmlhttp.close;}
}

//TOP TRACKS----------------------------------------------------
this.LOAD_TOP_TRACKS = function()
{
p.artist = p.eval("%artist%");
if (xmlhttp != null)
{   
url = "http://ws.audioscrobbler.com/2.0/?method=artist.getTopTracks&artist=" + encodeURIComponent(p.artist) + "&api_key=" + API + "&format=json&limit=50" + "&autocorrect=1";

xmlhttp.open("GET",url,true);
xmlhttp.setRequestHeader('User-Agent', "foobar2000_script");
xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4) {
        if (xmlhttp.status == 200) {
        data = xmlhttp.ResponseText;
 
try {
json_data = JSON.parse(data);

//Check Length
ln = json_data.toptracks.track;
ln = ln.length;

//List Tracks
for (i = 0; i < ln; i++)
{
list_tracks = json_data.toptracks.track[i].name.replace(/&amp;/g, " \& ");
list_tracks = CLEAN_TRACK_NAME(list_tracks); //Clean Track Name
do_youtube_search1(decodeURIComponent(p.artist), list_tracks);
}

} catch (err) {xmlhttp.close; p.console("Artist doesn't have tracks!");}       
       
} else
        if (xmlhttp.status == 404) {p.console("HTTP error: " + xmlhttp.status);}
        }}

}try {xmlhttp.send();} catch (err) {xmlhttp.close;}
}

//GENRE----------------------------------------------------
this.LOAD_GENRE = function()
{
if (YT_AUTO=="1")
if (YT_PLS_FOCUS=="1")
if (YT_STATION.indexOf("*")== 0)
if (xmlhttp != null)
{
url = "http://ws.audioscrobbler.com/2.0/?method=tag.getTopArtists&tag=" + encodeURIComponent(YT_STATION).replace("*", "") + "&api_key=" + API + "&format=json&limit=" + gnr_hot + "&autocorrect=1";
xmlhttp.open("GET",url,true);
xmlhttp.setRequestHeader('User-Agent', "foobar2000_script");
xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4) {
        if (xmlhttp.status == 200) {
        data = xmlhttp.ResponseText;
        xmlhttp.Close;
       
try {
json_data = JSON.parse(data);

//Check Length
ln = json_data.topartists.artist;
ln = ln.length;

//Select Random Genre Artist
randomnumber = Math.floor(Math.random()*(1-ln)+ln);
var i = randomnumber;
random_genre_artist = json_data.topartists.artist[i].name.replace(/&amp;/g, " \& ");

//Save Genre Artist
YT_SIM_ART = window.SetProperty("YT Similar", random_genre_artist);
YT_SIM_ART = random_genre_artist;
window.SetProperty("YT Similar", random_genre_artist);

        xmlhttp.close;
        LOAD_TRACK();

} catch (err) {xmlhttp.close; p.console("Station doesn't exist!");}
       
} else
      if (xmlhttp.status == 404) {p.console("HTTP error: " + xmlhttp.status);}
      }}

}try {xmlhttp.send();} catch (err) {xmlhttp.close;}
}

//LOVED----------------------------------------------------
this.LOVED = function()
{
                //List Files
                var arr = utils.Glob(folder_loved + "\\*.*").toArray();
                var a = [];

                for (i = 0; i < arr.length; i++) {
                if (arr[i]) a.push(arr[i]); 
                    }
                //Select Random File
                var randomnumber = Math.floor(Math.random()*Math.max(arr.length));
                i=randomnumber;
               
                file_path = arr[i];
                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[i].href.indexOf("about:/watch?v=") == 0)
          {
                i++; //Link

            //Find Title[OLD]
            /*{
            var st = text.indexOf( data[i].href.replace("about:/watch?", "") );
            var str = "a class=\"yt-uix-tile-link yt-ui-ellipsis yt-ui-ellipsis-2 yt-uix-sessionlink spf-link\">";
            st = text.indexOf(str, st) + str.length;
            var et = text.indexOf("</a>", st);
            var youtube_title = text.substr(st, et - st);
            var Y_Title = youtube_title.replace("'", "'").replace("&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[i].title;
            Remove_duration = Y_Title.substring(Y_Title.lastIndexOf(" - ")+1);
            Y_Title = data[i].title.replace(Remove_duration, "").trim();
            //p.console("Title: " + Y_Title);
               
            //Find Minutes
            var s = text.indexOf( data[i].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);
            first_match = "3dydfy://www.youtube.com/watch?" + (this.metadata ? this.metadata + "&" : "") + "fb2k_title=" + encodeURIComponent(stripped_title) + "&3dydfy_alt_length=" + encodeURIComponent(length) + "&fb2k_artist=" + encodeURIComponent(this.search_artist) + "&" + data[i].href.replace("about:/watch?", "");
            }
            //3dydfy
            if (!this.IsGoodMatch(Y_Title))
            continue;

            url = "3dydfy://www.youtube.com/watch?" + (this.metadata ? this.metadata + "&" : "") + "fb2k_title=" + encodeURIComponent(this.search_title) + "&3dydfy_alt_length=" + encodeURIComponent(length) + "&fb2k_artist=" + encodeURIComponent(this.search_artist) + "&" + data[i].href.replace("about:/watch?", "");
            break;
            }
        }

        if (!url.length)
        url = first_match;

        this.yt_link = url;

        doc.close();

        this.on_search_finished_callback(url, this.search_artist, this.search_title);
        }

        this.IsGoodMatch = function (video_name)
        {
        var clean_vid_name = clean(strip(video_name));
        var clean_artist = clean(strip(this.search_artist));
        var clean_title = clean(strip(this.search_title));

        if (clean_vid_name.indexOf(clean_artist) != -1 && clean_vid_name.indexOf(clean_title) != -1 && clean_vid_name.indexOf("full album") == -1)
        {
            //p.console("GOOD MATCH");
            return true;
        }
        else
        {
            //p.console("BAD MATCH");
            return false;
        }
    }

}

//Call Search
do_youtube_search1 = function (p_artist, p_title)
    {
    var yt_search1 = new youtube_search(function ()
    {
    yt_search1.on_state_change();
    }, on_youtube_search1_done);
    yt_search1.StartSearch(p_artist, p_title);
    }

on_youtube_search1_done = function (link, p_artist, p_title)
{
var url2="";
url2 = link;
if (!url2)
{p.console("Track Or Artist - Not Exist!"); LOAD_SIMILAR();}

if (link && link.length)
{
           
//p.console("" + "\"" + link + "\"");
YT_URL = window.SetProperty("YT URL", link);
var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath;
var str = tmppath + "\\foobar2000.exe /add ";
var go = str + link;
var tm = window.SetTimeout(function() {
p.run(go);
window.ClearTimeout™; tm = false;
}, 50);
}
    }
//**************************(END)**************************
this.artist = "";

//Set Panels
function pan1() { }
function pan2(x, y, w, h) {}
//---------------------------------------------------------

//Begin--->
var p = new panel("Youtube Radio", ["remap", "metadb"]);
var im = new pan2(0, 0, 0, 0);
var th = new pan1();

on_item_focus_change();
{
}

function on_metadb_changed() {
}

//Buttons---------------------------------------------------

var Buttons;
var g_tooltip = window.CreateTooltip();
var g_down = false;
var btn_down = null;
var cur_btn = null;

ButtonStates = {
normal: 0,
hover: 1,
down: 2
}

function Button(x, y, w, h, img_src, func, tiptext)  {
this.left = x;
this.top = y;
this.w = w;
this.h = h;
this.right = x + w;
this.bottom = y + h;
this.func = func;
this.tiptext = tiptext;
this.state = ButtonStates.normal;
this.img_normal = img_src && img_src.normal ? gdi.Image(img_src.normal) : null;
this.img_hover = img_src && img_src.hover ? gdi.Image(img_src.hover) : this.img_normal;
this.img_down = img_src && img_src.down ? gdi.Image(img_src.down) : this.img_hover;
this.img = this.img_normal;

this.alterImage = function(img_src) {
    this.img_normal = img_src && img_src.normal ? gdi.Image(img_src.normal) : null;
    this.img_hover = img_src && img_src.hover ? gdi.Image(img_src.hover) : this.img_normal;
    this.img_down = img_src && img_src.down ? gdi.Image(img_src.down) : this.img_hover;

    this.changeState(this.state);
}

this.traceMouse = function (x, y) {
    var b = (this.left < x) && (x < this.right) && (this.top < y) && (y < this.bottom);
    if (b)
    g_down ? this.changeState(ButtonStates.down) : this.changeState(ButtonStates.hover);
    else
    this.changeState(ButtonStates.normal);
    return b;
}

this.changeState = function (newstate) {
    if (newstate != this.state)
    window.RepaintRect(this.left, this.top, this.w, this.h);
    this.state = newstate;
    switch (this.state)
    {
    case ButtonStates.normal:
    this.img = this.img_normal;
    break;

    case ButtonStates.hover:
    this.img = this.img_hover;
    break;

    case ButtonStates.down:
    this.img = this.img_down;
    break;

    default:
    this.img = null;
}
}

this.draw = function (gr) {
    this.img && gr.DrawImage(this.img, this.left, this.top, this.w, this.h, 0, 0, this.w, this.h);
}

this.onClick = function () {
    this.func && this.func(x,y);
}

this.onMouseIn = function() {
    g_tooltip.Text = this.tiptext;
    g_tooltip.Activate();
}

this.onMouseOut = function() {
    g_tooltip.Deactivate();
}
}

function buttonsDraw(gr) {
for (i in Buttons) {
    Buttons[i].draw(gr);
}
}

function buttonsTraceMouse(x, y) {
var btn = null;
for (i in Buttons) {
    if (Buttons[i].traceMouse(x, y) && !btn)
    btn = Buttons[i];
}

return btn;
}

function on_mouse_move(x, y) {
var btn = buttonsTraceMouse(x, y);

if (btn != cur_btn) {
    cur_btn && cur_btn.onMouseOut();
    btn && btn.onMouseIn();
}

cur_btn = btn;
}

function on_mouse_lbtn_down(x, y) {
g_down = true;
btn_down = cur_btn;

if (cur_btn) {
    cur_btn.changeState(ButtonStates.down);
}
}

function on_mouse_lbtn_up(x, y) {
if (cur_btn) {
    cur_btn.changeState(ButtonStates.hover);
    if( btn_down == cur_btn )
    cur_btn.onClick(x, y);
}
g_down = false;
}

function on_mouse_leave() {
if (cur_btn) {
    cur_btn.changeState(ButtonStates.normal);
}
}

function on_size() {
ww = window.Width;
wh = window.Height;
    window.Repaint();
}

//Background
this.dui = window.InstanceType;
function on_paint(gr) {

    if (this.dui) {
    col = window.GetColorDUI(1);
    gr.FillSolidRect(0, 0, ww, wh, col);
    }
    else
    {
    col = window.GetColorCUI(3);   
    }

buttonsDraw(gr);

}

function RGB(r,g,b) {
return (0xff000000|(r<<16)|(g<<8)|(b));
}

function on_colors_changed() {
window.Repaint();
}

//Init Buttons--------------------------------------------

//Custom Colour
var custom = RGB(255,255,255);

//Button Width
var bw = 24;

//Button Height
var bh = 20;

//Button Position
var top_margin = 0;
var left_margin = 0;

//Folder Path
try {
var image_path0 = window.GetProperty("Button Path", "<default>");
if (image_path0=="<default>") {folder = fb.ProfilePath + "buttons";}
if (image_path0=="") {folder = fb.ProfilePath + "buttons";}
if (image_path0.indexOf(":\\") > 0) {folder = image_path0;}
var image_path = (folder + "\\");
} catch (err) {fb.trace("Youtube Radio: " + "TypeError: 'button path' undefined");}

//These 2 Lines Of Code Lock The Panel Size.
//window.MinWidth = window.MaxWidth = 24;
//window.MinHeight = window.MaxHeight = 20;

Buttons = {
but1: new Button(left_margin,top_margin,bw,bh, {normal: image_path + "youtube0.png", hover: image_path + "youtube1.png"}, function(){
    p.rbtn_up(24, 17);
    }, "Youtube")

}

function on_mouse_rbtn_up(x, y) {
return true;
}

Title: Foobar Youtube Radio
Post by: marc2003 on 2015-10-07 14:39:51
I haven't converted AppendMenuItem() to the new AppendTo() method, because i have some scripts that need to work in older WSH, changing this is not really necessary, as the old method continues to work in WSH 1.5.6.


yes but the "new" method works in v1.5.0 or above so scripts can easily be updated to support both. i suppose if you're clinging on to those ancient hacked builds of 1.4.something that allow transparency, then it's a problem.
Title: Foobar Youtube Radio
Post by: mire777 on 2015-10-07 17:53:27
I haven't converted AppendMenuItem() to the new AppendTo() method, because i have some scripts that need to work in older WSH, changing this is not really necessary, as the old method continues to work in WSH 1.5.6.


yes but the "new" method works in v1.5.0 or above so scripts can easily be updated to support both. i suppose if you're clinging on to those ancient hacked builds of 1.4.something that allow transparency, then it's a problem.


Yes i have some scripts that work only in 1.4, but since i'm now using DUI, i will update all...
Title: Foobar Youtube Radio
Post by: mire777 on 2015-10-07 19:08:14
Updated: Link> (http://www.mediafire.com/download/67f820sreiuhybp/Foobar+Youtube+Radio.zip)
It seems that ''artist.getSimilar'' API metod is down at the moment, so script wont work untill this be fixed by last.fm..
Title: Foobar Youtube Radio
Post by: marc2003 on 2015-10-07 20:22:40
you'd think after 2 months they'd start fixing stuff, not find new things to break.
Title: Foobar Youtube Radio
Post by: mire777 on 2015-10-07 23:34:14
you'd think after 2 months they'd start fixing stuff, not find new things to break.


Yes..  , 'artist.getSimilar' works again, untill they break it again
Title: Foobar Youtube Radio
Post by: mire777 on 2015-10-16 11:24:22
New version: Link> (http://www.mediafire.com/download/67f820sreiuhybp/Foobar+Youtube+Radio.zip)

Updates due to changes in tags handling in foo_youtube component.
-Fixed, script sometimes load full playlist instead of single file (if url has ''&list'' in path).
-Replaced '.fb' with '.plman' to support Marc WSH panel mod 1.6.0.
SimplePortal 1.0.0 RC1 © 2008-2020