示例#1
0
_embed_url_re = re.compile(
    '<meta itemprop="embedURL" content="http://www.viagame.com/embed/video/([^"]+)"'
)
_store_data_re = re.compile("window.fluxData\s*=\s*JSON.parse\(\"(.+)\"\);")
_url_re = re.compile("http(s)?://(www\.)?viagame.com/channels/.+")

_store_schema = validate.Schema(
    {
        "initialStoresData": [{
            "instanceName": validate.text,
            "storeName": validate.text,
            "initialData": validate.any(dict, list)
        }]
    },
    validate.get("initialStoresData")
)
_match_store_schema = validate.Schema(
    {
        "match": {
            "id": validate.text,
            "type": validate.text,
            "videos": [{
                "id": validate.text,
                "play_id": validate.text,
            }]
        }
    },
    validate.get("match")
)
示例#2
0
        "url":
        validate.all(validate.url(scheme="http"))
    }]),
    validate.optional("hlsvp"):
    validate.text,
    validate.optional("live_playback"):
    validate.transform(bool),
    "status":
    validate.text
})
_search_schema = validate.Schema(
    {"items": [{
        "id": {
            "videoId": validate.text
        }
    }]}, validate.get("items"))

_channelid_re = re.compile('meta itemprop="channelId" content="([^"]+)"')
_url_re = re.compile(
    """
    http(s)?://(\w+.)?
    (youtube.com|youtu.be)
    (?:
        /(watch.+v=|embed/|v/)
        (?P<video_id>[^/?&#]+)
    )?
    (?:
        /(user/)?(?P<user>[^/?]+)
    ?)?
""", re.VERBOSE)
示例#3
0
    )?
""", re.VERBOSE)
_channel_id_re = re.compile("\"cid\":(\d+)")

HLS_PLAYLIST_URL = (
    "http://iphone-streaming.ustream.tv"
    "/uhls/{0}/streams/live/iphone/playlist.m3u8"
)
RECORDED_URL = "http://tcdn.ustream.tv/video/{0}"
RTMP_URL = "rtmp://r{0}.1.{1}.channel.live.ums.ustream.tv:80/ustream"
SWF_URL = "http://static-cdn1.ustream.tv/swf/live/viewer.rsl:505.swf"

_module_info_schema = validate.Schema(
    list,
    validate.length(1),
    validate.get(0),
    dict
)
_recorded_schema = validate.Schema({
    validate.optional("stream"): [{
        "name": validate.text,
        "streams": [{
            "streamName": validate.text,
            "bitrate": float,
        }],
        validate.optional("url"): validate.text,
    }]
})
_channel_schema = validate.Schema({
    validate.optional("stream"):
        validate.any([{
示例#4
0
_stream_id_re = re.compile(
    r"<meta content='.+/([\w_-]+).+' property='og:video'>")
_url_re = re.compile("http(s)?://(\w+\.)?(majorleaguegaming\.com|mlg\.tv)")

_config_schema = validate.Schema({"media": [{"channel": validate.text}]})

_stream_schema = validate.Schema(
    {
        "data": {
            "items":
            validate.all([{
                "format": validate.text,
                "url": validate.text
            }], validate.filter(lambda s: s["format"] in STREAM_TYPES))
        }
    }, validate.get("data", {}), validate.get("items", []))


class MLGTV(Plugin):
    @classmethod
    def can_handle_url(self, url):
        return _url_re.match(url)

    def _find_channel_id(self, text):
        match = _stream_id_re.search(text)
        if match:
            return match.group(1)

    def _get_stream_id(self, channel_id):
        res = http.get(CONFIG_API_URL, params=dict(id=channel_id))
        config = http.json(res, schema=_config_schema)
示例#5
0
_live_schema = validate.Schema({
    validate.any("primary", "secondary"): {
        validate.text: {
            "rtmp_flash": {
                validate.text: {
                    "name": validate.text,
                    "server": validate.url(scheme="rtmp")
                }
            }
        }
    }
})
_schema = validate.Schema(
    validate.union({
        "lang":
        validate.all(validate.transform(_lang_re.search), validate.get(1)),
        "live":
        validate.all(validate.transform(_live_check_re.search),
                     validate.transform(bool)),
        "videos":
        validate.all(validate.transform(_video_re.findall),
                     [(validate.url(scheme="http"), validate.text)])
    }))


class Euronews(Plugin):
    @classmethod
    def can_handle_url(self, url):
        return _url_re.match(url)

    def _get_live_streams(self, lang):
示例#6
0
            }]
        ),
        validate.optional("hlsvp"): validate.text,
        validate.optional("live_playback"): validate.transform(bool),
        "status": validate.text
    }
)
_search_schema = validate.Schema(
    {
        "items": [{
            "id": {
                "videoId": validate.text
            }
        }]
    },
    validate.get("items")
)

_channelid_re = re.compile('meta itemprop="channelId" content="([^"]+)"')
_url_re = re.compile("""
    http(s)?://(\w+\.)?youtube.com
    (?:
        (?:
            /(watch.+v=|embed/|v/)
            (?P<video_id>[0-9A-z_-]{11})
        )
        |
        (?:
            /user/(?P<user>[^/?]+)
        )
    )
 def test_union(self):
     assert validate(union((get("foo"), get("bar"))),
                     {"foo": "alpha", "bar": "beta"}) == ("alpha", "beta")
示例#8
0
import re

from livestreamer.plugin import Plugin
from livestreamer.plugin.api import http, validate
from livestreamer.stream import HLSStream

STREAM_INFO_URL = "https://api.periscope.tv/api/v2/getAccessPublic"

STATUS_GONE = 410
STATUS_UNAVAILABLE = (STATUS_GONE, )

