mirror of
https://github.com/WhatCD/Gazelle.git
synced 2025-01-18 04:01:35 +00:00
Empty commit
This commit is contained in:
parent
8bcb79a947
commit
04e21fe020
@ -171,6 +171,12 @@ private static function lastfm_request($Method, $Args) {
|
||||
if (!defined('LASTFM_API_KEY')) {
|
||||
return false;
|
||||
}
|
||||
$RecentFailsKey = 'lastfm_api_fails';
|
||||
$RecentFails = (int)G::$Cache->get_value($RecentFailsKey);
|
||||
if ($RecentFails > 5) {
|
||||
// Take a break if last.fm's API is down/nonfunctional
|
||||
return false;
|
||||
}
|
||||
$Url = LASTFM_API_URL . $Method;
|
||||
if (is_array($Args)) {
|
||||
foreach ($Args as $Key => $Value) {
|
||||
@ -180,11 +186,16 @@ private static function lastfm_request($Method, $Args) {
|
||||
|
||||
$Curl = curl_init();
|
||||
curl_setopt($Curl, CURLOPT_HEADER, 0);
|
||||
curl_setopt($Curl, CURLOPT_CONNECTTIMEOUT, 30);
|
||||
curl_setopt($Curl, CURLOPT_TIMEOUT, 3);
|
||||
curl_setopt($Curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($Curl, CURLOPT_URL, $Url);
|
||||
$Return = curl_exec($Curl);
|
||||
$Errno = curl_errno($Curl);
|
||||
curl_close($Curl);
|
||||
if ($Errno) {
|
||||
G::$Cache->cache_value($RecentFailsKey, $RecentFails + 1, 1800);
|
||||
return false;
|
||||
}
|
||||
return json_decode($Return, true);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user