diff --git a/services/DSCP/__init__.py b/services/DSCP/__init__.py index 6c9c498..8549f34 100644 --- a/services/DSCP/__init__.py +++ b/services/DSCP/__init__.py @@ -292,8 +292,11 @@ class DSCP(Service): # Service specific functions - def period_filter(self, period): - return "dash_clear" in period.findtext("BaseURL") + def period_filter(self, period: Any) -> bool: + if period.findtext("BaseURL"): + return "dash_clear" in period.findtext("BaseURL") + + return False def configure(self): self.session.headers.update( @@ -301,16 +304,14 @@ class DSCP(Service): "origin": "https://www.discoveryplus.com", "referer": "https://www.discoveryplus.com/", "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() 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)) - if not site.ok: - raise ConnectionError(site.json()) + user = self.session.get(self.config["endpoints"]["user"].format(region=self.region)).json() + self.territory = user["data"]["attributes"]["currentLocationTerritory"] + self.site_id = user["meta"]["site"]["id"] - self.site_id = site.json()["meta"]["site"]["id"] diff --git a/services/DSCP/config.yaml b/services/DSCP/config.yaml index f900904..7325431 100644 --- a/services/DSCP/config.yaml +++ b/services/DSCP/config.yaml @@ -1,5 +1,6 @@ endpoints: 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" 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}"