示例#1
0
def play(account_id, channel_id, askpin):
    sl = utils.get_provider(account_id)

    if not sl:
        return

    logger.log.info('Play channel %s from %s' %
                    (channel_id, sl.account.provider))

    if askpin != 'False':
        pin_ok = utils.ask_for_pin(sl)
        if not pin_ok:
            xbmcplugin.setResolvedUrl(_id, False, xbmcgui.ListItem())
            return

    info = {}

    info = utils.call(sl, lambda: sl.channel_info(channel_id))

    if info:
        is_helper = inputstreamhelper.Helper(info['protocol'], drm=info['drm'])
        if is_helper.check_inputstream():
            playitem = xbmcgui.ListItem(path=info['path'])
            playitem.setProperty('inputstreamaddon',
                                 is_helper.inputstream_addon)
            playitem.setProperty('inputstream.adaptive.manifest_type',
                                 info['protocol'])
            playitem.setProperty('inputstream.adaptive.license_type',
                                 info['drm'])
            playitem.setProperty('inputstream.adaptive.license_key',
                                 info['key'])
            xbmcplugin.setResolvedUrl(_id, True, playitem)
示例#2
0
def play_archive_utc(station_id, utc, askpin):
    logger.log.info('play archive: ' + station_id + 'utc: ' + utc)
    sl = skylink.Skylink(_user_name, _password, _profile, _provider)

    if askpin != 'False':
        pin_ok = utils.ask_for_pin(sl)
        if not pin_ok:
            xbmcplugin.setResolvedUrl(_id, False, xbmcgui.ListItem())
            return
    try:
        info = utils.call(
            sl, lambda: sl.replay_info(locId_from_time(sl, station_id, utc)))
    except skylink.StreamNotResolvedException as e:
        xbmcgui.Dialog().ok(_addon.getAddonInfo('name'),
                            _addon.getLocalizedString(e.id))
        xbmcplugin.setResolvedUrl(_id, False, xbmcgui.ListItem())
        return

    if info:
        is_helper = inputstreamhelper.Helper(info['protocol'], drm=info['drm'])
        if is_helper.check_inputstream():
            playitem = xbmcgui.ListItem(path=info['path'])
            playitem.setProperty('inputstreamaddon',
                                 is_helper.inputstream_addon)
            playitem.setProperty('inputstream.adaptive.manifest_type',
                                 info['protocol'])
            playitem.setProperty('inputstream.adaptive.license_type',
                                 info['drm'])
            playitem.setProperty('inputstream.adaptive.license_key',
                                 info['key'])
            playitem.setProperty('inputstream.adaptive.stream_headers',
                                 info['headers'])
            xbmcplugin.setResolvedUrl(_id, True, playitem)
示例#3
0
def play(channel_id, askpin):
    logger.log.info('play: ' + channel_id)
    sl = skylink.Skylink(_user_name, _password, _profile, _provider)

    if askpin != 'False':
        pin_ok = utils.ask_for_pin(sl)
        if not pin_ok:
            xbmcplugin.setResolvedUrl(_id, False, xbmcgui.ListItem())
            return
    try:
        info = utils.call(sl, lambda: sl.channel_info(channel_id))
    except skylink.StreamNotResolvedException as e:
        xbmcgui.Dialog().ok(heading=_addon.getAddonInfo('name'),
                            line1=_addon.getLocalizedString(e.id))
        xbmcplugin.setResolvedUrl(_id, False, xbmcgui.ListItem())
        return

    if info:
        is_helper = inputstreamhelper.Helper(info['protocol'], drm=info['drm'])
        if is_helper.check_inputstream():
            playitem = xbmcgui.ListItem(path=info['path'])
            if (_python3):  # Python 3.x
                playitem.setProperty('inputstream',
                                     is_helper.inputstream_addon)
            else:  # Python 2.5+
                playitem.setProperty('inputstreamaddon',
                                     is_helper.inputstream_addon)
            playitem.setProperty('inputstream.adaptive.manifest_type',
                                 info['protocol'])
            playitem.setProperty('inputstream.adaptive.license_type',
                                 info['drm'])
            playitem.setProperty('inputstream.adaptive.license_key',
                                 info['key'])
            xbmcplugin.setResolvedUrl(_id, True, playitem)
示例#4
0
def days(accountid, stationid, channel, askpin):
    sl = utils.get_provider(accountid)

    if not sl:
        return

    now = datetime.datetime.now()
    xbmcplugin.setPluginCategory(
        _handle,
        _addon.getLocalizedString(30600) + ' / ' + channel)
    if askpin != 'False':
        pin_ok = utils.ask_for_pin(sl)
        if not pin_ok:
            xbmcplugin.endOfDirectory(_handle)
            return
    for day in range(0, 7):
        d = now - datetime.timedelta(days=day) if day > 0 else now
        title = _addon.getLocalizedString(
            30601) if day == 0 else _addon.getLocalizedString(
                30602) if day == 1 else d.strftime('%d. %m.').decode('UTF-8')
        title = _addon.getLocalizedString(
            int('3061' + str(d.weekday()))) + ', ' + title
        list_item = xbmcgui.ListItem(label=title)
        list_item.setArt({'icon': 'DefaultAddonPVRClient.png'})
        link = get_url(replay='programs',
                       accountid=accountid,
                       stationid=stationid,
                       channel=channel,
                       day=day,
                       first=True)
        is_folder = True
        xbmcplugin.addDirectoryItem(_handle, link, list_item, is_folder)
    xbmcplugin.endOfDirectory(_handle)