_url_re = re.compile(r"http(s)?://(www\.)?periscope.tv/w/(?P<token>[\w\-\=]+)")
_stream_schema = validate.Schema({"hls_url": validate.url(scheme="http")},
                                 validate.get("hls_url"))


class Periscope(Plugin):
    @classmethod
    def can_handle_url(cls, url):
        return _url_re.match(url)

    def _get_streams(self):
        match = _url_re.match(self.url)
        res = http.get(STREAM_INFO_URL,
                       params=match.groupdict(),
                       acceptable_status=STATUS_UNAVAILABLE)

        if res.status_code in STATUS_UNAVAILABLE:
            return

        playlist_url = http.json(res, schema=_stream_schema)
示例#9
0
文件: mips.py 项目: uguer30/Project
from livestreamer.plugin.api.utils import parse_query
from livestreamer.stream import RTMPStream

BALANCER_URL = "http://www.mips.tv:1935/loadbalancer"
PLAYER_URL = "http://mips.tv/embedplayer/{0}/1/500/400"
SWF_URL = "http://mips.tv/content/scripts/eplayer.swf"

_url_re = re.compile("http(s)?://(\w+.)?mips.tv/(?P<channel>[^/&?]+)")
_flashvars_re = re.compile("'FlashVars', '([^']+)'")
_rtmp_re = re.compile("redirect=(.+)")

_schema = validate.Schema(
    validate.transform(_flashvars_re.search),
    validate.any(
        None,
        validate.all(validate.get(1), validate.transform(parse_query), {
            "id": validate.transform(int),
            validate.optional("s"): validate.text
        })))
_rtmp_schema = validate.Schema(
    validate.transform(_rtmp_re.search),
    validate.get(1),
)


class Mips(Plugin):
    @classmethod
    def can_handle_url(self, url):
        return _url_re.match(url)

    def _get_streams(self):
示例#10
0
文件: mlgtv.py 项目: uguer30/Project
STREAM_TYPES = {
    "hls": HLSStream.parse_variant_playlist,
    "hds": HDSStream.parse_manifest
}

_stream_id_re = re.compile(r"<meta content='.+/([\w_-]+).+' property='og:video'>")
_player_config_re = re.compile(r"var playerConfig = (.+);")
_url_re = re.compile("http(s)?://(\w+\.)?(majorleaguegaming\.com|mlg\.tv)")

