From 4cf1cbb382d13d80c4bf46b9f2354594d66bb1dd Mon Sep 17 00:00:00 2001 From: smoralis Date: Sat, 5 Aug 2023 15:43:41 +0300 Subject: [PATCH] cover_url (planetradio api) --- profile/themes/footuner/js/lastfm_cover.js | 34 +++++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/profile/themes/footuner/js/lastfm_cover.js b/profile/themes/footuner/js/lastfm_cover.js index 77031b5..58bb01e 100644 --- a/profile/themes/footuner/js/lastfm_cover.js +++ b/profile/themes/footuner/js/lastfm_cover.js @@ -50,17 +50,40 @@ function delete_cover() { function lfm_download() { cover_url = tfo.cover_url.Eval(); - cover_url = cover_url.split('?')[0]; + cover_url = cover_url.split('?')[0]; if (cover_url && cover_url.match("^https?:\\/\\/.+\\.(jpg|jpeg|png|webp|avif|gif|svg)$")) { - cover_url = cover_url.split('?')[0]; + cover_url = cover_url.split('?')[0]; loaded = 0; album_cover_file = lastfm_cover_download_folder + "\\" + _fbSanitise(tfo.artist.Eval()) + " - " + _fbSanitise(tfo.title.Eval()) + "." + cover_url.split('.').pop(); - lfm_image_dl(cover_url, album_cover_file); + lfm_image_dl(cover_url, album_cover_file); return; } + if (cover_url && cover_url.match("https://listenapi.planetradio.co.uk")) { + xml2http.open('GET', cover_url); + xml2http.setRequestHeader('User-Agent', "spider_monkey_panel_footuner"); + xml2http.onreadystatechange = () => { + if (xml2http.readyState == 4) { + if (xml2http.status == 200) { + let json_data = _jsonParse(xml2http.responseText); + let album_url; + if (json_data.eventImageUrl) { + album_url = json_data.eventImageUrl; + album_url = album_url.split('?')[0]; + } + if (album_url) { + loaded = 0; + album_cover_file = lastfm_cover_download_folder + "\\" + _fbSanitise(tfo.artist.Eval()) + " - " + _fbSanitise(tfo.title.Eval()) + "." + album_url.split('.').pop(); + lfm_image_dl(album_url, album_cover_file); + return; + } + } + } + } + xml2http.send(); + } if (tfo.artist.Eval() && tfo.title.Eval() && api_key) { let url = "https://ws.audioscrobbler.com/2.0/?method=track.getInfo&api_key=" + api_key + "&artist=" + encodeURIComponent(tfo.artist.Eval()) + "&track=" + encodeURIComponent(tfo.title.Eval()) + "&format=json"; - xmlhttp.open('GET', url); + xmlhttp.open('GET', url); xmlhttp.setRequestHeader('User-Agent', "spider_monkey_panel_footuner"); xmlhttp.onreadystatechange = () => { if (xmlhttp.readyState == 4) { @@ -154,6 +177,9 @@ let timer = setInterval(() => { if (cover_url && cover_url.match("^https?:\\/\\/.+\\.(jpg|jpeg|png|webp|avif|gif|svg)$")) { window.NotifyOthers("lastfm", "Album cover_url found in stream"); } + if (cover_url && cover_url.match("https://listenapi.planetradio.co.uk")) { + window.NotifyOthers("lastfm", "Album cover_url (planetradio) found in stream"); + } thumbs.update(); } catch (err) { console.log(window.Name + " : (timer) : " + err);