Exemplo n.º 1
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)
Exemplo n.º 2
0
 def get_plot_line(start, title):
     return '[B]' + utils.dec_utf8(
         start.strftime('%H:%M')) + '[/B] ' + title + '[CR]'
Exemplo n.º 3
0
import inputstreamhelper
import logger
import skylink
import xbmc
import xbmcaddon
import xbmcgui
import xbmcplugin
import replay
import live
import library
import utils
import datetime

_id = int(sys.argv[1])
_addon = xbmcaddon.Addon()
_profile = utils.dec_utf8(xbmc.translatePath(_addon.getAddonInfo('profile')))
_user_name = xbmcplugin.getSetting(_id, 'username')
_password = xbmcplugin.getSetting(_id, 'password')
_provider = 'skylink.sk' if int(xbmcplugin.getSetting(
    _id, 'provider')) == 0 else 'skylink.cz'
_pin_protected_content = 'false' != xbmcplugin.getSetting(
    _id, 'pin_protected_content')
_a_show_live = 'false' != xbmcplugin.getSetting(_id, 'a_show_live')
_python3 = sys.version_info[0] >= 3


def play_archive(station_id, catchup_id, askpin):
    logger.log.info('play archive: ' + station_id + ' catchup_id: ' +
                    str(catchup_id))
    sl = skylink.Skylink(_user_name, _password, _profile, _provider)
Exemplo n.º 4
0
def programs(sl, stationid, channel, day=0, first=False):
    today = day == 0
    lastday = day == 7
    now = datetime.datetime.now()
    if today:
        from_date = now.replace(hour=0, minute=0, second=0, microsecond=0)
        to_date = now
        start_date = from_date
    elif lastday:
        then = now - datetime.timedelta(days=day)
        start_date = then.replace(hour=0, minute=0, second=0, microsecond=0)
        from_date = then + datetime.timedelta(seconds=REPLAY_LAST_GAP)
        to_date = start_date + datetime.timedelta(days=1)
    else:  #other days
        from_date = now.replace(hour=0, minute=0, second=0,
                                microsecond=0) - datetime.timedelta(days=day)
        to_date = from_date + datetime.timedelta(days=1)
        start_date = from_date

    epg = utils.call(
        sl, lambda: sl.epg([{
            'stationid': stationid
        }], from_date, to_date, False))

    xbmcplugin.setPluginCategory(
        _handle,
        _addon.getLocalizedString(30600) + ' / ' + channel)
    if day < 6 or (day == 6
                   and time_until_end_of_day(now).seconds > REPLAY_LAST_GAP):
        list_item = xbmcgui.ListItem(label=_addon.getLocalizedString(30604))
        list_item.setArt({'icon': 'DefaultVideoPlaylists.png'})
        link = get_url(replay='programs',
                       stationid=stationid,
                       channel=channel,
                       day=day + 1)
        is_folder = True
        xbmcplugin.addDirectoryItem(_handle, link, list_item, is_folder)
    if epg:
        for program in epg[0][stationid]:
            start = datetime.datetime.fromtimestamp(program['start'])
            show_item = (
                start.replace(hour=0, minute=0, second=0, microsecond=0) -
                start_date).days == 0  #started today
            if today:
                show_item = show_item and (start + datetime.timedelta(
                    minutes=program['duration'] + REPLAY_GAP) < now)
            if lastday:
                show_item = show_item and (
                    start > then and (start - then).seconds > REPLAY_LAST_GAP)
            if show_item:
                title = utils.dec_utf8(start.strftime('%H:%M'))
                title = title[1:] if title.startswith('0') else title
                title = title + ' - ' + program['title']
                list_item = xbmcgui.ListItem(label=title)
                list_item.setInfo(
                    'video', {
                        'title': program['title'],
                        'duration': program['duration'] * 60
                    })
                if 'cover' in program:
                    list_item.setArt({
                        'thumb': program['cover'],
                        'icon': program['cover']
                    })

                link = get_url(replay='replay', locId=program['locId'])
                is_folder = False
                list_item.setProperty('IsPlayable', 'true')
                xbmcplugin.addDirectoryItem(_handle, link, list_item,
                                            is_folder)
    if day > 0:
        list_item = xbmcgui.ListItem(label=_addon.getLocalizedString(30603))
        list_item.setArt({'icon': 'DefaultVideoPlaylists.png'})
        link = get_url(replay='programs',
                       stationid=stationid,
                       channel=channel,
                       day=day - 1)
        is_folder = True
        xbmcplugin.addDirectoryItem(_handle, link, list_item, is_folder)

    xbmcplugin.endOfDirectory(_handle, updateListing=not first)