_player_config_schema = validate.Schema(
    {
        "media": {
            "stream_name": validate.text
        }
    },
    validate.get("media", {}),
    validate.get("stream_name")
)
_stream_schema = validate.Schema(
    {
        "data": {
            "items": validate.all(
                [{
                    "format": validate.text,
                    "url": validate.text
                }],
                validate.filter(lambda s: s["format"] in STREAM_TYPES)
            )
        }
    },
    validate.get("data", {}),
示例#11
0
_url_re = re.compile("http(s)?://(\w+\.)?streamup.com/(?P<channel>[^/?]+)")
_flashvars_re = re.compile("flashvars\.(?P<var>\w+)\s?=\s?'(?P<value>[^']+)';")
_swf_url_re = re.compile("swfobject.embedSWF\(\s*\"(?P<player_url>[^\"]+)\",")

_schema = validate.Schema(
    validate.union({
        "vars":
        validate.all(validate.transform(_flashvars_re.findall),
                     validate.transform(dict), {
                         "owner": validate.text,
                         validate.optional("token"): validate.text
                     }),
        "swf":
        validate.all(validate.transform(_swf_url_re.search),
                     validate.get("player_url"), validate.endswith(".swf"))
    }))

_channel_details_schema = validate.Schema(
    {"channel": {
        "live": bool,
        "slug": validate.text
    }})


class StreamupCom(Plugin):
    @classmethod
    def can_handle_url(cls, url):
        return _url_re.match(url)

    def _get_streams(self):
示例#12
0
_schema = validate.Schema(
    validate.transform(_js_var_re.findall),
    validate.transform(dict),
    {
        "a": validate.transform(int),
        "b": validate.transform(int),
        "c": validate.transform(int),
        "d": validate.transform(int),
        "f": validate.transform(int),
        "v_part": validate.text,
    },
    validate.union({
        "server_ip": validate.transform(_parse_server_ip),
        "path": validate.all(
            validate.get("v_part"),
            validate.transform(_rtmp_re.findall),
            validate.get(0)
        )
    })
)


class LetOnTV(Plugin):
    @classmethod
    def can_handle_url(self, url):
        return _url_re.match(url)

    def _get_streams(self):
        match = _url_re.match(self.url)
        info = http.get(PLAYER_URL, params=match.groupdict(), schema=_schema)
示例#13
0
from livestreamer.plugin.api import http, validate
from livestreamer.stream import RTMPStream

_url_re = re.compile("http(s)?://(\w+\.)?ilive.to/")
_rtmp_re = re.compile("""
    \$.getJSON\("(?P<token_url>[^"]+)".*
    flashplayer:\s+"(?P<swf_url>[^"]+)".*
    streamer:\s+"(?P<rtmp_url>[^"]+)".*
    file:\s+"(?P<rtmp_playpath>[^"]+)\.flv"
""", re.VERBOSE | re.DOTALL)

_token_schema = validate.Schema(
    {
        "token": validate.text
    },
    validate.get("token")
)
_schema = validate.Schema(
    validate.transform(_rtmp_re.search),
    validate.any(
        None,
        validate.all(
            validate.transform(methodcaller("groupdict")),
            {
                "rtmp_playpath": validate.text,
                "rtmp_url": validate.all(
                    validate.transform(methodcaller("replace", "\\/", "/")),
                    validate.url(scheme="rtmp"),
                ),
                "swf_url": validate.url(scheme="http"),
                "token_url": validate.url(scheme="http")
示例#14
0
_url_re = re.compile(
    """
    http(s)?://(\w+\.)?gaminglive\.tv
    /(?P<type>channels|videos)/(?P<name>[^/]+)
""", re.VERBOSE)
_quality_re = re.compile("[^/]+-(?P<quality>[^/]+)")

_channel_schema = validate.Schema(
    {
        validate.optional("state"): {
            "stream": {
                "qualities": [validate.text],
                "rootUrl": validate.url(scheme="rtmp")
            }
        }
    }, validate.get("state"))

_vod_schema = validate.Schema(
    {
        "name": validate.text,
        "channel_slug": validate.text,
        "title": validate.text,
        "created_at": validate.transform(int)
    }, )


class GamingLive(Plugin):
    @classmethod
    def can_handle_url(self, url):
        return _url_re.match(url)
 def test_get(self):
     assert validate(get("key"), {"key": "value"}) == "value"
     assert validate(get("invalidkey", "default"), {"key": "value"}) == "default"
from livestreamer.stream import (
    HTTPStream, HLSStream, FLVPlaylist, extract_flv_header_tags
)

from livestreamer.plugin.api import http_session
http = http_session.HTTPSession()



_access_token_schema = validate.Schema(
    {
        "token": validate.text,
        "sig": validate.text
    },
    validate.union((
        validate.get("sig"),
        validate.get("token")
    ))
)


class UsherService(object):
    def _create_url(self, endpoint, **extra_params):
        url = "http://usher.twitch.tv{0}".format(endpoint)
        params = {
            "player": "twitchweb",
            "p": int(random() * 999999),
            "type": "any",
            "allow_source": "true",
            "allow_audio_only": "true",
        }
 def test_get_re(self):
     m = re.match("(\d+)p", "720p")
     assert validate(get(1), m) == "720"
示例#18
0
from livestreamer.plugin import Plugin
from livestreamer.plugin.api import http, validate
from livestreamer.stream import HTTPStream, RTMPStream

from livestreamer.plugin.api.support_plugin import common_jwplayer as jwplayer

BASE_VOD_URL = "https://www.connectcast.tv"
SWF_URL = "https://www.connectcast.tv/jwplayer/jwplayer.flash.swf"

_url_re = re.compile("http(s)?://(\w+\.)?connectcast.tv/")

_smil_schema = validate.Schema(
    validate.union({
        "base":
        validate.all(validate.xml_find("head/meta"), validate.get("base"),
                     validate.url(scheme="rtmp")),
        "videos":
        validate.all(validate.xml_findall("body/video"), [validate.get("src")])
    }))


class ConnectCast(Plugin):
    @classmethod
    def can_handle_url(self, url):
        return _url_re.match(url)

    def _get_smil_streams(self, url):
        res = http.get(url, verify=False)
        smil = http.xml(res, schema=_smil_schema)
示例#19
0
import re

from itertools import chain

from livestreamer.compat import urlparse
from livestreamer.plugin import Plugin
from livestreamer.plugin.api import http, validate
from livestreamer.stream import HLSStream, HTTPStream, RTMPStream

SWF_URL = "http://www.arte.tv/player/v2/jwplayer6/mediaplayer.6.6.swf"

_url_re = re.compile("http(s)?://(\w+\.)?arte.tv/")
_json_re = re.compile('arte_vp_(?:live-)?url="([^"]+)"')

_schema = validate.Schema(
    validate.transform(_json_re.search), validate.any(None, validate.all(validate.get(1), validate.url(scheme="http")))
)
_video_schema = validate.Schema(
    {
        "videoJsonPlayer": {
            "VSR": validate.any(
                [],
                {
                    validate.text: {
                        "height": int,
                        "mediaType": validate.text,
                        "url": validate.text,
                        validate.optional("streamer"): validate.text,
                    }
                },
            ),
_url_re = re.compile(
    "http(s)?://(\w+\.)?streamingvideoprovider.co.uk/(?P<channel>[^/&?]+)"
)
_hls_re = re.compile("'(http://.+\.m3u8)'")

_rtmp_schema = validate.Schema(
    validate.xml_findtext("./info/url"),
    validate.url(scheme="rtmp")
)
_hls_schema = validate.Schema(
    validate.transform(_hls_re.search),
    validate.any(
        None,
        validate.all(
            validate.get(1),
            validate.url(
                scheme="http",
                path=validate.endswith("m3u8")
            )
        )
    )
)


class Streamingvideoprovider(Plugin):
    @classmethod
    def can_handle_url(self, url):
        return _url_re.match(url)

    def _get_hls_stream(self, channel_name):
示例#21
0
            "layerList": validate.all(
                [{
                    "name": validate.text,
                    validate.optional("param"): dict
                }],
                validate.filter(lambda l: l["name"] in ("video", "reporting"))
            )
        }]
    }]
}])
_media_schema = validate.Schema(
    validate.any(
        _media_inner_schema,
        validate.all(
            {"sequence": _media_inner_schema},
            validate.get("sequence")
        )
    )
)
_vod_playlist_schema = validate.Schema({
    "duration": float,
    "fragments": [[int, float]],
    "template": validate.text
})
_vod_manifest_schema = validate.Schema({
    "alternates": [{
        "height": int,
        "template": validate.text,
        validate.optional("failover"): [validate.text]
    }]
})
示例#22
0
    /(?P<channel>[^/]+)
    (?:
        /(?P<media_id>[^/]+)
    )?
""", re.VERBOSE)

_live_schema = validate.Schema(
    {
        "livestream": [{
            "media_is_live":
            validate.all(validate.text, validate.transform(int),
                         validate.transform(bool)),
            "media_id":
            validate.text
        }],
    }, validate.get("livestream"), validate.length(1), validate.get(0))
_player_schema = validate.Schema({
    "clip": {
        "baseUrl":
        validate.any(None, validate.text),
        "bitrates":
        validate.all(
            validate.filter(lambda b: b.get("url") and b.get("label")),
            [{
                "label": validate.text,
                "url": validate.text,
            }],
        )
    },
    validate.optional("playlist"): [{
        validate.optional("connectionProvider"):
示例#23
0
            }, None)
    },
    validate.optional("viewerPlusSwfUrl"):
    validate.url(scheme="http"),
    validate.optional("hdPlayerSwfUrl"):
    validate.text
})
_smil_schema = validate.Schema(
    validate.union({
        "http_base":
        validate.all(
            validate.xml_find("{http://www.w3.org/2001/SMIL20/Language}head/"
                              "{http://www.w3.org/2001/SMIL20/Language}meta"
                              "[@name='httpBase']"),
            validate.xml_element(attrib={"content": validate.text}),
            validate.get("content")),
        "videos":
        validate.all(
            validate.xml_findall(
                "{http://www.w3.org/2001/SMIL20/Language}body/"
                "{http://www.w3.org/2001/SMIL20/Language}switch/"
                "{http://www.w3.org/2001/SMIL20/Language}video"),
            [
                validate.all(
                    validate.xml_element(
                        attrib={
                            "src":
                            validate.text,
                            "system-bitrate":
                            validate.all(validate.text, validate.transform(
                                int))
示例#24
0
    \.
    (?:
        dk|ee|lt|lv|no|se|com
    )
    /.+/
    (?P<stream_id>\d+)
""", re.VERBOSE)

