Minor improvements (#1633)

* Minor improvements

* Update CHANGELOG.md

* Update filelist.php

* Update ffprobe_info.php

* Updated

* Update announce.php

* Update announce.php

* Update ffprobe_info.php

* Updated

* Update ffprobe_info.php

* Update ffprobe_info.php

* Updated

* Update common.php

* Update common.php

* Revert "Update common.php"

This reverts commit 3793263ff0.

* Revert "Update common.php"

This reverts commit 3911e72dba.

* Update common.php

* Updated

* Update playback_m3u.tpl

* Update ffprobe_info.php

* Update playback_m3u.php

* Update dl.php

* Update dl.php

* Updated

* Update dl.php

* Update playback_m3u.php

* Revert "Update playback_m3u.php"

This reverts commit 8cf6e9a041.

* Revert "Update dl.php"

This reverts commit 7c11cc385b.

* Revert "Updated"

This reverts commit 9c004f0651.

* Revert "Update dl.php"

This reverts commit 26d5feffa5.

* Revert "Update dl.php"

This reverts commit 261f8d3e62.

* Update playback_m3u.php

* Updated

* Update dl.php

* Update dl.php

* Update CHANGELOG.md
This commit is contained in:
Roman Kelesidis 2024-09-19 20:57:36 +07:00 committed by GitHub
commit 001c210217
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 80 additions and 51 deletions

View file

@ -17,11 +17,13 @@ if (!$bb_cfg['torr_server']['enabled']) {
$this->ajax_die($lang['MODULE_OFF']);
}
if (!$attach_id = (int)$this->request['attach_id'] or !is_numeric($attach_id)) {
$attach_id = $this->request['attach_id'] ?? '';
if (empty($attach_id) || !is_numeric($attach_id)) {
$this->ajax_die($lang['INVALID_ATTACH_ID']);
}
if (!$file_index = (int)$this->request['file_index'] or !is_numeric($file_index)) {
$file_index = $this->request['file_index'] ?? '';
if (empty($file_index) || !is_numeric($file_index)) {
$this->ajax_die("Invalid file index: $file_index");
}
@ -61,11 +63,11 @@ if (isset($ffpInfo->streams)) {
if (!empty($stream->codec_name)) {
$result .= sprintf($lang['AUDIO_CODEC'], $stream->codec_long_name, mb_strtoupper($stream->codec_name, 'UTF-8')) . '<br>';
}
if (!empty($stream->bit_rate)) {
if (!empty($stream->bit_rate) && is_int($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->sample_rate) && is_int($stream->sample_rate)) {
$result .= sprintf($lang['SAMPLE_RATE'], humn_sample_rate($stream->sample_rate)) . '<br>';
}
if (!empty($stream->channels)) {
$result .= sprintf($lang['CHANNELS'], $stream->channels) . '<br>';
@ -103,4 +105,39 @@ if (isset($ffpInfo->streams)) {
$this->response['ffprobe_data'] = $result;
}
/**
* Bitrate to human-readable format
*
* @param int $bitrate
* @param string $space
* @return string
*/
function humn_bitrate(int $bitrate, string $space = '&nbsp;'): string
{
if ($bitrate >= 1000000) {
$unit = 'Mbps';
$bitrate /= 1000000;
} elseif ($bitrate >= 1000) {
$unit = 'kbps';
$bitrate /= 1000;
} else {
$unit = 'bps';
}
return sprintf('%d', commify($bitrate)) . $space . $unit;
}
/**
* Sample rate to human-readable format
*
* @param int $sample_rate
* @param string $space
* @return string
*/
function humn_sample_rate(int $sample_rate, string $space = '&nbsp;'): string
{
$unit = '';
return sprintf('%.1f', commify($sample_rate)) . $space . $unit;
}
$this->response['file_index'] = $file_index;