mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 14:10:57 +08:00
refactor default imdb
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
"require": {
|
||||
"php": "^7.2|^8",
|
||||
"swiftmailer/swiftmailer": "^6.2",
|
||||
"guzzlehttp/guzzle": "~6.0"
|
||||
"guzzlehttp/guzzle": "~6.0",
|
||||
"imdbphp/imdbphp": "^6.4"
|
||||
}
|
||||
}
|
||||
|
||||
259
composer.lock
generated
259
composer.lock
generated
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "5e27df0bf1d474656f062b3f264353ee",
|
||||
"content-hash": "add117e8cfda2fcb53a82b4804c76fd4",
|
||||
"packages": [
|
||||
{
|
||||
"name": "doctrine/lexer",
|
||||
@@ -72,20 +72,6 @@
|
||||
"parser",
|
||||
"php"
|
||||
],
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://www.doctrine-project.org/sponsorship.html",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://www.patreon.com/phpdoctrine",
|
||||
"type": "patreon"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/doctrine%2Flexer",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2020-05-25T17:44:05+00:00"
|
||||
},
|
||||
{
|
||||
@@ -150,12 +136,6 @@
|
||||
"validation",
|
||||
"validator"
|
||||
],
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/egulias",
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2020-12-29T14:50:06+00:00"
|
||||
},
|
||||
{
|
||||
@@ -365,6 +345,53 @@
|
||||
],
|
||||
"time": "2020-09-30T07:37:11+00:00"
|
||||
},
|
||||
{
|
||||
"name": "imdbphp/imdbphp",
|
||||
"version": "v6.4.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/tboothman/imdbphp.git",
|
||||
"reference": "35a1c0240e30c16fae68b2f69682da679cc2aa21"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/tboothman/imdbphp/zipball/35a1c0240e30c16fae68b2f69682da679cc2aa21",
|
||||
"reference": "35a1c0240e30c16fae68b2f69682da679cc2aa21",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
|
||||
"preferred": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"require": {
|
||||
"ext-curl": "*",
|
||||
"ext-dom": "*",
|
||||
"ext-json": "*",
|
||||
"php": ">=5.6",
|
||||
"psr/log": "~1.0",
|
||||
"psr/simple-cache": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"cache/array-adapter": "^1.0",
|
||||
"mockery/mockery": "1.3.3",
|
||||
"phpstan/phpstan": "^0.9.2",
|
||||
"phpunit/phpunit": "5.4.8"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Imdb\\": "src/Imdb"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"GPL-2.0-or-later"
|
||||
],
|
||||
"description": "Library for retrieving film and tv information from IMDb",
|
||||
"time": "2020-11-08T18:20:39+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/http-message",
|
||||
"version": "1.0.1",
|
||||
@@ -421,6 +448,113 @@
|
||||
],
|
||||
"time": "2016-08-06T14:39:51+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/log",
|
||||
"version": "1.1.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/log.git",
|
||||
"reference": "0f73288fd15629204f9d42b7055f72dacbe811fc"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc",
|
||||
"reference": "0f73288fd15629204f9d42b7055f72dacbe811fc",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
|
||||
"preferred": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.1.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psr\\Log\\": "Psr/Log/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "http://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common interface for logging libraries",
|
||||
"homepage": "https://github.com/php-fig/log",
|
||||
"keywords": [
|
||||
"log",
|
||||
"psr",
|
||||
"psr-3"
|
||||
],
|
||||
"time": "2020-03-23T09:12:05+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/simple-cache",
|
||||
"version": "1.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/simple-cache.git",
|
||||
"reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
|
||||
"reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
|
||||
"preferred": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psr\\SimpleCache\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "http://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common interfaces for simple caching",
|
||||
"keywords": [
|
||||
"cache",
|
||||
"caching",
|
||||
"psr",
|
||||
"psr-16",
|
||||
"simple-cache"
|
||||
],
|
||||
"time": "2017-10-23T01:57:42+00:00"
|
||||
},
|
||||
{
|
||||
"name": "ralouphie/getallheaders",
|
||||
"version": "3.0.3",
|
||||
@@ -532,16 +666,6 @@
|
||||
"mail",
|
||||
"mailer"
|
||||
],
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/swiftmailer/swiftmailer",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2021-01-12T09:35:59+00:00"
|
||||
},
|
||||
{
|
||||
@@ -611,20 +735,6 @@
|
||||
"portable",
|
||||
"shim"
|
||||
],
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2021-01-07T16:49:33+00:00"
|
||||
},
|
||||
{
|
||||
@@ -701,20 +811,6 @@
|
||||
"portable",
|
||||
"shim"
|
||||
],
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2021-01-07T16:49:33+00:00"
|
||||
},
|
||||
{
|
||||
@@ -788,20 +884,6 @@
|
||||
"portable",
|
||||
"shim"
|
||||
],
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2021-01-07T17:09:11+00:00"
|
||||
},
|
||||
{
|
||||
@@ -871,20 +953,6 @@
|
||||
"portable",
|
||||
"shim"
|
||||
],
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2021-01-07T16:49:33+00:00"
|
||||
},
|
||||
{
|
||||
@@ -950,20 +1018,6 @@
|
||||
"portable",
|
||||
"shim"
|
||||
],
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2021-01-07T16:49:33+00:00"
|
||||
}
|
||||
],
|
||||
@@ -976,6 +1030,5 @@
|
||||
"platform": {
|
||||
"php": "^7.2|^8"
|
||||
},
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "1.1.0"
|
||||
"platform-dev": []
|
||||
}
|
||||
|
||||
150
nexus/Imdb/Imdb.php
Normal file
150
nexus/Imdb/Imdb.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace Nexus\Imdb;
|
||||
|
||||
use Imdb\Config;
|
||||
use Imdb\Title;
|
||||
|
||||
class Imdb
|
||||
{
|
||||
private $config;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$config = new Config();
|
||||
$config->cachedir = ROOT_PATH . 'imdb/cache';
|
||||
$config->photodir = ROOT_PATH . 'imdb/pic_imdb';
|
||||
$config->photoroot = 'pic_imdb';
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
public function renderDetailsPageDescription($torrentId, $imdbId)
|
||||
{
|
||||
$movie = new Title($imdbId, $this->config);
|
||||
$country = $movie->country ();
|
||||
$director = $movie->director();
|
||||
$creator = $movie->creator(); // For TV series
|
||||
$write = $movie->writing();
|
||||
$produce = $movie->producer();
|
||||
$cast = $movie->cast();
|
||||
// $plot = $movie->plot ();
|
||||
$plot_outline = $movie->plotoutline();
|
||||
$compose = $movie->composer();
|
||||
$gen = $movie->genres();
|
||||
//$comment = $movie->comment();
|
||||
$similiar_movies = $movie->similiar_movies();
|
||||
|
||||
if (($photo_url = $movie->photo_localurl() ) != FALSE)
|
||||
$smallth = "<img src=\"".$photo_url. "\" width=\"105\" onclick=\"Preview(this);\" alt=\"poster\" />";
|
||||
else
|
||||
$smallth = "<img src=\"pic/imdb_pic/nophoto.gif\" alt=\"no poster\" />";
|
||||
|
||||
$autodata = '<a href="https://www.imdb.com/title/tt'.$thenumbers.'">https://www.imdb.com/title/tt'.$thenumbers."</a><br /><strong><font color=\"navy\">------------------------------------------------------------------------------------------------------------------------------------</font><br />\n";
|
||||
$autodata .= "<font color=\"darkred\" size=\"3\">".$lang_details['text_information']."</font><br />\n";
|
||||
$autodata .= "<font color=\"navy\">------------------------------------------------------------------------------------------------------------------------------------</font></strong><br />\n";
|
||||
$autodata .= "<strong><font color=\"DarkRed\">". $lang_details['text_title']."</font></strong>" . "".$movie->title ()."<br />\n";
|
||||
$autodata .= "<strong><font color=\"DarkRed\">".$lang_details['text_also_known_as']."</font></strong>";
|
||||
|
||||
$temp = "";
|
||||
foreach ($movie->alsoknow() as $ak)
|
||||
{
|
||||
// $temp .= $ak["title"].$ak["year"]. ($ak["country"] != "" ? " (".$ak["country"].")" : "") . ($ak["comment"] != "" ? " (" . $ak["comment"] . ")" : "") . ", ";
|
||||
$temp .= $ak["title"] . ", ";
|
||||
}
|
||||
$autodata .= rtrim(trim($temp), ",");
|
||||
$runtimes = str_replace(" min",$lang_details['text_mins'], $movie->runtime_all());
|
||||
$autodata .= "<br />\n<strong><font color=\"DarkRed\">".$lang_details['text_year']."</font></strong>" . "".$movie->year ()."<br />\n";
|
||||
$autodata .= "<strong><font color=\"DarkRed\">".$lang_details['text_runtime']."</font></strong>".$runtimes."<br />\n";
|
||||
$autodata .= "<strong><font color=\"DarkRed\">".$lang_details['text_votes']."</font></strong>" . "".$movie->votes ()."<br />\n";
|
||||
$autodata .= "<strong><font color=\"DarkRed\">".$lang_details['text_rating']."</font></strong>" . "".$movie->rating ()."<br />\n";
|
||||
$autodata .= "<strong><font color=\"DarkRed\">".$lang_details['text_language']."</font></strong>" . "".$movie->language ()."<br />\n";
|
||||
$autodata .= "<strong><font color=\"DarkRed\">".$lang_details['text_country']."</font></strong>";
|
||||
|
||||
$temp = "";
|
||||
for ($i = 0; $i < count ($country); $i++)
|
||||
{
|
||||
$temp .="$country[$i], ";
|
||||
}
|
||||
$autodata .= rtrim(trim($temp), ",");
|
||||
|
||||
$autodata .= "<br />\n<strong><font color=\"DarkRed\">".$lang_details['text_all_genres']."</font></strong>";
|
||||
$temp = "";
|
||||
for ($i = 0; $i < count($gen); $i++)
|
||||
{
|
||||
$temp .= "$gen[$i], ";
|
||||
}
|
||||
$autodata .= rtrim(trim($temp), ",");
|
||||
|
||||
$autodata .= "<br />\n<strong><font color=\"DarkRed\">".$lang_details['text_tagline']."</font></strong>" . "".$movie->tagline ()."<br />\n";
|
||||
if ($director){
|
||||
$autodata .= "<strong><font color=\"DarkRed\">".$lang_details['text_director']."</font></strong>";
|
||||
$temp = "";
|
||||
for ($i = 0; $i < count ($director); $i++)
|
||||
{
|
||||
$temp .= "<a target=\"_blank\" href=\"https://www.imdb.com/" . "".$director[$i]["imdb"]."" ."\">" . $director[$i]["name"] . "</a>, ";
|
||||
}
|
||||
$autodata .= rtrim(trim($temp), ",");
|
||||
}
|
||||
elseif ($creator)
|
||||
$autodata .= "<strong><font color=\"DarkRed\">".$lang_details['text_creator']."</font></strong>".$creator;
|
||||
|
||||
$autodata .= "<br />\n<strong><font color=\"DarkRed\">".$lang_details['text_written_by']."</font></strong>";
|
||||
$temp = "";
|
||||
for ($i = 0; $i < count ($write); $i++)
|
||||
{
|
||||
$temp .= "<a target=\"_blank\" href=\"https://www.imdb.com/" . "".$write[$i]["imdb"]."" ."\">" . "".$write[$i]["name"]."" . "</a>, ";
|
||||
}
|
||||
$autodata .= rtrim(trim($temp), ",");
|
||||
|
||||
$autodata .= "<br />\n<strong><font color=\"DarkRed\">".$lang_details['text_produced_by']."</font></strong>";
|
||||
$temp = "";
|
||||
for ($i = 0; $i < count ($produce); $i++)
|
||||
{
|
||||
$temp .= "<a target=\"_blank\" href=\"https://www.imdb.com/" . "".$produce[$i]["imdb"]."" ." \">" . "".$produce[$i]["name"]."" . "</a>, ";
|
||||
}
|
||||
$autodata .= rtrim(trim($temp), ",");
|
||||
|
||||
$autodata .= "<br />\n<strong><font color=\"DarkRed\">".$lang_details['text_music']."</font></strong>";
|
||||
$temp = "";
|
||||
for ($i = 0; $i < count($compose); $i++)
|
||||
{
|
||||
$temp .= "<a target=\"_blank\" href=\"https://www.imdb.com/" . "".$compose[$i]["imdb"]."" ." \">" . "".$compose[$i]["name"]."" . "</a>, ";
|
||||
}
|
||||
$autodata .= rtrim(trim($temp), ",");
|
||||
|
||||
$autodata .= "<br /><br />\n\n<strong><font color=\"navy\">------------------------------------------------------------------------------------------------------------------------------------</font><br />\n";
|
||||
$autodata .= "<font color=\"darkred\" size=\"3\">".$lang_details['text_plot_outline']."</font><br />\n";
|
||||
$autodata .= "<font color=\"navy\">------------------------------------------------------------------------------------------------------------------------------------</font></strong>";
|
||||
|
||||
// if(count($plot) == 0)
|
||||
// {
|
||||
// $autodata .= "<br />\n".$plot_outline;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// for ($i = 0; $i < count ($plot); $i++)
|
||||
// {
|
||||
// $autodata .= "<br />\n<font color=\"DarkRed\">.</font> ";
|
||||
// $autodata .= $plot[$i];
|
||||
// }
|
||||
// }
|
||||
if (!empty($plot_outline)) {
|
||||
$autodata .= "<br />\n".$plot_outline;
|
||||
}
|
||||
|
||||
|
||||
$autodata .= "<br /><br />\n\n<strong><font color=\"navy\">------------------------------------------------------------------------------------------------------------------------------------</font><br />\n";
|
||||
$autodata .= "<font color=\"darkred\" size=\"3\">".$lang_details['text_cast']."</font><br />\n";
|
||||
$autodata .= "<font color=\"navy\">------------------------------------------------------------------------------------------------------------------------------------</font></strong><br />\n";
|
||||
|
||||
for ($i = 0; $i < count ($cast); $i++)
|
||||
{
|
||||
// if ($i > 9)
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
$autodata .= "<font color=\"DarkRed\">.</font> " . "<a target=\"_blank\" href=\"https://www.imdb.com/" . "".$cast[$i]["imdb"]."" ."\">" . $cast[$i]["name"] . "</a> " .$lang_details['text_as']."<strong><font color=\"DarkRed\">" . "".$cast[$i]["role"]."" . " </font></strong><br />\n";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -14,14 +14,6 @@ class PTGen
|
||||
{
|
||||
private $apiPoint;
|
||||
|
||||
const FORMAT_HTML = 1;
|
||||
const FORMAT_JSON = 2;
|
||||
|
||||
private static $formatText = [
|
||||
self::FORMAT_HTML => 'HTML',
|
||||
self::FORMAT_JSON => 'json',
|
||||
];
|
||||
|
||||
const SITE_DOUBAN = 'douban';
|
||||
const SITE_IMDB = 'imdb';
|
||||
const SITE_BANGUMI = 'bangumi';
|
||||
@@ -57,24 +49,39 @@ class PTGen
|
||||
$this->apiPoint = $apiPoint;
|
||||
}
|
||||
|
||||
public function generate(string $url): array
|
||||
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']);
|
||||
return $this->request($targetUrl, $withoutCache);
|
||||
}
|
||||
|
||||
public function parse(string $url): array
|
||||
{
|
||||
foreach (self::$validSites as $site => $info) {
|
||||
if (preg_match($info['url_pattern'], $url, $matches)) {
|
||||
$targetUrl = sprintf('%s/?site=%s&sid=%s', trim($this->apiPoint, '/'), $site , $matches[1]);
|
||||
return $this->request($targetUrl);
|
||||
return [
|
||||
'site' => $site,
|
||||
'url' => $matches[0],
|
||||
'id' => $matches[1]
|
||||
];
|
||||
}
|
||||
}
|
||||
throw new PTGenException("invalid url: $url");
|
||||
}
|
||||
|
||||
private function buildDetailsPageTableRow($ptGenArr, $site)
|
||||
private function buildDetailsPageTableRow($torrentId, $ptGenArr, $site)
|
||||
{
|
||||
global $lang_details;
|
||||
$ptGenFormatted = $ptGenArr['format'];
|
||||
$prefix = sprintf("[img]%s[/img]\n", $ptGenArr['poster']);
|
||||
$ptGenFormatted = mb_substr($ptGenFormatted, mb_strlen($prefix, 'utf-8') + 1);
|
||||
$ptGenFormatted = format_comment($ptGenFormatted);
|
||||
$ptGenFormatted .= sprintf(
|
||||
'%s%s%s<a href="retriver.php?id=%s&type=1&siteid=%s">%s</a>',
|
||||
$lang_details['text_information_updated_at'], date('Y-m-d H:i:s', intval($ptGenArr['generate_at'] / 1000)), $lang_details['text_might_be_outdated'],
|
||||
$torrentId, $site, $lang_details['text_here_to_update']
|
||||
);
|
||||
$titleShowOrHide = $lang_details['title_show_or_hide'] ?? '';
|
||||
$id = 'pt-gen-' . $site;
|
||||
$html = <<<HTML
|
||||
@@ -100,15 +107,17 @@ HTML;
|
||||
return $html;
|
||||
}
|
||||
|
||||
private function request(string $url): array
|
||||
private function request(string $url, bool $withoutCache = false): array
|
||||
{
|
||||
global $Cache;
|
||||
$logPrefix = "url: $url";
|
||||
$cacheKey = __METHOD__ . ":$url";
|
||||
$cache = $Cache->get_value($cacheKey);
|
||||
if ($cache) {
|
||||
do_log("$logPrefix, from cache");
|
||||
return $cache;
|
||||
$cacheKey = $this->getApiPointResultCacheKey($url);
|
||||
if (!$withoutCache) {
|
||||
$cache = $Cache->get_value($cacheKey);
|
||||
if ($cache) {
|
||||
do_log("$logPrefix, from cache");
|
||||
return $cache;
|
||||
}
|
||||
}
|
||||
$http = new Client();
|
||||
$response = $http->get($url, ['timeout' => 10]);
|
||||
@@ -136,9 +145,21 @@ HTML;
|
||||
throw new PTGenException($msg);
|
||||
}
|
||||
$Cache->cache_value($cacheKey, $bodyArr, 24 * 3600);
|
||||
do_log("$logPrefix, success get from api point");
|
||||
return $bodyArr;
|
||||
}
|
||||
|
||||
public function deleteApiPointResultCache($url)
|
||||
{
|
||||
global $Cache;
|
||||
$Cache->delete_value($this->getApiPointResultCacheKey($url));
|
||||
}
|
||||
|
||||
private function getApiPointResultCacheKey($url)
|
||||
{
|
||||
return __METHOD__ . "_$url";
|
||||
}
|
||||
|
||||
public function renderUploadPageFormInput($ptGen = '')
|
||||
{
|
||||
global $lang_functions;
|
||||
@@ -153,7 +174,7 @@ HTML;
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function renderDetailsPageDescription(array $torrentPtGenArr): array
|
||||
public function renderDetailsPageDescription($torrentId, array $torrentPtGenArr): array
|
||||
{
|
||||
$html = '';
|
||||
$jsonArr = [];
|
||||
@@ -169,14 +190,14 @@ HTML;
|
||||
'link' => $link,
|
||||
'data' => $data,
|
||||
];
|
||||
$html .= $this->buildDetailsPageTableRow($data, $site);
|
||||
$html .= $this->buildDetailsPageTableRow($torrentId, $data, $site);
|
||||
} else {
|
||||
$ptGenArr = $this->generate($torrentPtGenArr[$site]['link']);
|
||||
$jsonArr[$site] = [
|
||||
'link' => $link,
|
||||
'data' => $ptGenArr,
|
||||
];
|
||||
$html .= $this->buildDetailsPageTableRow($ptGenArr, $site);
|
||||
$html .= $this->buildDetailsPageTableRow($torrentId, $ptGenArr, $site);
|
||||
if (!$update) {
|
||||
$update = true;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ die();
|
||||
$res = sql_query("SELECT torrents.cache_stamp, torrents.sp_state, torrents.url, torrents.small_descr, torrents.seeders, torrents.banned, torrents.leechers, torrents.info_hash, torrents.filename, nfo, LENGTH(torrents.nfo) AS nfosz, torrents.last_action, torrents.name, torrents.owner, torrents.save_as, torrents.descr, torrents.visible, torrents.size, torrents.added, torrents.views, torrents.hits, torrents.times_completed, torrents.id, torrents.type, torrents.numfiles, torrents.anonymous, torrents.pt_gen, categories.name AS cat_name, sources.name AS source_name, media.name AS medium_name, codecs.name AS codec_name, standards.name AS standard_name, processings.name AS processing_name, teams.name AS team_name, audiocodecs.name AS audiocodec_name FROM torrents LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN sources ON torrents.source = sources.id LEFT JOIN media ON torrents.medium = media.id LEFT JOIN codecs ON torrents.codec = codecs.id LEFT JOIN standards ON torrents.standard = standards.id LEFT JOIN processings ON torrents.processing = processings.id LEFT JOIN teams ON torrents.team = teams.id LEFT JOIN audiocodecs ON torrents.audiocodec = audiocodecs.id WHERE torrents.id = $id LIMIT 1")
|
||||
or sqlerr();
|
||||
$row = mysql_fetch_array($res);
|
||||
|
||||
if (get_user_class() >= $torrentmanage_class || $CURUSER["id"] == $row["owner"])
|
||||
$owned = 1;
|
||||
else $owned = 0;
|
||||
@@ -26,8 +25,9 @@ if (!$row)
|
||||
elseif ($row['banned'] == 'yes' && get_user_class() < $seebanned_class)
|
||||
permissiondenied();
|
||||
else {
|
||||
$torrentUpdate = [];
|
||||
if (!empty($_GET["hit"])) {
|
||||
sql_query("UPDATE torrents SET views = views + 1 WHERE id = $id");
|
||||
$torrentUpdate[] = 'views = views + 1';
|
||||
}
|
||||
|
||||
if (!isset($_GET["cmtpage"])) {
|
||||
@@ -396,9 +396,9 @@ else {
|
||||
|
||||
if (!empty($row['pt_gen'])) {
|
||||
$ptGen = new \Nexus\PTGen\PTGen();
|
||||
$ptGenResult = $ptGen->renderDetailsPageDescription(json_decode($row['pt_gen'], true));
|
||||
$ptGenResult = $ptGen->renderDetailsPageDescription($id, json_decode($row['pt_gen'], true));
|
||||
if ($ptGenResult['update']) {
|
||||
//@todo do some update
|
||||
$torrentUpdate[] = 'pt_gen = ' . sqlesc(json_encode($ptGenResult['json_arr']));
|
||||
}
|
||||
echo $ptGenResult['html'];
|
||||
}
|
||||
@@ -567,6 +567,9 @@ echo "</script>";
|
||||
stdhead($lang_details['head_comments_for_torrent']."\"" . $row["name"] . "\"");
|
||||
print("<h1 id=\"top\">".$lang_details['text_comments_for']."<a href=\"details.php?id=".$id."\">" . htmlspecialchars($row["name"]) . "</a></h1>\n");
|
||||
}
|
||||
if (!empty($torrentUpdate)) {
|
||||
sql_query("UPDATE torrents SET " . join(",", $torrentUpdate) . " WHERE id = $id") or sqlerr(__FILE__, __LINE__);
|
||||
}
|
||||
|
||||
// -----------------COMMENT SECTION ---------------------//
|
||||
if ($CURUSER['showcomment'] != 'no'){
|
||||
|
||||
@@ -8,12 +8,12 @@ permissiondenied();
|
||||
}
|
||||
$id = intval($_GET["id"] ?? 0);
|
||||
$type = intval($_GET["type"] ?? 0);
|
||||
$siteid = intval($_GET["siteid"] ?? 0); // 1 for IMDb
|
||||
$siteid = $_GET["siteid"] ?? 0; // 1 for IMDb
|
||||
|
||||
if (!isset($id) || !$id || !is_numeric($id) || !isset($type) || !$type || !is_numeric($type) || !isset($siteid) || !$siteid || !is_numeric($siteid))
|
||||
if (!isset($id) || !$id || !is_numeric($id) || !isset($type) || !$type || !is_numeric($type) || !isset($siteid) || !$siteid)
|
||||
die();
|
||||
|
||||
$r = sql_query("SELECT * from torrents WHERE id = " . sqlesc($id)) or sqlerr(__FILE__, __LINE__);
|
||||
$r = sql_query("SELECT id, url, pt_gen from torrents WHERE id = " . sqlesc($id)) or sqlerr(__FILE__, __LINE__);
|
||||
if(mysql_num_rows($r) != 1)
|
||||
die();
|
||||
|
||||
@@ -42,6 +42,19 @@ switch ($siteid)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case \Nexus\PTGen\PTGen::SITE_IMDB:
|
||||
case \Nexus\PTGen\PTGen::SITE_DOUBAN:
|
||||
case \Nexus\PTGen\PTGen::SITE_BANGUMI:
|
||||
{
|
||||
$ptGenInfo = json_decode($row['pt_gen'], true);
|
||||
$link = $ptGenInfo[$siteid]['link'];
|
||||
$ptGen = new \Nexus\PTGen\PTGen();
|
||||
$result = $ptGen->generate($link, true);
|
||||
$ptGenInfo[$siteid]['data'] = $result;
|
||||
sql_query(sprintf("update torrents set pt_gen = %s where id = %s", sqlesc(json_encode($ptGenInfo)), $id)) or sqlerr(__FILE__, __LINE__);
|
||||
header("Location: " . get_protocol_prefix() . "$BASEURL/details.php?id=".htmlspecialchars($id));
|
||||
break;
|
||||
}
|
||||
default :
|
||||
{
|
||||
die("Error!");
|
||||
|
||||
@@ -37,6 +37,23 @@ $updateset = array();
|
||||
//$dname = $row["save_as"];
|
||||
|
||||
$url = parse_imdb_id($_POST['url'] ?? '');
|
||||
/**
|
||||
* add PT-Gen
|
||||
* @since 1.6
|
||||
*/
|
||||
if (!empty($_POST['pt_gen'])) {
|
||||
//use PT-Gen imdb for url
|
||||
$postPtGen = $_POST['pt_gen'];
|
||||
$ptGenImdbLink = $postPtGen[\Nexus\PTGen\PTGen::SITE_IMDB]['link'] ?? '';
|
||||
if (empty($url) && !empty($ptGenImdbLink)) {
|
||||
$ptGen = new \Nexus\PTGen\PTGen();
|
||||
$ptGenImdbInfo = $ptGen->parse($ptGenImdbLink);
|
||||
$url = str_replace('tt', '', $ptGenImdbInfo['id']);
|
||||
}
|
||||
$updateset[] = "pt_gen = " . sqlesc(json_encode($postPtGen));
|
||||
} else {
|
||||
$updateset[] = "pt_gen = ''";
|
||||
}
|
||||
|
||||
if ($enablenfo_main=='yes'){
|
||||
$nfoaction = $_POST['nfoaction'];
|
||||
@@ -168,13 +185,6 @@ if(get_user_class()>=$torrentmanage_class && $CURUSER['picker'] == 'yes')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* add PT-Gen
|
||||
* @since 1.6
|
||||
*/
|
||||
if (!empty($_POST['pt_gen'])) {
|
||||
$updateset[] = "pt_gen = " . sqlesc(json_encode($_POST['pt_gen']));
|
||||
}
|
||||
|
||||
sql_query("UPDATE torrents SET " . join(",", $updateset) . " WHERE id = $id") or sqlerr(__FILE__, __LINE__);
|
||||
|
||||
|
||||
@@ -333,10 +333,17 @@ foreach ($promotionrules_torrent as $rule)
|
||||
* add PT-Gen
|
||||
* @since 1.6
|
||||
*/
|
||||
$ptGen = sqlesc(json_encode($_POST['pt_gen'] ?? []));
|
||||
$postPtGen = $_POST['pt_gen'] ?? [];
|
||||
$ptGenImdbLink = $postPtGen[\Nexus\PTGen\PTGen::SITE_IMDB]['link'] ?? '';
|
||||
if (empty($url) && !empty($ptGenImdbLink)) {
|
||||
//use PT-Gen imdb for url
|
||||
$ptGen = new \Nexus\PTGen\PTGen();
|
||||
$ptGenImdbInfo = $ptGen->parse($ptGenImdbLink);
|
||||
$url = str_replace('tt', '', $ptGenImdbInfo['id']);
|
||||
}
|
||||
|
||||
$ret = sql_query("INSERT INTO torrents (filename, owner, visible, anonymous, name, size, numfiles, type, url, small_descr, descr, ori_descr, category, source, medium, codec, audiocodec, standard, processing, team, save_as, sp_state, added, last_action, nfo, info_hash, pt_gen) VALUES (".sqlesc($fname).", ".sqlesc($CURUSER["id"]).", 'yes', ".sqlesc($anonymous).", ".sqlesc($torrent).", ".sqlesc($totallen).", ".count($filelist).", ".sqlesc($type).", ".sqlesc($url).", ".sqlesc($small_descr).", ".sqlesc($descr).", ".sqlesc($descr).", ".sqlesc($catid).", ".sqlesc($sourceid).", ".sqlesc($mediumid).", ".sqlesc($codecid).", ".sqlesc($audiocodecid).", ".sqlesc($standardid).", ".sqlesc($processingid).", ".sqlesc($teamid).", ".sqlesc($dname).", ".sqlesc($sp_state) .
|
||||
", " . sqlesc(date("Y-m-d H:i:s")) . ", " . sqlesc(date("Y-m-d H:i:s")) . ", ".sqlesc($nfo).", " . sqlesc($infohash). ", $ptGen)");
|
||||
", " . sqlesc(date("Y-m-d H:i:s")) . ", " . sqlesc(date("Y-m-d H:i:s")) . ", ".sqlesc($nfo).", " . sqlesc($infohash). ", " . sqlesc(json_encode($postPtGen)) . ")");
|
||||
if (!$ret) {
|
||||
if (mysql_errno() == 1062)
|
||||
bark($lang_takeupload['std_torrent_existed']);
|
||||
|
||||
Reference in New Issue
Block a user