_stream_schema = validate.Schema(
    {
        "streams": validate.all(
            {validate.text: validate.any(validate.text, int, None)},
            validate.filter(lambda k, v: isinstance(v, validate.text))
        )
    },
    validate.get("streams")
)


class Viasat(Plugin):
    @classmethod
    def can_handle_url(cls, url):
        return _url_re.match(url)

    def _get_swf_url(self):
        res = http.get(self.url)
        match = _swf_url_re.search(res.text)
        if not match:
            raise PluginError("Unable to find SWF URL in the HTML")

        return match.group(1)
示例#25
0
        "name":
        validate.text,
        validate.optional("sequenceList"): [{
            "layerList":
            validate.all([{
                "name": validate.text,
                validate.optional("param"): dict
            }], validate.filter(lambda l: l["name"] in ("video", "reporting")))
        }]
    }]
}])
_media_schema = validate.Schema(
    validate.any(
        _media_inner_schema,
        validate.all({"sequence": _media_inner_schema},
                     validate.get("sequence"))))
_vod_playlist_schema = validate.Schema({
    "duration": float,
    "fragments": [[int, float]],
    "template": validate.text
})
_vod_manifest_schema = validate.Schema({
    "alternates": [{
        "height": int,
        "template": validate.text,
        validate.optional("failover"): [validate.text]
    }]
})


class DailyMotion(Plugin):
示例#26
0
    )
    \.
    (?:
        dk|ee|lt|lv|no|se|com
    )
    (/.+?/|/embed\?id=)
    (?P<stream_id>\d+)
""", re.VERBOSE)

_stream_schema = validate.Schema(
    {
        "streams":
        validate.all(
            {validate.text: validate.any(validate.text, int, None)},
            validate.filter(lambda k, v: isinstance(v, validate.text)))
    }, validate.get("streams"))


class Viasat(Plugin):
    @classmethod
    def can_handle_url(cls, url):
        return _url_re.match(url)

    def _get_swf_url(self):
        res = http.get(self.url)
        match = _swf_url_re.search(res.text)
        if not match:
            raise PluginError("Unable to find SWF URL in the HTML")

        return match.group(1)
示例#27
0
    http(s)?://(\w+\.)?
    (?P<domain>vaughnlive|breakers|instagib|vapers).tv
    /(?P<channel>[^/&?]+)
""", re.VERBOSE)
_channel_not_found_re = re.compile("<title>Channel Not Found")


def decode_token(token):
    return token.replace("0m0", "")


_schema = validate.Schema(
    validate.transform(lambda s: s.split(";:mvnkey%")), validate.length(2),
    validate.union({
        "server":
        validate.all(validate.get(0), validate.text),
        "token":
        validate.all(validate.get(1), validate.text,
                     validate.transform(decode_token))
    }))


class VaughnLive(Plugin):
    @classmethod
    def can_handle_url(cls, url):
        return _url_re.match(url)

    def _get_streams(self):
        res = http.get(self.url)
        if _channel_not_found_re.search(res.text):
            return
示例#28
0
    """
    http(s)?://(www\.)?douyutv.com
    /(?P<channel>[^/]+)
""", re.VERBOSE)

_room_schema = validate.Schema(
    {
        "data":
        validate.any(
            None, {
                "show_status": validate.all(validate.text,
                                            validate.transform(int)),
                "rtmp_url": validate.text,
                "rtmp_live": validate.text
            })
    }, validate.get("data"))


class Douyutv(Plugin):
    @classmethod
    def can_handle_url(self, url):
        return _url_re.match(url)

    def _get_streams(self):
        match = _url_re.match(self.url)
        channel = match.group("channel")

        res = http.get(API_URL.format(channel))
        room = http.json(res, schema=_room_schema)
        if not room:
            return
示例#29
0
    (?:
        (?P<hours>\d+)h
    )?
    (?:
        (?P<minutes>\d+)m
    )?
    (?:
        (?P<seconds>\d+)s
    )?
