Esempio n. 1
0
def play(id, start_from=0):
    asset = api.stream(id)

    start = arrow.get(asset.get('preCheckTime', asset['transmissionTime']))

    if start > arrow.now():
        return gui.ok(_(_.GAME_NOT_STARTED, start=start.humanize()))

    stream = _get_stream(asset)

    item = plugin.Item(
        path=stream['manifest']['uri'],
        art=False,
        headers=HEADERS,
    )

    if stream['mediaFormat'] == 'dash':
        item.inputstream = inputstream.MPD()
    elif stream['mediaFormat'] == 'hls-ts':
        item.inputstream = inputstream.HLS()

    if start_from:
        item.properties['ResumeTime'] = start_from
        item.properties['TotalTime'] = start_from

    return item
Esempio n. 2
0
def play(id, start_from=0, play_type=FROM_LIVE, **kwargs):
    asset = api.stream(id)
    start_from = int(start_from)
    play_type = int(play_type)
    is_live = kwargs.get(ROUTE_LIVE_TAG) == ROUTE_LIVE_SUFFIX

    now = arrow.now()
    start = arrow.get(asset.get('preCheckTime', asset['transmissionTime']))
    if start > now:
        raise PluginError(
            _(_.GAME_NOT_STARTED,
              start=_makeHumanised(now, start).upper() + ' ' +
              _makeTime(start)))

    streams = [asset['recommendedStream']]
    streams.extend(asset['alternativeStreams'])
    streams = [s for s in streams if s['mediaFormat'] in SUPPORTED_FORMATS]

    if not streams:
        raise PluginError(_.NO_STREAM)

    provider = PREFER_PROVIDER or api.cdn_selection(
        'live' if is_live else 'vod')
    streams = sorted(
        streams,
        key=lambda k:
        (k['provider'] == provider, k['mediaFormat'] == PREFER_FORMAT),
        reverse=True)
    stream = streams[0]

    log.debug('Stream CDN: {provider} | Stream Format: {mediaFormat}'.format(
        **stream))

    item = plugin.Item(
        path=stream['manifest']['uri'],
        art=False,
        headers=HEADERS,
    )

    if is_live and (
            play_type == FROM_LIVE or (play_type == FROM_CHOOSE and gui.yes_no(
                _.PLAY_FROM, yeslabel=_.FROM_LIVE, nolabel=_.FROM_START))):
        start_from = 0

    if stream['mediaFormat'] == FORMAT_DASH:
        item.inputstream = inputstream.MPD()
    elif stream['mediaFormat'] == FORMAT_HLS_TS:
        hls = inputstream.HLS()

        if is_live and start_from == 0 and not hls.check():
            raise PluginError(_.HLS_REQUIRED)
        else:
            item.inputstream = hls

    if start_from:
        item.properties['ResumeTime'] = start_from
        item.properties['TotalTime'] = start_from

    return item
Esempio n. 3
0
def play_channel(id, **kwargs):
    url = api.play_channel(id)

    return plugin.Item(
        path        = url,
        headers     = HEADERS,
        inputstream = inputstream.HLS(),
    )
def play(id, **kwargs):
    data = api.media(id)
    item = _process_media(data)

    if settings.getBool('subtitles', True):
        item.subtitles = api.get_subtitles(data.get('closed_captions', []))

    item.path = data['encodings'][0]['master_playlist_url']
    item.inputstream = inputstream.HLS()

    return item
def play(slug, **kwargs):
    channel = get_channels()[slug]

    item = plugin.Item(
        path=channel['master_url'],
        headers=channel['headers'],
        info={'plot': channel.get('description')},
        video=channel.get('video', {}),
        audio=channel.get('audio', {}),
        art={'thumb': channel.get('logo')},
    )

    if channel.get('hls', False) and settings.getBool('use_ia_hls', False):
        item.inputstream = inputstream.HLS()

    return item
Esempio n. 6
0
def play(slug, **kwargs):
    region = get_region()
    channel = get_channels(region)[slug]

    item = plugin.Item(
        path=channel['mjh_master'],
        headers=channel['headers'],
        info={'plot': channel.get('description')},
        video=channel.get('video', {}),
        audio=channel.get('audio', {}),
        art={'thumb': channel.get('logo')},
    )

    if channel.get('hls', False):
        item.inputstream = inputstream.HLS()

    return item
def play(id, start_from=0, play_type=FROM_LIVE, **kwargs):
    asset = api.stream(id)
    start_from = int(start_from)
    play_type = int(play_type)

    start = arrow.get(asset.get('preCheckTime', asset['transmissionTime']))
    if start > arrow.now():
        raise PluginError(_(_.GAME_NOT_STARTED, start=start.humanize()))

    stream = _get_stream(asset)

    item = plugin.Item(
        path=stream['manifest']['uri'],
        art=False,
        headers=HEADERS,
    )

    if asset['isLive'] and play_type == FROM_LIVE or (
            play_type == FROM_CHOOSE and gui.yes_no(
                _.PLAY_FROM, yeslabel=_.FROM_LIVE, nolabel=_.FROM_START)):
        start_from = 0

    hls = inputstream.HLS()

    if stream['mediaFormat'] == 'dash':
        item.inputstream = inputstream.MPD()
    elif stream['mediaFormat'] == 'hls-ts':
        #If live stream FROM_LIVE and no HLS
        if asset['isLive'] and not start_from and not hls.check():
            raise PluginError(_.HLS_REQUIRED)
        else:
            item.inputstream = hls

    if start_from:
        item.properties['ResumeTime'] = start_from
        item.properties['TotalTime'] = start_from

    return item