106
API.WebRadio.Tools / Re : Bibliothèques hébergées v3.5.1 (Stable)
« le: 31 Janvier 2018 à 02:31:50 »
Update : 31/01/2018 :
-: Correction d'un bug avec les ".
-: Correction d'un bug avec les ".
Cette section vous permet de consulter les contributions (messages, sujets et fichiers joints) d'un utilisateur. Vous ne pourrez voir que les contributions des zones auxquelles vous avez accès.
Cela vient d'un nouvel encodage de l'api en UTF-8.
Pouvez-vous m’envoyer en MP le script en question... je vais faire les modifications pour prendre en charge correctement l'UTF-8.
c'est fait!
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="//ajax.webradio.tools/3.5.1/webradio.tools.min.js"></script>
<script type="text/javascript">
/*################################*/
/*###### CONFIGURATION DU VU #####*/
/*################################*/
var src = ''; // Icecast = http://[IP/URL]:[PORT][/MOUNT], Shoutcast = http://[IP/URL]:[PORT]/;stream.mp3
var type = 'audio/mpeg';// MP3/AAC = audio/mpeg, OGG = audio/ogg
var preload = 'auto'; // auto, metadata, none
var controls = true; // true, false
var autoplay = false; // true, false
var vu_range = 3.9; // High frequency dead zone
var vu_height = 13.5; // Maximum height of the VU
var vu_color_a = '#FFFFFF'; // VU CAP Color #FFFFFF
var vu_color_b = '#00FF00'; // VU TOP Color #00FF00
var vu_color_c = '#FFFF00'; // VU MIDDLE Color #FFFF00
var vu_color_d = '#FF0000'; // VU BOTTOM Color #FF0000
var volume_color_h = 217; // 0 to 359 (H Color > https://www.w3schools.com/colors/colors_hsl.asp)
var volume_color_l = 61; // 0 to 100 (L Color > https://www.w3schools.com/colors/colors_hsl.asp)
</script>
<div id="show_canvas"><canvas id="canvas" width="300" height="60"></canvas></div> <!-- Afficher le VU -->
<div id="show_player"></div> <!-- Affiche le player (obligatoir) -->
<span id="play">PLAY</span> <!-- Afficher le bouton PLAY -->
<span id="stop">STOP</span> <!-- Afficher le bouton STOP -->
<span id="play_stop">PLAY&STOP</span> <!-- Afficher le bouton PLAY/STOP -->
<span id="mute">MUTE</span> <!-- Afficher le bouton MUTE -->
<div id="volume"></div> <!-- Afficher le volume -->
<?php
####################################
###### CONFIGURATION DE L'API ######
####################################
$q = ""; // {artiste} ou {titre} ou {artiste} - {titre}
$ssl = TRUE; // Secure Socket Layer (SSL) (avec = TRUE | sans = FALSE)
####################################
######### NE PAS MODIFIER ##########
####################################
function BomUTF8($data){ if(substr($data,0,3)==chr(hexdec('EF')).chr(hexdec('BB')).chr(hexdec('BF'))){ return substr($data,3); } else { return $data; } }
$_curl = curl_init();
curl_setopt_array($_curl, array(
CURLOPT_URL => ($ssl?'https':'http').'://covers.webradio.tools/?q='.rawurlencode($q),
CURLOPT_TIMEOUT => 3,
CURLOPT_HEADER => false,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_RETURNTRANSFER => true
)); $api = json_decode(BomUTF8(curl_exec($_curl)));
curl_close($_curl);
####################################
##### DÉFINITION DES REQUÊTES ######
####################################
print $api->query; // Affiche le terme de la recherche
print $api->request_method; // Affiche la méthode de contact (GET|POST)
print $api->server_protocol; // Affiche le protocole serveur utiliser
print $api->remote_addr; // Affiche l'adresse IP du client qui demande la page
print $api->execution_time; // Affiche le temps de réponse de l'API
print $api->callmeback; // Affiche le délai avant de pouvoir recontacter l'API (/1000)
print $api->version; // Affiche la version de l'API
print $api->copyright; // Affiche le copyright
print $api->result[0]->artist; // Affiche l'artiste
print $api->result[0]->title; // Affiche le titre
print $api->result[0]->covers->small; // Affiche la pochette (small)
print $api->result[0]->covers->medium; // Affiche la pochette (medium)
print $api->result[0]->covers->large; // Affiche la pochette (large)
print $api->result[0]->covers->extralarge; // Affiche la pochette (extralarge)
?>
<script type="text/javascript">
function webradio_tools(){ $(function(){
/*################################*/
/*#### CONFIGURATION DE L'API ####*/
/*################################*/
var a = ''; // IP/URL du serveur (sans http://)
var b = ''; // Port du serveur
var c = ''; // Point de montage (ICECAST='/stream' | SHOUTCAST='')
var d = ''; // UID Radionomy (Affiche le nombre d'auditeurs)
/*################################*/
/*####### NE PAS MODIFIER ########*/
/*################################*/
$.get('//api.3.5.1.webradio.tools/' + a + ':' + b + c + '/' + d, function(api){
var api = $.parseJSON(api); setTimeout('webradio_tools();', api.callmeback);
/*################################*/
/*### DÉFINITION DES REQUÊTES ####*/
/*################################*/
$('#DivName').html(api.ip); // Affiche l'adresse IP/URL
$('#DivName').html(api.port); // Affiche le port
$('#DivName').html(api.mount); // Affiche le point de montage (/stream)
$('#DivName').html(api.server_type); // Affiche le type de serveur
$('#DivName').html(api.radionomy_uid); // Affiche le UID Radionomy
$('#DivName').html(api.request_method); // Affiche la méthode de contact (GET|POST)
$('#DivName').html(api.server_protocol); // Affiche le protocole serveur utiliser
$('#DivName').html(api.cache_timestamp); // Affiche le temps de mise en cache
$('#DivName').html(api.callmeback); // Affiche le délai avant de pouvoir recontacter l'API (/1000)
$('#DivName').html(api.version); // Affiche la version de l'API
$('#DivName').html(api.copyright); // Affiche le copyright
$('#DivName').html(api.current_song.artist); // Affiche l'artiste
$('#DivName').html(api.current_song.title); // Affiche le titre
$('#DivName').html(api.current_song.covers.small); // Affiche la pochette (small)
$('#DivName').html(api.current_song.covers.medium); // Affiche la pochette (medium)
$('#DivName').html(api.current_song.covers.large); // Affiche la pochette (large)
$('#DivName').html(api.current_song.covers.extralarge); // Affiche la pochette (extralarge)
$('#DivName').html(api.listener.now); // Affiche le nombre d'auditeurs
$('#DivName').html(api.listener.peak); // Affiche le pic d'auditeurs
$('#DivName').html(api.song_history.No1.artist); // Affiche le dernier artiste No1
$('#DivName').html(api.song_history.No1.title); // Affiche le dernier titre No1
$('#DivName').html(api.song_history.No1.covers.small); // Affiche la dernière pochette No1 (small)
$('#DivName').html(api.song_history.No1.covers.medium); // Affiche la dernière pochette No1 (medium)
$('#DivName').html(api.song_history.No1.covers.large); // Affiche la dernière pochette No1 (large)
$('#DivName').html(api.song_history.No1.covers.extralarge); // Affiche la dernière pochette No1 (extralarge)
$('#DivName').html(api.song_history.No2.artist); // Affiche le dernier artiste No2
$('#DivName').html(api.song_history.No2.title); // Affiche le dernier titre No2
$('#DivName').html(api.song_history.No2.covers.small); // Affiche la dernière pochette No2 (small)
$('#DivName').html(api.song_history.No2.covers.medium); // Affiche la dernière pochette No2 (medium)
$('#DivName').html(api.song_history.No2.covers.large); // Affiche la dernière pochette No2 (large)
$('#DivName').html(api.song_history.No2.covers.extralarge); // Affiche la dernière pochette No2 (extralarge)
$('#DivName').html(api.song_history.No3.artist); // Affiche le dernier artiste No3
$('#DivName').html(api.song_history.No3.title); // Affiche le dernier titre No3
$('#DivName').html(api.song_history.No3.covers.small); // Affiche la dernière pochette No3 (small)
$('#DivName').html(api.song_history.No3.covers.medium); // Affiche la dernière pochette No3 (medium)
$('#DivName').html(api.song_history.No3.covers.large); // Affiche la dernière pochette No3 (large)
$('#DivName').html(api.song_history.No3.covers.extralarge); // Affiche la dernière pochette No3 (extralarge)
$('#DivName').html(api.song_history.No4.artist); // Affiche le dernier artiste No4
$('#DivName').html(api.song_history.No4.title); // Affiche le dernier titre No4
$('#DivName').html(api.song_history.No4.covers.small); // Affiche la dernière pochette No4 (small)
$('#DivName').html(api.song_history.No4.covers.medium); // Affiche la dernière pochette No4 (medium)
$('#DivName').html(api.song_history.No4.covers.large); // Affiche la dernière pochette No4 (large)
$('#DivName').html(api.song_history.No4.covers.extralarge); // Affiche la dernière pochette No4 (extralarge)
$('#DivName').html(api.song_history.No5.artist); // Affiche le dernier artiste No5
$('#DivName').html(api.song_history.No5.title); // Affiche le dernier titre No5
$('#DivName').html(api.song_history.No5.covers.small); // Affiche la dernière pochette No5 (small)
$('#DivName').html(api.song_history.No5.covers.medium); // Affiche la dernière pochette No5 (medium)
$('#DivName').html(api.song_history.No5.covers.large); // Affiche la dernière pochette No5 (large)
$('#DivName').html(api.song_history.No5.covers.extralarge); // Affiche la dernière pochette No5 (extralarge)
});
}); }
$(document).ready(function(){ webradio_tools(); }); $.ajaxSetup({ cache: false });
</script>
<?php
####################################
###### CONFIGURATION DE L'API ######
####################################
$a = ''; // IP/URL du serveur (sans http://)
$b = ''; // Port du serveur
$c = ''; // Point de montage (ICECAST='/stream' | SHOUTCAST='')
$d = ''; // UID Radionomy (Affiche le nombre d'auditeurs)
$ssl = TRUE; // Secure Socket Layer (SSL) (avec = TRUE | sans = FALSE)
####################################
######### NE PAS MODIFIER ##########
####################################
function BomUTF8($data){ if(substr($data,0,3)==chr(hexdec('EF')).chr(hexdec('BB')).chr(hexdec('BF'))){ return substr($data,3); } else { return $data; } }
if(!file_exists('./cache')){ if(!mkdir ('./cache',0777)){ exit('Erreur de création du dossier "cache" ...'); } } $date = '-1';
$cache = './cache/api.webradio.tools.json';
$_cache = './cache/api.webradio.tools.call';
if($lines = file($_cache)){
$date = (isset($lines[1]) ? $lines[1] : '-1');
$time = $lines[0];
$expire = time() - $time;
} else { $expire = time() - 1; }
if(@file_exists($cache) && $date > $expire && file_get_contents($cache) != ''){
$api = json_decode(@file_get_contents($cache));
} else { $_curl = curl_init();
curl_setopt_array($_curl, array(
CURLOPT_URL => ($ssl?'https':'http').'://api.3.5.1.webradio.tools/'.$a.':'.$b.$c.'/'.$d,
CURLOPT_TIMEOUT => 3,
CURLOPT_HEADER => false,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_RETURNTRANSFER => true
)); $api = BomUTF8(curl_exec($_curl));
$callmeback = json_decode($api);
$callmeback = $callmeback->callmeback/1000;
curl_close($_curl);
if(!$api){ $api = json_decode(@file_get_contents($cache)); } else {
@file_put_contents($cache, $api);
@file_put_contents($_cache, $callmeback."\n".time());
} $api = json_decode($api);
}
####################################
##### DÉFINITION DES REQUÊTES ######
####################################
print $api->ip; // Affiche l'adresse IP/URL
print $api->port; // Affiche le port
print $api->mount; // Affiche le point de montage (/stream)
print $api->server_type; // Affiche le type de serveur
print $api->radionomy_uid; // Affiche le UID Radionomy
print $api->request_method; // Affiche la méthode de contact (GET|POST)
print $api->server_protocol; // Affiche le protocole serveur utiliser
print $api->cache_timestamp; // Affiche le temps de mise en cache
print $api->callmeback; // Affiche le délai avant de pouvoir recontacter l'API (/1000)
print $api->version; // Affiche la version de l'API
print $api->copyright; // Affiche le copyright
print $api->current_song->artist; // Affiche l'artiste
print $api->current_song->title; // Affiche le titre
print $api->current_song->covers->small; // Affiche la pochette (small)
print $api->current_song->covers->medium; // Affiche la pochette (medium)
print $api->current_song->covers->large; // Affiche la pochette (large)
print $api->current_song->covers->extralarge; // Affiche la pochette (extralarge)
print $api->listener->now; // Affiche le nombre d'auditeurs
print $api->listener->peak; // Affiche le pic d'auditeurs
print $api->song_history->No1->artist; // Affiche le dernier artiste No1
print $api->song_history->No1->title; // Affiche le dernier titre No1
print $api->song_history->No1->covers->small; // Affiche la dernière pochette No1 (small)
print $api->song_history->No1->covers->medium; // Affiche la dernière pochette No1 (medium)
print $api->song_history->No1->covers->large; // Affiche la dernière pochette No1 (large)
print $api->song_history->No1->covers->extralarge; // Affiche la dernière pochette No1 (extralarge)
print $api->song_history->No2->artist; // Affiche le dernier artiste No2
print $api->song_history->No2->title; // Affiche le dernier titre No2
print $api->song_history->No2->covers->small; // Affiche la dernière pochette No2 (small)
print $api->song_history->No2->covers->medium; // Affiche la dernière pochette No2 (medium)
print $api->song_history->No2->covers->large; // Affiche la dernière pochette No2 (large)
print $api->song_history->No2->covers->extralarge; // Affiche la dernière pochette No2 (extralarge)
print $api->song_history->No3->artist; // Affiche le dernier artiste No3
print $api->song_history->No3->title; // Affiche le dernier titre No3
print $api->song_history->No3->covers->small; // Affiche la dernière pochette No3 (small)
print $api->song_history->No3->covers->medium; // Affiche la dernière pochette No3 (medium)
print $api->song_history->No3->covers->large; // Affiche la dernière pochette No3 (large)
print $api->song_history->No3->covers->extralarge; // Affiche la dernière pochette No3 (extralarge)
print $api->song_history->No4->artist; // Affiche le dernier artiste No4
print $api->song_history->No4->title; // Affiche le dernier titre No4
print $api->song_history->No4->covers->small; // Affiche la dernière pochette No4 (small)
print $api->song_history->No4->covers->medium; // Affiche la dernière pochette No4 (medium)
print $api->song_history->No4->covers->large; // Affiche la dernière pochette No4 (large)
print $api->song_history->No4->covers->extralarge; // Affiche la dernière pochette No4 (extralarge)
print $api->song_history->No5->artist; // Affiche le dernier artiste No5
print $api->song_history->No5->title; // Affiche le dernier titre No5
print $api->song_history->No5->covers->small; // Affiche la dernière pochette No5 (small)
print $api->song_history->No5->covers->medium; // Affiche la dernière pochette No5 (medium)
print $api->song_history->No5->covers->large; // Affiche la dernière pochette No5 (large)
print $api->song_history->No5->covers->extralarge; // Affiche la dernière pochette No5 (extralarge)
?>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="//ajax.webradio.tools/3.5.1/webradio.tools.min.js"></script>
<script type="text/javascript">
/*################################*/
/*#### CONFIGURATION DE L'API ####*/
/*################################*/
var a = ''; // IP/URL du serveur (sans http://)
var b = ''; // Port du serveur
var c = ''; // Point de montage (ICECAST='/stream' | SHOUTCAST='')
var d = 'small'; // Taille de l'image (small, medium, large, extralarge)
var e = '//covers.webradio.tools/no_img.png'; // Pochette par défaut
var f = ''; // UID Radionomy (Affiche le nombre d'auditeurs)
</script>
<!-- ###############################
##### DÉFINITION DES REQUÊTES ######
################################ -->
<span id="artist_wrt"></span> <!-- Affiche l'artiste -->
<span id="title_wrt"></span> <!-- Affiche le titre -->
<span id="albcov_wrt"></span> <!-- Affiche la pochette -->
<span id="current_wrt"></span> <!-- Affiche le nombre d'auditeurs -->
<span id="current_peak_wrt"></span> <!-- Affiche le pic d'auditeurs -->
<span id="last_artist_1"></span> <!-- Affiche le dernier artiste No1 -->
<span id="last_title_1"></span> <!-- Affiche le dernier titre No1 -->
<span id="last_albcov_1"></span> <!-- Affiche la dernière pochette No1 -->
<span id="last_artist_2"></span> <!-- Affiche le dernier artiste No2 -->
<span id="last_title_2"></span> <!-- Affiche le dernier titre No2 -->
<span id="last_albcov_2"></span> <!-- Affiche la dernière pochette No2 -->
<span id="last_artist_3"></span> <!-- Affiche le dernier artiste No3 -->
<span id="last_title_3"></span> <!-- Affiche le dernier titre No3 -->
<span id="last_albcov_3"></span> <!-- Affiche la dernière pochette No3 -->
<span id="last_artist_4"></span> <!-- Affiche le dernier artiste No4 -->
<span id="last_title_4"></span> <!-- Affiche le dernier titre No4 -->
<span id="last_albcov_4"></span> <!-- Affiche la dernière pochette No4 -->
<span id="last_artist_5"></span> <!-- Affiche le dernier artiste No5 -->
<span id="last_title_5"></span> <!-- Affiche le dernier titre No5 -->
<span id="last_albcov_5"></span> <!-- Affiche la dernière pochette No5 -->