Example #1
0
    def get(self, options):
        data = self.get_urldata()

        if self.exclude(options):
            yield ServiceError("Excluding video")
            return

        match = re.search("<link rel='shortlink' href='http://www.dplay.se/\?p=(\d+)", data)
        if not match:
            yield ServiceError("Can't find video id")
            return

        data = self.http.request("get", "http://geo.dplay.se/geo.js").text
        dataj = json.loads(data)
        geo = dataj["countryCode"]
        timestamp = (int(time.time())+3600)*1000
        cookie = {"dsc-geo": quote('{"countryCode":"%s","expiry":%s}' % (geo, timestamp))}
        data = self.http.request("get", "https://secure.dplay.se/secure/api/v2/user/authorization/stream/%s?stream_type=hds" % match.group(1), cookies=cookie)
        dataj = json.loads(data.text)
        if "hds" in dataj:
            streams = hdsparse(copy.copy(options), self.http.request("get", dataj["hds"], params={"hdcore": "3.8.0"}), dataj["hds"])
            if streams:
                for n in list(streams.keys()):
                    yield streams[n]
        data = self.http.request("get", "https://secure.dplay.se/secure/api/v2/user/authorization/stream/%s?stream_type=hls" % match.group(1), cookies=cookie)
        dataj = json.loads(data.text)
        if "hls" in dataj:
            streams = hlsparse(options, self.http.request("get", dataj["hls"]), dataj["hls"])
            if streams:
                for n in list(streams.keys()):
                    yield streams[n]
Example #2
0
    def get(self):
        data = self.get_urldata()
        premium = False
        parse = urlparse(self.url)
        domain = re.search(r"(dplay\.\w\w)", parse.netloc).group(1)

        match = re.search(r"<link rel='shortlink' href='[^']+/\?p=(\d+)", data)
        if not match:
            match = re.search(r'data-video-id="([^"]+)"', data)
            if not match:
                yield ServiceError("Can't find video id")
                return
        vid = match.group(1)
        data = self.http.request("get", "http://%s/api/v2/ajax/videos?video_id=%s" % (parse.netloc, vid)).text
        dataj = json.loads(data)
        if dataj["data"] is None:
            yield ServiceError("Cant find video. wrong url without video?")
            return
        if self.options.username and self.options.password:
            premium = self._login(self.options)
            if not premium:
                yield ServiceError("Wrong username or password")
                return

        what = self._playable(dataj, premium)
        if what == 1:
            yield ServiceError("Premium content")
            return
        if what == 2:
            yield ServiceError("DRM protected. Can't do anything")
            return

        if self.options.output_auto:
            directory = os.path.dirname(self.options.output)
            self.options.service = "dplay"
            name = self._autoname(dataj)
            if name is None:
                yield ServiceError("Cant find vid id for autonaming")
                return
            title = "%s-%s-%s" % (name, vid, self.options.service)
            if len(directory):
                self.options.output = os.path.join(directory, title)
            else:
                self.options.output = title

        if self.exclude():
            yield ServiceError("Excluding video")
            return

        subt = "subtitles_%s_srt" % self._country2lang()
        suburl = dataj["data"][0][subt]
        if len(suburl) > 0:
            yield subtitle(copy.copy(self.options), "raw", suburl)

        data = self.http.request("get", "http://geo.%s/geo.js" % domain).text
        dataj = json.loads(data)
        geo = dataj["countryCode"]
        timestamp = (int(time.time()) + 3600) * 1000
        cookie = {"dsc-geo": quote('{"countryCode":"%s","expiry":%s}' % (geo, timestamp))}
        if self.options.cookies:
            self.options.cookies.update(cookie)
        else:
            self.options.cookies = cookie
        data = self.http.request(
            "get",
            "https://secure.%s/secure/api/v2/user/authorization/stream/%s?stream_type=hds" % (domain, vid),
            cookies=self.options.cookies,
        )
        if data.status_code == 403 or data.status_code == 401:
            yield ServiceError("Geoblocked video")
            return
        dataj = json.loads(data.text)
        if "hds" in dataj:
            streams = hdsparse(
                copy.copy(self.options),
                self.http.request("get", dataj["hds"], params={"hdcore": "3.8.0"}),
                dataj["hds"],
            )
            if streams:
                for n in list(streams.keys()):
                    yield streams[n]
        data = self.http.request(
            "get",
            "https://secure.%s/secure/api/v2/user/authorization/stream/%s?stream_type=hls" % (domain, vid),
            cookies=self.options.cookies,
        )
        dataj = json.loads(data.text)
        if "hls" in dataj:
            streams = hlsparse(self.options, self.http.request("get", dataj["hls"]), dataj["hls"])
            if streams:
                for n in list(streams.keys()):
                    yield streams[n]
