1. 新增BDInfo解析

2. 优化MediaInfo显示
3. 修改MediaInfo和BDInfo支持多语言
This commit is contained in:
tonghoil
2025-09-14 21:30:18 +08:00
parent 01cbb0fa61
commit 0ff6f4a559
12 changed files with 1267 additions and 28 deletions

View File

@@ -312,8 +312,11 @@ $lang_functions = array
'text_tag_hdr' => 'HDR',
'text_required' => '不能为空',
'text_invalid' => '非法',
'text_technical_info' => 'MediaInfo',
'text_technical_info_help_text' => 'MediaInfo 来自软件 <b><a href="https://mediaarea.net/en/MediaInfo" target=\'_blank\'>MediaInfo</a></b>,用该软件打开文件,语言选择英语,点击菜单视图(View)->文件(Text),在框中右键->全选,再右键->复制,粘贴到这里来。',
'text_technical_info' => 'MediaInfo/BDInfo',
'text_technical_info_help_text' => '<b>&middot;</b> MediaInfo 来自软件 <b><a href="https://mediaarea.net/en/MediaInfo" target=\'_blank\'>MediaInfo</a></b>,用该软件打开文件,语言选择英语,点击菜单视图(View)->文件(Text),在框中右键->全选,再右键->复制,粘贴到这里来。
<br>
<b>&middot;</b> BDInfo 来自软件 <b><a href="https://github.com/UniqProject/BDInfo" target=\'_blank\'>BDInfo</a></b>,用该软件打开文件,点击扫描比特率(Scan Bitrates) 查看报告(View Report...),在框中右键->全选,再右键->复制,粘贴到这里来。
',
'text_management_system' => '管理系统',
'text_seed_points' => '做种积分',
'spoiler_expand_collapse' => '点击展开/收缩',

View File

@@ -707,8 +707,11 @@ $lang_settings = array
'text_login_secret_lifetime_unit' => '分钟',
'row_login_secret_lifetime' => '登录密钥有效期',
'text_login_secret_lifetime_deadline' => '当前密钥有效期至',
'row_enable_technical_info' => '启用 MediaInfo',
'text_enable_technical_info' => "默认'否'。MediaInfo 来自软件 <b><a href=\"https://mediaarea.net/en/MediaInfo\" target='_blank'>MediaInfo</a></b> Text 视图的结果",
'row_enable_technical_info' => '启用 MediaInfo/BDInfo',
'text_enable_technical_info' => '默认\'否\'。<br>
MediaInfo 来自软件 <b><a href="https://mediaarea.net/en/MediaInfo" target=\'_blank\'>MediaInfo</a></b> Text 视图的结果 <br>
BDInfo 来自软件 <b><a href="https://github.com/UniqProject/BDInfo" target=\'_blank\'>BDInfo</a></b> View Reports的结果
',
'row_sticky_first_level_background_color' => '一级置顶背景颜色',
'text_sticky_first_level_background_color_note' => '一级置顶背景颜色,不设置则无背景色。',
'row_sticky_second_level_background_color' => '二级置顶背景颜色',

View File

@@ -319,8 +319,11 @@ $lang_functions = array
'text_tag_hdr' => 'HDR',
'text_required' => '不能為空',
'text_invalid' => '非法',
'text_technical_info' => 'MediaInfo',
'text_technical_info_help_text' => 'MediaInfo 自軟 <b><a href="https://mediaarea.net/en/MediaInfo" target=\'_blank\'>MediaInfo</a></b>,用該軟打開文件,語言選擇英語,點擊菜單視圖(View)->文件(Text),在框中右鍵->全選,再右鍵->復制,粘貼到這來。',
'text_technical_info' => 'MediaInfo/BDInfo',
'text_technical_info_help_text' => '<b>&middot;</b> MediaInfo 自軟 <b><a href="https://mediaarea.net/en/MediaInfo" target=\'_blank\'>MediaInfo</a></b>,用該軟打開文件,語言選擇英語,點擊菜單視圖(View)->文件(Text),在框中右鍵->全選,再右鍵->複製,粘貼到這來。
<br>
<b>&middot;</b> BDInfo 来自軟體 <b><a href="https://github.com/UniqProject/BDInfo" target=\'_blank\'>BDInfo</a></b>,用該軟體打開,點擊掃描比特率(Scan Bitrates) 查看報告(View Report...),在框中右鍵->全選,再右鍵->複製,粘貼到這裡來。
',
'text_management_system' => '管理系統',
'text_seed_points' => '做種積分',
'spoiler_expand_collapse' => '點擊展開/收縮',

