Beispiel #1
0
def list_epg_item(pid, SESSION):
    url = 'http://zattoo.com/zapi/program/details?program_id=%s&complete=True' % pid
    json_data = get_json_data(url, SESSION)
    program_info = json.loads(json_data)['program']
    channel_name = program_info['channel_name'].encode('utf-8')
    cid = program_info['cid']
    countries = program_info['country'].replace('|', ', ').encode('utf-8')
    genres = ', '.join(program_info['genres']).encode('utf-8')
    categories = ', '.join(program_info['categories']).encode('utf-8')
    directors = ', '.join([
        d['person'] for d in program_info['credits'] if d['role'] == 'director'
    ]).encode('utf-8')
    actors = ', '.join([
        a['person'] for a in program_info['credits'] if a['role'] == 'actor'
    ]).encode('utf-8')
    desc = program_info['description'].encode('utf-8')
    subtitle = (program_info['episode_title'] or '').encode('utf-8')
    thumb = program_info['image_url']
    title = program_info['title'].encode('utf-8')
    if subtitle:
        title = '%s: %s' % (title, subtitle)
    year = program_info['year']
    text = ''
    if desc:
        text += '[COLOR blue]Plot:[/COLOR] %s\n\n' % desc
    if categories:
        text += '[COLOR blue]Kategorien:[/COLOR] %s' % categories
    if genres:
        text += '\n[COLOR blue]Genre:[/COLOR] %s' % genres
    if countries:
        text += '\n[COLOR blue]Produktionsland:[/COLOR] %s' % countries
    if directors:
        text += '\n[COLOR blue]Direktoren:[/COLOR] %s' % directors
    if actors:
        text += '\n[COLOR blue]Schauspieler:[/COLOR] %s' % actors

    if text:
        title = '[B][COLOR blue]%s[/COLOR][/B] %s' % (channel_name, title)
        if year:
            title = '%s (%i)' % (title, year)
        window = pyxbmct.AddonDialogWindow(title)
        window.connect(pyxbmct.ACTION_NAV_BACK, window.close)
        window.setGeometry(1000, 700, 1, 1)
        box = pyxbmct.TextBox()
        window.placeControl(box, 0, 0)
        box.setText(text)
        window.doModal()
        del window
Beispiel #2
0
def list_epg_item(pid, SESSION):
    url = 'http://zattoo.com/zapi/program/details?program_id=%s&complete=True' % pid
    json_data = get_json_data(url, SESSION)
    program_info = json.loads(json_data)['program']
    channel_name = program_info['channel_name'].encode('utf-8')
    cid = program_info['cid']
    countries = program_info['country'].replace('|',', ').encode('utf-8')
    genres = ', '.join(program_info['genres']).encode('utf-8')
    categories = ', '.join(program_info['categories']).encode('utf-8')
    directors = ', '.join([d['person'] for d in program_info['credits'] if d['role'] == 'director']).encode('utf-8')
    actors = ', '.join([a['person'] for a in program_info['credits'] if a['role'] == 'actor']).encode('utf-8')
    desc = program_info['description'].encode('utf-8')
    subtitle = (program_info['episode_title'] or '').encode('utf-8')
    thumb = program_info['image_url']
    title = program_info['title'].encode('utf-8')
    if subtitle:
        title = '%s: %s' % (title, subtitle)
    year = program_info['year']   
    text = ''
    if desc:
        text += '[COLOR blue]Plot:[/COLOR] %s\n\n' % desc
    if categories:
        text += '[COLOR blue]Kategorien:[/COLOR] %s' % categories
    if genres:
        text += '\n[COLOR blue]Genre:[/COLOR] %s' % genres
    if countries:
        text += '\n[COLOR blue]Produktionsland:[/COLOR] %s' % countries
    if directors:
        text += '\n[COLOR blue]Direktoren:[/COLOR] %s' % directors
    if actors:
        text += '\n[COLOR blue]Schauspieler:[/COLOR] %s' % actors
        
    if text:
        title = '[B][COLOR blue]%s[/COLOR][/B] %s' % (channel_name, title)
        if year:
            title = '%s (%i)' % (title, year)
        window = pyxbmct.AddonDialogWindow(title)
        window.connect(pyxbmct.ACTION_NAV_BACK, window.close)
        window.setGeometry(1000, 700, 1, 1)
        box = pyxbmct.TextBox()
        window.placeControl(box, 0, 0)
        box.setText(text)
        window.doModal()
        del window
