Exemplo n.º 1
0
def service():
    alerts = userdata.get('alerts', [])
    if not alerts:
        return

    now     = arrow.now()
    notify  = []
    _alerts = []

    for id in alerts:
        asset = api.event(id)
        start = arrow.get(asset.get('preCheckTime', asset['transmissionTime']))

        #If we are streaming and started less than 10 minutes ago
        if asset.get('isStreaming', False) and (now - start).total_seconds() <= 60*10:
            notify.append(asset)
        elif start > now:
            _alerts.append(id)

    userdata.set('alerts', _alerts)

    for asset in notify:
        if not gui.yes_no(_(_.EVENT_STARTED, event=asset['title']), yeslabel=_.WATCH, nolabel=_.CLOSE):
            continue

        with signals.throwable():
            start_from = 1
            start      = arrow.get(asset['transmissionTime'])

            if start < now and 'preCheckTime' in asset:
                precheck = arrow.get(asset['preCheckTime'])
                if precheck < start:
                    start_from = (start - precheck).seconds

            play(id=asset['id'], start_from=start_from, play_type=settings.getEnum('live_play_type', LIVE_PLAY_TYPES, default=FROM_CHOOSE))
Exemplo n.º 2
0
def _parse_video(row):
    asset   = row['asset']
    display = row['contentDisplay']
    alerts  = userdata.get('alerts', [])

    now      = arrow.now()
    start    = arrow.get(asset['transmissionTime'])
    precheck = start

    if 'preCheckTime' in asset:
        precheck = arrow.get(asset['preCheckTime'])
        if precheck > start:
            precheck = start

    start_from = (start - precheck).seconds

    title = display['title']
    if 'heroHeader' in display:
        title += ' [' + display['heroHeader'].replace('${DATE_HUMANISED}', _makeHumanised(now, start).upper()).replace('${TIME}', _makeTime(start)) + ']'

    item = plugin.Item(
        label = title,
        art  = {
            'thumb' : _get_image(asset, 'video', 'thumb'),
            'fanart': _get_image(asset, 'video', 'fanart'),
        },
        info = {
            'plot': display.get('description'),
            'plotoutline': display.get('description'),
            'mediatype': 'video',
        },
        playable = True,
        is_folder = False,
    )

    is_live = False

    if now < start:
        is_live = True
        toggle_alert = plugin.url_for(alert, asset=asset['id'], title=asset['title'])

        if asset['id'] not in userdata.get('alerts', []):
            item.info['playcount'] = 0
            item.context.append((_.SET_REMINDER, "XBMC.RunPlugin({})".format(toggle_alert)))
        else:
            item.info['playcount'] = 1
            item.context.append((_.REMOVE_REMINDER, "XBMC.RunPlugin({})".format(toggle_alert)))

    elif asset['isLive'] and asset.get('isStreaming', False):
        is_live = True

        item.context.append((_.FROM_LIVE, "XBMC.PlayMedia({})".format(
            plugin.url_for(play, id=asset['id'], play_type=FROM_LIVE, _is_live=is_live)
        )))

        item.context.append((_.FROM_START, "XBMC.PlayMedia({})".format(
            plugin.url_for(play, id=asset['id'], start_from=start_from, play_type=FROM_START, _is_live=is_live)
        )))

    item.path = plugin.url_for(play, id=asset['id'], start_from=start_from, play_type=settings.getEnum('live_play_type', LIVE_PLAY_TYPES, default=FROM_CHOOSE), _is_live=is_live)

    return item
Exemplo n.º 3
0
def _parse_video(asset):
    alerts = userdata.get('alerts', [])

    now = arrow.now()
    start = arrow.get(asset['transmissionTime'])
    precheck = start

    if 'preCheckTime' in asset:
        precheck = arrow.get(asset['preCheckTime'])
        if precheck > start:
            precheck = start

    start_from = (start - precheck).seconds

    item = plugin.Item(
        label=asset['title'],
        art={
            'thumb': _get_image(asset, 'video', 'thumb'),
            'fanart': _get_image(asset, 'video', 'fanart'),
        },
        info={
            'plot': asset.get('description'),
            'plotoutline': asset.get('description-short'),
            'mediatype': 'video',
        },
        playable=True,
        is_folder=False,
    )

    is_live = False

    if now < start:
        is_live = True
        item.label = _(_.STARTING_SOON,
                       title=asset['title'],
                       humanize=start.humanize())
        toggle_alert = plugin.url_for(alert,
                                      asset=asset['id'],
                                      title=asset['title'])

        if asset['id'] not in userdata.get('alerts', []):
            item.info['playcount'] = 0
            item.context.append(
                (_.SET_REMINDER, "XBMC.RunPlugin({})".format(toggle_alert)))
        else:
            item.info['playcount'] = 1
            item.context.append(
                (_.REMOVE_REMINDER, "XBMC.RunPlugin({})".format(toggle_alert)))

    elif asset['isLive'] and asset.get('isStreaming', False):
        is_live = True
        item.label = _(_.LIVE, title=asset['title'])

        item.context.append((_.FROM_LIVE, "XBMC.PlayMedia({})".format(
            plugin.url_for(play,
                           id=asset['id'],
                           is_live=is_live,
                           play_type=FROM_LIVE))))

        item.context.append((_.FROM_START, "XBMC.PlayMedia({})".format(
            plugin.url_for(play,
                           id=asset['id'],
                           is_live=is_live,
                           start_from=start_from,
                           play_type=FROM_START))))

    item.path = plugin.url_for(play,
                               id=asset['id'],
                               is_live=is_live,
                               start_from=start_from,
                               play_type=settings.getEnum('live_play_type',
                                                          LIVE_PLAY_TYPES,
                                                          default=FROM_CHOOSE))

    return item