diff --git a/assets/controllers/movie_results_controller.js b/assets/controllers/movie_results_controller.js index 29543e4..79bfe85 100644 --- a/assets/controllers/movie_results_controller.js +++ b/assets/controllers/movie_results_controller.js @@ -16,6 +16,7 @@ export default class extends Controller { }; static targets = ['list'] + static outlets = ['loading-icon'] options = [] optionsLoaded = false @@ -33,6 +34,8 @@ export default class extends Controller { this.element.innerHTML = response; this.options = this.element.querySelectorAll('tbody tr'); this.options.forEach((option) => option.querySelector('.download-btn').dataset['title'] = this.titleValue); + this.dispatch('optionsLoaded', {detail: {options: this.options}}) + this.loadingIconOutlet.toggleIcon(); }); } } diff --git a/assets/controllers/result_filter_controller.js b/assets/controllers/result_filter_controller.js index 55aeba4..7b7ed9c 100644 --- a/assets/controllers/result_filter_controller.js +++ b/assets/controllers/result_filter_controller.js @@ -36,19 +36,9 @@ export default class extends Controller { await this.filter(); } - async movieResultsOutletConnected(outlet) { - await this.parseDownloadOptionForFilter(outlet) - } - - async tvResultsOutletConnected(outlet) { - await this.parseDownloadOptionForFilter(outlet) - } - - async parseDownloadOptionForFilter(outlet) { - if (outlet.options.length === 0) { - await outlet.setOptions(); - } - outlet.options.forEach((option) => { + // Event is fired from movies/tvshows controllers to populate this data + async loadOptions({detail: { options }}) { + await options.forEach((option) => { this.addLanguages(option, option.dataset); this.addProviders(option, option.dataset); this.addQualities(option, option.dataset); diff --git a/assets/controllers/tv_results_controller.js b/assets/controllers/tv_results_controller.js index 291b7f1..79d5c38 100644 --- a/assets/controllers/tv_results_controller.js +++ b/assets/controllers/tv_results_controller.js @@ -51,6 +51,7 @@ export default class extends Controller { this.countTarget.innerText = 0; this.episodeSelectorTarget.disabled = true; } + this.dispatch('optionsLoaded', {detail: {options: this.options}}) this.loadingIconOutlet.increaseCount(); } else { console.log(`HTTP Response Code: ${response?.status}`) diff --git a/src/Controller/IndexController.php b/src/Controller/IndexController.php index 17da040..fe1d7f6 100644 --- a/src/Controller/IndexController.php +++ b/src/Controller/IndexController.php @@ -8,6 +8,7 @@ use App\Monitor\Action\Handler\MonitorTvShowHandler; use App\Monitor\Framework\Scheduler\MonitorDispatcher; use App\Tmdb\Tmdb; use App\Tmdb\TmdbResult; +use App\User\Framework\Entity\User; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -23,6 +24,8 @@ final class IndexController extends AbstractController #[Route('/', name: 'app_index')] public function index(Request $request): Response { + /** @var User $user */ + $user = $this->getUser(); return $this->render('index/index.html.twig', [ 'active_downloads' => $this->getUser()->getActiveDownloads(), 'recent_downloads' => $this->getUser()->getDownloads(), diff --git a/src/User/Action/Command/SaveUserMediaPreferencesCommand.php b/src/User/Action/Command/SaveUserMediaPreferencesCommand.php index 19878b4..94fe7fc 100644 --- a/src/User/Action/Command/SaveUserMediaPreferencesCommand.php +++ b/src/User/Action/Command/SaveUserMediaPreferencesCommand.php @@ -10,6 +10,7 @@ class SaveUserMediaPreferencesCommand implements CommandInterface public function __construct( public string $resolution, public string $codec, + public string $quality, public string $language, public string $provider, ) {} diff --git a/src/User/Action/Input/SaveUserMediaPreferencesInput.php b/src/User/Action/Input/SaveUserMediaPreferencesInput.php index 5c9b979..9ea533e 100644 --- a/src/User/Action/Input/SaveUserMediaPreferencesInput.php +++ b/src/User/Action/Input/SaveUserMediaPreferencesInput.php @@ -18,6 +18,9 @@ class SaveUserMediaPreferencesInput implements InputInterface #[SourceRequest('resolution')] public string $resolution, + #[SourceRequest('quality')] + public string $quality, + #[SourceRequest('codec')] public string $codec, @@ -33,6 +36,7 @@ class SaveUserMediaPreferencesInput implements InputInterface return new SaveUserMediaPreferencesCommand( $this->resolution, $this->codec, + $this->quality, $this->language, $this->provider, ); diff --git a/src/User/Framework/Controller/Web/PreferencesController.php b/src/User/Framework/Controller/Web/PreferencesController.php index 49c38dc..0e59bf7 100644 --- a/src/User/Framework/Controller/Web/PreferencesController.php +++ b/src/User/Framework/Controller/Web/PreferencesController.php @@ -12,6 +12,7 @@ use App\User\Framework\Repository\PreferencesRepository; use App\Util\Broadcaster; use App\Util\CountryLanguages; use App\Util\ProviderList; +use App\Util\QualityList; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; @@ -36,7 +37,8 @@ class PreferencesController extends AbstractController [ 'preferences' => $this->preferencesRepository->findEnabled(), 'languages' => $languages, - 'providers' => ProviderList::$providers, + 'providers' => ProviderList::getProviders(), + 'qualities' => QualityList::getBaseQualities(), 'mediaPreferences' => $mediaPreferences, 'downloadPreferences' => $downloadPreferences, ] @@ -67,6 +69,7 @@ class PreferencesController extends AbstractController 'preferences' => $this->preferencesRepository->findEnabled(), 'languages' => $languages, 'providers' => ProviderList::$providers, + 'qualities' => QualityList::getBaseQualities(), 'mediaPreferences' => $mediaPreferences, 'downloadPreferences' => $downloadPreferences, ] diff --git a/src/Util/QualityList.php b/src/Util/QualityList.php new file mode 100644 index 0000000..80abe57 --- /dev/null +++ b/src/Util/QualityList.php @@ -0,0 +1,115 @@ + [ + "DVDRip", + "DVDMux", + "DVDR", + "DVD-Full", + "Full-Rip", + "ISO rip", + "lossless rip", + "untouched rip", + "DVD-5", + "DVD-9", + ], + "HDTV, PDTV or DSRip" => [ + "DSR", + "DSRip", + "SATRip", + "DTHRip", + "DVBRip", + "HDTV", + "PDTV", + "DTVRip", + "TVRip", + "HDTVRip", + ], + "VODRip" => [ + "VODRip", + "VODR", + ], + "HC HD-Rip" => [ + "HC", + "HD-Rip", + ], + "WEBCap" => [ + "WEB-Cap", + "WEBCAP", + "WEB Cap", + ], + "HDRip" => [ + "HDRip", + "WEB-DLRip", + ], + "WEBRip" => [ + "WEBRip", + "WEB Rip", + "WEB-Rip", + "WEBRip (P2P)", + "WEB Rip (P2P)", + "WEB-Rip (P2P)", + ], + "WEB-DL" => [ + "WEBDL", + "WEB DL", + "WEB-DL", + "WEB (Scene)", + "WEBRip", + ], + "Blu-ray/BD/BRRip" => [ + "Blu-Ray", + "BluRay", + "BLURAY", + "BDRip", + "BRip", + "BRRip", + "BDR[13]", + "BD25", + "BD50", + "BD66", + "BD100", + "BD5", + "BD9", + "BDMV", + "BDISO", + "COMPLETE.BLURAY", + ], + "4K" => [ + "CBR", + "VBR", + ], + ]; + + public static function getQualities(): array + { + return self::$qualities; + } + + public static function getBaseQualities(): array + { + return array_keys(self::$qualities); + } + + public static function getBaseQualityFromSubQuality(string $key): ?string + { + return array_search($key, self::$qualities) ?? null; + } + + public static function getAsReverseMap(): array + { + $results = []; + + foreach (self::$qualities as $baseQualtiy => $subQualities) { + foreach ($subQualities as $subQuality) { + $results[$subQuality] = $baseQualtiy; + } + } + + return $results; + } +} diff --git a/templates/components/Filter.html.twig b/templates/components/Filter.html.twig index 53c5dc8..f6befe6 100644 --- a/templates/components/Filter.html.twig +++ b/templates/components/Filter.html.twig @@ -1,10 +1,10 @@