refactor(DSCP): Perform check before returning period_filter
This commit is contained in:
parent
f0f7e26268
commit
a731f64f5c
@ -292,8 +292,11 @@ class DSCP(Service):
|
|||||||
|
|
||||||
# Service specific functions
|
# Service specific functions
|
||||||
|
|
||||||
def period_filter(self, period):
|
def period_filter(self, period: Any) -> bool:
|
||||||
return "dash_clear" in period.findtext("BaseURL")
|
if period.findtext("BaseURL"):
|
||||||
|
return "dash_clear" in period.findtext("BaseURL")
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def configure(self):
|
def configure(self):
|
||||||
self.session.headers.update(
|
self.session.headers.update(
|
||||||
@ -301,16 +304,14 @@ class DSCP(Service):
|
|||||||
"origin": "https://www.discoveryplus.com",
|
"origin": "https://www.discoveryplus.com",
|
||||||
"referer": "https://www.discoveryplus.com/",
|
"referer": "https://www.discoveryplus.com/",
|
||||||
"x-disco-client": "WEB:UNKNOWN:dplus_us:2.44.4",
|
"x-disco-client": "WEB:UNKNOWN:dplus_us:2.44.4",
|
||||||
"x-disco-params": "realm=go,siteLookupKey=dplus_us,bid=dplus,features=ar",
|
"x-disco-params": "realm=go,bid=dplus,hn=www.discoveryplus.com,hth=,features=ar",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
info = self.session.get(self.config["endpoints"]["info"]).json()
|
info = self.session.get(self.config["endpoints"]["info"]).json()
|
||||||
self.region = info["data"]["attributes"]["baseApiUrl"].split("-")[0].split("//")[1]
|
self.region = info["data"]["attributes"]["baseApiUrl"].split("-")[0].split("//")[1]
|
||||||
self.territory = info["data"]["attributes"]["mainTerritoryCode"]
|
|
||||||
|
|
||||||
site = self.session.get(self.config["endpoints"]["prod"].format(region=self.region))
|
user = self.session.get(self.config["endpoints"]["user"].format(region=self.region)).json()
|
||||||
if not site.ok:
|
self.territory = user["data"]["attributes"]["currentLocationTerritory"]
|
||||||
raise ConnectionError(site.json())
|
self.site_id = user["meta"]["site"]["id"]
|
||||||
|
|
||||||
self.site_id = site.json()["meta"]["site"]["id"]
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
endpoints:
|
endpoints:
|
||||||
info: https://global-prod.disco-api.com/bootstrapInfo
|
info: https://global-prod.disco-api.com/bootstrapInfo
|
||||||
|
user: https://{region}-prod-direct.discoveryplus.com/users/me
|
||||||
prod: "https://{region}-prod-direct.discoveryplus.com/cms/configs/web-prod"
|
prod: "https://{region}-prod-direct.discoveryplus.com/cms/configs/web-prod"
|
||||||
show: "https://{region}-prod-direct.discoveryplus.com/cms/routes/show/{title_id}?include=default&decorators=viewingHistory,isFavorite,playbackAllowed"
|
show: "https://{region}-prod-direct.discoveryplus.com/cms/routes/show/{title_id}?include=default&decorators=viewingHistory,isFavorite,playbackAllowed"
|
||||||
seasons: "https://{region}-prod-direct.discoveryplus.com/cms/collections/{content_id}?include=default&decorators=viewingHistory,isFavorite,playbackAllowed,contentAction,badges&{season}&{show_id}"
|
seasons: "https://{region}-prod-direct.discoveryplus.com/cms/collections/{content_id}?include=default&decorators=viewingHistory,isFavorite,playbackAllowed,contentAction,badges&{season}&{show_id}"
|
||||||
|
Loading…
Reference in New Issue
Block a user