View difference between Paste ID: qkxggr8e and 8Gj5gFLr
SHOW: | | - or go back to the newest paste.
1
// ==PREPROCESSOR==
2
// @name "Youtube Radio"
3
// @author "Mire777"
4
// @feature "v1.4"
5
// @feature "watch-metadb"
6
// ==/PREPROCESSOR==
7
8
//Properties
9-
auto_yt = window.GetProperty("YT  Radio", "0");
9+
auto_yt = window.GetProperty("YT  Playlist", "0");
10
AUTO = window.GetProperty("YT  Auto", "0");
11
ooo2 = window.GetProperty("YT Track", "");
12
START_ARTIST = window.GetProperty("YT  Station", "");
13
last_fm = window.GetProperty("YT Similar", "");
14
YT_URL = window.GetProperty("YT URL", "");
15
art = window.GetProperty("YT   Artist Variety (1-20)", "20");
16
sng = window.GetProperty("YT   Song  Hotness (1-20)", "20");
17
gnr = window.GetProperty("YT   Tag  Hotness (1-100)", "27");
18
pls = window.GetProperty("FB Playlist", "YT Radio");
19
20
var MF_GRAYED = 0x00000001;
21
var MF_STRING = 0x00000000;
22
var IDC_ARROW = 32512;
23
var IDC_HAND = 32649;
24
25
function RGB(r, g, b) {
26
	return (0xff000000 | (r << 16) | (g << 8) | (b));
27
}
28
29
function RGBA(r, g, b, a) {
30
	return ((a << 24) | (r << 16) | (g << 8) | (b));
31
}
32
33
function on_colors_changed() {
34
	p.colors_changed();
35
}
36
37
function on_selection_changed() {
38
	p.item_focus_change();
39
}
40
41
function on_playlist_switch() {
42
    set_focus0(); //Check Playlist
43
}
44
45
function on_playback_new_track() {
46
	p.item_focus_change();
47
    downloadLFM();
48
}
49
50
function on_playback_dynamic_info_track() {
51
	p.item_focus_change();
52
}
53
54
function on_playback_stop() {
55
	p.item_focus_change();
56
}
57
58
function on_item_focus_change() {
59
	p.item_focus_change();
60
}
61
62
function on_mouse_leave() {
63
	
64
}
65
66
function on_mouse_rbtn_up(x, y) {
67
	p.rbtn_up(x, y);
68
	return true;
69
}
70
71
//Playlist
72
function GetPlaylistID(Playlist_Name)
73
{
74
    for (var i = 0; i < fb.PlaylistCount; i++)
75
    {
76
        if (fb.GetPlaylistName(i) == Playlist_Name)
77
        
78
        {
79
            return i;
80
        }
81
    }
82
    // create playlist if it doesn't exist
83
    fb.CreatePlaylist(fb.PlaylistCount, Playlist_Name);
84
    return i;
85
}
86
87
//Playlist(Check)
88
function GetPlaylistID0(Playlist_Name)
89
{
90
    for (var i = 0; i < fb.PlaylistCount; i++)
91
    
92
    if (fb.GetPlaylistName(i) == Playlist_Name)
93
        
94
        {
95
            return i;
96
        }
97
}
98
99
//Focus on playlist(Check)
100
function set_focus0()
101
{   if (pls>"")
102
    {
103
var PL_NM = (GetPlaylistID0(pls + " ["+ START_ARTIST +"]"));
104
if (fb.ActivePlaylist == PL_NM) {auto_yt = 1; window.SetProperty("YT  Playlist", "1");}
105-
if (fb.ActivePlaylist == PL_NM) {auto_yt = 1; window.SetProperty("YT  Radio", "1");}
105+
106
{auto_yt = 0; window.SetProperty("YT  Playlist", "0");}
107-
{auto_yt = 0; window.SetProperty("YT  Radio", "0");}
107+
108
}
109
110
//Focus on playlist(YT Radio)
111
function set_focus()
112
{   if (pls>"")
113
    fb.ActivePlaylist = (GetPlaylistID(pls + " ["+ START_ARTIST +"]"));
114
}
115
116
//Focus on playlist(Same Video)
117
function set_focus2()
118
{   if (pls>"")
119
    fb.ActivePlaylist = (GetPlaylistID(pls + " [Same Video]"));
120
}
121
122
123
//Focus on playlist(Search Videos)
124
function set_focus3()
125
{   if (pls>"")
126
    fb.ActivePlaylist = (GetPlaylistID(pls + " [Search Videos]"));
127
}
128
129
//Panel
130
function panel(name, features) {
131
	this.item_focus_change = function() {
132
		if (!this.metadb_func) return;
133
		switch(this.selection_mode) {
134
			case 0:
135
				this.metadb = fb.GetSelection();
136
				break;
137
			case 1:
138
				this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
139
				break;
140
			case 2:
141
				this.metadb = fb.GetFocusItem();
142
				break;
143
		}
144
		if (this.metadb) on_metadb_changed();
145
	}
146
147
//Metadb
148
this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
149
150
151
//Size	
152
	this.size = function() {
153
		this.w = window.Width;
154
		this.h = window.Height;
155
	}
156
157
//Move	
158
	this.move = function(x, y) {
159
		this.mx = x;
160
		this.my = y;
161
	}
162
163
//Menu	
164
	this.rbtn_up = function(x, y) {
165
		var _menu = window.CreatePopupMenu();
166
		var idx;
167
		switch(true) {
168
			
169
			
170
			case typeof th == "object":
171
			case typeof im == "object":
172
on_item_focus_change()
173
if (pls>"")
174
{					
175
if(AUTO==1) _menu.AppendMenuItem(MF_STRING, 1902, "Youtube Radio");
176
if(AUTO==0) _menu.AppendMenuItem(MF_STRING, 1903, "Youtube Radio");
177
_menu.CheckMenuItem(1902, AUTO?1:0);
178
179
_menu.AppendMenuSeparator();
180
{
181
if(auto_yt==1 && AUTO==1 && START_ARTIST>"") {_menu.AppendMenuItem(MF_STRING, 22, "Get Next Video");}
182
else
183
{_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Get Next Video");}
184
185
_menu.AppendMenuItem(MF_STRING, 401, "Search Videos");
186
187
_menu.AppendMenuSeparator();
188
189
_menu.AppendMenuItem(MF_STRING, 1914, "Start Radio Station");
190
191
p.artist = p.eval("%artist%");
192
if (p.artist == "" || p.artist == "?") {_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Same Artist Station");}
193
else
194
{_menu.AppendMenuItem(MF_STRING, 1915, "Same Artist Station");}
195
196
_menu.AppendMenuSeparator();
197
198
p.artist = p.eval("%artist%");
199
if (p.artist == "" || p.artist == "?") {_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Open Same Video");}
200
else
201
{_menu.AppendMenuItem(MF_STRING, 403, "Open Same Video");}
202
203
p.artist = p.eval("%artist%");
204
if (p.artist == "" || p.artist == "?") {_menu.AppendMenuItem(MF_STRING| MF_GRAYED, 2000, "Find in Browser");}
205
else
206
{_menu.AppendMenuItem(MF_STRING, 404, "Find in Browser");}
207
					
208
_menu.AppendMenuSeparator();
209
210
_menu.AppendMenuItem(MF_STRING, 9, "Properties...");
211
}				
212
}
213
} 
214
if (pls=="") {_menu.AppendMenuItem(MF_STRING, 9, "Please Set: (FB Playlist)");}
215
if (utils.IsKeyPressed(0x10)) _menu.AppendMenuItem(MF_STRING, 10, "Configure...");
216
		
217
        idx = _menu.TrackPopupMenu(x, y);
218
		switch(idx) {
219
           case 9:
220
				window.ShowProperties();
221
				break;
222
                
223
           case 10:
224
				window.ShowConfigure();
225
				break;
226
                
227
           case 22:
228
                set_focus(); //Focus on playlist
229
				downloadLFM();
230
				break;
231
                
232
           case 401:
233
                set_focus3(); //Focus on playlist
234
				fb.RunMainMenuCommand("View/Youtube Source");
235
				break;
236
                
237
           case 403:
238
            this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
239-
            on_item_focus_change();
239+
240
            downloadART_TITLE();
241
				break;
242
			
243
           case 404:
244
            p.artist = p.eval("%artist% %title%");
245
            p.browser("http://www.youtube.com/results?search_query=" + encodeURIComponent(p.artist));
246
                break;
247
           
248
           case 1902:
249
                AUTO = 0;
250
                window.SetProperty("YT  Auto", "0");
251
                break;
252
       
253
           case 1903:
254
                AUTO = 1;
255
                window.SetProperty("YT  Auto", "1");
256
                break; 
257
           
258
           case 1914:
259
            var Start;
260
            Start = this.InputBox("Type Artist to Start Station\n\n( *genre - will play genre station)", "Youtube Radio", "");
261
            if (Start=="")
262
            {
263
            }
264
            else
265
            {
266
            auto_yt = 1;
267
            window.SetProperty("YT  Playlist", "1");
268-
            window.SetProperty("YT  Radio", "1");
268+
269
            window.SetProperty("YT  Auto", "1");
270
            START_ARTIST = Start;
271
            window.SetProperty("YT  Station", Start);
272
            set_focus(); //Focus on playlist
273
            downloadLFM();
274
            }
275
                break;
276
            
277
        case 1915:
278
            this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
279
            p.artist = p.eval("%artist%");
280
            if (p.artist == "" || p.artist == "?") return;
281
            START_ARTIST = p.artist;
282
            window.SetProperty("YT  Station", p.artist);
283
            auto_yt = 1;
284
            window.SetProperty("YT  Playlist", "1");
285-
            window.SetProperty("YT  Radio", "1");
285+
286
            window.SetProperty("YT  Auto", "1");
287
            set_focus(); //Focus on playlist
288-
            on_item_focus_change();
288+
289
                break;
290
        }
291
		_menu.Dispose();
292
	}
293
294
//Features init
295
	this.features_init = function() {
296
		for (i = 0; i < this.features.length; i++) {
297
			switch(this.features[i]) {
298
				case "metadb":
299
					this.selection_mode = 1;
300
					break;
301
				case "remap":
302
					this.artist_tf = ("%artist%");
303
					break;
304
			}
305
		}
306
	}
307
	
308
	this.check_feature = function(f) {
309
		for (i = 0; i < this.features.length; i++) {
310
			if (this.features[i] == f) return true;
311
		}
312
		return false;
313
	}
314
	
315
	this.eval = function(tf) {
316
		if (!this.metadb || tf == "") return "";
317
		if (fb.IsPlaying && this.metadb.RawPath.indexOf("file://") != 0) {
318
			return fb.TitleFormat(tf).Eval();
319
		} else {
320
			return fb.TitleFormat(tf).EvalWithMetadb(this.metadb);
321
		}
322
	}
323
	
324
//Console Msg
325
	this.console = function(message) {
326
	this.name = "Youtube Radio"	
327
        fb.trace(this.name + ": " + message);
328
	}
329
	
330
//Trim
331
String.prototype.trim = function() {
332
	return this.replace(/^\s+|\s+$/g, "");
333
}    
334
335
//Input Box    
336
	this.InputBox = function(prompt, title, value) {
337
		prompt = prompt.replace(/"/g, '" + Chr(34) + "').replace(/\n/g, '" + Chr(13) + "');
338
		title = title.replace(/"/g, '" + Chr(34) + "');
339
		value = value.replace(/"/g, '" + Chr(34) + "');
340
		var temp_value = this.vb.eval('InputBox' + '("' + prompt + '", "' + title + '", "' + value + '")');
341
		if (typeof temp_value == "undefined") return value;
342
		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");
343
		return temp_value.trim();
344
	}
345
346
//Msg Box	
347
	this.MsgBox = function(prompt, buttons, title) {
348
		prompt = prompt.replace(/"/g, '" + Chr(34) + "').replace(/\n/g, '" + Chr(13) + "');
349
		title = title.replace(/"/g, '" + Chr(34) + "');
350
		return this.vb.eval('MsgBox' + '("' + prompt + '", "' + buttons + '", "' + title + '")');
351
	}
352
353
//Browser	
354
	this.browser = function(command) {
355
		if (!this.run(command)) this.MsgBox("Unable to launch your default browser.", 0, "Youtube Radio");
356
	}
357
358
//Run Command	
359
	this.run = function(command) {
360
		try {
361
			this.WshShell.Run(command);
362
			return true;
363
		} catch(e) {
364
			return false;
365
		}
366
	}
367
	
368
//futures	
369
    this.metadb_func = typeof on_metadb_changed == "function";
370
	this.features = features;
371
	this.dui = window.InstanceType;
372
	this.metadb = fb.GetFocusItem();
373
	this.WshShell = new ActiveXObject("WScript.Shell");
374
	this.fso = new ActiveXObject("Scripting.FileSystemObject");
375
	this.vb = new ActiveXObject("ScriptControl");
376
	this.vb.Language = "VBScript";
377
	this.artist_tf = "%path%";
378
	this.features_init();
379
    this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
380
    if (fb.GetFocusItem())
381
    {this.artist = fb.TitleFormat(this.artist_tf).EvalWithMetadb(this.metadb);}
382
383
}
384
//YT NAMES-------------------------------------------------
385
386
//Clean Art Name
387
CLEAN_ART_NAME = function (t)
388
{
389
    try
390
    {
391
        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","'");
392
    } catch (e) {}
393
}
394
395
//Clean Track Name
396
CLEAN_TRACK_NAME = function (t)
397
{
398
    try
399
    {
400
        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(last_fm) + " -"," ").replace(decodeURIComponent(last_fm) + " - "," ").replace(" - Live ","").replace(" - Live","").replace(" Pt.1","").replace(" - Demo;2 Digital Remaster 66  ","").replace(" - Demo;2 Digital Remaster","").replace(" - Demo;","").replace(" - Demo","").replace("Digital Remaster","").replace("Original-  ","").replace("Original- ","").replace("Original-","").replace(" - Vocal Version","").replace(" Mega-Mix","").replace("Mega-Mix","").replace(" - Original Mix","").replace(" Pop Radio Edit","").replace(" Radio Edit","").replace(" - Single Version","").replace(" - Edited Version","").replace("- ","").replace("- ","").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(last_fm), " ").replace(" - Survival Remix","").replace(" Radio Mix","").replace(" Survival Remix","").replace("Survival Remix","").replace(decodeURIComponent(last_fm) + "-"," ").replace(decodeURIComponent(last_fm)," ").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();
401
    } catch (e) {}
402
}
403
404
//Clean Genre Name
405
CLEAN_GENRE_NAME = function (t)
406
{
407
    try
408
    {
409
        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];
410
    } catch (e) {}
411
}
412
413
//*********************YT RADIO START**********************
414
415
//SIMILAR--------------------------------------------------
416
this.downloadLFM = function()
417
{     if (AUTO=="1")
418
      if (auto_yt=="1")
419
    
420
    { var randomnumber=Math.floor(Math.random()*art)
421
      var a=randomnumber;
422
        if (START_ARTIST == "" || START_ARTIST == "?") return;
423
		if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
424
		this.xmlhttp.open("GET", "http://www.last.fm/music/" + encodeURIComponent(START_ARTIST) + "/+similar"+ "?page=" + a, true);
425
		this.xmlhttp.send();
426
		this.xmlhttp.onreadystatechange = function() {
427
			if (this.xmlhttp.readyState == 4) {
428
				if (this.xmlhttp.status == 200) {
429
					var text = this.xmlhttp.responsetext;
430
					if (!this.doc) this.doc = new ActiveXObject("htmlfile");
431
					this.doc.open();
432
					var div = this.doc.createElement("div");
433
					div.innerHTML = text;
434
					var data = div.getElementsByTagName("a");
435
					var urls = [];
436
    
437
			
438
439
for (i = 0; i < data.length; i++) {
440
     if (data[i].href.indexOf("about:/music/") == 0) urls.push(CLEAN_ART_NAME(data[i].href));   
441
}
442
443
//select random URL
444
var randomnumber = Math.floor(Math.random()*(20-50)+50);
445
do{
446
randomnumber = Math.floor(Math.random()*(20-50)+50);
447
} while(randomnumber%2!=1);
448
i=randomnumber;
449
450
{
451
452
//Start with urls[i]
453
if (urls[i] > "") 
454
{
455
//p.console("" + urls[i]);
456
last_fm = window.SetProperty("YT Similar", urls[i]);
457
last_fm = urls[i];
458
window.SetProperty("YT Similar", urls[i]);
459
}
460
else
461
{
462
last_fm = window.SetProperty("YT Similar", "");
463
last_fm = "";
464
window.SetProperty("YT Similar", "");
465
}                   
466
}
467
            
468
                this.doc.close();
469
                if (START_ARTIST.indexOf("*")== 0) {downloadGENRE();}
470
                else
471
                if (last_fm == "" || last_fm == "?") {downloadLFM();}
472
                else
473
                downloadTRACK();
474
				} else {
475
                if (START_ARTIST.indexOf("*")== 0) {downloadGENRE();}
476
                else
477
                if (this.xmlhttp.status == 404) {p.console("HTTP error: " + this.xmlhttp.status); downloadLFM();}
478
                }
479
			}
480
		}
481
	}                             
482
483
}
484
485
//TRACK----------------------------------------------------
486
this.downloadTRACK = function()
487
{
488
     
489
    {var randomnumber=Math.floor(Math.random()*sng)
490
      var a=randomnumber;
491
        if (last_fm == "" || last_fm == "?") return;
492
		if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
493
		this.xmlhttp.open("GET", "http://www.last.fm/music/" + encodeURIComponent(last_fm) + "/+tracks" + "?page=" + a, true);
494
		this.xmlhttp.send();
495
		this.xmlhttp.onreadystatechange = function() {
496
			if (this.xmlhttp.readyState == 4) {
497
				if (this.xmlhttp.status == 200) {
498
					var text = this.xmlhttp.responsetext;
499
					if (!this.doc) this.doc = new ActiveXObject("htmlfile");
500
					this.doc.open();
501
					var div = this.doc.createElement("tr");
502
					div.innerHTML = text;
503
					var data = div.getElementsByTagName("td");
504
					var urls = [];
505
    
506
			
507
508
for (i = 0; i < data.length; i++) {
509
    if (data[i].title) urls.push(CLEAN_TRACK_NAME(data[i].title));
510
}
511
512
//select random URL
513
var randomnumber = Math.floor(Math.random()*Math.max(urls.length));
514
i=randomnumber;
515
516
{
517
518
//Start with urls[i]
519
if (urls[i] > "") 
520
{
521
p.console("" + last_fm + " - " + urls[i]);
522
523
ooo2 = window.SetProperty("YT Track", urls[i]);
524
ooo2 = urls[i];
525
window.SetProperty("YT Track", urls[i]);
526
}
527
else
528
{
529
ooo2 = window.SetProperty("YT Track", "");
530
ooo2 = "";
531
window.SetProperty("YT Track", "");
532
}
533
}
534
535
                this.doc.close();
536
                if (ooo2 == "" || ooo2 == "?") {downloadLFM();}
537
                else
538
                set_focus(); //focus on playlist
539
                downloadYT(decodeURIComponent(last_fm), decodeURIComponent(ooo2));
540
				} else {
541-
                do_youtube_search1(decodeURIComponent(last_fm), decodeURIComponent(ooo2));
541+
542
                if (START_ARTIST.indexOf("*")== 0) {downloadGENRE();}
543
                else
544
                if (this.xmlhttp.status == 404) {downloadLFM();}
545
                
546
                }
547
			}
548
		}
549
	}
550
}
551
552
553
//SAME VIDEO-----------------------------------------------
554
this.downloadART_TITLE = function()
555
     {
556
       var artist0 = p.eval("%artist%");
557
       var title0 = p.eval("%title%");
558
       if(artist0 > "?" && title0 > "?") {set_focus2(); downloadYT(decodeURIComponent(artist0), decodeURIComponent(title0));}
559
}
560-
       if(artist0 > "?" && title0 > "?") {set_focus2(); do_youtube_search1(decodeURIComponent(artist0), decodeURIComponent(title0));}
560+
561
//GENRE----------------------------------------------------
562
this.downloadGENRE = function()
563
     {
564
         
565
      if (START_ARTIST.indexOf("*")== 0)
566
   
567
    { var randomnumber=Math.floor(Math.random()*gnr)
568
      var a=randomnumber;
569
        if (START_ARTIST == "" || START_ARTIST == "?") return;
570
		if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
571
		this.xmlhttp.open("GET", "http://www.last.fm/music/+tag/" + encodeURIComponent(START_ARTIST).replace("*","") + "?page=" + a, true);
572
		this.xmlhttp.send();
573
		this.xmlhttp.onreadystatechange = function() {
574
			if (this.xmlhttp.readyState == 4) {
575
				if (this.xmlhttp.status == 200) {
576
					var text = this.xmlhttp.responsetext;
577
					if (!this.doc) this.doc = new ActiveXObject("htmlfile");
578
					this.doc.open();
579
					var div = this.doc.createElement("li");
580
					div.innerHTML = text;
581
					var data = div.getElementsByTagName("a");
582
					var urls = [];
583
    
584
			
585
586
for (i = 0; i < data.length; i++) {
587
    if (data[i].className.indexOf("name") == 0)
588
    if (data[i].href.indexOf("about:/music/") == 0) urls.push(CLEAN_GENRE_NAME(data[i].href));
589
 }
590
591
//select random URL
592
var randomnumber = Math.floor(Math.random()*(0-9)+9);
593
do{
594
randomnumber = Math.floor(Math.random()*(0-9)+9);
595
} while(randomnumber%2!=0);
596
597
i=randomnumber;
598
599
{
600
601
//Start with urls[i]
602
if (urls[i] > "") 
603
{
604
//p.console("" + urls[i]);
605
last_fm = window.SetProperty("YT Similar", urls[i]);
606
last_fm = urls[i];
607
window.SetProperty("YT Similar", urls[i]);
608
}
609
else
610
{
611
last_fm = window.SetProperty("YT Similar", "");
612
last_fm = "";
613
window.SetProperty("YT Similar", "");
614
}
615
}
616
                this.doc.close();
617
                if (last_fm == "" || last_fm == "?") {downloadGENRE();}
618
                else
619
                downloadTRACK();
620
				} else {
621
					p.console("HTTP error: " + this.xmlhttp.status);
622
				    if (this.xmlhttp.status == 404) {downloadGENRE();}
623
                }
624
			}
625
		}
626
	}
627
}
628
629
//LOAD YOUTUBE VIDEO---------------------------------------
630
631
//Convert minutes
632-
strip_title = function (t1, t2)
632+
633
{
634
    var parts = min.split(':'),
635
    minutes = +parts[0],
636-
        if (t1 == t2)
636+
637-
            return t1;
637+
638-
        if (t1.match(RegExp(t2 + "( and | & )", "i")))
638+
639-
            return t1;
639+
640-
        var a = "(by the |by: |by |of |the |feat. |ft. |)";
640+
//Start
641-
        var b = "( feat.| ft.|)";
641+
this.downloadYT = function(p_art, p_titl)
642-
        var t3 = "";
642+
   {
643-
        if (!t2.match(/^the /i))
643+
        if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
644
        this.xmlhttp.open("GET", "http://www.youtube.com/results?search_query=" +  encodeURIComponent(p_art) + " %2D " + encodeURIComponent(p_titl), true);
645-
            t3 = t1.replace(RegExp("[^a-z\\d_)\\]\"]*(" + a + t2 + b + ")[^a-z\\d_(\\[\"]*","gi")," - ").replace(/^[^a-z()\[\]\d\"]*|[^a-z()\[\]\d\"]*$/gi, "");
645+
646
        this.xmlhttp.onreadystatechange = function() {
647
        if (this.xmlhttp.readyState == 4) {
648
        if (this.xmlhttp.status == 200) {
649-
            var t4 = t2.replace(/^the /i, "")
649+
650-
            t3 = t1.replace(RegExp("[^a-z\\d_)\\]\"]*(" + a + t4 + b + ")[^a-z\\d_(\\[\"]*","gi")," - ").replace(/^[^a-z()\[\]\d\"]*|[^a-z()\[\]\d\"]*$/gi, "");
650+
        if (!this.doc) this.doc = new ActiveXObject("htmlfile");
651
        this.doc.open();
652-
        return t3.match(/\S/) ? t3 : t1;
652+
        var div = this.doc.createElement("div");
653
        div.innerHTML = text;
654-
    catch (e)
654+
655
        var urls = [];
656-
        return t1;
656+
657
//Find minutes..
658
for (var i = 0; i < 34; i++)
659
{
660
if (data[i].href.indexOf("about:/watch?v=") == 0)
661
{
662
        i++;
663
        //p.console("I: " + i);
664
        var s = text.indexOf( data[i].href.replace("about:/watch?", "") );
665
        var str = "<span class=\"video-time\">";
666
        s = text.indexOf(str, s) + str.length;
667
        var e = text.indexOf("</span>", s);
668
        var length = text.substr(s, e - s);
669
        length = convert(length);
670
        length = length ? length : "";
671-
strip = function (t)
671+
}} 
672
673
if (length=="")
674
{
675-
        t = t.replace(/[\.,\!\?\:;'"\-_]/g,"").toLowerCase();
675+
for (var i = 0; i < 35; i++)
676-
        return t;
676+
677-
    } catch (e)
677+
if (data[i].href.indexOf("about:/watch?v=") == 0)
678-
    {}
678+
679
        i++;
680
        //p.console("I: " + i);
681-
clean = function (t)
681+
        var s = text.indexOf( data[i].href.replace("about:/watch?", "") );
682
        var str = "<span class=\"video-time\">";
683
        s = text.indexOf(str, s) + str.length;
684
        var e = text.indexOf("</span>", s);
685-
        return t.replace(/'/g, "’").toLowerCase();
685+
        var length = text.substr(s, e - s);
686
        length = convert(length);
687
        length = length ? length : "";
688
}}     
689
}
690
691
//Find video
692-
youtube_search = function (state_change_callback, p_on_search_finished_callback)
692+
693
    if (data[i].href.indexOf("about:/watch?v=") == 0) urls.push("" + data[i].href.replace(/about:\//,"").replace("watch?",""));
694-
    this.xmlhttp = null;
694+
695-
    this.http_callback_funct = null;
695+
696-
    this.ready_state_change_callback = state_change_callback;
696+
i = 1;
697-
    this.search_done = false;
697+
698-
    this.on_search_finished_callback = p_on_search_finished_callback;
698+
699-
    this.yt_link;
699+
 
700-
    this.search_artist;
700+
701-
    this.search_title;
701+
702-
    this.metadata;
702+
703
if (urls[i] > "" && ooo2 > "")
704-
    this.on_state_change = function ()
704+
705
YT_URL = window.SetProperty("YT URL", urls[i]);
706-
        if (this.xmlhttp != null && this.xmlhttp.readyState == 4 && this.xmlhttp.status == 200 && this.http_callback_funct != null)
706+
YT_URL = urls[i];
707-
            this.http_callback_funct();
707+
window.SetProperty("YT URL", urls[i]);
708
 
709
var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath;
710-
    this.StartSearch = function (p_artist, p_title, p_extra_metadata)
710+
711
var go = str + "3dydfy://www.youtube.com/watch?fb2k_artist=" + encodeURIComponent(p_art) + "&fb2k_title=" + encodeURIComponent(p_titl) + "&3dydfy_alt_length=" + encodeURIComponent(length) + "&"  + urls[i];
712-
        this.search_artist = p_artist;
712+
713-
        this.search_title = p_title;
713+
714-
        this.metadata = p_extra_metadata;
714+
715-
        this.http_callback_funct = null;
715+
716-
        this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
716+
YT_URL = window.SetProperty("YT URL", "");
717
YT_URL = "";
718-
        var URL = "http://www.youtube.com/results?search_query=" + encodeURIComponent(p_artist + " " + p_title);
718+
window.SetProperty("YT URL", "");
719
}
720-
        this.http_callback_funct = this.AnalyseSearch;
720+
721-
        this.xmlhttp.open("GET", URL);
721+
 
722-
        this.xmlhttp.onreadystatechange = this.ready_state_change_callback;
722+
723
                if (YT_URL == "" || YT_URL == "?") {downloadLFM();}
724
                } else {
725
                p.console("HTTP error: " + this.xmlhttp.status);
726-
    this.AnalyseSearch = function ()
726+
727
                else
728
                if (this.xmlhttp.status == 404) {downloadLFM();}
729-
        var doc = new ActiveXObject("htmlfile");
729+
730-
        doc.open();
730+
731-
        var div = doc.createElement("div");
731+
732
    }
733
    
734-
        var url = "";
734+
735-
        var first_match;
735+
736
737-
        re_test:
737+
738
function pan1() { }
739-
        for (var i = 0; i < data.length; i++)
739+
740
//---------------------------------------------------------
741-
            if (data[i].href.indexOf("about:/watch?v=") == 0)
741+
742
//Begin--->
743-
                i++; //the title is on the second link
743+
744
var im = new pan2(0, 0, 0, 0);
745-
//check if track exist?                
745+
746-
//if((data[i].title.toLowerCase()).indexOf(decodeURIComponent(last_fm.toLowerCase()).split(" ")[0]) > 0)
746+
747-
//if((data[i].title.toLowerCase()).indexOf(decodeURIComponent(ooo2.toLowerCase()).split(" ")[0]) > 0)
747+
748-
//if((data[i].title.toLowerCase()).indexOf(decodeURIComponent(ooo2.toLowerCase()).split(" ")[1]) > 0)
748+
749-
//if((data[i].title.toLowerCase()).indexOf(decodeURIComponent(ooo2.toLowerCase()).split(" ")[2]) > 0)
749+
750
751
function on_metadb_changed() {
752-
                var s = text.indexOf( data[i].href.replace("about:/watch?", "") );
752+
753-
                var str = "<span class=\"video-time\">";
753+
754-
                s = text.indexOf(str, s) + str.length;
754+
755-
                var e = text.indexOf("</span>", s);
755+
756-
                var length = text.substr(s, e - s);
756+
757-
                length = convert(length);
757+
758-
                length = length ? length : "";
758+
759-
                if (!first_match)
759+
760-
{                   
760+
761-
                    // title stripped of artist name if same as search_artist
761+
762-
                    var stripped_title = strip_title(data[i].title, this.search_artist); 
762+
763-
                    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?", "");
763+
764
ButtonStates = {
765-
                //3dydfy
765+
766-
                if (!this.IsGoodMatch(data[i].title))
766+
767-
                    continue;
767+
768
}
769-
                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?", "");
769+
770
function Button(x, y, w, h, img_src, func, tiptext)  {
771
	this.left = x;
772
	this.top = y;
773
	this.w = w;
774
	this.h = h;
775
	this.right = x + w;
776-
        if (!url.length)
776+
777-
            url = first_match;
777+
778
	this.tiptext = tiptext;
779-
        this.yt_link = url;
779+
780
	this.img_normal = img_src && img_src.normal ? gdi.Image(img_src.normal) : null;
781-
        doc.close();
781+
782
	this.img_down = img_src && img_src.down ? gdi.Image(img_src.down) : this.img_hover;
783-
        this.on_search_finished_callback(url, this.search_artist, this.search_title);
783+
784
	
785
	this.alterImage = function(img_src) {
786
		this.img_normal = img_src && img_src.normal ? gdi.Image(img_src.normal) : null;
787-
    this.IsGoodMatch = function (video_name)
787+
788
		this.img_down = img_src && img_src.down ? gdi.Image(img_src.down) : this.img_hover;
789-
        var clean_vid_name = clean(strip(video_name));
789+
790-
        var clean_artist = clean(strip(this.search_artist));
790+
791-
        var clean_title = clean(strip(this.search_title));
791+
792
	
793-
        if (clean_vid_name.indexOf(clean_artist) != -1 && clean_vid_name.indexOf(clean_title) != -1 && clean_vid_name.indexOf("full album") == -1)
793+
794
		var b = (this.left < x) && (x < this.right) && (this.top < y) && (y < this.bottom);
795-
            //p.console("GOOD MATCH");
795+
796-
            return true;
796+
797
		else
798
			this.changeState(ButtonStates.normal);
799
		return b;
800-
            //p.console("BAD MATCH");
800+
801-
            return false;
801+
802
	
803
	this.changeState = function (newstate) {
804
		if (newstate != this.state)
805
			window.RepaintRect(this.left, this.top, this.w, this.h);
806
		this.state = newstate;
807-
//Call Search
807+
808-
do_youtube_search1 = function (p_artist, p_title)
808+
809
		case ButtonStates.normal:
810-
        var yt_search1 = new youtube_search(function ()
810+
811
			break;
812-
            yt_search1.on_state_change();
812+
813-
        }, on_youtube_search1_done);
813+
814-
        yt_search1.StartSearch(p_artist, p_title);
814+
815
			break;
816
			
817-
    on_youtube_search1_done = function (link, p_artist, p_title)
817+
818
			this.img = this.img_down;
819-
var url2="";
819+
820-
url2 = link;
820+
821-
if (!url2)
821+
822-
{p.console("Track Or Artist - Not Exist!"); downloadLFM();} 
822+
823
		}
824-
        if (link && link.length)
824+
825
	
826
	this.draw = function (gr) {
827-
p.console("" + "\"" + link + "\"");
827+
828-
YT_URL = window.SetProperty("YT URL", link);
828+
829
	
830
	this.onClick = function () {
831-
var go = str + link;
831+
832
	}
833
	
834
	this.onMouseIn = function() {
835
		g_tooltip.Text = this.tiptext;
836
		g_tooltip.Activate();
837
	}
838
	
839
	this.onMouseOut = function() {
840
		g_tooltip.Deactivate();
841
	}
842
}
843
844
function buttonsDraw(gr) {
845
	for (i in Buttons) {
846
		Buttons[i].draw(gr);
847
	}
848
}
849
850
function buttonsTraceMouse(x, y) {
851
	var btn = null;
852
	for (i in Buttons) {
853
		if (Buttons[i].traceMouse(x, y) && !btn)
854
			btn = Buttons[i];
855
	}
856
857
	return btn;
858
}
859
860
function on_mouse_move(x, y) {
861
	var btn = buttonsTraceMouse(x, y);
862
	
863
	if (btn != cur_btn) {
864
		cur_btn && cur_btn.onMouseOut();
865
		btn && btn.onMouseIn();
866
	}
867
	
868
	cur_btn = btn;
869
}
870
871
function on_mouse_lbtn_down(x, y) {
872
	g_down = true;
873
	btn_down = cur_btn;
874
875
	if (cur_btn) {
876
		cur_btn.changeState(ButtonStates.down);
877
	}
878
}
879
880
function on_mouse_lbtn_up(x, y) {
881
	if (cur_btn) {
882
		cur_btn.changeState(ButtonStates.hover);
883
		if( btn_down == cur_btn )
884
			cur_btn.onClick(x, y);
885
	}
886
	g_down = false;
887
}
888
889
function on_mouse_leave() {
890
	if (cur_btn) {
891
		cur_btn.changeState(ButtonStates.normal);
892
	}
893
}
894
895
function on_size() {
896
	ww = window.Width;
897
	wh = window.Height;
898
    window.Repaint();
899
}
900
901
//Background
902
this.dui = window.InstanceType;
903
function on_paint(gr) {
904
	
905
        if (this.dui) {
906
			col = window.GetColorDUI(1);
907
			gr.FillSolidRect(0, 0, ww, wh, col);
908
        } 
909
        else
910
        {
911
        col = window.GetColorCUI(3);    
912
		}
913
914
	buttonsDraw(gr);
915
	
916
}
917
918
function RGB(r,g,b) {
919
	return (0xff000000|(r<<16)|(g<<8)|(b)); 
920
}
921
922
function on_colors_changed() {
923
    window.Repaint();
924
}
925
926
//Init Buttons--------------------------------------------
927
928
//Custom colour
929
var custom = RGB(255,255,255);
930
931
//Button width
932
var bw = 24;
933
934
//Button height
935
var bh = 20;
936
937
//Button position
938
var top_margin = -1;
939
var left_margin = 0;
940
941
var image_path0 = window.GetProperty("Button Path", fb.ProfilePath + "image");
942
var image_path = (image_path0 + "\\");
943
944
//These 2 lines of code lock the panel size.
945
//window.MinWidth = window.MaxWidth = 24;
946
//window.MinHeight = window.MaxHeight = 20;
947
948
949
Buttons = {
950
	but1: new Button(left_margin,top_margin,bw,bh, {normal: image_path + "youtube0.png", hover: image_path + "youtube1.png"}, function(){
951
        p.rbtn_up(24, 17);
952
        //downloadONE();
953
        }, "Youtube")
954
	
955
}
956
957
function on_mouse_rbtn_up(x, y) {
958
return true;
959
}