View File

@@ -707,8 +707,11 @@ $lang_settings = array
'text_login_secret_lifetime_unit' => '分鐘',
'row_login_secret_lifetime' => '登錄密鑰有效期',
'text_login_secret_lifetime_deadline' => '當前密鑰有效期至',
'row_enable_technical_info' => '用 MediaInfo',
'text_enable_technical_info' => "默認'否'。MediaInfo 來自軟件 <b><a href=\"https://mediaarea.net/en/MediaInfo\" target='_blank'>MediaInfo</a></b> Text 視圖的結果",
'row_enable_technical_info' => '用 MediaInfo/BDInfo',
'text_enable_technical_info' => '默认\'否\'。<br>
MediaInfo 来自軟體 <b><a href="https://mediaarea.net/en/MediaInfo" target=\'_blank\'>MediaInfo</a></b> Text 視圖的結果 <br>
BDInfo 来自軟體 <b><a href="https://github.com/UniqProject/BDInfo" target=\'_blank\'>BDInfo</a></b> View Reports的結果
',
'row_sticky_first_level_background_color' => '一級置頂背景顏色',
'text_sticky_first_level_background_color_note' => '一級置頂背景顏色,不設置則無背景色。',
'row_sticky_second_level_background_color' => '二級置頂背景顏色',

View File

@@ -320,8 +320,11 @@ $lang_functions = array
'text_tag_hdr' => 'HDR',
'text_required' => 'Required',
'text_invalid' => 'Invalid',
'text_technical_info' => 'MediaInfo',
'text_technical_info_help_text' => 'MediaInfo comes from software <b><a href="https://mediaarea.net/en/MediaInfo" target=\'_blank\'>MediaInfo</a></b>open file, language select english, click the view menu > text > right click in the box > select all > copy > past into this box.',
'text_technical_info' => 'MediaInfo/BDInfo',
'text_technical_info_help_text' => '<b>&middot;</b> MediaInfo comes from software <b><a href="https://mediaarea.net/en/MediaInfo" target=\'_blank\'>MediaInfo</a></b>open file, language select english, click the view menu > text > right click in the box > select all > copy > past into this box.
<br>
<b>&middot;</b> BDInfo comes from software <b><a href="https://github.com/UniqProject/BDInfo" target=\'_blank\'>BDInfo</a></b>open the file with this software, click Scan Bitrates to view the report, right-click in the box > select all, right-click > copy, and paste it here.
',
'text_management_system' => 'Management',
'text_seed_points' => 'Seed points',
'spoiler_expand_collapse' => 'Click to expand/collapse',

View File

@@ -707,9 +707,12 @@ $lang_settings = array
'text_login_secret_lifetime_unit' => 'minute',
'row_login_secret_lifetime' => 'Login secret lifetime',
'text_login_secret_lifetime_deadline' => 'Current login secret deadline',
'row_enable_technical_info' => 'Enable MediaInfo',
'text_enable_technical_info' => "Default 'No'. MediaInfo comes from software <b><a href=\"https://mediaarea.net/en/MediaInfo\" target='_blank'>MediaInfo</a></b> Text view",
'row_sticky_first_level_background_color' => 'Sticky first level bg color',
'row_enable_technical_info' => 'Enable MediaInfo/BDInfo',
'text_enable_technical_info' => 'Default \'No\'. <br>
MediaInfo comes from software <b><a href="https://mediaarea.net/en/MediaInfo" target=\'_blank\'>MediaInfo</a></b> the result of "Text view" <br>
BDInfo comes from software <b><a href="https://github.com/UniqProject/BDInfo" target=\'_blank\'>BDInfo</a></b> the result of "View Reports"
',
'row_sticky_first_level_background_color' => 'Sticky first level bg color',
'text_sticky_first_level_background_color_note' => 'Sticky first level bg color, it will be none if not set.',
'row_sticky_second_level_background_color' => 'Sticky second level bg color',
'text_sticky_second_level_background_color_note' => 'Sticky second level bg color, it will be none if not set.',

File diff suppressed because it is too large Load Diff

View File

@@ -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);
}
}
}

View File