""", re.VERBOSE)

_access_token_schema = validate.Schema(
    {
        "token": validate.text,
        "sig": validate.text
    }, validate.union((validate.get("sig"), validate.get("token"))))
_token_schema = validate.Schema(
    {
        "chansub": {
            "restricted_bitrates":
            validate.all([validate.text],
                         validate.filter(lambda n: not re.match(
                             r"(.+_)?archives|live|chunked", n)))
        }
    }, validate.get("chansub"))
_user_schema = validate.Schema(
    {validate.optional("display_name"): validate.text},
    validate.get("display_name"))
_video_schema = validate.Schema({
    "chunks": {
        validate.text: [{
示例#30
0
from livestreamer.plugin import Plugin
from livestreamer.plugin.api import http, validate
from livestreamer.stream import HTTPStream, RTMPStream

from livestreamer.plugin.api.support_plugin import common_jwplayer as jwplayer

BASE_VOD_URL = "https://www.connectcast.tv"
SWF_URL = "https://www.connectcast.tv/jwplayer/jwplayer.flash.swf"

_url_re = re.compile("http(s)?://(\w+\.)?connectcast.tv/")

_smil_schema = validate.Schema(
    validate.union({
        "base": validate.all(
            validate.xml_find("head/meta"),
            validate.get("base"),
            validate.url(scheme="rtmp")
        ),
        "videos": validate.all(
            validate.xml_findall("body/video"),
            [validate.get("src")]
        )
    })
)


class ConnectCast(Plugin):
    @classmethod
    def can_handle_url(self, url):
        return _url_re.match(url)
示例#31
0
import re

from livestreamer.plugin import Plugin
from livestreamer.plugin.api import http, validate
from livestreamer.stream import HLSStream

API_BASE = "http://gox.gomexp.com/cgi-bin"
API_URL_APP = API_BASE + "/app_api.cgi"
API_URL_LIVE = API_BASE + "/gox_live.cgi"

_url_re = re.compile("http(s)?://(www\.)?gomexp.com")

_entries_schema = validate.Schema(
    validate.xml_findall("./ENTRY/*/[@reftype='live'][@href]"),
    [validate.get("href")])


class GOMeXP(Plugin):
    @classmethod
    def can_handle_url(self, url):
        return _url_re.match(url)

    def _get_live_cubeid(self):
        res = http.get(API_URL_APP, params=dict(mode="get_live"))
        root = http.xml(res)
        return root.findtext("./cube/cubeid")

    def _get_streams(self):
        cubeid = self._get_live_cubeid()
        if not cubeid:
示例#32
0
                    "name": validate.text,
                    validate.optional("sequenceList"): [
                        {
                            "layerList": validate.all(
                                [{"name": validate.text, validate.optional("param"): dict}],
                                validate.filter(lambda l: l["name"] in ("video", "reporting")),
                            )
                        }
                    ],
                }
            ]
        }
    ]
)
_media_schema = validate.Schema(
    validate.any(_media_inner_schema, validate.all({"sequence": _media_inner_schema}, validate.get("sequence")))
)
_vod_playlist_schema = validate.Schema({"duration": float, "fragments": [[int, float]], "template": validate.text})
_vod_manifest_schema = validate.Schema(
    {"alternates": [{"height": int, "template": validate.text, validate.optional("failover"): [validate.text]}]}
)


class DailyMotion(Plugin):
    @classmethod
    def can_handle_url(self, url):
        return _url_re.match(url)

    def _get_streams_from_media(self, media_id):
        res = http.get(STREAM_INFO_URL.format(media_id), cookies=COOKIES)
        media = http.json(res, schema=_media_schema)
示例#33
0
        svtflow |
        oppetarkiv
    )
    .se
""", re.VERBOSE)

_video_schema = validate.Schema(
    {
        "video": {
            "videoReferences":
            validate.all([{
                "url": validate.text,
                "playerType": validate.text
            }], validate.filter(lambda r: r["playerType"] in STREAM_TYPES)),
        }
    }, validate.get("video"), validate.get("videoReferences"))


class SVTPlay(Plugin):
    @classmethod
    def can_handle_url(self, url):
        return _url_re.match(url)

    def _get_streams(self):
        res = http.get(self.url, params=dict(output="json"))
        videos = http.json(res, schema=_video_schema)
        streams = {}
        for video in videos:
            url = video["url"]
            stream_type = video["playerType"]
            parser = STREAM_TYPES[stream_type]
示例#34
0
from livestreamer.stream import HLSStream

_url_re = re.compile("http(s)?://(\w+\.)?ssh101\.com/")

_live_re = re.compile("""
\s*jwplayer\(\"player\"\)\.setup\({.*?
\s*primary:\s+"([^"]+)".*?
\s*file:\s+"([^"]+)"
""", re.DOTALL)

_live_schema = validate.Schema(
    validate.transform(_live_re.search),
    validate.any(
        None,
        validate.union({
            "type": validate.get(1),
            "url": validate.all(
                validate.get(2),
                validate.url(scheme="http"),
            ),
        })
    )
)

class SSH101(Plugin):
    @classmethod
    def can_handle_url(self, url):
        return _url_re.match(url)

    def _get_streams(self):
        res = http.get(self.url, schema=_live_schema)
示例#35
0
_url_re = re.compile("""
    http(s)?://(staging|alpha)\.gaminglive\.tv
    /\#/channels/(?P<channel>[^/]+)
""", re.VERBOSE)
_quality_re = re.compile("[^/]+-(?P<quality>[^/]+)")

_channel_schema = validate.Schema(
    {
        validate.optional("state"): {
            "stream": {
                "qualities": [validate.text],
                "rootUrl": validate.url(scheme="rtmp")
            }
        }
    },
    validate.get("state")
)