Example #3
0
    def get(self):
        data = self.get_urldata()
        premium = False
        parse = urlparse(self.url)
        domain = re.search(r"(dplay\.\w\w)", parse.netloc).group(1)

        match = re.search(r"<link rel='shortlink' href='[^']+/\?p=(\d+)", data)
        if not match:
            match = re.search(r'data-video-id="([^"]+)"', data)
            if not match:
                yield ServiceError("Can't find video id")
                return
        vid = match.group(1)
        data = self.http.request(
            "get", "http://%s/api/v2/ajax/videos?video_id=%s" %
            (parse.netloc, vid)).text
        dataj = json.loads(data)
        if dataj["data"] is None:
            yield ServiceError("Cant find video. wrong url without video?")
            return
        if self.options.username and self.options.password:
            premium = self._login(self.options)
            if not premium:
                yield ServiceError("Wrong username or password")
                return

        what = self._playable(dataj, premium)
        if what == 1:
            yield ServiceError("Premium content")
            return
        if what == 2:
            yield ServiceError("DRM protected. Can't do anything")
            return

        if self.options.output_auto:
            directory = os.path.dirname(self.options.output)
            self.options.service = "dplay"
            name = self._autoname(dataj)
            if name is None:
                yield ServiceError("Cant find vid id for autonaming")
                return
            title = "%s-%s-%s" % (name, vid, self.options.service)
            if len(directory):
                self.options.output = os.path.join(directory, title)
            else:
                self.options.output = title

        if self.exclude():
            yield ServiceError("Excluding video")
            return

        suburl = dataj["data"][0]["subtitles_sv_srt"]
        if len(suburl) > 0:
            yield subtitle(copy.copy(self.options), "raw", suburl)

        data = self.http.request("get", "http://geo.%s/geo.js" % domain).text
        dataj = json.loads(data)
        geo = dataj["countryCode"]
        timestamp = (int(time.time()) + 3600) * 1000
        cookie = {
            "dsc-geo":
            quote('{"countryCode":"%s","expiry":%s}' % (geo, timestamp))
        }
        if self.options.cookies:
            self.options.cookies.update(cookie)
        else:
            self.options.cookies = cookie
        data = self.http.request(
            "get",
            "https://secure.%s/secure/api/v2/user/authorization/stream/%s?stream_type=hds"
            % (domain, vid),
            cookies=self.options.cookies)
        if data.status_code == 403 or data.status_code == 401:
            yield ServiceError("Geoblocked video")
            return
        dataj = json.loads(data.text)
        if "hds" in dataj:
            streams = hdsparse(
                copy.copy(self.options),
                self.http.request("get",
                                  dataj["hds"],
                                  params={"hdcore": "3.8.0"}), dataj["hds"])
            if streams:
                for n in list(streams.keys()):
                    yield streams[n]
        data = self.http.request(
            "get",
            "https://secure.%s/secure/api/v2/user/authorization/stream/%s?stream_type=hls"
            % (domain, vid),
            cookies=self.options.cookies)
        dataj = json.loads(data.text)
        if "hls" in dataj:
            streams = hlsparse(self.options,
                               self.http.request("get", dataj["hls"]),
                               dataj["hls"])
            if streams:
                for n in list(streams.keys()):
                    yield streams[n]
