mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 03:57:22 +08:00
fix cover issue on page torrents.php
This commit is contained in:
@@ -326,4 +326,9 @@ class Setting extends NexusModel
|
|||||||
{
|
{
|
||||||
return self::get('system.is_record_seeding_bonus_log') == 'yes';
|
return self::get('system.is_record_seeding_bonus_log') == 'yes';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getIsImdbEnabled(): bool
|
||||||
|
{
|
||||||
|
return self::get('main.showimdbinfo') == 'yes';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-12
@@ -3620,19 +3620,17 @@ foreach ($rows as $row)
|
|||||||
|
|
||||||
//cover
|
//cover
|
||||||
$coverSrc = $tdCover = '';
|
$coverSrc = $tdCover = '';
|
||||||
|
|
||||||
if ($showCover) {
|
if ($showCover) {
|
||||||
if ($imdb_id = parse_imdb_id($row["url"])) {
|
if (!empty($row['cover'])) {
|
||||||
try {
|
|
||||||
if ($imdb->getCacheStatus($imdb_id) == 1) {
|
|
||||||
$coverSrc = $imdb->getMovie($imdb_id)->photo(false);
|
|
||||||
}
|
|
||||||
} catch (\Exception $exception) {
|
|
||||||
do_log("torrent: {$row['id']} get cover from imdb error: ".$exception->getMessage() . "\n[stacktrace]\n" . $exception->getTraceAsString(), 'error');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (empty($coverSrc) && !empty($row['cover'])) {
|
|
||||||
$coverSrc = $row['cover'];
|
$coverSrc = $row['cover'];
|
||||||
}
|
}
|
||||||
|
if (empty($coverSrc) && !empty($row['url'])) {
|
||||||
|
$imdb_id = parse_imdb_id($row["url"]);
|
||||||
|
if ($imdb_id) {
|
||||||
|
$coverSrc = $imdb->getMovieCover($imdb_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
$tdCover = sprintf('<td class="embedded" style="text-align: center;width: 46px;height: 46px"><img src="pic/misc/spinner.svg" data-src="%s" class="nexus-lazy-load" style="max-height: 46px;max-width: 46px" /></td>', $coverSrc);
|
$tdCover = sprintf('<td class="embedded" style="text-align: center;width: 46px;height: 46px"><img src="pic/misc/spinner.svg" data-src="%s" class="nexus-lazy-load" style="max-height: 46px;max-width: 46px" /></td>', $coverSrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4812,13 +4810,11 @@ function get_torrent_promotion_append_sub($promotion = 1,$forcemode = "",$showti
|
|||||||
|
|
||||||
function get_hr_img(array $torrent, $searchBoxId)
|
function get_hr_img(array $torrent, $searchBoxId)
|
||||||
{
|
{
|
||||||
// $mode = get_setting('hr.mode');
|
|
||||||
$mode = \App\Models\HitAndRun::getConfig('mode', $searchBoxId);
|
$mode = \App\Models\HitAndRun::getConfig('mode', $searchBoxId);
|
||||||
$result = '';
|
$result = '';
|
||||||
if ($mode == \App\Models\HitAndRun::MODE_GLOBAL || ($mode == \App\Models\HitAndRun::MODE_MANUAL && isset($torrent['hr']) && $torrent['hr'] == \App\Models\Torrent::HR_YES)) {
|
if ($mode == \App\Models\HitAndRun::MODE_GLOBAL || ($mode == \App\Models\HitAndRun::MODE_MANUAL && isset($torrent['hr']) && $torrent['hr'] == \App\Models\Torrent::HR_YES)) {
|
||||||
$result = '<img class="hitandrun" src="pic/trans.gif" alt="H&R" title="H&R" />';
|
$result = '<img class="hitandrun" src="pic/trans.gif" alt="H&R" title="H&R" />';
|
||||||
}
|
}
|
||||||
do_log("searchBoxId: $searchBoxId, mode: $mode, result: $result");
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ function get_global_sp_state()
|
|||||||
{
|
{
|
||||||
static $global_promotion_state;
|
static $global_promotion_state;
|
||||||
$cacheKey = \App\Models\Setting::TORRENT_GLOBAL_STATE_CACHE_KEY;
|
$cacheKey = \App\Models\Setting::TORRENT_GLOBAL_STATE_CACHE_KEY;
|
||||||
if (!$global_promotion_state) {
|
if (is_null($global_promotion_state)) {
|
||||||
$row = \Nexus\Database\NexusDB::remember($cacheKey, 600, function () use ($cacheKey) {
|
$row = \Nexus\Database\NexusDB::remember($cacheKey, 600, function () use ($cacheKey) {
|
||||||
return \Nexus\Database\NexusDB::getOne('torrents_state', 1);
|
return \Nexus\Database\NexusDB::getOne('torrents_state', 1);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
namespace Nexus\Imdb;
|
namespace Nexus\Imdb;
|
||||||
|
|
||||||
|
use App\Models\Setting;
|
||||||
use Imdb\Config;
|
use Imdb\Config;
|
||||||
use Imdb\Title;
|
use Imdb\Title;
|
||||||
|
use Nexus\Database\NexusDB;
|
||||||
use Nexus\PTGen\PTGen;
|
use Nexus\PTGen\PTGen;
|
||||||
|
|
||||||
class Imdb
|
class Imdb
|
||||||
@@ -300,4 +302,27 @@ class Imdb
|
|||||||
}
|
}
|
||||||
return $this->ptGen;
|
return $this->ptGen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getMovieCover($imdbId): string
|
||||||
|
{
|
||||||
|
static $enabled;
|
||||||
|
if (is_null($enabled)) {
|
||||||
|
$enabled = Setting::getIsImdbEnabled();
|
||||||
|
}
|
||||||
|
if (!$enabled) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return NexusDB::remember("imdb:cover:$imdbId", 3600, function() use($imdbId) {
|
||||||
|
if ($this->getCacheStatus($imdbId) != 1) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return $this->getMovie($imdbId)->photo(false);
|
||||||
|
} catch (\Exception $exception) {
|
||||||
|
do_log($exception->getMessage() . $exception->getTraceAsString(), 'error');
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -943,7 +943,9 @@ if ($shouldUseMeili) {
|
|||||||
$resultFromSearchRep = $searchRep->search($searchParams, $CURUSER['id']);
|
$resultFromSearchRep = $searchRep->search($searchParams, $CURUSER['id']);
|
||||||
$count = $resultFromSearchRep['total'];
|
$count = $resultFromSearchRep['total'];
|
||||||
} else {
|
} else {
|
||||||
|
do_log("[BEFORE_TORRENT_COUNT_SQL]", 'debug');
|
||||||
$res = sql_query($sql);
|
$res = sql_query($sql);
|
||||||
|
do_log("[AFTER_TORRENT_COUNT_SQL] $sql", 'debug');
|
||||||
$count = 0;
|
$count = 0;
|
||||||
while($row = mysql_fetch_array($res)) {
|
while($row = mysql_fetch_array($res)) {
|
||||||
$count += $row[0];
|
$count += $row[0];
|
||||||
@@ -956,8 +958,6 @@ elseif ($torrentsperpage_main)
|
|||||||
$torrentsperpage = $torrentsperpage_main;
|
$torrentsperpage = $torrentsperpage_main;
|
||||||
else $torrentsperpage = 100;
|
else $torrentsperpage = 100;
|
||||||
|
|
||||||
do_log("[TORRENT_COUNT_SQL] $sql", 'debug');
|
|
||||||
|
|
||||||
if ($count)
|
if ($count)
|
||||||
{
|
{
|
||||||
if (isset($searchstr) && (!isset($_GET['notnewword']) || !$_GET['notnewword'])){
|
if (isset($searchstr) && (!isset($_GET['notnewword']) || !$_GET['notnewword'])){
|
||||||
|
|||||||
Reference in New Issue
Block a user