Skip to content

Commit

Permalink
refactor: Remove TERRITORY_MAP constant, trim SAR China manually
Browse files Browse the repository at this point in the history
e.g., Hong Kong SAR China, Macao SAR China
  • Loading branch information
rlaphoenix committed Mar 10, 2024
1 parent 4f79550 commit 18aa068
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 0 additions & 3 deletions devine/core/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
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",
Expand Down
5 changes: 3 additions & 2 deletions devine/core/tracks/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
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
Expand Down Expand Up @@ -326,7 +326,8 @@ def get_track_name(self) -> Optional[str]:
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
Expand Down

0 comments on commit 18aa068

Please sign in to comment.