technicial info

This commit is contained in:
xiaomlove
2021-03-16 23:28:37 +08:00
parent 6cd63a1791
commit 7e72392356
8 changed files with 187 additions and 17 deletions

View File

@@ -314,6 +314,7 @@ $lang_functions = array
'text_tag_mother_language_subtitle' => '中字', 'text_tag_mother_language_subtitle' => '中字',
'text_required' => '不能为空', 'text_required' => '不能为空',
'text_invalid' => '非法', 'text_invalid' => '非法',
'text_technical_info' => '技术信息',
); );
?> ?>

View File

@@ -702,6 +702,8 @@ $lang_settings = array
'text_login_secret_lifetime_unit' => '分钟', 'text_login_secret_lifetime_unit' => '分钟',
'row_login_secret_lifetime' => '登录密钥有效期', 'row_login_secret_lifetime' => '登录密钥有效期',
'text_login_secret_lifetime_deadline' => '当前密钥有效期至', 'text_login_secret_lifetime_deadline' => '当前密钥有效期至',
'row_enable_technical_info' => '启用技术信息',
'text_enable_technical_info' => "默认'是'。文件技术信息来自软件 <b><a href=\"https://mediaarea.net/en/MediaInfo\" target='_blank'>MediaInfo</a></b> Text 视图的结果",
); );
?> ?>

View File

@@ -40,6 +40,8 @@ $lang_upload = array
'text_chinese_title' => "中文名:", 'text_chinese_title' => "中文名:",
'text_english_title' => "英文名:", 'text_english_title' => "英文名:",
'text_titles_note' => "(如果英文名不存在,使用拼音或不填写)", 'text_titles_note' => "(如果英文名不存在,使用拼音或不填写)",
'row_technical_info' => '技术信息',
'row_technical_info_help_text' => '文件技术信息来自软件 <b><a href="https://mediaarea.net/en/MediaInfo" target=\'_blank\'>MediaInfo</a></b>,用该软件打开文件,点击菜单视图(View)->文件(Text),在框中右键->全选,再右键->复制,粘贴到这里来。'
); );
?> ?>

View File

@@ -0,0 +1,152 @@
<?php
namespace Nexus\Torrent;
class TechnicalInformation
{
private $mediaInfo;
private $mediaInfoArr;
public function __construct(string $mediaInfo)
{
$this->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 = '<table>';
if (!empty($runtime)) {
}
}
}

View File