示例#5
0
def days(sl, stationid, channel, askpin):
    now = datetime.datetime.now()
    xbmcplugin.setPluginCategory(
        _handle,
        _addon.getLocalizedString(30600) + ' / ' + channel)
    if askpin != 'False':
        pin_ok = utils.ask_for_pin(sl)
        if not pin_ok:
            xbmcplugin.endOfDirectory(_handle)
            return
    for day in range(0, 8):
        if day < 7 or time_until_end_of_day(now).seconds > REPLAY_LAST_GAP:
            d = now - datetime.timedelta(days=day) if day > 0 else now
            title = _addon.getLocalizedString(
                30601) if day == 0 else _addon.getLocalizedString(
                    30602) if day == 1 else utils.dec_utf8(
                        d.strftime('%d. %m.'))
            title = _addon.getLocalizedString(
                int('3061' + str(d.weekday()))) + ', ' + title
            list_item = xbmcgui.ListItem(label=title)
            list_item.setArt({'icon': 'DefaultAddonPVRClient.png'})
            link = get_url(replay='programs',
                           stationid=stationid,
                           channel=channel,
                           day=day,
                           first=True)
            is_folder = True
            xbmcplugin.addDirectoryItem(_handle, link, list_item, is_folder)
    xbmcplugin.endOfDirectory(_handle)
示例#6
0
def play(sl, lid, stationid, askpin):
    if askpin != 'False':
        pin_ok = utils.ask_for_pin(sl)
        if not pin_ok:
            xbmcplugin.setResolvedUrl(_handle, False, xbmcgui.ListItem())
            return

    today = datetime.datetime.now()
    epg = utils.call(
        sl, lambda: sl.epg([{
            'stationid': stationid
        }], today, today + datetime.timedelta(days=1), False))
    plot = generate_plot(epg[0][stationid], '') if epg else u''

    try:
        info = utils.call(sl, lambda: sl.channel_info(lid))
    except StreamNotResolvedException as e:
        xbmcgui.Dialog().ok(_addon.getAddonInfo('name'),
                            _addon.getLocalizedString(e.id))
        xbmcplugin.setResolvedUrl(_handle, False, xbmcgui.ListItem())
        return

    if info:
        is_helper = inputstreamhelper.Helper(info['protocol'], drm=info['drm'])
        if is_helper.check_inputstream():
            playitem = xbmcgui.ListItem(path=info['path'])
            if plot:
                playitem.setInfo('video', {'plot': plot})
            if (sys.version_info[0] >= 3):  # Python 3.x
                playitem.setProperty('inputstream',
                                     is_helper.inputstream_addon)
            else:  # Python 2.5+
                playitem.setProperty('inputstreamaddon',
                                     is_helper.inputstream_addon)
            playitem.setProperty('inputstream.adaptive.manifest_type',
                                 info['protocol'])
            playitem.setProperty('inputstream.adaptive.license_type',
                                 info['drm'])
            playitem.setProperty('inputstream.adaptive.license_key',
                                 info['key'])
            playitem.setProperty('inputstream.adaptive.stream_headers',
                                 info['headers'])
            xbmcplugin.setResolvedUrl(_handle, True, playitem)
示例#7
0
def listOfItems(sl, ctype, category):
    title = _addon.getLocalizedString(30800)
    ctp = None
    for tp in TYPES:
        if tp['code'] == ctype:
            ctp = tp
            title += ' / ' + tp['msg']
            break
    cat = None
    for ct in CATEGORIES:
        if ct['code'] == category:
            cat = ct
            title += ' / ' + ct['msg']
            break
    xbmcplugin.setPluginCategory(_handle, title)

    if ctp is None or cat is None:
        xbmcgui.Dialog().ok(heading=_addon.getLocalizedString(30800),
                            line1=_addon.getLocalizedString(30806))
        xbmcplugin.endOfDirectory(_handle)
        return

    if cat['pin'] and not utils.ask_for_pin(sl):
        xbmcplugin.endOfDirectory(_handle)
        return

    #get possible owners
    owners_data = utils.call(sl, lambda: sl.library_owners())
    products_data = utils.call(sl, lambda: sl.products())
    owners = []
    os = u''

    for owner in owners_data:
        valid = True
        owner.update({'pin':
                      int(owner['flags']) & 4 > 0})  #TODO brutforced test!!!
        if owner['pin'] and not sl._show_pin_protected:
            valid = False
        else:
            for product in products_data:
                if owner['name'] == product['name'] and not product['owned']:
                    valid = False
        if valid:
            owners.append(owner)

    params = ctp['data'].copy()
    params.update({'c': category, 'os': ','.join([o['id'] for o in owners])})

    items = utils.call(sl, lambda: sl.library(params))

    for item in items:
        list_item = xbmcgui.ListItem(label=item['title'])
        list_item.setInfo(
            'video', {
                'title': item['title'],
                'plot': item['description'] if 'description' in item else ''
            })
        list_item.setArt({'thumb': item['poster']})
        link = get_url(library='play' if ctp['isMovie'] else 'seasons',
                       lid=item['id'],
                       ctype=ctype)
        is_folder = not ctp['isMovie']
        if ctp['isMovie']:
            list_item.setProperty('IsPlayable', 'true')
        xbmcplugin.addDirectoryItem(_handle, link, list_item, is_folder)
    xbmcplugin.addSortMethod(_handle, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
    xbmcplugin.endOfDirectory(_handle)