Example #4
0
    def get(self, options):
        data = self.get_urldata()
        premium = False
        if self.exclude(options):
            yield ServiceError("Excluding video")
            return

        match = re.search("<link rel='shortlink' href='http://www.dplay.se/\?p=(\d+)", data)
        if not match:
            yield ServiceError("Can't find video id")
            return
        vid = match.group(1)
        data = self.http.request("get", "http://www.dplay.se/api/v2/ajax/videos?video_id=%s" % vid).text
        dataj = json.loads(data)

        if options.username and options.password:
            premium = self._login(options)
            if not premium:
                yield ServiceError("Wrong username or password")
                return

        what = self._playable(dataj, premium)
        if what == 1:
            yield ServiceError("Premium content")
            return
        if what == 2:
            yield ServiceError("DRM protected. Can't do anything")
            return

        if options.output_auto:
            directory = os.path.dirname(options.output)
            options.service = "dplay"
            name = self._autoname(dataj)
            if name is None:
                yield ServiceError("Cant find vid id for autonaming")
                return
            title = "%s-%s-%s" % (name, vid, options.service)
            if len(directory):
                options.output = os.path.join(directory, title)
            else:
                options.output = title
        suburl = dataj["data"][0]["subtitles_sv_srt"]
        if len(suburl) > 0:
            yield subtitle(copy.copy(options), "raw", suburl)

        if options.force_subtitle:
            return

        data = self.http.request("get", "http://geo.dplay.se/geo.js").text
        dataj = json.loads(data)
        geo = dataj["countryCode"]
        timestamp = (int(time.time())+3600)*1000
        cookie = {"dsc-geo": quote('{"countryCode":"%s","expiry":%s}' % (geo, timestamp))}
        if options.cookies:
            options.cookies.update(cookie)
        else:
            options.cookies = cookie
        data = self.http.request("get", "https://secure.dplay.se/secure/api/v2/user/authorization/stream/%s?stream_type=hds" % vid, cookies=options.cookies)
        dataj = json.loads(data.text)
        if "hds" in dataj:
            streams = hdsparse(copy.copy(options), self.http.request("get", dataj["hds"], params={"hdcore": "3.8.0"}), dataj["hds"])
            if streams:
                for n in list(streams.keys()):
                    yield streams[n]
        data = self.http.request("get", "https://secure.dplay.se/secure/api/v2/user/authorization/stream/%s?stream_type=hls" % vid, cookies=options.cookies)
        dataj = json.loads(data.text)
        if "hls" in dataj:
            streams = hlsparse(options, self.http.request("get", dataj["hls"]), dataj["hls"])
            if streams:
                for n in list(streams.keys()):
                    yield streams[n]
Example #5
0
    def get(self):
        parse = urlparse(self.url)
        match = re.search('window.server_path = ({.*});', self.get_urldata())
        if not match:
            yield ServiceError("Cant find api key")
            return

        janson = json.loads(match.group(1))
        clientid = janson["sdk"]["clientId"]
        clientapikey = janson["sdk"]["clientApiKey"]

        token = "https://global-api.svcs.eurosportplayer.com/token"
        header = {"authorization": "Bearer {}".format(clientapikey)}
        data = {"grant_type": "client_credentials", "latitude": 0, "longitude": 0, "platform": "browser", "token": str(uuid.uuid4())}
        res = self.http.post(token, headers=header, data=data)
        access_token = res.json()["access_token"]

        logindict = {"type": "email-password", "email": {"address": self.options.username}, "password": {"value": self.options.password}}

        res = self.http.post("https://eu-west-1-api.svcs.eurosportplayer.com/v2/user/identity", json=logindict,
                             headers={"authorization": access_token, "Accept": "application/vnd.identity-service+json; version=1.0"})
        if res.status_code > 400:
            yield ServiceError("Wrong username or password")
            return

        data = {"grant_type": "urn:mlbam:params:oauth:grant_type:token", "latitude": "0", "longitude": "0", "platform": "browser", "token": res.json()["code"]}
        header = {"authorization": "Bearer {}".format(clientapikey)}
        res = self.http.post("https://global-api.svcs.eurosportplayer.com/token", headers=header, data=data)
        refresh = res.json()["refresh_token"]

        data = {"grant_type": "refresh_token", "latitude": 0, "longitude": 0, "platform": "browser", "token": refresh}
        header = {"authorization": "Bearer {}".format(clientapikey)}
        res = self.http.post("https://global-api.svcs.eurosportplayer.com/token", headers=header, data=data)
        access_token = res.json()["access_token"]

        url = "https://bam-sdk-configs.mlbam.net/v0.1/{}/browser/v2.1/macosx/chrome/prod.json".format(clientid)
        res = self.http.get(url)
        janson = res.json()
        scenario = janson["media"]["playbackScenarios"]["unlimited"]

        query = {"preferredLanguages": ["sv", "en"], "mediaRights": ["GeoMediaRight"], "uiLang": "sv", "include_images": True}

        if parse.path[:5] == "/chan":
            pagetype = "channel"
            match = re.search('/([^/]+)$', parse.path)
            if not match:
                yield ServiceError("Cant find channel")
                return

            vid, = match.groups()
            query["pageType"] = pagetype
            query["channelCallsign"] = vid
            query["channelCallsigns"] = vid
            query["onAir"] = True

            self.options.live = True  # lets override to true

            url = "https://search-api.svcs.eurosportplayer.com/svc/search/v2/graphql/persisted/query/eurosport/web/Airings/onAir?variables={}".format(quote(json.dumps(query)))
            res = self.http.get(url, headers={"authorization": access_token})
            vid2 = res.json()["data"]["Airings"][0]["channel"]["id"]
            url = "https://global-api.svcs.eurosportplayer.com/channels/{}/scenarios/{}".format(vid2, scenario)
            res = self.http.get(url, headers={"authorization": access_token, "Accept": "application/vnd.media-service+json; version=1"})
            hls_url = res.json()["stream"]["slide"]
        else:
            pagetype = "event"
            match = re.search('/([^/]+)/([^/]+)$', parse.path)
            if not match:
                yield ServiceError("Cant fint event id")
                return

            query["title"], query["contentId"] = match.groups()
            query["pageType"] = pagetype

            url = "https://search-api.svcs.eurosportplayer.com/svc/search/v2/graphql/persisted/query/eurosport/Airings?variables={}".format(quote(json.dumps(query)))
            res = self.http.get(url, headers={"authorization": access_token})
            programid = res.json()["data"]["Airings"][0]["programId"]
            mediaid = res.json()["data"]["Airings"][0]["mediaId"]

            url = "https://global-api.svcs.eurosportplayer.com/programs/{}/media/{}/scenarios/{}".format(programid, mediaid, scenario)
            res = self.http.get(url, headers={"authorization": access_token, "Accept": "application/vnd.media-service+json; version=1"})
            hls_url = res.json()["stream"]["complete"]

        streams = hlsparse(self.options, self.http.request("get", hls_url), hls_url, authorization=access_token)
        if streams:
            for n in list(streams.keys()):
                yield streams[n]
Example #6
0
    def _get_hls_url(self, channel):
        access = self._get_access_token(channel)

        query = "token=%s&sig=%s" % (quote(access['token']), access['sig'])
        return "%s/%s.m3u8?%s" % (self.hls_base_url, channel, query)
Example #7
0
    def get(self):
        parse = urlparse(self.url)
        match = re.search('window.server_path = ({.*});', self.get_urldata())
        if not match:
            yield ServiceError("Cant find api key")
            return

        janson = json.loads(match.group(1))
        clientid = janson["sdk"]["clientId"]
        clientapikey = janson["sdk"]["clientApiKey"]

        token = "https://global-api.svcs.eurosportplayer.com/token"
        header = {"authorization": "Bearer {}".format(clientapikey)}
        data = {
            "grant_type": "client_credentials",
            "latitude": 0,
            "longitude": 0,
            "platform": "browser",
            "token": str(uuid.uuid4())
        }
        res = self.http.post(token, headers=header, data=data)
        access_token = res.json()["access_token"]

        logindict = {
            "type": "email-password",
            "email": {
                "address": self.options.username
            },
            "password": {
                "value": self.options.password
            }
        }

        res = self.http.post(
            "https://eu-west-1-api.svcs.eurosportplayer.com/v2/user/identity",
            json=logindict,
            headers={
                "authorization": access_token,
                "Accept": "application/vnd.identity-service+json; version=1.0"
            })
        if res.status_code > 400:
            yield ServiceError("Wrong username or password")
            return

        data = {
            "grant_type": "urn:mlbam:params:oauth:grant_type:token",
            "latitude": "0",
            "longitude": "0",
            "platform": "browser",
            "token": res.json()["code"]
        }
        header = {"authorization": "Bearer {}".format(clientapikey)}
        res = self.http.post(
            "https://global-api.svcs.eurosportplayer.com/token",
            headers=header,
            data=data)
        refresh = res.json()["refresh_token"]

        data = {
            "grant_type": "refresh_token",
            "latitude": 0,
            "longitude": 0,
            "platform": "browser",
            "token": refresh
        }
        header = {"authorization": "Bearer {}".format(clientapikey)}
        res = self.http.post(
            "https://global-api.svcs.eurosportplayer.com/token",
            headers=header,
            data=data)
        access_token = res.json()["access_token"]

        url = "https://bam-sdk-configs.mlbam.net/v0.1/{}/browser/v2.1/macosx/chrome/prod.json".format(
            clientid)
        res = self.http.get(url)
        janson = res.json()
        scenario = janson["media"]["playbackScenarios"]["unlimited"]

        query = {
            "preferredLanguages": ["sv", "en"],
            "mediaRights": ["GeoMediaRight"],
            "uiLang": "sv",
            "include_images": True
        }

        if parse.path[:5] == "/chan":
            pagetype = "channel"
            match = re.search('/([^/]+)$', parse.path)
            if not match:
                yield ServiceError("Cant find channel")
                return

            vid, = match.groups()
            query["pageType"] = pagetype
            query["channelCallsign"] = vid
            query["channelCallsigns"] = vid
            query["onAir"] = True

            self.options.live = True  # lets override to true

            url = "https://search-api.svcs.eurosportplayer.com/svc/search/v2/graphql/persisted/query/eurosport/web/Airings/onAir?variables={}".format(
                quote(json.dumps(query)))
            res = self.http.get(url, headers={"authorization": access_token})
            vid2 = res.json()["data"]["Airings"][0]["channel"]["id"]
            url = "https://global-api.svcs.eurosportplayer.com/channels/{}/scenarios/{}".format(
                vid2, scenario)
            res = self.http.get(
                url,
                headers={
                    "authorization": access_token,
                    "Accept": "application/vnd.media-service+json; version=1"
                })
            hls_url = res.json()["stream"]["slide"]
        else:
            pagetype = "event"
            match = re.search('/([^/]+)/([^/]+)$', parse.path)
            if not match:
                yield ServiceError("Cant fint event id")
                return

            query["title"], query["contentId"] = match.groups()
            query["pageType"] = pagetype

            url = "https://search-api.svcs.eurosportplayer.com/svc/search/v2/graphql/persisted/query/eurosport/Airings?variables={}".format(
                quote(json.dumps(query)))
            res = self.http.get(url, headers={"authorization": access_token})
            programid = res.json()["data"]["Airings"][0]["programId"]
            mediaid = res.json()["data"]["Airings"][0]["mediaId"]

            url = "https://global-api.svcs.eurosportplayer.com/programs/{}/media/{}/scenarios/{}".format(
                programid, mediaid, scenario)
            res = self.http.get(
                url,
                headers={
                    "authorization": access_token,
                    "Accept": "application/vnd.media-service+json; version=1"
                })
            hls_url = res.json()["stream"]["complete"]

        streams = hlsparse(self.options,
                           self.http.request("get", hls_url),
                           hls_url,
                           authorization=access_token)
        if streams:
            for n in list(streams.keys()):
                yield streams[n]
Example #8
0
    def _get_hls_url(self, channel):
        access = self._get_access_token(channel)

        query = "token=%s&sig=%s" % (quote(access['token']), access['sig'])
        return "%s/%s.m3u8?%s" % (self.hls_base_url, channel, query)