From f0b589c8a53661ff3e3269ca94eea64bf8485e09 Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Sun, 10 Mar 2024 15:10:33 +0000 Subject: [PATCH] refactor(Track): Remove TERRITORY_MAP constant, trim SAR China manually e.g., Hong Kong SAR China, Macao SAR China --- devine/core/constants.py | 3 --- devine/core/tracks/track.py | 5 +++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/devine/core/constants.py b/devine/core/constants.py index 13adfff..4fa9561 100644 --- a/devine/core/constants.py +++ b/devine/core/constants.py @@ -5,9 +5,6 @@ DOWNLOAD_CANCELLED = Event() DOWNLOAD_LICENCE_ONLY = Event() DRM_SORT_MAP = ["ClearKey", "Widevine"] -TERRITORY_MAP = { - "Hong Kong SAR China": "Hong Kong" -} LANGUAGE_MAX_DISTANCE = 5 # this is max to be considered "same", e.g., en, en-US, en-AU VIDEO_CODEC_MAP = { "AVC": "H.264", diff --git a/devine/core/tracks/track.py b/devine/core/tracks/track.py index f7c41ec..e1db539 100644 --- a/devine/core/tracks/track.py +++ b/devine/core/tracks/track.py @@ -17,7 +17,7 @@ from langcodes import Language from requests import Session from devine.core.config import config -from devine.core.constants import DOWNLOAD_CANCELLED, DOWNLOAD_LICENCE_ONLY, TERRITORY_MAP +from devine.core.constants import DOWNLOAD_CANCELLED, DOWNLOAD_LICENCE_ONLY from devine.core.downloaders import aria2c, curl_impersonate, requests from devine.core.drm import DRM_T, Widevine from devine.core.utilities import get_binary_path, get_boxes, try_ensure_utf8 @@ -326,7 +326,8 @@ class Track: simplified_language = self.language.simplify_script() script = simplified_language.script_name(max_distance=25) territory = simplified_language.territory_name(max_distance=25) - territory = TERRITORY_MAP.get(territory, territory) + if territory and territory.endswith(" SAR China"): + territory = territory.split(" SAR China")[0] if (script or "").lower() == (territory or "").lower(): script = None