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