class GamingLive(Plugin):
    @classmethod
    def can_handle_url(self, url):
        return _url_re.match(url)

    @classmethod
    def stream_weight(cls, key):
        weight = QUALITY_WEIGHTS.get(key)
        if weight:
            return weight, "gaminglive"

        return Plugin.stream_weight(key)
示例#36
0
    (?P<channel>[^/]+)
    (?:
        /
        (?P<video_type>[bc])
        /
        (?P<video_id>\d+)
    )?
""", re.VERBOSE)

_access_token_schema = validate.Schema(
    {
        "token": validate.text,
        "sig": validate.text
    },
    validate.union((
        validate.get("sig"),
        validate.get("token")
    ))
)
_token_schema = validate.Schema(
    {
        "chansub": {
            "restricted_bitrates": validate.all(
                [validate.text],
                validate.filter(
                    lambda n: not re.match(r"(.+_)?archives|live|chunked", n)
                )
            )
        }
    },
    validate.get("chansub")
示例#37
0
    "h264_aac_ts_http_m3u8_http": (
        "HLS", HLSStream.parse_variant_playlist
    )
}

_url_re = re.compile("""
    http(s)?://(\w+\.)?zdf.de/zdfmediathek(\#)?/.+
    /(live|video)
    /(?P<video_id>\d+)
""", re.VERBOSE | re.IGNORECASE)

_schema = validate.Schema(
    validate.xml_findall("video/formitaeten/formitaet"),
    [
        validate.union({
            "type": validate.get("basetype"),
            "quality": validate.xml_findtext("quality"),
            "url": validate.all(
                validate.xml_findtext("url"),
                validate.url()
            )
        })
    ]
)


class zdf_mediathek(Plugin):
    @classmethod
    def can_handle_url(cls, url):
        return _url_re.match(url)
示例#38
0
        /(?P<media_id>[^/]+)
    )?
""", re.VERBOSE)

