refactor(Track): Remove TERRITORY_MAP constant, trim SAR China manually

e.g., Hong Kong SAR China, Macao SAR China
This commit is contained in:
rlaphoenix 2024-03-10 15:10:33 +00:00
parent 4f79550301
commit f0b589c8a5
2 changed files with 3 additions and 5 deletions

View File

@ -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",

View File

@ -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