Skip to content

Commit

Permalink
cover_url (planetradio api)
Browse files Browse the repository at this point in the history
  • Loading branch information
smoralis committed Aug 5, 2023
1 parent 1ed4dbd commit 4cf1cbb
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions profile/themes/footuner/js/lastfm_cover.js
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 4cf1cbb

Please sign in to comment.