|
|
@ -9,22 +9,20 @@ class PremiumizeMe { |
|
|
* @return array[string]mixed Informations sur le lien premiumizeme |
|
|
* @return array[string]mixed Informations sur le lien premiumizeme |
|
|
*/ |
|
|
*/ |
|
|
static function getLink($url) { |
|
|
static function getLink($url) { |
|
|
$fields = [ |
|
|
|
|
|
'method' => 'directdownloadlink', |
|
|
|
|
|
'params[login]' => getenv('PREM_CID'), |
|
|
|
|
|
'params[pass]' => getenv('PREM_PIN'), |
|
|
|
|
|
'params[link]' => $url |
|
|
|
|
|
]; |
|
|
|
|
|
$httpFields = http_build_query($fields); |
|
|
|
|
|
|
|
|
|
|
|
$ch = curl_init(); |
|
|
|
|
|
curl_setopt($ch, CURLOPT_URL, 'https://www.premiumize.me/api/transfer/directdl'); |
|
|
|
|
|
|
|
|
$fields = [ |
|
|
|
|
|
'customer_id' => getenv('PREM_CID'), |
|
|
|
|
|
'pin' => getenv('PREM_PIN'), |
|
|
|
|
|
'src' => $url |
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
$ch = curl_init(); |
|
|
|
|
|
curl_setopt($ch, CURLOPT_URL, 'https://www.premiumize.me/api/transfer/directdl'); |
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
|
curl_setopt($ch, CURLOPT_POST, 1); |
|
|
curl_setopt($ch, CURLOPT_POST, 1); |
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields)); |
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields)); |
|
|
|
|
|
|
|
|
$curlResult = curl_exec($ch); |
|
|
|
|
|
curl_close($ch); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$curlResult = curl_exec($ch); |
|
|
|
|
|
curl_close($ch); |
|
|
$data = json_decode($curlResult); |
|
|
$data = json_decode($curlResult); |
|
|
$retour = get_object_vars($data->content[0]); |
|
|
$retour = get_object_vars($data->content[0]); |
|
|
return $retour; |
|
|
return $retour; |
|
|
@ -147,7 +145,10 @@ class PremiumizeMe { |
|
|
|
|
|
|
|
|
// Pour le moment nous ne gérons que des cas avec un seul fichier retourné
|
|
|
// Pour le moment nous ne gérons que des cas avec un seul fichier retourné
|
|
|
$premInfos = PremiumizeMe::getLink($element->url); |
|
|
$premInfos = PremiumizeMe::getLink($element->url); |
|
|
var_dump('test'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
file_put_contents( 'test', $premInfos, FILE_APPEND); |
|
|
|
|
|
file_put_contents('test', stat(file_exists(DOWNLOADINGDIR.DIRECTORY_SEPARATOR.$premInfos['path']))); |
|
|
|
|
|
file_put_contents('test', stat(file_exists(DOWNLOADEDDIR.DIRECTORY_SEPARATOR.$premInfos['path']))); |
|
|
if (file_exists(DOWNLOADINGDIR.DIRECTORY_SEPARATOR.$premInfos['path']) || file_exists(DOWNLOADEDDIR.DIRECTORY_SEPARATOR.$premInfos['path'])) { |
|
|
if (file_exists(DOWNLOADINGDIR.DIRECTORY_SEPARATOR.$premInfos['path']) || file_exists(DOWNLOADEDDIR.DIRECTORY_SEPARATOR.$premInfos['path'])) { |
|
|
$element->addEvent(['state' => 'dupp' ]); |
|
|
$element->addEvent(['state' => 'dupp' ]); |
|
|
$element->updateState('dupp'); |
|
|
$element->updateState('dupp'); |
|
|
@ -160,7 +161,7 @@ var_dump('test'); |
|
|
'premURL' => $premInfos['link'], |
|
|
'premURL' => $premInfos['link'], |
|
|
'filename' => $premInfos['path'] |
|
|
'filename' => $premInfos['path'] |
|
|
]); |
|
|
]); |
|
|
var_dump('dl'); |
|
|
|
|
|
|
|
|
|
|
|
$fp = fopen(DOWNLOADINGDIR.DIRECTORY_SEPARATOR.$premInfos['path'], 'w+'); |
|
|
$fp = fopen(DOWNLOADINGDIR.DIRECTORY_SEPARATOR.$premInfos['path'], 'w+'); |
|
|
$ch = curl_init($premInfos['link']); |
|
|
$ch = curl_init($premInfos['link']); |
|
|
|
|
|
|
|
|
@ -173,7 +174,6 @@ var_dump('dl'); |
|
|
$retour = curl_getinfo($ch); |
|
|
$retour = curl_getinfo($ch); |
|
|
curl_close($ch); |
|
|
curl_close($ch); |
|
|
fclose($fp); |
|
|
fclose($fp); |
|
|
var_dump('end'); |
|
|
|
|
|
|
|
|
|
|
|
$element->updateState('downloaded'); |
|
|
$element->updateState('downloaded'); |
|
|
$element->addEvent([ |
|
|
$element->addEvent([ |
|
|
|