From f315343798514c44f67dfeb689d6e396bcae7a15 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Wed, 27 Mar 2019 00:25:02 +0100 Subject: [PATCH] refactor: Cleanup best format logic Reuse $defaultFormat everywhere instead of duplicating conditions --- controllers/FrontController.php | 19 +++++++++---------- templates/video.tpl | 4 ++-- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/controllers/FrontController.php b/controllers/FrontController.php index 1e22d87..04e6b7a 100644 --- a/controllers/FrontController.php +++ b/controllers/FrontController.php @@ -97,9 +97,7 @@ class FrontController $session_factory = new SessionFactory(); $session = $session_factory->newInstance($cookies); $this->sessionSegment = $session->getSegment(self::class); - if ($this->config->remux) { - $this->defaultFormat = 'bestvideo+bestaudio,best'; - } elseif ($this->config->stream) { + if ($this->config->stream) { $this->defaultFormat = 'best'; } } @@ -316,13 +314,14 @@ class FrontController $response, $template, [ - 'video' => $video, - 'class' => 'video', - 'title' => $title, - 'description' => $description, - 'config' => $this->config, - 'canonical' => $this->getCanonicalUrl($request), - 'locale' => $this->localeManager->getLocale(), + 'video' => $video, + 'class' => 'video', + 'title' => $title, + 'description' => $description, + 'config' => $this->config, + 'canonical' => $this->getCanonicalUrl($request), + 'locale' => $this->localeManager->getLocale(), + 'defaultFormat' => $this->defaultFormat, ] ); diff --git a/templates/video.tpl b/templates/video.tpl index 4dfef1a..0d1f08e 100644 --- a/templates/video.tpl +++ b/templates/video.tpl @@ -27,7 +27,7 @@ {/if}