_live_schema = validate.Schema(
    {
        "livestream": [{
            "media_is_live": validate.all(
                validate.text,
                validate.transform(int),
                validate.transform(bool)
            ),
            "media_id": validate.text
        }],
    },
    validate.get("livestream"),
    validate.length(1),
    validate.get(0)
)
_player_schema = validate.Schema(
    {
        "clip": {
            "baseUrl": validate.any(None, validate.text),
            "bitrates": validate.all(
                validate.filter(lambda b: b.get("url") and b.get("label")),
                [{
                    "label": validate.text,
                    "url": validate.text
                }],
            )
        },
示例#39
0
""", re.VERBOSE)
_file_re = re.compile("\"?file\"?:\s+['\"]([^'\"]+)['\"]")
_swf_url_re = re.compile("swfobject.embedSWF\(\"([^\"]+)\",")

_schema = validate.Schema(
    validate.union({
        "urls":
        validate.all(validate.transform(_file_re.findall),
                     validate.map(unquote), [validate.url()]),
        "swf":
        validate.all(
            validate.transform(_swf_url_re.search),
            validate.any(
                None,
                validate.all(
                    validate.get(1),
                    validate.url(scheme="http",
                                 path=validate.endswith("swf")))))
    }))


class Aliez(Plugin):
    @classmethod
    def can_handle_url(self, url):
        return _url_re.match(url)

    def _get_streams(self):
        res = http.get(self.url, schema=_schema)
        streams = {}
        for url in res["urls"]:
            parsed = urlparse(url)
示例#40
0
    )
    .se
""", re.VERBOSE)

_video_schema = validate.Schema(
    {
        "video": {
            "videoReferences": validate.all(
                [{
                    "url": validate.text,
                    "playerType": validate.text
                }],
            ),
        }
    },
    validate.get("video"),
    validate.get("videoReferences")
)


class SVTPlay(Plugin):
    @classmethod
    def can_handle_url(self, url):
        return _url_re.match(url)

    def _create_streams(self, stream_type, parser, video):
        try:
            streams = parser(self.session, video["url"])
            return streams.items()
        except IOError as err:
            self.logger.error("Failed to extract {0} streams: {1}",
示例#41
0
            None,
            {
                "streams": validate.all(
                    [{
                        "quality": validate.text,
                        "url": validate.url(
                            scheme="http",
                            path=validate.endswith(".m3u8")
                        )
                    }],
                    validate.filter(lambda s: s["quality"] != "adaptive")
                )
            }
        )
    },
    validate.get("stream_data")
)
_login_schema = validate.Schema({
    "auth": validate.text,
    "expires": validate.all(
        validate.text,
        validate.transform(parse_timestamp)
    ),
    "user": {
        "username": validate.text
    }
})
_session_schema = validate.Schema(
    {
        "session_id": validate.text
    },
示例#42
0
ASSIGN_PATH = "/broad_stream_assign.html"
CHANNEL_RESULT_ERROR = 0
CHANNEL_RESULT_OK = 1
# original, hd, sd
quality = "original"
_url_re = re.compile(r"http(s)?://afreeca.com/(?P<bid>\w+)(/\d+)?")

_channel_schema = validate.Schema(
    {
        "CHANNEL": {
            "RESULT": validate.transform(int),
            "BNO": validate.text,
            "CDN": validate.text,
            "RMD": validate.text,
        }
    }, validate.get("CHANNEL"))
_channel_aid_schema = validate.Schema(
    {"CHANNEL": {
        "RESULT": validate.transform(int),
        "AID": validate.text,
    }}, validate.get("CHANNEL"))
_stream_schema = validate.Schema({
    validate.optional("view_url"):
    validate.url(scheme=validate.any("rtmp", "http"))
})


class AfreecaTV_PC(Plugin):
    @classmethod
    def can_handle_url(self, url):
        return _url_re.match(url)
示例#43
0
STREAM_WEIGHTS = {"low": 540, "middle": 720, "source": 1080}

_url_re = re.compile(
    """
    http(s)?://(www\.)?douyu.com
    /(?P<channel>[^/]+)
""", re.VERBOSE)

_json_re = re.compile(r"var\s*\$ROOM\s*=\s*({.+?});")

_room_id_schema = validate.Schema(
    validate.all(
        validate.transform(_json_re.search),
        validate.any(
            None,
            validate.all(validate.get(1), validate.transform(parse_json), {
                "room_id":
                validate.any(validate.text, validate.transform(int))
            }))))

_room_schema = validate.Schema(
    {
        "data":
        validate.any(None, {
            "show_status":
            validate.all(validate.text, validate.transform(int))
        })
    }, validate.get("data"))

_lapi_schema = validate.Schema(
    {
示例#44
0
import re

from livestreamer.plugin import Plugin
from livestreamer.plugin.api import http, validate
from livestreamer.stream import RTMPStream

_url_re = re.compile("http(s)?://(\w+.)?beam.pro/(?P<channel>[^/]+)")

CHANNEL_INFO = "https://beam.pro/api/v1/channels/{0}"
CHANNEL_MANIFEST = "https://beam.pro/api/v1/channels/{0}/manifest.smil"

_assets_schema = validate.Schema(
    validate.union({
        "base": validate.all(
            validate.xml_find("./head/meta"),
            validate.get("base"),
            validate.url(scheme="rtmp")
        ),
        "videos": validate.all(
            validate.xml_findall(".//video"),
            [
                validate.union({
                    "src": validate.all(
                        validate.get("src"),
                        validate.text
                    ),
                    "height": validate.all(
                        validate.get("height"),
                        validate.text,
                        validate.transform(int)
                    )
示例#45
0
REDIRECT_SERVICE_URI = "https://lancer.streamup.com/api/redirect/{0}"

_url_re = re.compile("http(s)?://(\w+\.)?streamup.com/(?P<channel>[^/?]+)")
_flashvars_re = re.compile("flashvars\.(?P<var>\w+)\s?=\s?'(?P<value>[^']+)';")
_swf_url_re = re.compile('swfobject.embedSWF\(\s*"(?P<player_url>[^"]+)",')

_schema = validate.Schema(
    validate.union(
        {
            "vars": validate.all(
                validate.transform(_flashvars_re.findall),
                validate.transform(dict),
                {"owner": validate.text, validate.optional("token"): validate.text},
            ),
            "swf": validate.all(
                validate.transform(_swf_url_re.search), validate.get("player_url"), validate.endswith(".swf")
            ),
        }
    )
)

_channel_details_schema = validate.Schema({"channel": {"live": bool, "slug": validate.text}})


class StreamupCom(Plugin):
    @classmethod
    def can_handle_url(cls, url):
        return _url_re.match(url)

    def _get_streams(self):
        res = http.get(self.url, schema=_schema)
示例#46
0
    http(s)?://(\w+\.)?
    (?P<domain>vaughnlive|breakers|instagib|vapers).tv
    /(?P<channel>[^/&?]+)
""", re.VERBOSE)
_channel_not_found_re = re.compile("<title>Channel Not Found")


def decode_token(token):
    return token.replace("0m0", "")

_schema = validate.Schema(
    validate.transform(lambda s: s.split(";:mvnkey-")),
    validate.length(2),
    validate.union({
        "server": validate.all(
            validate.get(0),
            validate.text
        ),
        "token": validate.all(
            validate.get(1),
            validate.text,
            validate.transform(decode_token)
        )
    })
)


class VaughnLive(Plugin):
    @classmethod
    def can_handle_url(cls, url):
        return _url_re.match(url)
示例#47
0
    )?
    (?:
        (?P<minutes>\d+)m
    )?
    (?:
        (?P<seconds>\d+)s
    )?
""", re.VERBOSE)

_access_token_schema = validate.Schema(
    {
        "token": validate.text,
        "sig": validate.text
    },
    validate.union((
        validate.get("sig"),
        validate.get("token")
    ))
)
_token_schema = validate.Schema(
    {
        "chansub": {
            "restricted_bitrates": validate.all(
                [validate.text],
                validate.filter(
                    lambda n: not re.match(r"(.+_)?archives|live|chunked", n)
                )
            )
        }
    },
    validate.get("chansub")
示例#48
0
                path=validate.endswith(".m3u8")
            ),
        }, None)
    },
    validate.optional("viewerPlusSwfUrl"): validate.url(scheme="http"),
    validate.optional("hdPlayerSwfUrl"): validate.text
})
_smil_schema = validate.Schema(validate.union({
    "http_base": validate.all(
        validate.xml_find("{http://www.w3.org/2001/SMIL20/Language}head/"
                          "{http://www.w3.org/2001/SMIL20/Language}meta"
                          "[@name='httpBase']"),
        validate.xml_element(attrib={
            "content": validate.text
        }),
        validate.get("content")
    ),
    "videos": validate.all(
        validate.xml_findall("{http://www.w3.org/2001/SMIL20/Language}body/"
                             "{http://www.w3.org/2001/SMIL20/Language}switch/"
                             "{http://www.w3.org/2001/SMIL20/Language}video"),
        [
            validate.all(
                validate.xml_element(attrib={
                    "src": validate.text,
                    "system-bitrate": validate.all(
                        validate.text,
                        validate.transform(int)
                    )
                }),
                validate.transform(
示例#49
0
        (/embed/|/channel/id/)(?P<channel_id>\d+)
    )?
    (?:
        /recorded/(?P<video_id>\d+)
    )?
""", re.VERBOSE)
_channel_id_re = re.compile("\"cid\":(\d+)")

HLS_PLAYLIST_URL = ("http://iphone-streaming.ustream.tv"
                    "/uhls/{0}/streams/live/iphone/playlist.m3u8")
RECORDED_URL = "http://tcdn.ustream.tv/video/{0}"
RTMP_URL = "rtmp://r{0}.1.{1}.channel.live.ums.ustream.tv:80/ustream"
SWF_URL = "http://static-cdn1.ustream.tv/swf/live/viewer.rsl:505.swf"

_module_info_schema = validate.Schema(list, validate.length(1),
                                      validate.get(0), dict)
_recorded_schema = validate.Schema({
    validate.optional("stream"): [{
        "name":
        validate.text,
        "streams": [{
            "streamName": validate.text,
            "bitrate": float,
        }],
        validate.optional("url"):
        validate.text,
    }]
})
_channel_schema = validate.Schema({
    validate.optional("stream"):
    validate.any([{
示例#50
0
import re

from livestreamer.plugin import Plugin
from livestreamer.plugin.api import http, validate
from livestreamer.stream import HLSStream

_url_re = re.compile("http(s)?://chaturbate.com/[^/?&]+")
_playlist_url_re = re.compile("html \+= \"src='(?P<url>[^']+)'\";")
_schema = validate.Schema(
    validate.transform(_playlist_url_re.search),
    validate.any(
        None,
        validate.all(
            validate.get("url"),
            validate.url(
                scheme="http",
                path=validate.endswith(".m3u8")
            )
        )
    )
)


class Chaturbate(Plugin):
    @classmethod
    def can_handle_url(self, url):
        return _url_re.match(url)

    def _get_streams(self):
        playlist_url = http.get(self.url, schema=_schema)
        if not playlist_url:
示例#51
0
            None,
            {
                "streams": validate.all(
                    [{
                        "quality": validate.text,
                        "url": validate.url(
                            scheme="http",
                            path=validate.endswith(".m3u8")
                        )
                    }],
                    validate.filter(lambda s: s["quality"] != "adaptive")
                )
            }
        )
    },
    validate.get("stream_data")
)
_login_schema = validate.Schema({
    "auth": validate.text,
    "expires": validate.all(
        validate.text,
        validate.transform(parse_timestamp)
    ),
    "user": {
        "username": validate.text
    }
})
_session_schema = validate.Schema(
    {
        "session_id": validate.text
    },
示例#52
0
import re

from livestreamer.plugin import Plugin
from livestreamer.plugin.api import http, validate
from livestreamer.plugin.api.utils import parse_query
from livestreamer.stream import RTMPStream


VIEW_LIVE_API_URL = "http://api.afreeca.tv/live/view_live.php"

_url_re = re.compile("http(s)?://(\w+\.)?afreeca.tv/(?P<channel>[\w\-_]+)")
_flashvars_re = re.compile('<param name="flashvars" value="([^"]+)" />')

_flashvars_schema = validate.Schema(
    validate.transform(_flashvars_re.findall),
    validate.get(0),
    validate.transform(parse_query),
    validate.any(
        {
            "s": validate.text,
            "id": validate.text
        },
        {}
    )
)
_view_live_schema = validate.Schema(
    {
        "channel": {
            "strm": [{
                "brt": validate.text,
                "bps": validate.text,
示例#53
0
        "quality": validate.text,
        "url": validate.url(scheme="rtmp")
    }]
})
_vod_schema = validate.Schema(
    {
        "data": {
            "streams": {
                validate.text: {
                    "name": validate.text,
                    "url": validate.url(scheme="rtmp")
                }
            }
        }
    },
    validate.get("data")
)


class Filmon(Plugin):
    @classmethod
    def can_handle_url(cls, url):
        return _url_re.match(url)

    @classmethod
    def stream_weight(cls, key):
        weight = QUALITY_WEIGHTS.get(key)
        if weight:
            return weight, "filmon"

        return Plugin.stream_weight(key)
示例#54
0
from itertools import chain

from livestreamer.compat import urlparse
from livestreamer.plugin import Plugin
from livestreamer.plugin.api import http, validate
from livestreamer.stream import HLSStream, HTTPStream, RTMPStream

SWF_URL = "http://www.arte.tv/player/v2/jwplayer6/mediaplayer.6.6.swf"

_url_re = re.compile("http(s)?://(\w+\.)?arte.tv/")
_json_re = re.compile("arte_vp_(?:live-)?url=(['\"])(.+?)\\1")

_schema = validate.Schema(
    validate.transform(_json_re.search),
    validate.any(None,
                 validate.all(validate.get(2), validate.url(scheme="http"))))
_video_schema = validate.Schema({
    "videoJsonPlayer": {
        "VSR":
        validate.any(
            [],
            {
                validate.text: {
                    "height": int,
                    "mediaType": validate.text,
                    "url": validate.text,
                    validate.optional("streamer"): validate.text
                },
            },
        ),
        "VTY":
示例#55
0
_url_re = re.compile("http(s)?://(\w+\.)?ssh101\.com/")

_live_re = re.compile(
    """
\s*jwplayer\(\"player\"\)\.setup\({.*?
\s*primary:\s+"([^"]+)".*?
\s*file:\s+"([^"]+)"
""", re.DOTALL)

_live_schema = validate.Schema(
    validate.transform(_live_re.search),
    validate.any(
        None,
        validate.union({
            "type":
            validate.get(1),
            "url":
            validate.all(
                validate.get(2),
                validate.url(scheme="http"),
            ),
        })))


class SSH101(Plugin):
    @classmethod
    def can_handle_url(self, url):
        return _url_re.match(url)

    def _get_streams(self):
        res = http.get(self.url, schema=_live_schema)