Fix for getting CSRF token for Germany region (Amazon)
This commit is contained in:
chu23465 2025-04-30 08:31:28 +05:30
parent a80eb98e36
commit 34bf93c2d5
2 changed files with 11 additions and 6 deletions

View File

@ -99,7 +99,8 @@ endpoints:
# chapters/scenes # chapters/scenes
xray: '/swift/page/xray' xray: '/swift/page/xray'
# device registration # device registration
ontv: '/region/eu/ontv/code?ref_=atv_auth_red_aft' #/gp/video/ontv/code ontv: '/region/eu/ontv/code?ref_=atv_auth_red_aft'
ontvold: '/gp/video/ontv/code/ref=atv_device_code'
devicelink: '/gp/video/api/codeBasedLinking' devicelink: '/gp/video/api/codeBasedLinking'
codepair: '/auth/create/codepair' codepair: '/auth/create/codepair'
register: '/auth/register' register: '/auth/register'

View File

@ -788,7 +788,7 @@ class Amazon(BaseService):
def prepare_endpoint(self, name: str, uri: str, region: dict) -> str: def prepare_endpoint(self, name: str, uri: str, region: dict) -> str:
if name in ("browse", "playback", "licence", "xray"): if name in ("browse", "playback", "licence", "xray"):
return f"https://{(region['base_manifest'])}{uri}" return f"https://{(region['base_manifest'])}{uri}"
if name in ("ontv", "devicelink", "details", "getDetailWidgets"): if name in ("ontv", "ontvold", "devicelink", "details", "getDetailWidgets"):
if self.pv: if self.pv:
host = "www.primevideo.com" host = "www.primevideo.com"
else: else:
@ -961,9 +961,10 @@ class Amazon(BaseService):
return "".join(match.groups()) return "".join(match.groups())
else: else:
try: try:
mpd_url = "".join( if not "live" in mpd_url:
re.split(r"(?i)(/)", mpd_url)[:5] + re.split(r"(?i)(/)", mpd_url)[9:] mpd_url = "".join(
) re.split(r"(?i)(/)", mpd_url)[:5] + re.split(r"(?i)(/)", mpd_url)[9:]
)
except IndexError: except IndexError:
self.log.warning("Unable to parse manifest URL") self.log.warning("Unable to parse manifest URL")
return mpd_url return mpd_url
@ -1231,7 +1232,10 @@ class Amazon(BaseService):
this token is used to register the device this token is used to register the device
:return: OnTV Page's CSRF Token :return: OnTV Page's CSRF Token
""" """
res = self.session.get(self.endpoints["ontv"]) try:
res = self.session.get(self.endpoints["ontv"])
except:
res = self.session.get(self.endpoints["ontvold"])
response = res.text response = res.text
if 'input type="hidden" name="appAction" value="SIGNIN"' in response: if 'input type="hidden" name="appAction" value="SIGNIN"' in response:
raise self.log.exit( raise self.log.exit(