@@ -308,7 +308,28 @@ JS;
//technical info
if ($settingMain['enable_technical_info'] == 'yes') {
$technicalInfo = new \Nexus\Torrent\TechnicalInformation($row['technical_info'] ?? '');
$technicalData = $row['technical_info'] ?? '';
// 判断是否为BDINFO格式
$isBdInfo = false;
if (!empty($technicalData)) {
$firstLine = strtok($technicalData, "\n");
if (strpos($firstLine, 'DISC INFO') !== false
|| strpos($firstLine, 'Disc Title') !== false
|| strpos($firstLine, 'Disc Label') !== false
) {
$isBdInfo = true;
}
}
if ($isBdInfo) {
// 使用BdInfoExtra处理BDINFO格式
$technicalInfo = new \Nexus\Torrent\BdInfoExtra($technicalData);
} else {
// 使用TechnicalInformation处理MediaInfo格式
$technicalInfo = new \Nexus\Torrent\TechnicalInformation($technicalData);
}
$technicalInfoResult = $technicalInfo->renderOnDetailsPage();
if (!empty($technicalInfoResult)) {
tr($lang_functions['text_technical_info'], $technicalInfoResult, 1);

View File

@@ -86,6 +86,20 @@ return [
'logs_label' => 'Approval logs'
],
'show_hide_media_info' => 'Show/Hide raw MediaInfo',
'show_hide_bd_info' => 'Show/Hide raw BDInfo',
'collapse_show_more_audio' => 'Collapse/Expand more audio tracks',
'collapse_show_more_subtitles' => 'Collapse/Expand more subtitles',
'technicalinfo_duration' => 'Duration',
'technicalinfo_resolution' => 'Resolution',
'technicalinfo_bit_rate' => 'Bit Rate',
'technicalinfo_bit_depth' => 'Bit Depth',
'technicalinfo_frame_rate' => 'Frame Rate',
'technicalinfo_profile' => 'Profile',
'technicalinfo_format' => 'Format',
'technicalinfo_extras' => 'Extras',
'technicalinfo_ref_frames' => 'Ref.Frames',
'technicalinfo_audio' => 'Audio #',
'technicalinfo_subtitles' => 'Subtitles #',
'promotion_time_types' => [
\App\Models\Torrent::PROMOTION_TIME_TYPE_GLOBAL => 'Global',
\App\Models\Torrent::PROMOTION_TIME_TYPE_PERMANENT => 'Permanent',

View File

@@ -86,6 +86,20 @@ return [
'logs_label' => '审核记录',
],
'show_hide_media_info' => '显示/隐藏原始 MediaInfo',
'show_hide_bd_info' => '显示/隐藏原始 BDInfo',
'collapse_show_more_audio' => '收起/展开更多音轨',
'collapse_show_more_subtitles' => '收起/展开更多字幕',
'technicalinfo_duration' => '时长',
'technicalinfo_resolution' => '分辨率',
'technicalinfo_bit_rate' => '比特率',
'technicalinfo_bit_depth' => '位深',
'technicalinfo_frame_rate' => '帧率',
'technicalinfo_profile' => '档次',
'technicalinfo_format' => '格式',
'technicalinfo_extras' => '附加内容',
'technicalinfo_ref_frames' => '关键帧',
'technicalinfo_audio' => '音轨 #',
'technicalinfo_subtitles' => '字幕 #',
'promotion_time_types' => [
\App\Models\Torrent::PROMOTION_TIME_TYPE_GLOBAL => '全局',
\App\Models\Torrent::PROMOTION_TIME_TYPE_PERMANENT => '永久',

View File

@@ -86,6 +86,20 @@ return [
'logs_label' => '審核記錄'
],
'show_hide_media_info' => '顯示/隱藏原始 MediaInfo',
'show_hide_bd_info' => '顯示/隱藏原始 BDInfo',
'collapse_show_more_audio' => '收起/展開更多音軌',
'collapse_show_more_subtitles' => '收起/展開更多字幕',
'technicalinfo_duration' => '時長',
'technicalinfo_resolution' => '分辨率',
'technicalinfo_bit_rate' => '比特率',
'technicalinfo_bit_depth' => '位深',
'technicalinfo_frame_rate' => '幀率',
'technicalinfo_profile' => '檔次',
'technicalinfo_format' => '格式',
'technicalinfo_extras' => '附加內容',
'technicalinfo_ref_frames' => '關鍵幀',
'technicalinfo_audio' => '音軌 #',
'technicalinfo_subtitles' => '字幕 #',
'promotion_time_types' => [
\App\Models\Torrent::PROMOTION_TIME_TYPE_GLOBAL => '全局',
\App\Models\Torrent::PROMOTION_TIME_TYPE_PERMANENT => '永久',