mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 12:07:23 +08:00
1. 新增BDInfo解析
2. 优化MediaInfo显示 3. 修改MediaInfo和BDInfo支持多语言
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -95,6 +95,7 @@ class TechnicalInformation
|
||||
public function getAudios()
|
||||
{
|
||||
$result = [];
|
||||
$audioIndex = 1;
|
||||
foreach ($this->mediaInfoArr as $parentKey => $values) {
|
||||
if (strpos($parentKey, 'Audio') === false) {
|
||||
continue;
|
||||
@@ -116,7 +117,9 @@ class TechnicalInformation
|
||||
$audioInfoArr[]= "@" . $values['Bit rate'];
|
||||
}
|
||||
if (!empty($audioInfoArr)) {
|
||||
$result[$parentKey] = implode(" ", $audioInfoArr);
|
||||
// 使用多语言支持的键名
|
||||
$result[nexus_trans('torrent.technicalinfo_audio') . $audioIndex] = implode(" ", $audioInfoArr);
|
||||
$audioIndex++;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
@@ -125,6 +128,7 @@ class TechnicalInformation
|
||||
public function getSubtitles()
|
||||
{
|
||||
$result = [];
|
||||
$subtitleIndex = 1;
|
||||
foreach ($this->mediaInfoArr as $parentKey => $values) {
|
||||
if (strpos($parentKey, 'Text') === false) {
|
||||
continue;
|
||||
@@ -140,7 +144,9 @@ class TechnicalInformation
|
||||
$subtitlesInfoArr[] = $values['Format'];
|
||||
}
|
||||
if (!empty($subtitlesInfoArr)) {
|
||||
$result[$parentKey] = implode(" ", $subtitlesInfoArr);
|
||||
// 使用多语言支持的键名
|
||||
$result[nexus_trans('torrent.technicalinfo_subtitles') . $subtitleIndex] = implode(" ", $subtitlesInfoArr);
|
||||
$subtitleIndex++;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
@@ -183,8 +189,11 @@ class TechnicalInformation
|
||||
$subtitles = $summaryInfo['subtitles'] ?: [];
|
||||
|
||||
// dd($summaryInfo, $videos, $audios, $subtitles);
|
||||
if (empty($videos) && empty($audios) && empty($subtitles)) {
|
||||
return sprintf('<div class="nexus-media-info-raw"><pre>%s</pre></div>', $this->mediaInfo);
|
||||
if (empty($this->mediaInfo)) { //为空不渲染mediainfo
|
||||
return '';
|
||||
} else if (empty($videos) && empty($audios) && empty($subtitles)) { // 信息不全显示点击展开
|
||||
$rawmediaInfo = sprintf('[spoiler=%s][raw]<pre>%s</pre>[/raw][/spoiler]', nexus_trans('torrent.show_hide_media_info'), $this->mediaInfo);
|
||||
return sprintf('<div class="nexus-media-info-raw"><pre>%s</pre></div>', format_comment($rawmediaInfo, false));
|
||||
}
|
||||
|
||||
$result = '<table style="border: none;width: 100%"><tbody><tr>';
|
||||
@@ -211,15 +220,15 @@ class TechnicalInformation
|
||||
public function getSummaryInfo(): array
|
||||
{
|
||||
$videos = [
|
||||
'Runtime' => $this->getRuntime(),
|
||||
'Resolution' => $this->getResolution(),
|
||||
'Bitrate' => $this->getBitrate(),
|
||||
nexus_trans('torrent.technicalinfo_duration') => $this->getRuntime(),
|
||||
nexus_trans('torrent.technicalinfo_resolution') => $this->getResolution(),
|
||||
nexus_trans('torrent.technicalinfo_bit_rate') => $this->getBitrate(),
|
||||
'HDR' => $this->getHDRFormat(),
|
||||
'Bit depth' => $this->getBitDepth(),
|
||||
'Frame rate' => $this->getFramerate(),
|
||||
'Profile' => $this->getProfile(),
|
||||
'Format' => $this->getVideoFormat(),
|
||||
'Ref.Frames' => $this->getRefFrame(),
|
||||
nexus_trans('torrent.technicalinfo_bit_depth') => $this->getBitDepth(),
|
||||
nexus_trans('torrent.technicalinfo_frame_rate') => $this->getFramerate(),
|
||||
nexus_trans('torrent.technicalinfo_profile') => $this->getProfile(),
|
||||
nexus_trans('torrent.technicalinfo_format') => $this->getVideoFormat(),
|
||||
nexus_trans('torrent.technicalinfo_ref_frames') => $this->getRefFrame(),
|
||||
];
|
||||
$videos = array_filter($videos) ?: null;
|
||||
$audios = $this->getAudios() ?: null;
|
||||
@@ -230,14 +239,70 @@ class TechnicalInformation
|
||||
private function buildTdTable(array $parts)
|
||||
{
|
||||
$table = '<table style="border: none;"><tbody>';
|
||||
|
||||
// 检查是否为音频或字幕数据
|
||||
$isAudioOrSubtitle = false;
|
||||
$audioOrSubtitleCount = 0;
|
||||
$audioPrefix = nexus_trans('torrent.technicalinfo_audio');
|
||||
$subtitlePrefix = nexus_trans('torrent.technicalinfo_subtitles');
|
||||
foreach ($parts as $key => $value) {
|
||||
if (strpos($key, $audioPrefix) === 0 || strpos($key, $subtitlePrefix) === 0) {
|
||||
$isAudioOrSubtitle = true;
|
||||
$audioOrSubtitleCount++;
|
||||
}
|
||||
}
|
||||
|
||||
$displayCount = 0;
|
||||
$hiddenParts = [];
|
||||
|
||||
foreach ($parts as $key => $value) {
|
||||
$displayCount++;
|
||||
|
||||
// 如果是音频或字幕,且超过3条,则隐藏多余的
|
||||
if ($isAudioOrSubtitle && $audioOrSubtitleCount > 3) {
|
||||
if ($displayCount <= 3) {
|
||||
// 显示前3条
|
||||
$table .= '<tr>';
|
||||
$table .= sprintf('<td style="border: none; padding-right: 5px;padding-bottom: 5px;"><b>%s: </b>%s</td>', $key, $value);
|
||||
$table .= '</tr>';
|
||||
} else {
|
||||
// 收集隐藏的部分
|
||||
$hiddenParts[$key] = $value;
|
||||
}
|
||||
} else {
|
||||
// 非音频/字幕数据,或数量不超过3条,正常显示
|
||||
$table .= '<tr>';
|
||||
$table .= sprintf('<td style="border: none; padding-right: 5px;padding-bottom: 5px;"><b>%s: </b>%s</td>', $key, $value);
|
||||
$table .= '</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
// 如果有隐藏的部分,添加spoiler
|
||||
if (!empty($hiddenParts)) {
|
||||
$hiddenContent = '';
|
||||
foreach ($hiddenParts as $key => $value) {
|
||||
$hiddenContent .= sprintf('<b>%s: </b>%s<br>', $key, $value);
|
||||
}
|
||||
$hiddenContent = rtrim($hiddenContent, '<br>');
|
||||
|
||||
$spoilerTitle = $isAudioOrSubtitle && strpos(array_keys($parts)[0], $audioPrefix) === 0
|
||||
? nexus_trans('torrent.collapse_show_more_audio')
|
||||
: nexus_trans('torrent.collapse_show_more_subtitles');
|
||||
|
||||
$spoiler = sprintf('[spoiler=%s]%s[/spoiler]', $spoilerTitle, $hiddenContent);
|
||||
$table .= '<tr>';
|
||||
$table .= sprintf('<td style="border: none; padding-right: 5px;padding-bottom: 5px;"><b>%s: </b>%s</td>', $key, $value);
|
||||
// 检查format_comment函数是否存在
|
||||
if (function_exists('format_comment')) {
|
||||
$table .= sprintf('<td style="border: none; padding-right: 5px;padding-bottom: 5px;">%s</td>', format_comment($spoiler, false));
|
||||
} else {
|
||||
$table .= sprintf('<td style="border: none; padding-right: 5px;padding-bottom: 5px;">%s</td>', $spoiler);
|
||||
}
|
||||
$table .= '</tr>';
|
||||
}
|
||||
|
||||
$table .= '</tbody>';
|
||||
$table .= '</table>';
|
||||
return sprintf('<td style="border: none; padding-right: 5px;padding-bottom: 5px">%s</td>', $table);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user