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