def test_length(self):
        assert validate(length(1), [1,2,3]) == [1,2,3]

        def invalid_length():
            validate(length(2), [1])

        self.assertRaises(ValueError, invalid_length)
    def test_length(self):
        assert validate(length(1), [1, 2, 3]) == [1, 2, 3]

        def invalid_length():
            validate(length(2), [1])

        self.assertRaises(ValueError, invalid_length)
Esempio n. 3
0
        /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"):
Esempio n. 4
0
}

_url_re = re.compile("""
    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):
Esempio n. 5
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"):
Esempio n. 6
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"):
Esempio n. 7
0
_url_re = re.compile(
    """
    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):
 def invalid_length():
     validate(length(2), [1])
Esempio n. 9
0
_channel_not_found_re = re.compile("<title>Channel Not Found")


def decode_token(token):
    def decode_part(part):
        part = int(part.replace("0m0", ""))
        part /= DEBUG_PORT_ID
        part /= SET_GEO_CODE
        return chr(int(part))

    return "".join(decode_part(part) for part in token.split(":"))


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

class VaughnLive(Plugin):
    @classmethod
Esempio n. 10
0
_channel_not_found_re = re.compile("<title>Channel Not Found")


def decode_token(token):
    def decode_part(part):
        part = int(part.replace("0m0", ""))
        part /= DEBUG_PORT_ID
        part /= SET_GEO_CODE
        return chr(int(part))

    return "".join(decode_part(part) for part in token.split(":"))


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


class VaughnLive(Plugin):
 def invalid_length():
     validate(length(2), [1])