Beispiel #3
0
def list_channels(session, pg_hash, USE_FANARTS = False):
    if not pg_hash or not session:
        from resources.lib.api import login
        login()
        import xbmcaddon
        addon = xbmcaddon.Addon(id = 'plugin.video.zattoo_com')
        pg_hash = addon.getSetting('pg_hash')
        session = addon.getSetting('session')
    try:
        json_data = json.loads(get_json_data('https://zattoo.com/zapi/v2/cached/channels/%s?details=True' % pg_hash, session))
    except urllib2.HTTPError:
        from resources.lib.api import login
        login()
        import xbmcaddon
        addon = xbmcaddon.Addon(id = 'plugin.video.zattoo_com')
        pg_hash = addon.getSetting('pg_hash')
        session = addon.getSetting('session')
        json_data = json.loads(get_json_data('https://zattoo.com/zapi/v2/cached/channels/%s?details=True' % pg_hash, session))
    except urllib2.URLError:
        from resources.lib.functions import warning
        warning('Keine Netzwerkverbindung!')
        return
    except:
        from resources.lib.functions import warning
        warning('TV Daten konnten nicht geladen werden!')
        return
    
    channel_groups = json_data['channel_groups']#[:3]
    current_timestamp = int(time.time())
    
    for group in channel_groups:
        for channel in group['channels']:
            for quality in channel['qualities']:
                if quality['availability'] == 'available':
                    channel_name = quality['title']
                    id = channel['cid']
                    thumb = 'http://thumb.zattic.com/%s/500x288.jpg?r=%i' % (id, current_timestamp)
                    try:
                        title = channel['now']['t']
                        subtitle = channel['now']['et']
                        if subtitle:
                            title = '%s: %s' % (title, subtitle)
                    except:
                        title = ''
                    item = xbmcgui.ListItem('[B][COLOR blue]%s[/COLOR][/B] %s' % (channel_name, title), thumbnailImage=thumb)
                    try:
                        duration_in_seconds = round_seconds(channel['now']['e'] - current_timestamp)
                    except:
                        duration_in_seconds = 0
                    try:
                        next = '[B][COLOR blue]Danach:[/COLOR][/B] %s (%i Min.)' % (
                                channel['next']['t'], (channel['next']['e'] - channel['next']['s']) / 60)
                        item.addContextMenuItems(
                            [('EPG Daten laden', 'xbmc.RunPlugin(plugin://plugin.video.zattoo_com/?mode=epg&id=%s)' % channel['now']['id'])]
                        )
                    except:
                        next = ''
                    if USE_FANARTS:
                        try:
                            fanart = channel['now']['i'].replace('format_480x360.jpg', 'format_1280x720.jpg')
                        except:
                            fanart = 'http://thumb.zattic.com/%s/1280x720.jpg' % id
                        item.setProperty('fanart_image', fanart)
                    item.setInfo(type='Video', infoLabels={
                        'Title': title or channel_name,
                        'Plot': next,
                        }
                    )
                    item.addStreamInfo('video', {'duration': duration_in_seconds})
                    item.setProperty('IsPlayable', 'true')
                    xbmcplugin.addDirectoryItem(handle=ADDON_HANDLE, url='%s?mode=watch&id=%s' % (URI, id), listitem=item)
                    break
    xbmcplugin.endOfDirectory(ADDON_HANDLE)
