diff --git a/README-EN.md b/README-EN.md
index 6a057f00..f215d882 100644
--- a/README-EN.md
+++ b/README-EN.md
@@ -30,3 +30,7 @@ Complete PT website building solution. Based on NexusPHP + Laravel Framework + E
Blog:[https://nexusphp.org](https://nexusphp.org/)
Documentation:[https://doc.nexusphp.org](https://doc.nexusphp.org/en/)
Telegram: [https://t.me/nexusphp](https://t.me/nexusphp)
+
+## Project supported by JetBrains
+Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects.
+[](https://www.jetbrains.com/?from=https://github.com/xiaomlove/nexusphp)
diff --git a/README.md b/README.md
index 0a35271e..21acdf19 100644
--- a/README.md
+++ b/README.md
@@ -35,3 +35,6 @@ B站: [xiaomlove](https://space.bilibili.com/1319303059)
微信公众号:

+## Project supported by JetBrains
+Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects.
+[](https://www.jetbrains.com/?from=https://github.com/xiaomlove/nexusphp)
diff --git a/app/Console/Commands/Test.php b/app/Console/Commands/Test.php
index 2b2d3339..c4161db1 100644
--- a/app/Console/Commands/Test.php
+++ b/app/Console/Commands/Test.php
@@ -126,10 +126,8 @@ class Test extends Command
// $r = $rep->getContinuousDays($attendance);
// $r = $rep->getContinuousPoints(11);
- $url = 'https://www.imdb.com/title/tt4574334/?ref_=vp_vi_tt';
- $imdb = new Imdb();
- $rating = $imdb->getRating($url);
- dd($rating);
+ $r = json_decode('http://www.imdb.com/title/tt0468569', true);
+ dd($r);
}
diff --git a/include/constants.php b/include/constants.php
index 6816791b..77006dff 100644
--- a/include/constants.php
+++ b/include/constants.php
@@ -1,6 +1,6 @@
buildInput("url", $imdbNumber ? "http://www.imdb.com/title/tt".parse_imdb_id($imdb_url) : "", $lang_functions['text_imdb_url_note'], $lang_functions['pt_gen_get_description']);
+ $y = $ptGen->buildInput("url", $imdbNumber ? "http://www.imdb.com/title/tt".parse_imdb_id($imdb_url) : "", $lang_functions['text_imdb_url_note'], nexus_trans('ptgen.btn_get_desc'));
return tr($lang_functions['row_imdb_url'], $y, 1);
// ($showextinfo['imdb'] == 'yes' ? tr($lang_functions['row_imdb_url'], "
".$lang_functions['text_imdb_url_note']."", 1) : "");
diff --git a/lang/chs/lang_functions.php b/lang/chs/lang_functions.php
index 881eb05c..2509a83e 100644
--- a/lang/chs/lang_functions.php
+++ b/lang/chs/lang_functions.php
@@ -297,12 +297,6 @@ $lang_functions = array
'text_inactive_account_be_deleted' => "内做些下载。没有流量的用户会被删除账号。",
'text_attendance' => '签到得魔力',
'text_attended' => '(签到已得%u, 补签卡:%d)',
- 'row_pt_gen_douban_url' => "PT-Gen douban 链接",
- 'text_pt_gen_douban_url_note' => "(来自 douban 的链接。如电影 Transformers 的链接是 https://movie.douban.com/subject/1794171/)",
- 'row_pt_gen_imdb_url' => "PT-Gen imdb 链接",
- 'text_pt_gen_imdb_url_note' => "(来自 imdb 的链接。如电影 Transformers 的链接是 https://www.imdb.com/title/tt0418279/)",
- 'row_pt_gen_bangumi_url' => "PT-Gen bangumi 链接",
- 'text_pt_gen_bangumi_url_note' => "(来自 bangumi 的链接。如动画 星际牛仔 的链接是 https://bangumi.tv/subject/253/)",
'imdb_cache_dir_can_not_create' => 'imdb 缓存目录无法创建',
'imdb_cache_dir_is_not_writeable' => 'imdb 缓存目录不可写',
'imdb_photo_dir_can_not_create' => 'imdb 图片目录无法创建',
@@ -322,7 +316,6 @@ $lang_functions = array
'text_seed_points' => '做种积分',
'spoiler_expand_collapse' => '点击展开/收缩',
'spoiler_default_title' => '折叠内容',
- 'pt_gen_get_description' => '获取简介',
);
?>
diff --git a/lang/cht/lang_functions.php b/lang/cht/lang_functions.php
index 09709085..0936fe9d 100644
--- a/lang/cht/lang_functions.php
+++ b/lang/cht/lang_functions.php
@@ -323,7 +323,6 @@ $lang_functions = array
'text_seed_points' => '做種積分',
'spoiler_expand_collapse' => '點擊展開/收縮',
'spoiler_default_title' => '折疊內容',
- 'pt_gen_get_description' => '獲取簡介',
);
?>
diff --git a/lang/en/lang_functions.php b/lang/en/lang_functions.php
index 88143e48..7a5a3690 100644
--- a/lang/en/lang_functions.php
+++ b/lang/en/lang_functions.php
@@ -324,7 +324,6 @@ $lang_functions = array
'text_seed_points' => 'Seed points',
'spoiler_expand_collapse' => 'Click to expand/collapse',
'spoiler_default_title' => 'Collapse content',
- 'pt_gen_get_description' => 'Get desc',
);
?>
diff --git a/nexus/PTGen/PTGen.php b/nexus/PTGen/PTGen.php
index 83771dc7..afe31431 100644
--- a/nexus/PTGen/PTGen.php
+++ b/nexus/PTGen/PTGen.php
@@ -9,7 +9,9 @@
namespace Nexus\PTGen;
use App\Models\Torrent;
+use Carbon\Carbon;
use GuzzleHttp\Client;
+use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Nexus\Imdb\Imdb;
@@ -20,6 +22,9 @@ class PTGen
const SITE_DOUBAN = 'douban';
const SITE_IMDB = 'imdb';
const SITE_BANGUMI = 'bangumi';
+ const SITE_STEAM = 'steam';
+ const SITE_INDIENOVA = 'indienova';
+ const SITE_EPIC = 'epic';
public static array $validSites = [
self::SITE_IMDB => [
@@ -39,6 +44,23 @@ class PTGen
'home_page' => 'https://bangumi.tv/',
'rating_average_img' => 'pic/bangumi.jpg',
],
+ //Banned !
+// self::SITE_STEAM => [
+// 'url_pattern' => '/(?:https?:\/\/)?(?:store\.)?steam(?:powered|community)\.com\/app\/(\d+)\/?/',
+// 'home_page' => 'https://store.steampowered.com/',
+// 'rating_average_img' => 'pic/steam.svg',
+// ],
+ self::SITE_INDIENOVA => [
+ 'url_pattern' => '/(?:https?:\/\/)?indienova\.com\/game\/(\S+)/',
+ 'home_page' => 'https://indienova.com/',
+ 'rating_average_img' => 'pic/invienova.jpg',
+ ],
+ //seems url_pattern has changed
+// self::SITE_EPIC => [
+// 'url_pattern' => '/(?:https?:\/\/)?www\.epicgames\.com\/store\/[a-zA-Z-]+\/product\/(\S+)\/\S?/',
+// 'home_page' => 'https://store.epicgames.com/',
+// 'rating_average_img' => 'pic/epic_game.png',
+// ],
];
@@ -196,18 +218,21 @@ HTML;
return __METHOD__ . "_$url";
}
- public function renderUploadPageFormInput($ptGen = '')
+ public function renderUploadPageFormInput($ptGen = ''): string
{
- global $lang_functions;
- $html = '';
- $ptGen = (array)json_decode($ptGen, true);
+ $arr = json_decode($ptGen, true);
+ $link = is_array($arr) ? $arr['__link'] : $ptGen;
+ $y = $this->buildInput("pt_gen", $link, nexus_trans('ptgen.tooltip', ['sites' => $this->buildTooltip()]), nexus_trans('ptgen.btn_get_desc'));
+ return tr(nexus_trans('ptgen.label'), $y, 1, '', true);
+ }
+
+ private function buildTooltip(): string
+ {
+ $results = [];
foreach (self::$validSites as $site => $info) {
- $value = $ptGen[$site]['link'] ?? '';
- $x = $lang_functions["row_pt_gen_{$site}_url"];
- $y = $this->buildInput("pt_gen[{$site}][link]", $value, $lang_functions["text_pt_gen_{$site}_url_note"], $lang_functions['pt_gen_get_description']);
- $html .= tr($x, $y, 1);
+ $results[] = sprintf('%s', $info['home_page'], $site);
}
- return $html;
+ return implode(' / ', $results);
}
public function buildInput($name, $value, $note, $btnText): string
@@ -317,7 +342,9 @@ HTML;
public function isIyuu(array $bodyArr): bool
{
- return isset($bodyArr['ret']) && $bodyArr['ret'] == 200;
+ return false;
+ //Not support, due to change frequently
+// return isset($bodyArr['ret']) && $bodyArr['ret'] == 200;
}
public function listRatings(array $ptGenData, string $imdbLink, string $desc = ''): array
@@ -340,7 +367,7 @@ HTML;
// from original structure fetch
if ($this->isRawPTGen($data)) {
$log .= ", isRawPTGen";
- $rating = $data["{$site}_rating_average"] ?? '';
+ $rating = $this->getRawPTGenRating($data, $site);
} elseif ($this->isIyuu($data)) {
$log .= ", isIyuu";
$pattern = $info['rating_pattern_in_desc'] ?? null;
@@ -361,7 +388,7 @@ HTML;
$imdb = new Imdb();
$imdbRating = $imdb->getRating($imdbLink);
$results[self::SITE_IMDB] = $imdbRating;
- $log .= ", again 'imdb' from: $imdbLink} -> $imdbRating";
+ $log .= ", again 'imdb' from: $imdbLink -> $imdbRating";
}
//Otherwise, get from desc
if (!empty($desc)) {
@@ -386,31 +413,80 @@ HTML;
return $results;
}
- public function updateTorrentPtGen(array $torrentInfo, $siteId = null)
+ public function updateTorrentPtGen(array $torrentInfo): bool|array
{
- $ptGenInfo = json_decode($torrentInfo['pt_gen'], true);
- foreach (self::$validSites as $site => $siteConfig) {
- if ($siteId !== null && $siteId != $site) {
- //If specific, only update it
- continue;
+ $now = Carbon::now();
+ $log = "torrent: " . $torrentInfo['id'];
+ $arr = json_decode($torrentInfo['pt_gen'], true);
+ if (is_array($arr)) {
+ if (!empty($arr['__updated_at'])) {
+ $log .= ", updated_at: " . $arr['__updated_at'];
+ $updatedAt = Carbon::parse($arr['__updated_at']);
+ $diffInDays = $now->diffInDays($updatedAt);
+ $log .= ", diffInDays: $diffInDays";
+ if ($diffInDays < 30) {
+ do_log("$log, less 30 days, don't update");
+ return false;
+ }
}
- if (empty($ptGenInfo[$site]['link'])) {
- do_log("site: $site no link...");
+ $link = $this->getLink($arr);
+ } else {
+ $link = $torrentInfo['pt_gen'];
+ }
+ if (empty($link)) {
+ do_log("$log, no link...");
+ return false;
+ }
+ $ptGenInfo = [];
+ foreach (self::$validSites as $site => $siteConfig) {
+ if (!preg_match($siteConfig['url_pattern'], $link, $matches)) {
continue;
}
try {
- $response = $this->generate($ptGenInfo[$site]['link'], true);
+ $response = $this->generate($matches[0], true);
$ptGenInfo[$site]['data'] = $response;
} catch (\Exception $exception) {
- do_log("site: $site can not be updated: " . $exception->getMessage(), 'error');
+ do_log("$log, site: $site can not be updated: " . $exception->getMessage(), 'error');
}
}
$siteIdAndRating = $this->listRatings($ptGenInfo, $torrentInfo['url'], $torrentInfo['descr']);
foreach ($siteIdAndRating as $key => $value) {
$ptGenInfo[$key]['data']["__rating"] = $value;
}
+ $ptGenInfo['__link'] = $link;
+ $ptGenInfo['__updated_at'] = $now->toDateTimeString();
Torrent::query()->where('id', $torrentInfo['id'])->update(['pt_gen' => $ptGenInfo]);
+ do_log("$log, success update");
return $ptGenInfo;
}
+ public function getLink(array $ptGenInfo)
+ {
+ if (isset($ptGenInfo['__link'])) {
+ //new
+ return $ptGenInfo['__link'];
+ }
+ $result = '';
+ foreach ($ptGenInfo as $item) {
+ if (!empty($item['link'])) {
+ //old, use the last one
+ $result = $item['link'];
+ }
+ }
+ return $result;
+ }
+
+ private function getRawPTGenRating(array $ptGenInfo, $site)
+ {
+ $key = $site . "_rating_average";
+ if (isset($ptGenInfo[$key])) {
+ return $ptGenInfo[$key];
+ }
+ if ($site == self::SITE_INDIENOVA) {
+ $parts = preg_split('/[\s:]+/', $ptGenInfo['rate']);
+ return Arr::last($parts);
+ }
+ return '';
+ }
+
}
diff --git a/public/details.php b/public/details.php
index 5295ff80..9eea10e0 100644
--- a/public/details.php
+++ b/public/details.php
@@ -277,11 +277,7 @@ if (!$row) {
if (get_setting('main.enable_pt_gen_system') == 'yes' && !empty($row['pt_gen'])) {
$ptGen = new \Nexus\PTGen\PTGen();
- $ptGenResult = $ptGen->renderDetailsPageDescription($id, json_decode($row['pt_gen'], true));
- if ($ptGenResult['update']) {
- $torrentUpdate[] = 'pt_gen = ' . sqlesc(json_encode($ptGenResult['json_arr']));
- }
- echo $ptGenResult['html'];
+ $ptGen->updateTorrentPtGen($row);
}
if ($imdb_id)
{
diff --git a/public/pic/epic_game.png b/public/pic/epic_game.png
new file mode 100644
index 00000000..805b187e
Binary files /dev/null and b/public/pic/epic_game.png differ
diff --git a/public/pic/invienova.jpg b/public/pic/invienova.jpg
new file mode 100644
index 00000000..af3fdb2e
Binary files /dev/null and b/public/pic/invienova.jpg differ
diff --git a/public/pic/steam.svg b/public/pic/steam.svg
new file mode 100644
index 00000000..ed285988
--- /dev/null
+++ b/public/pic/steam.svg
@@ -0,0 +1,16 @@
+
+
diff --git a/public/takeedit.php b/public/takeedit.php
index d5908acd..a8f90f19 100644
--- a/public/takeedit.php
+++ b/public/takeedit.php
@@ -19,7 +19,7 @@ if (!$id)
die();
-$res = sql_query("SELECT category, owner, filename, save_as, anonymous, picktype, picktime, added FROM torrents WHERE id = ".mysql_real_escape_string($id));
+$res = sql_query("SELECT category, owner, filename, save_as, anonymous, picktype, picktime, added, pt_gen FROM torrents WHERE id = ".mysql_real_escape_string($id));
$row = mysql_fetch_array($res);
$torrentAddedTimeString = $row['added'];
if (!$row)
@@ -28,7 +28,6 @@ if (!$row)
if ($CURUSER["id"] != $row["owner"] && get_user_class() < $torrentmanage_class)
bark($lang_takeedit['std_not_owner']);
$oldcatmode = get_single_value("categories","mode","WHERE id=".sqlesc($row['category']));
-
$updateset = array();
//$fname = $row["filename"];
@@ -42,15 +41,12 @@ $url = parse_imdb_id($_POST['url'] ?? '');
* @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']);
+ $existsPtGenInfo = json_decode($row['pt_gen'], true) ?? [];
+ $ptGen = new \Nexus\PTGen\PTGen();
+ if ($postPtGen != $ptGen->getLink($existsPtGenInfo)) {
+ $updateset[] = "pt_gen = " . sqlesc($postPtGen);
}
- $updateset[] = "pt_gen = " . sqlesc(json_encode($postPtGen));
} else {
$updateset[] = "pt_gen = ''";
}
diff --git a/public/takeupload.php b/public/takeupload.php
index 4118ed72..93c834d4 100644
--- a/public/takeupload.php
+++ b/public/takeupload.php
@@ -293,18 +293,6 @@ foreach ($promotionrules_torrent as $rule)
}
}
$dateTimeStringNow = \Carbon\Carbon::now()->toDateTimeString();
-/**
- * add PT-Gen
- * @since 1.6
- */
-$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']);
-}
$torrentSavePath = getFullDirectory($torrent_dir);
if (!is_dir($torrentSavePath)) {
@@ -315,7 +303,7 @@ if (!is_writable($torrentSavePath)) {
}
$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, technical_info) 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). ", " . sqlesc(json_encode($postPtGen)) . ", " . sqlesc($_POST['technical_info'] ?? '') . ")");
+", " . sqlesc(date("Y-m-d H:i:s")) . ", " . sqlesc(date("Y-m-d H:i:s")) . ", ".sqlesc($nfo).", " . sqlesc($infohash). ", " . sqlesc($_POST['pt_gen']) . ", " . sqlesc($_POST['technical_info'] ?? '') . ")");
if (!$ret) {
if (mysql_errno() == 1062)
bark($lang_takeupload['std_torrent_existed']);
diff --git a/resources/lang/en/ptgen.php b/resources/lang/en/ptgen.php
new file mode 100644
index 00000000..a38d0da8
--- /dev/null
+++ b/resources/lang/en/ptgen.php
@@ -0,0 +1,7 @@
+ 'PT-Gen',
+ 'tooltip' => 'Link comes from::sites ',
+ 'btn_get_desc' => 'Get desc',
+];
diff --git a/resources/lang/zh_CN/ptgen.php b/resources/lang/zh_CN/ptgen.php
new file mode 100644
index 00000000..63982837
--- /dev/null
+++ b/resources/lang/zh_CN/ptgen.php
@@ -0,0 +1,7 @@
+ 'PT-Gen',
+ 'tooltip' => '来自::sites 的链接',
+ 'btn_get_desc' => '获取简介',
+];
diff --git a/resources/lang/zh_TW/ptgen.php b/resources/lang/zh_TW/ptgen.php
new file mode 100644
index 00000000..06193b59
--- /dev/null
+++ b/resources/lang/zh_TW/ptgen.php
@@ -0,0 +1,7 @@
+ 'PT-Gen',
+ 'tooltip' => '來自::sites 的鏈接',
+ 'btn_get_desc' => '獲取簡介',
+];