From 83863bd66c2aab86f4a99f84521e49cc2bc0b8a7 Mon Sep 17 00:00:00 2001 From: bellington3 <71927099+bellington3@users.noreply.github.com> Date: Sat, 17 Oct 2020 12:14:36 +0000 Subject: [PATCH] Provide config toggle to disable the 'convert seek' function (#311) * Provide config toggle to disable the 'convert seek' function in the frontend * Add convertSeek config option to config.example * Only send from/to if convertSeek is activated --- classes/Config.php | 7 +++++++ classes/Controller/DownloadController.php | 8 ++++++-- config/config.example.yml | 3 +++ templates/index.tpl | 2 ++ tests/ConfigTest.php | 1 + 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/classes/Config.php b/classes/Config.php index 56a0fe4..48625a1 100644 --- a/classes/Config.php +++ b/classes/Config.php @@ -147,6 +147,13 @@ class Config */ public $defaultAudio = false; + /** + * Disable audio conversion from/to seeker. + * + * @var bool + */ + public $convertSeek = true; + /** * Config constructor. * diff --git a/classes/Controller/DownloadController.php b/classes/Controller/DownloadController.php index 834f48d..e3c547c 100644 --- a/classes/Controller/DownloadController.php +++ b/classes/Controller/DownloadController.php @@ -101,8 +101,12 @@ class DownloadController extends BaseController */ private function getConvertedAudioResponse(Request $request, Response $response) { - $from = $request->getQueryParam('from'); - $to = $request->getQueryParam('to'); + $from = null; + $to = null; + if ($this->config->convertSeek) { + $from = $request->getQueryParam('from'); + $to = $request->getQueryParam('to'); + } $response = $response->withHeader( 'Content-Disposition', diff --git a/config/config.example.yml b/config/config.example.yml index 29511a2..3ce5614 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -58,3 +58,6 @@ debug: false # True to enable audio conversion mode by default defaultAudio: false + +# False to disable convert seek functionality +convertSeek: true diff --git a/templates/index.tpl b/templates/index.tpl index c606933..b26eb64 100644 --- a/templates/index.tpl +++ b/templates/index.tpl @@ -24,6 +24,7 @@ + {if $config->convertSeek}