Beispiel #4
0
def get_playlist_url(cid, SESSION):
    from resources.lib.api import get_json_data
    json_data = get_json_data('https://zattoo.com/zapi/watch', SESSION, {'stream_type':'hls', 'cid':cid})
    return json.loads(json_data)['stream']['url']
Beispiel #5
0
def get_playlist_url(cid, SESSION):
    from resources.lib.api import get_json_data
    json_data = get_json_data('http://zattoo.com/zapi/watch', SESSION, {'stream_type':'hls', 'cid':cid})
    return json.loads(json_data)['stream']['url']
Beispiel #6
0
def list_channels(session, pg_hash, USE_FANARTS = False):
    if not pg_hash or not session:
        from resources.lib.api import login
        login()
        import xbmcaddon
        addon = xbmcaddon.Addon(id = 'plugin.video.zattoo_com')
        pg_hash = addon.getSetting('pg_hash')
        session = addon.getSetting('session')
    try:
        json_data = json.loads(get_json_data('http://zattoo.com/zapi/v2/cached/channels/%s?details=True' % pg_hash, session))
    except urllib2.HTTPError:
        from resources.lib.api import login
        login()
        import xbmcaddon
        addon = xbmcaddon.Addon(id = 'plugin.video.zattoo_com')
        pg_hash = addon.getSetting('pg_hash')
        session = addon.getSetting('session')
        json_data = json.loads(get_json_data('http://zattoo.com/zapi/v2/cached/channels/%s?details=True' % pg_hash, session))
    except urllib2.URLError:
        from resources.lib.functions import warning
        warning('Keine Netzwerkverbindung!')
        return
    except:
        from resources.lib.functions import warning
        warning('TV Daten konnten nicht geladen werden!')
        return
    
    channel_groups = json_data['channel_groups']#[:3]
    current_timestamp = int(time.time())
    
    for group in channel_groups:
        for channel in group['channels']:
            for quality in channel['qualities']:
                if quality['availability'] == 'available':
                    channel_name = quality['title']
                    id = channel['cid']
                    thumb = 'http://thumb.zattic.com/%s/500x288.jpg?r=%i' % (id, current_timestamp)
                    try:
                        title = channel['now']['t']
                        subtitle = channel['now']['et']
                        if subtitle:
                            title = '%s: %s' % (title, subtitle)
                    except:
                        title = ''
                    item = xbmcgui.ListItem('[B][COLOR blue]%s[/COLOR][/B] %s' % (channel_name, title), thumbnailImage=thumb)
                    try:
                        duration_in_seconds = round_seconds(channel['now']['e'] - current_timestamp)
                    except:
                        duration_in_seconds = 0
                    try:
                        next = '[B][COLOR blue]Danach:[/COLOR][/B] %s (%i Min.)' % (
                                channel['next']['t'], (channel['next']['e'] - channel['next']['s']) / 60)
                        item.addContextMenuItems(
                            [('EPG Daten laden', 'xbmc.RunPlugin(plugin://plugin.video.zattoo_com/?mode=epg&id=%s)' % channel['now']['id'])]
                        )
                    except:
                        next = ''
                    if USE_FANARTS:
                        try:
                            fanart = channel['now']['i'].replace('format_480x360.jpg', 'format_1280x720.jpg')
                        except:
                            fanart = 'http://thumb.zattic.com/%s/1280x720.jpg' % id
                        item.setProperty('fanart_image', fanart)
                    item.setInfo(type='Video', infoLabels={
                        'Title': title or channel_name,
                        'Plot': next,
                        }
                    )
                    item.addStreamInfo('video', {'duration': duration_in_seconds})
                    item.setProperty('IsPlayable', 'true')
                    xbmcplugin.addDirectoryItem(handle=ADDON_HANDLE, url='%s?mode=watch&id=%s' % (URI, id), listitem=item)
                    break
    xbmcplugin.endOfDirectory(ADDON_HANDLE)