diff --git a/assets/controllers/result_filter_controller.js b/assets/controllers/result_filter_controller.js index 7b7ed9c..36692da 100644 --- a/assets/controllers/result_filter_controller.js +++ b/assets/controllers/result_filter_controller.js @@ -27,6 +27,7 @@ export default class extends Controller { static values = { 'media-type': String, 'episodes': Array, + 'reverseMappedQualities': Object, } async connect() { @@ -100,7 +101,9 @@ export default class extends Controller { addQualities(option, props) { if (!this.qualities.includes(props['quality'])) { - this.qualities.push(props['quality']); + if (props['quality'].toLowerCase() in this.reverseMappedQualitiesValue) { + this.qualities.push(props['quality']); + } } const preferred = this.qualityTarget.dataset.preferred; diff --git a/src/Twig/Components/Filter.php b/src/Twig/Components/Filter.php index d7e135f..4ab789c 100644 --- a/src/Twig/Components/Filter.php +++ b/src/Twig/Components/Filter.php @@ -4,6 +4,7 @@ namespace App\Twig\Components; use Aimeos\Map; use App\User\Framework\Repository\PreferencesRepository; +use App\Util\QualityList; use Symfony\Bundle\SecurityBundle\Security; use Symfony\UX\LiveComponent\Attribute\AsLiveComponent; use Symfony\UX\LiveComponent\DefaultActionTrait; @@ -17,6 +18,8 @@ final class Filter public array $userPreferences = []; + public array $reverseMappedQualities = []; + public function __construct( private readonly PreferencesRepository $preferencesRepository, private readonly Security $security, @@ -27,5 +30,6 @@ final class Filter ->toArray(); $this->userPreferences = Map::from($this->security->getUser()->getUserPreferenceValues()) ->toArray(); + $this->reverseMappedQualities = QualityList::getAsReverseMap(); } } diff --git a/src/User/Framework/Entity/User.php b/src/User/Framework/Entity/User.php index d894bd5..60eec6d 100644 --- a/src/User/Framework/Entity/User.php +++ b/src/User/Framework/Entity/User.php @@ -209,7 +209,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface return Map::from($this->userPreferences) ->rekey(fn(UserPreference $userPreference) => $userPreference->getPreference()->getId()) ->map(function (UserPreference $userPreference) { - if (in_array($userPreference->getPreference()->getId(), ['language', 'provider'])) { + if (in_array($userPreference->getPreference()->getId(), ['language', 'provider', 'quality'])) { return $userPreference->getPreferenceValue(); } foreach ($userPreference->getPreference()->getPreferenceOptions() as $preferenceOption) { diff --git a/src/Util/QualityList.php b/src/Util/QualityList.php index 80abe57..b4a0868 100644 --- a/src/Util/QualityList.php +++ b/src/Util/QualityList.php @@ -5,83 +5,83 @@ namespace App\Util; class QualityList { public static $qualities = [ - "DVD-Rip" => [ - "DVDRip", - "DVDMux", - "DVDR", - "DVD-Full", - "Full-Rip", - "ISO rip", + "dvd-rip" => [ + "dvdrip", + "dvdmux", + "dvdr", + "dvd-full", + "full-rip", + "iso rip", "lossless rip", "untouched rip", - "DVD-5", - "DVD-9", + "dvd-5", + "dvd-9", ], - "HDTV, PDTV or DSRip" => [ - "DSR", - "DSRip", - "SATRip", - "DTHRip", - "DVBRip", - "HDTV", - "PDTV", - "DTVRip", - "TVRip", - "HDTVRip", + "hdtv, pdtv or dsrip" => [ + "dsr", + "dsrip", + "satrip", + "dthrip", + "dvbrip", + "hdtv", + "pdtv", + "dtvrip", + "tvrip", + "hdtvrip", ], - "VODRip" => [ - "VODRip", - "VODR", + "vodrip" => [ + "vodrip", + "vodr", ], - "HC HD-Rip" => [ - "HC", - "HD-Rip", + "hc hd-rip" => [ + "hc", + "hd-rip", ], - "WEBCap" => [ - "WEB-Cap", - "WEBCAP", - "WEB Cap", + "webcap" => [ + "web-cap", + "webcap", + "web cap", ], - "HDRip" => [ - "HDRip", - "WEB-DLRip", + "hdrip" => [ + "hdrip", + "web-dlrip", ], - "WEBRip" => [ - "WEBRip", - "WEB Rip", - "WEB-Rip", - "WEBRip (P2P)", - "WEB Rip (P2P)", - "WEB-Rip (P2P)", + "webrip" => [ + "webrip", + "web rip", + "web-rip", + "webrip (p2p)", + "web rip (p2p)", + "web-rip (p2p)", ], - "WEB-DL" => [ - "WEBDL", - "WEB DL", - "WEB-DL", - "WEB (Scene)", - "WEBRip", + "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", + "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", + "4k" => [ + "cbr", + "vbr", ], ]; diff --git a/templates/components/Filter.html.twig b/templates/components/Filter.html.twig index f6befe6..2ffb3b0 100644 --- a/templates/components/Filter.html.twig +++ b/templates/components/Filter.html.twig @@ -1,5 +1,5 @@