fix(services): match service aliases without case

Uppercase entries in ALIASES never resolved, because get_tag lowercased the input but not the alias. Match real tags first so a service's own tag cannot be taken by another service's alias.
This commit is contained in:
imSp4rky
2026-08-24 11:56:46 -06:00
parent 87cdb30229
commit 0a68cc2452
5 changed files with 58 additions and 20 deletions
+5 -5
View File
@@ -171,7 +171,7 @@ class Service(metaclass=ABCMeta):
still, during track download.
"""
ALIASES: tuple[str, ...] = () # list of aliases for the service; alternatives to the service tag.
ALIASES: tuple[str, ...] = () # alternative tags for the service, matched without case.
GEOFENCE: tuple[str, ...] = () # list of ip regions required to use the service. empty list == no specific region.
ANIME: bool = False # service catalogue is anime; metadata lookups prefer AniList. Title.anime overrides per title.
DAILY: bool = False # catalog is daily/date-based. episodes are named by air date. Title.daily overrides per title.
@@ -489,8 +489,8 @@ class Service(metaclass=ABCMeta):
read by the Cdm and decrypted.
This is a very important request to get correct. A bad, unexpected, or missing
value in the request can cause the service to detect your CDM device. The device
can then be banned, revoked, disabled, or downgraded.
value in the request can cause the service to detect your CDM device.
The service can then ban, revoke, disable, or downgrade that device.
:param challenge: The license challenge from the Widevine CDM.
:param title: The current `Title` from get_titles that unshackle processes now. unshackle
@@ -510,8 +510,8 @@ class Service(metaclass=ABCMeta):
read by the CDM and decrypted.
This is a very important request to get correct. A bad, unexpected, or missing
value in the request can cause the service to detect your CDM device. The device
can then be banned, revoked, disabled, or downgraded.
value in the request can cause the service to detect your CDM device.
The service can then ban, revoke, disable, or downgrade that device.
:param challenge: The license challenge from the PlayReady CDM.
:param title: The current `Title` from get_titles that unshackle processes now. unshackle
+11 -7
View File
@@ -317,18 +317,22 @@ class Services(click.Group):
def get_tag(value: str) -> str:
"""
Get the Service Tag (the name of the service's directory, not one of its aliases) by an Alias.
Input value can be of any case-sensitivity.
Input value can be of any case-sensitivity, and so can the alias it matches.
A real tag always wins over an alias: services do declare aliases that collide with another service's tag.
This method returns the original input value if it does not match a service tag.
"""
original_value = value
value = value.lower()
value_lower = value.lower()
tags = [path.parent.stem for path in SERVICES]
for path in SERVICES:
tag = path.parent.stem
if value in (tag.lower(), *ALIASES.get(tag, [])):
for tag in tags:
if value_lower == tag.lower():
return tag
return original_value
for tag in tags:
if any(value_lower == alias.lower() for alias in ALIASES.get(tag, ())):
return tag
return value
@staticmethod
def load(tag: str) -> Service: