Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 532334
Collapse All | Expand All

(-)a/src/livestreamer/plugins/twitch.py (-8 / +9 lines)
Lines 125-132 def time_to_offset(t): Link Here
125
125
126
126
127
class UsherService(object):
127
class UsherService(object):
128
    def _create_url(self, endpoint, asset, **extra_params):
128
    def _create_url(self, endpoint, **extra_params):
129
        url = "http://usher.twitch.tv/{0}/{1}".format(endpoint, asset)
129
        url = "http://usher.twitch.tv{0}".format(endpoint)
130
        params = {
130
        params = {
131
            "player": "twitchweb",
131
            "player": "twitchweb",
132
            "p": int(random() * 999999),
132
            "p": int(random() * 999999),
Lines 145-155 def _create_url(self, endpoint, asset, **extra_params): Link Here
145
145
146
        return req.url
146
        return req.url
147
147
148
    def select(self, channel, **extra_params):
148
    def channel(self, channel, **extra_params):
149
        return self._create_url("select", channel, **extra_params)
149
        return self._create_url("/api/channel/hls/{0}.m3u8".format(channel),
150
                                **extra_params)
150
151
151
    def vod(self, vod_id, **extra_params):
152
    def video(self, video_id, **extra_params):
152
        return self._create_url("vod", vod_id, **extra_params)
153
        return self._create_url("/vod/{0}".format(video_id), **extra_params)
153
154
154
155
155
class TwitchAPI(object):
156
class TwitchAPI(object):
Lines 417-425 def _get_hls_streams(self, type="live"): Link Here
417
        self._authenticate()
418
        self._authenticate()
418
        sig, token = self._access_token(type)
419
        sig, token = self._access_token(type)
419
        if type == "live":
420
        if type == "live":
420
            url = self.usher.select(self.channel, nauthsig=sig, nauth=token)
421
            url = self.usher.channel(self.channel, sig=sig, token=token)
421
        elif type == "video":
422
        elif type == "video":
422
            url = self.usher.vod(self.video_id, nauthsig=sig, nauth=token)
423
            url = self.usher.video(self.video_id, nauthsig=sig, nauth=token)
423
424
424
        try:
425
        try:
425
            streams = HLSStream.parse_variant_playlist(self.session, url)
426
            streams = HLSStream.parse_variant_playlist(self.session, url)

Return to bug 532334