ptgen api point support parameter & default user

This commit is contained in:
xiaomlove
2022-02-28 23:20:42 +08:00
parent 5ed80ed637
commit b9d5df232b
51 changed files with 447 additions and 51 deletions
+7 -2
View File
@@ -31,6 +31,11 @@ class Imdb
$this->config = $config;
}
public function setDebug($debug)
{
$this->config->debug = $debug;
}
private function checkDir($dir, $langKeyPrefix)
{
global $lang_functions;
@@ -121,7 +126,7 @@ class Imdb
{
$id = parse_imdb_id($id);
$movie = $this->getMovie($id);
//because getPate() is protected, so...
//because getPage() is protected, so...
$movie->title();
$movie->photo_localurl();
$movie->releaseInfo();
@@ -278,4 +283,4 @@ class Imdb
}
return $this->ptGen;
}
}
}
+9 -1
View File
@@ -9,6 +9,7 @@
namespace Nexus\PTGen;
use GuzzleHttp\Client;
use Illuminate\Support\Str;
class PTGen
{
@@ -56,7 +57,13 @@ class PTGen
public function generate(string $url, bool $withoutCache = false): array
{
$parsed = $this->parse($url);
$targetUrl = sprintf('%s/?site=%s&sid=%s', trim($this->apiPoint, '/'), $parsed['site'] , $parsed['id']);
$targetUrl = trim($this->apiPoint, '/');
if (Str::contains($targetUrl, '?')) {
$targetUrl .= "&";
} else {
$targetUrl .= "?";
}
$targetUrl .= sprintf('site=%s&sid=%s', $parsed['site'] , $parsed['id']);
return $this->request($targetUrl, $withoutCache);
}
@@ -128,6 +135,7 @@ HTML;
return $cache;
}
}
do_log("$logPrefix, going to send request...");
$http = new Client();
$response = $http->get($url, ['timeout' => 5]);
$statusCode = $response->getStatusCode();