Exemple #1
0
def login():
    USER_NAME = addon.getSetting('username')
    PASSWORD = addon.getSetting('password')
    if not USER_NAME or not PASSWORD:
        from resources.lib.functions import warning
        return warning('Bitte Benutzerdaten eingeben!', exit = True)
    handshake_cookie = get_session_cookie()
    try:
        login_json_data = get_json_data('https://zattoo.com/zapi/account/login', handshake_cookie, {'login': USER_NAME, 'password': PASSWORD})
    except urllib2.HTTPError:
        from resources.lib.functions import warning
        return warning('Falsche Logindaten!', exit = True)        
    import json
    pg_hash = json.loads(login_json_data)['account']['power_guide_hash']
    update_pg_hash(pg_hash)
    
    
Exemple #2
0
def get_app_token():
    try:
        html = urllib2.urlopen('http://zattoo.com/').read()
        return search("window\.appToken\s*=\s*'(.*)'", html).group(1)
    except urllib2.URLError:
        from resources.lib.functions import warning
        return warning('Keine Netzwerkverbindung!', exit = True)
    except:
        return ''
Exemple #3
0
def get_app_token():
    try:
        html = urllib2.urlopen('https://zattoo.com/').read()
        return search("window\.appToken\s*=\s*'(.*)'", html).group(1)
    except urllib2.URLError:
        from resources.lib.functions import warning
        return warning('Keine Netzwerkverbindung!', exit=True)
    except:
        return ''
Exemple #4
0
def login():
    USER_NAME = addon.getSetting('username')
    PASSWORD = addon.getSetting('password')
    if not USER_NAME or not PASSWORD:
        from resources.lib.functions import warning
        return warning('Bitte Benutzerdaten eingeben!', exit=True)
    handshake_cookie = get_session_cookie()
    try:
        login_json_data = get_json_data(
            'https://zattoo.com/zapi/v2/account/login', handshake_cookie, {
                'login': USER_NAME,
                'password': PASSWORD
            })
    except urllib2.HTTPError:
        from resources.lib.functions import warning
        return warning('Falsche Logindaten!', exit=True)
    import json
    pg_hash = json.loads(login_json_data)['session']['power_guide_hash']
    update_pg_hash(pg_hash)
Exemple #5
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)
Exemple #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)