updated API to v2 for better efficiency
Este commit está contenido en:
43
js/script.js
43
js/script.js
@@ -3,13 +3,13 @@
|
||||
const RADIO_NAME = 'Game! Radio 1';
|
||||
|
||||
// SELECT ARTWORK PROVIDER, ITUNES, DEEZER & SPOTIFY eg : spotify
|
||||
var API_SERVICE = 'SPOTIFY';
|
||||
var API_SERVICE = 'deezer';
|
||||
|
||||
// Change Stream URL Here, Supports, ICECAST, ZENO, SHOUTCAST, RADIOJAR ETC.... DOES NOT SUPPORT HLS
|
||||
const URL_STREAMING = 'https://stream-51.zeno.fm/cfhkm5fs1uhvv?zs=HOu6hxV1SG-7iGi9WGVTqQ';
|
||||
|
||||
//NOW PLAYING API.
|
||||
const API_URL = 'https://api.joeycast.com/songid/4eb1b192-cff3-4b95-a46c-13cbc5048730'
|
||||
const API_URL = 'https://api-v2.streamafrica.net/metadata?url=' + URL_STREAMING
|
||||
|
||||
// Visit https://api.vagalume.com.br/docs/ to get your API key
|
||||
const API_KEY = "18fe07917957c289983464588aabddfb";
|
||||
@@ -75,10 +75,10 @@ function Page() {
|
||||
xhttp.onreadystatechange = function () {
|
||||
if (this.readyState === 4 && this.status === 200) {
|
||||
var data = JSON.parse(this.responseText);
|
||||
var artworking = data.results;
|
||||
var gotit = artworking.artwork;
|
||||
var artwork = data.results.artwork;
|
||||
var artworkXL = artwork.large;
|
||||
|
||||
document.querySelectorAll('#historicSong article .cover-historic')[n].style.backgroundImage = 'url(' + gotit + ')';
|
||||
document.querySelectorAll('#historicSong article .cover-historic')[n].style.backgroundImage = 'url(' + artworkXL + ')';
|
||||
}
|
||||
// Formating characters to UTF-8
|
||||
var music = info.song.replace(/'/g, '\'');
|
||||
@@ -94,7 +94,7 @@ function Page() {
|
||||
$historicDiv[n].classList.add('animated');
|
||||
$historicDiv[n].classList.add('slideInRight');
|
||||
}
|
||||
xhttp.open('GET', 'https://api.streamafrica.net/new.search.php?query=' + info.artist + ' ' + info.song + '&service=' + API_SERVICE.toLowerCase());
|
||||
xhttp.open('GET', 'https://api-v2.streamafrica.net/musicsearch?query=' + info.artist + ' ' + info.song + '&service=' + API_SERVICE.toLowerCase());
|
||||
xhttp.send();
|
||||
|
||||
setTimeout(function () {
|
||||
@@ -118,7 +118,7 @@ function Page() {
|
||||
if (this.readyState === 4 && this.status === 200) {
|
||||
var data = JSON.parse(this.responseText);
|
||||
var artworkUrl100 = data.results;
|
||||
var urlCoverArt = artworkUrl100.artwork;
|
||||
var urlCoverArt = artworkUrl100.artwork.medium;
|
||||
|
||||
coverArt.style.backgroundImage = 'url(' + urlCoverArt + ')';
|
||||
coverArt.className = 'animated bounceInLeft';
|
||||
@@ -168,7 +168,7 @@ function Page() {
|
||||
}
|
||||
}
|
||||
}
|
||||
xhttp.open('GET', 'https://api.streamafrica.net/new.search.php?query=' + artist + ' ' + song + '&service=' + API_SERVICE.toLowerCase());
|
||||
xhttp.open('GET', 'https://api-v2.streamafrica.net/musicsearch?query=' + artist + ' ' + song + '&service=' + API_SERVICE.toLowerCase());
|
||||
xhttp.send();
|
||||
}
|
||||
|
||||
@@ -334,37 +334,33 @@ function mute() {
|
||||
function getStreamingData() {
|
||||
var xhttp = new XMLHttpRequest();
|
||||
xhttp.onreadystatechange = function () {
|
||||
|
||||
if (this.readyState === 4 && this.status === 200) {
|
||||
|
||||
if(this.response.length === 0) {
|
||||
console.log('%cdebug', 'font-size: 22px')
|
||||
if (this.response.length === 0) {
|
||||
console.log('%cdebug', 'font-size: 22px');
|
||||
}
|
||||
|
||||
var data = JSON.parse(this.responseText);
|
||||
console.log('Received data:', data); // Add this line for debugging
|
||||
|
||||
var page = new Page();
|
||||
|
||||
// Formating characters to UTF-8
|
||||
let song = data.currentSong.replace(/'/g, '\'');
|
||||
currentSong = song.replace(/&/g, '&');
|
||||
|
||||
let artist = data.currentArtist.replace(/'/g, '\'');
|
||||
currentArtist = artist.replace(/&/g, '&');
|
||||
let song = data.song ? data.song.replace(/'/g, '\'') : '';
|
||||
let artist = data.artist ? data.artist.replace(/'/g, '\'') : '';
|
||||
|
||||
// Change the title
|
||||
document.title = currentSong + ' - ' + currentArtist + ' | ' + RADIO_NAME;
|
||||
document.title = song + ' - ' + artist + ' | ' + RADIO_NAME;
|
||||
|
||||
if (document.getElementById('currentSong').innerHTML !== song) {
|
||||
page.refreshCover(currentSong, currentArtist);
|
||||
page.refreshCurrentSong(currentSong, currentArtist);
|
||||
page.refreshLyric(currentSong, currentArtist);
|
||||
page.refreshCover(song, artist);
|
||||
page.refreshCurrentSong(song, artist);
|
||||
page.refreshLyric(song, artist);
|
||||
|
||||
for (var i = 0; i < 2; i++) {
|
||||
page.refreshHistoric(data.songHistory[i], i);
|
||||
page.refreshHistoric(data.history[i], i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var d = new Date();
|
||||
@@ -538,4 +534,3 @@ function intToDecimal(vol) {
|
||||
function decimalToInt(vol) {
|
||||
return vol * 100;
|
||||
}
|
||||
|
||||
|
||||
Referencia en una nueva incidencia
Block a user