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