Example #1
0
    def _get_live_streams(self, player):
        mappers = []
        swf_url = SWF_URL
        for playlist in player.get("playlist", []):
            bitrates = playlist.get("bitrates")
            provider = playlist.get("connectionProvider")
            rtmp = None

            if bitrates:
                rtmp = playlist.get("netConnectionUrl")
            elif provider and provider in player["plugins"]:
                provider = player["plugins"][provider]
                swf_name = provider["url"]
                swf_url = SWF_BASE + swf_name
                rtmp = provider["netConnectionUrl"]
                bitrates = player["clip"]["bitrates"]
            else:
                continue

            mapper = StreamMapper(cmp=lambda provider, bitrate: bitrate[
                "provider"].startswith(provider))
            mapper.map("hls", self._create_hls_streams)
            mapper.map("rtmp", self._create_rtmp_stream, rtmp, swf_url)
            mappers.append(mapper(bitrates))

        return chain.from_iterable(mappers)
Example #2
0
    def _get_live_streams(self, player):
        mappers = []
        swf_url = SWF_URL
        for playlist in player.get("playlist", []):
            bitrates = playlist.get("bitrates")
            provider = playlist.get("connectionProvider")
            rtmp = None

            if bitrates:
                rtmp = playlist.get("netConnectionUrl")
            elif provider and provider in player["plugins"]:
                provider = player["plugins"][provider]
                swf_name = provider["url"]
                swf_url = SWF_BASE + swf_name
                rtmp = provider["netConnectionUrl"]
                bitrates = player["clip"]["bitrates"]
            else:
                continue

            mapper = StreamMapper(
                cmp=lambda provider, bitrate: bitrate["provider"].startswith(provider)
            )
            mapper.map("hls", self._create_hls_streams)
            mapper.map("rtmp", self._create_rtmp_stream, rtmp, swf_url)
            mappers.append(mapper(bitrates))

        return chain.from_iterable(mappers)
Example #3
0
    def _get_video_streams(self, player):
        base_url = player["clip"]["baseUrl"] or VOD_BASE_URL
        mapper = StreamMapper(cmp=lambda ext, bitrate: urlparse(bitrate["url"])
                              .path.endswith(ext))
        mapper.map(".m3u8", self._create_video_stream, HLSStream, base_url)
        mapper.map(".mp4", self._create_video_stream, HTTPStream, base_url)
        mapper.map(".flv", self._create_video_stream, HTTPStream, base_url)

        return mapper(player["clip"]["bitrates"])
Example #4
0
    def _get_streams(self):
        res = http.get(self.url, params=dict(output="json"))
        videos = http.json(res, schema=_video_schema)

        mapper = StreamMapper(cmp=lambda type, video: video["playerType"] == type)
        mapper.map("ios", self._create_streams, "HLS", HLSStream.parse_variant_playlist)
        mapper.map("flash", self._create_streams, "HDS", HDSStream.parse_manifest)

        return mapper(videos)
Example #5
0
    def _get_video_streams(self, player):
        base_url = player["clip"]["baseUrl"] or VOD_BASE_URL
        mapper = StreamMapper(
            cmp=lambda ext, bitrate: urlparse(bitrate["url"]).path.endswith(ext)
        )
        mapper.map(".m3u8", self._create_video_stream, HLSStream, base_url)
        mapper.map(".mp4", self._create_video_stream, HTTPStream, base_url)
        mapper.map(".flv", self._create_video_stream, HTTPStream, base_url)

        return mapper(player["clip"]["bitrates"])
Example #6
0
    def _get_streams(self):
        channel = _url_re.match(self.url).group("channel")
        urls = http.get(CHANNEL_URL, params=dict(n=channel), schema=_schema)
        if not urls:
            return

        mapper = StreamMapper(cmp=lambda scheme, url: url.startswith(scheme))
        mapper.map("http", self._create_hls_streams)
        mapper.map("rtmp", self._create_rtmp_stream)

        return mapper(urls)
Example #7
0
    def _get_streams(self):
        res = http.get(self.url, params=dict(output="json"))
        videos = http.json(res, schema=_video_schema)

        mapper = StreamMapper(
            cmp=lambda type, video: video["playerType"] == type)
        mapper.map("ios", self._create_streams, "HLS",
                   HLSStream.parse_variant_playlist)
        mapper.map("flash", self._create_streams, "HDS",
                   HDSStream.parse_manifest)

        return mapper(videos)
Example #8
0
    def _get_streams(self):
        res = http.get(self.url)
        channel_id = self._find_channel_id(res.text)
        if not channel_id:
            return

        res = http.get(PLAYER_EMBED_URL.format(channel_id))
        stream_id = self._find_stream_id(res.text)
        if not stream_id:
            return

        res = http.get(STREAM_API_URL.format(stream_id),
                       params=dict(format="all"))
        items = http.json(res, schema=_stream_schema)

        mapper = StreamMapper(
            cmp=lambda type, stream: stream["format"] == type
        )
        mapper.map("hls", self._create_streams, HLSStream.parse_variant_playlist)
        mapper.map("hds", self._create_streams, HDSStream.parse_manifest)

        return mapper(items)
Example #9
0
    def _extract_streams(self, stream_id):
        res = http.get(STREAM_API_URL.format(stream_id), raise_for_status=False)
        stream_info = http.json(res, schema=_stream_schema)

        mapper = StreamMapper(lambda pattern, video: re.search(pattern, video[1]))
        mapper.map(r"\.m3u8$", self._create_dynamic_streams, "HLS", HLSStream.parse_variant_playlist)
        mapper.map(r"\.f4m$", self._create_dynamic_streams, "HDS", HDSStream.parse_manifest)
        mapper.map(r"^rtmp://", self._create_rtmp_stream)

        return mapper(stream_info.items())
Example #10
0
    def _extract_streams(self, stream_id):
        res = http.get(STREAM_API_URL.format(stream_id), raise_for_status=False)
        stream_info = http.json(res, schema=_stream_schema)

        mapper = StreamMapper(lambda pattern, video: re.search(pattern, video[1]))
        mapper.map(r"\.m3u8$", self._create_dynamic_streams, "HLS", HLSStream.parse_variant_playlist)
        mapper.map(r"\.f4m$", self._create_dynamic_streams, "HDS", HDSStream.parse_manifest)
        mapper.map(r"^rtmp://", self._create_rtmp_stream)

        return mapper(stream_info.items())