diff --git a/lang/chs/lang_functions.php b/lang/chs/lang_functions.php index a6f184ed..c77efa27 100644 --- a/lang/chs/lang_functions.php +++ b/lang/chs/lang_functions.php @@ -314,6 +314,7 @@ $lang_functions = array 'text_tag_mother_language_subtitle' => '中字', 'text_required' => '不能为空', 'text_invalid' => '非法', + 'text_technical_info' => '技术信息', ); ?> diff --git a/lang/chs/lang_settings.php b/lang/chs/lang_settings.php index af3185a0..69d693d0 100644 --- a/lang/chs/lang_settings.php +++ b/lang/chs/lang_settings.php @@ -702,6 +702,8 @@ $lang_settings = array 'text_login_secret_lifetime_unit' => '分钟', 'row_login_secret_lifetime' => '登录密钥有效期', 'text_login_secret_lifetime_deadline' => '当前密钥有效期至', + 'row_enable_technical_info' => '启用技术信息', + 'text_enable_technical_info' => "默认'是'。文件技术信息来自软件 MediaInfo Text 视图的结果", ); ?> diff --git a/lang/chs/lang_upload.php b/lang/chs/lang_upload.php index e45c71e9..6f6cc2ed 100644 --- a/lang/chs/lang_upload.php +++ b/lang/chs/lang_upload.php @@ -40,6 +40,8 @@ $lang_upload = array 'text_chinese_title' => "中文名:", 'text_english_title' => "英文名:", 'text_titles_note' => "(如果英文名不存在,使用拼音或不填写)", + 'row_technical_info' => '技术信息', + 'row_technical_info_help_text' => '文件技术信息来自软件 MediaInfo,用该软件打开文件,点击菜单视图(View)->文件(Text),在框中右键->全选,再右键->复制,粘贴到这里来。' ); ?> diff --git a/nexus/Torrent/TechnicalInformation.php b/nexus/Torrent/TechnicalInformation.php new file mode 100644 index 00000000..e035b24a --- /dev/null +++ b/nexus/Torrent/TechnicalInformation.php @@ -0,0 +1,152 @@ +mediaInfo = $mediaInfo; + $this->mediaInfoArr = $this->getMediaInfoArr($mediaInfo); + } + + public function getMediaInfoArr(string $mediaInfo) + { + $arr = preg_split('/[\r\n]+/', $mediaInfo); + $result = []; + $parentKey = ""; + foreach ($arr as $key => $value) { + $value = trim($value); + if (empty($value)) { + continue; + } + $rowKeyValue = explode(':', $value); + $rowKeyValue = array_filter(array_map('trim', $rowKeyValue)); + if (count($rowKeyValue) == 1) { + $parentKey = $rowKeyValue[0]; + } elseif (count($rowKeyValue) == 2) { + if (empty($parentKey)) { + continue; + } + $result[$parentKey][$rowKeyValue[0]] = $rowKeyValue[1]; + } + } + return $result; + + } + + public function getRuntime() + { + return $this->mediaInfoArr['General']['Duration'] ?? ''; + } + + public function getResolution() + { + $width = $this->mediaInfoArr['Video']['Width'] ?? ''; + $height = $this->mediaInfoArr['Video']['Height'] ?? ''; + $ratio = $this->mediaInfoArr['Video']['Display aspect ratio'] ?? ''; + $result = $width . 'x' . $height; + if ($ratio) { + $result .= "($ratio)"; + } + return $result; + } + + public function getBitrate() + { + $result = $this->mediaInfoArr['Video']['Bit rate'] ?? ''; + return $result; + } + + public function getFramerate() + { + $result = $this->mediaInfoArr['Video']['Frame rate'] ?? ''; + return $result; + } + + public function getProfile() + { + $result = $this->mediaInfoArr['Video']['Format profile'] ?? ''; + return $result; + } + + public function getRefFrame() + { + foreach ($this->mediaInfoArr['Video'] as $key => $value) { + if (strpos($key, 'Reference frames') !== false) { + return $value; + } + } + return ''; + } + + public function getAudios() + { + $result = []; + foreach ($this->mediaInfoArr as $parentKey => $values) { + if (strpos($parentKey, 'Audio') == false) { + continue; + } + $audioInfoArr = []; + if (!empty($values['Language'])) { + $audioInfoArr[] = $values['Language']; + } + if (!empty($values['Format'])) { + $audioInfoArr[] = $values['Format']; + } + if (!empty($values['Channel(s)'])) { + $audioInfoArr[] = $values['Channel(s)']; + } + if (!empty($values['Bit rate'])) { + $audioInfoArr[]= "@" . $values['Bit rate']; + } + if (!empty($audioInfoArr)) { + $result[$parentKey] = implode(" ", $audioInfoArr); + } + } + return $result; + } + + public function getSubtitles() + { + $result = []; + foreach ($this->mediaInfoArr as $parentKey => $values) { + if (strpos($parentKey, 'Text') == false) { + continue; + } + $audioInfoArr = []; + if (!empty($values['Language'])) { + $audioInfoArr[] = $values['Language']; + } + if (!empty($values['Format'])) { + $audioInfoArr[] = $values['Format']; + } + if (!empty($audioInfoArr)) { + $result[$parentKey] = implode(" ", $audioInfoArr); + } + } + return $result; + } + + public function renderOnDetailsPage() + { + global $lang_functions; + $runtime = $this->getRuntime(); + $resolution = $this->getResolution(); + $bitrate = $this->getBitrate(); + $profile = $this->getProfile(); + $framerate = $this->getFramerate(); + $refFrame = $this->getRefFrame(); + $audios = $this->getAudios(); + $subtitles = $this->getSubtitles(); + $html = ''; + if (!empty($runtime)) { + + } + + } +} \ No newline at end of file diff --git a/public/details.php b/public/details.php index 60a40c3b..67ef762f 100644 --- a/public/details.php +++ b/public/details.php @@ -18,6 +18,8 @@ if (get_user_class() >= $torrentmanage_class || $CURUSER["id"] == $row["owner"]) $owned = 1; else $owned = 0; +$settingMain = get_setting('main'); + if (!$row) stderr($lang_details['std_error'], $lang_details['std_no_torrent_id']); elseif ($row['banned'] == 'yes' && get_user_class() < $seebanned_class) @@ -160,10 +162,16 @@ else { /**************end custom fields****************/ if ($CURUSER['showdescription'] != 'no' && !empty($row["descr"])){ - $torrentdetailad=$Advertisement->get_ad('torrentdetail'); - tr("\"Show/Hide\" ".$lang_details['row_description']."", "
".($Advertisement->enable_ad() && $torrentdetailad ? "
".$torrentdetailad[0]."
" : "").format_comment($row["descr"])."
", 1); + $torrentdetailad=$Advertisement->get_ad('torrentdetail'); + tr("\"Show/Hide\" ".$lang_details['row_description']."", "
".($Advertisement->enable_ad() && $torrentdetailad ? "
".$torrentdetailad[0]."
" : "").format_comment($row["descr"])."
", 1); } + //technical info + if ($settingMain['enable_technical_info'] == 'yes') { + $technicalInfo = new \Nexus\Torrent\TechnicalInformation($row['technical_info']); + + } + if (get_user_class() >= $viewnfo_class && $CURUSER['shownfo'] != 'no' && $row["nfosz"] > 0){ if (!$nfo = $Cache->get_value('nfo_block_torrent_id_'.$id)){ $nfo = code($row["nfo"], $view == "magic"); diff --git a/public/settings.php b/public/settings.php index a8cb5b27..bf5a3245 100644 --- a/public/settings.php +++ b/public/settings.php @@ -41,7 +41,7 @@ if ($action == 'savesettings_main') // save main 'showpolls','showstats','showlastxtorrents', 'showtrackerload','showshoutbox','showfunbox','showoffer','sptime','showhelpbox','enablebitbucket', 'smalldescription','altname','extforum','extforumurl','defaultlang','defstylesheet', 'donation','spsct','browsecat','specialcat','waitsystem', 'maxdlsystem','bitbucket','torrentnameprefix', 'showforumstats','verification','invite_count','invite_timeout', 'seeding_leeching_time_calc_start', - 'startsubid', 'logo', 'showlastxforumposts' + 'startsubid', 'logo', 'showlastxforumposts', 'enable_technical_info' ); GetVar($validConfig); $MAIN = []; @@ -643,6 +643,7 @@ elseif ($action == 'mainsettings') // main settings yesorno($lang_settings['row_enable_pt_gen_system'],'enable_pt_gen_system', $MAIN['enable_pt_gen_system'], $lang_settings['text_enable_pt_gen_system_note']); tr($lang_settings['row_pt_gen_api_point']," ".$lang_settings['text_pt_gen_api_point_note'], 1); yesorno($lang_settings['row_enable_nfo'],'enablenfo', $MAIN['enablenfo'], $lang_settings['text_enable_nfo_note']); + yesorno($lang_settings['row_enable_technical_info'],'enable_technical_info', $MAIN['enable_technical_info'], $lang_settings['text_enable_technical_info']); yesorno($lang_settings['row_enable_school_system'],'enableschool', $MAIN['enableschool'], $lang_settings['text_school_system_note']); yesorno($lang_settings['row_restrict_email_domain'],'restrictemail', $MAIN['restrictemail'], $lang_settings['text_restrict_email_domain_note']); yesorno($lang_settings['row_show_shoutbox'],'showshoutbox', $MAIN['showshoutbox'], $lang_settings['text_show_shoutbox_note']); diff --git a/public/takeupload.php b/public/takeupload.php index ce1c72a9..6e2e23b9 100644 --- a/public/takeupload.php +++ b/public/takeupload.php @@ -342,8 +342,8 @@ if (empty($url) && !empty($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, tags) 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)) . ", " . array_sum($_POST['tags'] ?? []) . ")"); +$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, tags, 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)) . ", " . array_sum($_POST['tags'] ?? []) . ", " . sqlesc($_POST['technical_info'] ?? '') . ")"); if (!$ret) { if (mysql_errno() == 1062) bark($lang_takeupload['std_torrent_existed']); @@ -372,18 +372,18 @@ if (!empty($_POST['custom_fields'])) { } } } -if (!empty($_FILES['custom_fields'])) { - foreach ($_FILES['custom_fields'] as $customField => $customValue) { - $customData = [ - 'torrent_id' => $id, - 'custom_field_id' => $customField, - 'custom_field_value' => $value, - 'created_at' => $now, - 'updated_at' => $now, - ]; - \Nexus\Database\DB::insert('torrents_custom_field_values', $customData); - } -} +//if (!empty($_FILES['custom_fields'])) { +// foreach ($_FILES['custom_fields'] as $customField => $customValue) { +// $customData = [ +// 'torrent_id' => $id, +// 'custom_field_id' => $customField, +// 'custom_field_value' => $value, +// 'created_at' => $now, +// 'updated_at' => $now, +// ]; +// \Nexus\Database\DB::insert('torrents_custom_field_values', $customData); +// } +//} @sql_query("DELETE FROM files WHERE torrent = $id"); foreach ($filelist as $file) { diff --git a/public/upload.php b/public/upload.php index 69d5e0fa..498c54f5 100644 --- a/public/upload.php +++ b/public/upload.php @@ -73,6 +73,10 @@ stdhead($lang_upload['head_upload']); textbbcode("upload","descr","",false); print("\n"); + if ($settingMain['enable_technical_info'] == 'yes') { + tr($lang_upload['row_technical_info'], '
' . $lang_upload['row_technical_info_help_text'], 1); + } + if ($allowtorrents){ $disablespecial = " onchange=\"disableother('browsecat','specialcat')\""; $s = "