@@ -18,6 +18,8 @@ if (get_user_class() >= $torrentmanage_class || $CURUSER["id"] == $row["owner"])
$owned = 1; $owned = 1;
else $owned = 0; else $owned = 0;
$settingMain = get_setting('main');
if (!$row) if (!$row)
stderr($lang_details['std_error'], $lang_details['std_no_torrent_id']); stderr($lang_details['std_error'], $lang_details['std_no_torrent_id']);
elseif ($row['banned'] == 'yes' && get_user_class() < $seebanned_class) elseif ($row['banned'] == 'yes' && get_user_class() < $seebanned_class)
@@ -160,10 +162,16 @@ else {
/**************end custom fields****************/ /**************end custom fields****************/
if ($CURUSER['showdescription'] != 'no' && !empty($row["descr"])){ if ($CURUSER['showdescription'] != 'no' && !empty($row["descr"])){
$torrentdetailad=$Advertisement->get_ad('torrentdetail'); $torrentdetailad=$Advertisement->get_ad('torrentdetail');
tr("<a href=\"javascript: klappe_news('descr')\"><span class=\"nowrap\"><img class=\"minus\" src=\"pic/trans.gif\" alt=\"Show/Hide\" id=\"picdescr\" title=\"".($lang_details['title_show_or_hide'] ?? '')."\" /> ".$lang_details['row_description']."</span></a>", "<div id='kdescr'>".($Advertisement->enable_ad() && $torrentdetailad ? "<div align=\"left\" style=\"margin-bottom: 10px\" id=\"ad_torrentdetail\">".$torrentdetailad[0]."</div>" : "").format_comment($row["descr"])."</div>", 1); tr("<a href=\"javascript: klappe_news('descr')\"><span class=\"nowrap\"><img class=\"minus\" src=\"pic/trans.gif\" alt=\"Show/Hide\" id=\"picdescr\" title=\"".($lang_details['title_show_or_hide'] ?? '')."\" /> ".$lang_details['row_description']."</span></a>", "<div id='kdescr'>".($Advertisement->enable_ad() && $torrentdetailad ? "<div align=\"left\" style=\"margin-bottom: 10px\" id=\"ad_torrentdetail\">".$torrentdetailad[0]."</div>" : "").format_comment($row["descr"])."</div>", 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 (get_user_class() >= $viewnfo_class && $CURUSER['shownfo'] != 'no' && $row["nfosz"] > 0){
if (!$nfo = $Cache->get_value('nfo_block_torrent_id_'.$id)){ if (!$nfo = $Cache->get_value('nfo_block_torrent_id_'.$id)){
$nfo = code($row["nfo"], $view == "magic"); $nfo = code($row["nfo"], $view == "magic");

View File

@@ -41,7 +41,7 @@ if ($action == 'savesettings_main') // save main
'showpolls','showstats','showlastxtorrents', 'showtrackerload','showshoutbox','showfunbox','showoffer','sptime','showhelpbox','enablebitbucket', 'showpolls','showstats','showlastxtorrents', 'showtrackerload','showshoutbox','showfunbox','showoffer','sptime','showhelpbox','enablebitbucket',
'smalldescription','altname','extforum','extforumurl','defaultlang','defstylesheet', 'donation','spsct','browsecat','specialcat','waitsystem', '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', '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); GetVar($validConfig);
$MAIN = []; $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']); 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'],"<input type='text' name=\"pt_gen_api_point\" style=\"width: 300px\" value={$MAIN['pt_gen_api_point']}> ".$lang_settings['text_pt_gen_api_point_note'], 1); tr($lang_settings['row_pt_gen_api_point'],"<input type='text' name=\"pt_gen_api_point\" style=\"width: 300px\" value={$MAIN['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_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_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_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']); yesorno($lang_settings['row_show_shoutbox'],'showshoutbox', $MAIN['showshoutbox'], $lang_settings['text_show_shoutbox_note']);

View File

@@ -342,8 +342,8 @@ if (empty($url) && !empty($ptGenImdbLink)) {
$url = str_replace('tt', '', $ptGenImdbInfo['id']); $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) . $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(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 (!$ret) {
if (mysql_errno() == 1062) if (mysql_errno() == 1062)
bark($lang_takeupload['std_torrent_existed']); bark($lang_takeupload['std_torrent_existed']);
@@ -372,18 +372,18 @@ if (!empty($_POST['custom_fields'])) {
} }
} }
} }
if (!empty($_FILES['custom_fields'])) { //if (!empty($_FILES['custom_fields'])) {
foreach ($_FILES['custom_fields'] as $customField => $customValue) { // foreach ($_FILES['custom_fields'] as $customField => $customValue) {
$customData = [ // $customData = [
'torrent_id' => $id, // 'torrent_id' => $id,
'custom_field_id' => $customField, // 'custom_field_id' => $customField,
'custom_field_value' => $value, // 'custom_field_value' => $value,
'created_at' => $now, // 'created_at' => $now,
'updated_at' => $now, // 'updated_at' => $now,
]; // ];
\Nexus\Database\DB::insert('torrents_custom_field_values', $customData); // \Nexus\Database\DB::insert('torrents_custom_field_values', $customData);
} // }
} //}
@sql_query("DELETE FROM files WHERE torrent = $id"); @sql_query("DELETE FROM files WHERE torrent = $id");
foreach ($filelist as $file) { foreach ($filelist as $file) {

View File

@@ -73,6 +73,10 @@ stdhead($lang_upload['head_upload']);
textbbcode("upload","descr","",false); textbbcode("upload","descr","",false);
print("</td></tr>\n"); print("</td></tr>\n");
if ($settingMain['enable_technical_info'] == 'yes') {
tr($lang_upload['row_technical_info'], '<textarea name="technical_info" rows="8" style="width: 650px;"></textarea><br/>' . $lang_upload['row_technical_info_help_text'], 1);
}
if ($allowtorrents){ if ($allowtorrents){
$disablespecial = " onchange=\"disableother('browsecat','specialcat')\""; $disablespecial = " onchange=\"disableother('browsecat','specialcat')\"";
$s = "<select name=\"type\" id=\"browsecat\" ".($allowtwosec ? $disablespecial : "").">\n<option value=\"0\">".$lang_upload['select_choose_one']."</option>\n"; $s = "<select name=\"type\" id=\"browsecat\" ".($allowtwosec ? $disablespecial : "").">\n<option value=\"0\">".$lang_upload['select_choose_one']."</option>\n";