fix: no url to download in aliyun
parent
f6f9687e53
commit
d46cd7c962
|
@ -11,6 +11,8 @@ class Aliyundrive {
|
||||||
$this->api_url = 'https://api.aliyundrive.com/v2';
|
$this->api_url = 'https://api.aliyundrive.com/v2';
|
||||||
$this->api_url_v3 = 'https://api.aliyundrive.com/adrive/v3';
|
$this->api_url_v3 = 'https://api.aliyundrive.com/adrive/v3';
|
||||||
$this->driveId = getConfig('driveId', $tag);
|
$this->driveId = getConfig('driveId', $tag);
|
||||||
|
//$this->DownurlStrName = 'download_url';
|
||||||
|
$this->DownurlStrName = 'url';
|
||||||
$res = $this->get_access_token(getConfig('refresh_token', $tag));
|
$res = $this->get_access_token(getConfig('refresh_token', $tag));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +53,7 @@ class Aliyundrive {
|
||||||
$tmp['time'] = $files['updated_at'];
|
$tmp['time'] = $files['updated_at'];
|
||||||
$tmp['size'] = $files['size'];
|
$tmp['size'] = $files['size'];
|
||||||
$tmp['mime'] = $files['file']['mimeType'];
|
$tmp['mime'] = $files['file']['mimeType'];
|
||||||
$tmp['url'] = $files['download_url'];
|
$tmp['url'] = $files[$this->DownurlStrName];
|
||||||
$tmp['content'] = $files['content'];
|
$tmp['content'] = $files['content'];
|
||||||
if (isset($files['exist'])) $tmp['exist'] = $files['exist'];
|
if (isset($files['exist'])) $tmp['exist'] = $files['exist'];
|
||||||
if (isset($files['rapid_upload'])) $tmp['rapid_upload'] = $files['rapid_upload'];
|
if (isset($files['rapid_upload'])) $tmp['rapid_upload'] = $files['rapid_upload'];
|
||||||
|
@ -67,7 +69,7 @@ class Aliyundrive {
|
||||||
$filename = strtolower($file['name']);
|
$filename = strtolower($file['name']);
|
||||||
if ($file['type']=='file') {
|
if ($file['type']=='file') {
|
||||||
$tmp['list'][$filename]['type'] = 'file';
|
$tmp['list'][$filename]['type'] = 'file';
|
||||||
$tmp['list'][$filename]['url'] = $file['download_url'];
|
$tmp['list'][$filename]['url'] = $file[$this->DownurlStrName];
|
||||||
$tmp['list'][$filename]['mime'] = $file['file']['content_type'];
|
$tmp['list'][$filename]['mime'] = $file['file']['content_type'];
|
||||||
} elseif ($file['type']=='folder') {
|
} elseif ($file['type']=='folder') {
|
||||||
$tmp['list'][$filename]['type'] = 'folder';
|
$tmp['list'][$filename]['type'] = 'folder';
|
||||||
|
@ -123,7 +125,7 @@ class Aliyundrive {
|
||||||
if (!(isset($files['content'])&&$files['content']['stat']==200)) {
|
if (!(isset($files['content'])&&$files['content']['stat']==200)) {
|
||||||
$header['Referer'] = 'https://www.aliyundrive.com/';
|
$header['Referer'] = 'https://www.aliyundrive.com/';
|
||||||
$header['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36';
|
$header['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36';
|
||||||
$content1 = curl('GET', $files['download_url'], '', $header);
|
$content1 = curl('GET', $files[$this->DownurlStrName], '', $header);
|
||||||
$tmp = null;
|
$tmp = null;
|
||||||
$tmp = json_decode(json_encode($content1), true);
|
$tmp = json_decode(json_encode($content1), true);
|
||||||
if ($tmp['body']===null) {
|
if ($tmp['body']===null) {
|
||||||
|
@ -346,7 +348,7 @@ class Aliyundrive {
|
||||||
$r = bchexdec( substr(md5($this->access_token), 0, 16) );
|
$r = bchexdec( substr(md5($this->access_token), 0, 16) );
|
||||||
$o = bcmod($r, $oldfile['size']);
|
$o = bcmod($r, $oldfile['size']);
|
||||||
}
|
}
|
||||||
$res = curl('GET', $oldfile['download_url'], '', [
|
$res = curl('GET', $oldfile[$this->DownurlStrName], '', [
|
||||||
'Referer' => ''
|
'Referer' => ''
|
||||||
, 'Range' => 'bytes=' . $o . '-' . ($o+7)
|
, 'Range' => 'bytes=' . $o . '-' . ($o+7)
|
||||||
]);
|
]);
|
||||||
|
@ -627,7 +629,7 @@ class Aliyundrive {
|
||||||
}
|
}
|
||||||
$res = json_decode($result['body'], true);
|
$res = json_decode($result['body'], true);
|
||||||
//if (isset($res['url']))
|
//if (isset($res['url']))
|
||||||
$res['download_url'] = $_SERVER['host'] . path_format($_SERVER['base_disk_path'] . '/' . $path . '/' . $filename);
|
$res[$this->DownurlStrName] = $_SERVER['host'] . path_format($_SERVER['base_disk_path'] . '/' . $path . '/' . $filename);
|
||||||
}
|
}
|
||||||
return output(json_encode($this->files_format($res), JSON_UNESCAPED_SLASHES), $result['stat']);
|
return output(json_encode($this->files_format($res), JSON_UNESCAPED_SLASHES), $result['stat']);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue