mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-24 07:05:47 -07:00
Updated
This commit is contained in:
parent
28fe3e1afe
commit
e9032dc6a8
3 changed files with 61 additions and 60 deletions
|
@ -29,8 +29,61 @@ if (!$info_hash = (string)$this->request['info_hash']) {
|
|||
$this->ajax_die('Invalid info_hash');
|
||||
}
|
||||
|
||||
dump($attach_id);
|
||||
dump($file_index);
|
||||
dump($info_hash);
|
||||
$isAudio = (bool)$this->request['is_audio'];
|
||||
|
||||
$this->response['ffprobe_data'] = '123';
|
||||
// Get ffprobe info from TorrServer
|
||||
$ffpInfo = (new \TorrentPier\TorrServerAPI())->getFfpInfo($info_hash, $file_index, $attach_id);
|
||||
$ffpInfo = $ffpInfo->{$filesCount};
|
||||
if (isset($ffpInfo->streams)) {
|
||||
// Video codec information
|
||||
$videoCodecIndex = array_search('video', array_column($ffpInfo->streams, 'codec_type'));
|
||||
if (is_int($videoCodecIndex)) {
|
||||
$videoCodecInfo = $ffpInfo->streams[$videoCodecIndex];
|
||||
}
|
||||
// Audio codec information
|
||||
$audioTracks = array_filter($ffpInfo->streams, function ($e) {
|
||||
return $e->codec_type === 'audio';
|
||||
});
|
||||
$audioDub = array_map(function ($stream) {
|
||||
global $lang;
|
||||
|
||||
$result = '<span class="warnColor2">' . sprintf($lang['AUDIO_TRACK'], (!isset($stream->index) || $stream->index === 0) ? 1 : $stream->index) . '</span><br>';
|
||||
if (isset($stream->tags->language)) {
|
||||
if (isset($stream->tags->title)) {
|
||||
$result .= '<b>' . mb_strtoupper($stream->tags->language, 'UTF-8') . ' (' . $stream->tags->title . ')' . '</b>';
|
||||
} else {
|
||||
$result .= '<b>' . mb_strtoupper($stream->tags->language, 'UTF-8') . '</b>';
|
||||
}
|
||||
$result .= '<br>';
|
||||
}
|
||||
|
||||
if (!empty($stream->codec_name)) {
|
||||
$result .= sprintf($lang['AUDIO_CODEC'], mb_strtoupper($stream->codec_name, 'UTF-8')) . '<br>';
|
||||
}
|
||||
if (!empty($stream->bit_rate)) {
|
||||
$result .= sprintf($lang['BITRATE'], humn_bitrate($stream->bit_rate)) . '<br>';
|
||||
}
|
||||
if (!empty($stream->sample_rate)) {
|
||||
$result .= sprintf($lang['SAMPLE_RATE'], $stream->sample_rate) . '<br>';
|
||||
}
|
||||
if (!empty($stream->channels)) {
|
||||
$result .= sprintf($lang['CHANNELS'], $stream->channels) . '<br>';
|
||||
}
|
||||
if (!empty($stream->channel_layout)) {
|
||||
$result .= sprintf($lang['CHANNELS_LAYOUT'], $stream->channel_layout);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}, $audioTracks);
|
||||
|
||||
$template->assign_block_vars('m3ulist.ffprobe', [
|
||||
'FILESIZE' => sprintf($lang['FILESIZE'] . ': <b>%s</b>', humn_size($ffpInfo->format->size)),
|
||||
'RESOLUTION' => (!$isAudio && isset($videoCodecInfo)) ? sprintf($lang['RESOLUTION'], $videoCodecInfo->width . 'x' . $videoCodecInfo->height) : '',
|
||||
'VIDEO_CODEC' => (!$isAudio && isset($videoCodecInfo->codec_name)) ? sprintf($lang['VIDEO_CODEC'], mb_strtoupper($videoCodecInfo->codec_name, 'UTF-8')) : '',
|
||||
'AUDIO_DUB' => implode('<hr>', $audioDub)
|
||||
]);
|
||||
}
|
||||
|
||||
$this->response['ffprobe_data'] = '
|
||||
|
||||
';
|
||||
|
|
|
@ -94,59 +94,6 @@ foreach ($m3uData as $entry) {
|
|||
'M3U_DL_LINK' => $m3uFile,
|
||||
'TITLE' => $title,
|
||||
]);
|
||||
|
||||
// Get ffprobe info from TorrServer
|
||||
$ffpInfo = (new \TorrentPier\TorrServerAPI())->getFfpInfo($row['info_hash'] ?? $row['info_hash_v2'], $filesCount, $row['attach_id']);
|
||||
$ffpInfo = $ffpInfo->{$filesCount};
|
||||
if (isset($ffpInfo->streams)) {
|
||||
// Video codec information
|
||||
$videoCodecIndex = array_search('video', array_column($ffpInfo->streams, 'codec_type'));
|
||||
if (is_int($videoCodecIndex)) {
|
||||
$videoCodecInfo = $ffpInfo->streams[$videoCodecIndex];
|
||||
}
|
||||
// Audio codec information
|
||||
$audioTracks = array_filter($ffpInfo->streams, function ($e) {
|
||||
return $e->codec_type === 'audio';
|
||||
});
|
||||
$audioDub = array_map(function ($stream) {
|
||||
global $lang;
|
||||
|
||||
$result = '<span class="warnColor2">' . sprintf($lang['AUDIO_TRACK'], (!isset($stream->index) || $stream->index === 0) ? 1 : $stream->index) . '</span><br>';
|
||||
if (isset($stream->tags->language)) {
|
||||
if (isset($stream->tags->title)) {
|
||||
$result .= '<b>' . mb_strtoupper($stream->tags->language, 'UTF-8') . ' (' . $stream->tags->title . ')' . '</b>';
|
||||
} else {
|
||||
$result .= '<b>' . mb_strtoupper($stream->tags->language, 'UTF-8') . '</b>';
|
||||
}
|
||||
$result .= '<br>';
|
||||
}
|
||||
|
||||
if (!empty($stream->codec_name)) {
|
||||
$result .= sprintf($lang['AUDIO_CODEC'], mb_strtoupper($stream->codec_name, 'UTF-8')) . '<br>';
|
||||
}
|
||||
if (!empty($stream->bit_rate)) {
|
||||
$result .= sprintf($lang['BITRATE'], humn_bitrate($stream->bit_rate)) . '<br>';
|
||||
}
|
||||
if (!empty($stream->sample_rate)) {
|
||||
$result .= sprintf($lang['SAMPLE_RATE'], $stream->sample_rate) . '<br>';
|
||||
}
|
||||
if (!empty($stream->channels)) {
|
||||
$result .= sprintf($lang['CHANNELS'], $stream->channels) . '<br>';
|
||||
}
|
||||
if (!empty($stream->channel_layout)) {
|
||||
$result .= sprintf($lang['CHANNELS_LAYOUT'], $stream->channel_layout);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}, $audioTracks);
|
||||
|
||||
$template->assign_block_vars('m3ulist.ffprobe', [
|
||||
'FILESIZE' => sprintf($lang['FILESIZE'] . ': <b>%s</b>', humn_size($ffpInfo->format->size)),
|
||||
'RESOLUTION' => (!$isAudio && isset($videoCodecInfo)) ? sprintf($lang['RESOLUTION'], $videoCodecInfo->width . 'x' . $videoCodecInfo->height) : '',
|
||||
'VIDEO_CODEC' => (!$isAudio && isset($videoCodecInfo->codec_name)) ? sprintf($lang['VIDEO_CODEC'], mb_strtoupper($videoCodecInfo->codec_name, 'UTF-8')) : '',
|
||||
'AUDIO_DUB' => implode('<hr>', $audioDub)
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// Generate output
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
<h1 class="pagetitle">{PAGE_TITLE}</h1>
|
||||
|
||||
<script type="text/javascript">
|
||||
ajax.ffprobe_info = function (file_index) {
|
||||
ajax.ffprobe_info = function (file_index, is_audio) {
|
||||
ajax.exec({
|
||||
action: 'ffprobe_info',
|
||||
attach_id: {ATTACH_ID},
|
||||
info_hash: '{INFO_HASH}',
|
||||
file_index: file_index
|
||||
file_index: file_index,
|
||||
is_audio: is_audio
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
@ -32,7 +33,7 @@
|
|||
<td width="40%"><b>{m3ulist.TITLE}</b>
|
||||
<hr>
|
||||
<div id="ffprobe_{m3ulist.ROW_NUMBER}">
|
||||
<a href="#" onclick="ajax.ffprobe_info({m3ulist.ROW_NUMBER}); return false;">{L_SHOW_MORE_INFORMATION_FILE}</a>
|
||||
<a href="#" onclick="ajax.ffprobe_info({m3ulist.ROW_NUMBER}, {m3ulist.IS_AUDIO}); return false;">{L_SHOW_MORE_INFORMATION_FILE}</a>
|
||||
</div>
|
||||
<!-- BEGIN ffprobe -->
|
||||
<hr><!-- IF m3ulist.ffprobe.RESOLUTION -->{m3ulist.ffprobe.RESOLUTION}<br><!-- ENDIF -->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue