Esempio n. 1
0
def add_or_remove(video_id, is_add):
    root_list = get_root_list()

    my_list = get_mylist(root_list)[0]
    auth = generic_utility.get_setting('authorization_url')
    track_id = get.track_id_list(my_list)

    if is_add:
        add_or_remove_str = 'addToList'
        add_or_remove_msg = 'added'
    else:
        add_or_remove_str = 'removeFromList'
        add_or_remove_msg = 'removed'

    post = ('{"callPath":["lolomos","%s","%s"],"params":["%s",2,["videos",%s],%s,null,null],' +
            '"authURL":"%s"}') % (root_list, add_or_remove_str, my_list, video_id, track_id, auth)

    content = connect.load_netflix_site(generic_utility.evaluator()+'&method=call', post, options=True)

    jsn = json.loads(content)

    generic_utility.log('mylist: '+my_list)
    generic_utility.log(str(jsn))
    if '"invalidated"' in content:
        generic_utility.notification('Successfully '+add_or_remove_msg)
    elif 'already exists' in content:
        generic_utility.notification('already exists')

    generic_utility.debug('add to mylist content: '+content)
Esempio n. 2
0
def cache():
    try:
        xbmcvfs.rmdir(generic_utility.cache_dir(), force=True)
        generic_utility.log('Cache folder deleted.')
        generic_utility.notification(generic_utility.get_string(30309))
    except Exception:
        pass
def get_root_list_id_from_cookie():
    from resources import connect
    profile = generic_utility.get_setting('selected_profile')

    session = connect.get_netflix_session(False)

    root_list_id = None
    if not profile:
        generic_utility.log('kein profil!')
        for cur_cookie in session.cookies:
            if 'lhpuuidh-browse-' in cur_cookie.name:
#                generic_utility.log('found cookie: '+cur_cookie.value)
                root_list_id = cur_cookie.value
                break
            elif 'lhpuuid-kid-' in cur_cookie.name:
                root_list_id = cur_cookie.value
    else:
        for cur_cookie in session.cookies:
            if 'lhpuuidh-browse-'+profile in cur_cookie.name:
                root_list_id = cur_cookie.value
                break
            elif 'lhpuuid-kid-'+profile in cur_cookie.name:
                root_list_id = cur_cookie.value

    if not root_list_id:
        raise ValueError('root_list_id not found in cookies!')

    splt = root_list_id.split('%3A')
    if(len(splt) != 3):
        raise ValueError('Invalid split: '+root_list_id)

#    generic_utility.log('root: '+str(splt[2]))
    return splt[2]
Esempio n. 4
0
def get_root_list_id_from_cookie():
    from resources import connect
    profile = generic_utility.get_setting('selected_profile')

    session = connect.get_netflix_session(False)

    root_list_id = None
    if not profile:
        generic_utility.log('kein profil!')
        for cur_cookie in session.cookies:
            if 'lhpuuidh-browse-' in cur_cookie.name:
                #                generic_utility.log('found cookie: '+cur_cookie.value)
                root_list_id = cur_cookie.value
                break
            elif 'lhpuuid-kid-' in cur_cookie.name:
                root_list_id = cur_cookie.value
    else:
        for cur_cookie in session.cookies:
            if 'lhpuuidh-browse-' + profile in cur_cookie.name:
                root_list_id = cur_cookie.value
                break
            elif 'lhpuuid-kid-' + profile in cur_cookie.name:
                root_list_id = cur_cookie.value

    if not root_list_id:
        raise ValueError('root_list_id not found in cookies!')

    splt = root_list_id.split('%3A')
    if (len(splt) != 3):
        raise ValueError('Invalid split: ' + root_list_id)


#    generic_utility.log('root: '+str(splt[2]))
    return splt[2]
Esempio n. 5
0
    def playInternal(self, video_id, series_id):
        xbmc.audioSuspend()
        self.disable_screensaver()

        if generic_utility.get_setting('disable_lirc') == 'true':
            xbmc.executebuiltin('LIRC.Stop')

        try:
            self.launch_browser('http://netflix.com/watch/%s' % video_id)
        except:
            generic_utility.log(traceback.format_exc(), xbmc.LOGERROR)
            generic_utility.notification(
                'Error launching browser. See logfile')

        self.enable_screensaver()
        xbmc.audioResume()
        if generic_utility.get_setting('disable_lirc') == 'true':
            xbmc.executebuiltin('LIRC.Start')
        try:
            self.update_playcount(video_id)
        except:
            generic_utility.log(traceback.format_exc(), xbmc.LOGERROR)
            generic_utility.notification(
                'Cannot update playcount. See logfile')
        self.close()
def clear_netflix_cookies(conn):
    try:
        sql = 'DELETE FROM cookies where host_key = ?'
        cur = conn.cursor()
        cur.execute(sql, ('.netflix.com',))
        conn.commit()
    except: generic_utility.log('Error clearing Chrome-Cookie: ' +traceback.format_exc(), xbmc.LOGERROR)
    def get_launch_script(self, type):
        path = addon_path + '/resources/scripts/' + type + '/'
        browser_name = None
        double_quotes = ''
        bash = ''
        if generic_utility.windows():
            path += 'windows/'
            ending = '.cmd'
            double_quotes = '"'
        elif generic_utility.darwin():
            path += 'darwin/'
            ending = '.sh'
            bash = 'sh '
        else:
            path += 'linux/'
            ending = '.sh'
            bash = 'sh '
        browser_name = self.get_browser_scriptname(browser_name)

        script = path + browser_name + ending
        custom_script = path + browser_name + "_custom" + ending

        if generic_utility.windows():
            script = script.replace('/', '\\')
            custom_script = custom_script.replace('/', '\\')

        if os.path.isfile(custom_script):
            script = custom_script
        elif not os.path.isfile(script):
            generic_utility.log('Script: ' + script + ' not found!')
            script = ''
        return bash + double_quotes + script + double_quotes
Esempio n. 8
0
def choose():
    profiles = []
    content = connect.load_netflix_site(generic_utility.profile_url)
    #    generic_utility.log('choose: '+content)
    match = json.loads(content)['profiles']
    for item in match:
        profile = {
            'name': item['firstName'],
            'token': item['guid'],
            'is_kid': item['experience'] == 'jfk'
        }
        profiles.append(profile)
    if len(match) > 0:
        dialog = xbmcgui.Dialog()
        nr = dialog.select(generic_utility.get_string(30103),
                           [profile['name'] for profile in profiles])
        if nr >= 0:
            selected_profile = profiles[nr]
        else:
            selected_profile = profiles[0]

        switch_profile(selected_profile['token'])

        generic_utility.set_setting('selected_profile',
                                    selected_profile['token'])
        generic_utility.set_setting(
            'is_kid', 'true' if selected_profile['is_kid'] else 'false')
        generic_utility.set_setting('profile_name', selected_profile['name'])
    else:
        generic_utility.log('Choose profile: no profiles were found!',
                            loglevel=xbmc.LOGERROR)
Esempio n. 9
0
def load():
    profile_id = generic_utility.get_setting('selected_profile')
    if profile_id:
        switch_profile(profile_id)
    else:
        generic_utility.log('Load profile: no stored profile found!',
                            loglevel=xbmc.LOGERROR)
Esempio n. 10
0
    def get_launch_script(self, type):
        path = addon_path + '/resources/scripts/'+type+'/'
        browser_name = None
        double_quotes=''
        bash = ''
        if generic_utility.windows():
            path += 'windows/'
            ending = '.cmd'
            double_quotes = '"'
        elif generic_utility.darwin():
            path += 'darwin/'
            ending = '.sh'
            bash = 'sh '
        else:
            path += 'linux/'
            ending = '.sh'
            bash = 'sh '
        browser_name = self.get_browser_scriptname(browser_name)

        script = path+browser_name+ending
        custom_script = path+browser_name+"_custom"+ending
		
        if generic_utility.windows():
            script = script.replace('/','\\')
            custom_script = custom_script.replace('/','\\')
        
        if os.path.isfile(custom_script):
            script = custom_script
        elif not os.path.isfile(script):
            generic_utility.log('Script: '+script+' not found!')
            script = ''
        return bash + double_quotes+script+double_quotes
Esempio n. 11
0
    def onAction(self, action):
        ACTION_NAV_BACK = 92
        ACTION_PREVIOUS_MENU = 10
        ACTION_STOP = 13

        ACTION_SELECT_ITEM = 7
        ACTION_PLAYER_PLAY = 79
        ACTION_PLAYER_PLAYPAUSE = 229
        ACTION_PAUSE = 12

        ACTION_PLAYER_REWIND = 78
        ACTION_MOVE_LEFT = 1
        ACTION_REWIND = 17

        ACTION_PLAYER_FORWARD = 77
        ACTION_MOVE_RIGHT = 2
        ACTION_FORWARD = 16

        ACTION_MOVE_UP = 3
        ACTION_MOVE_DOWN = 4

        if action.getId() in(ACTION_NAV_BACK, ACTION_PREVIOUS_MENU, ACTION_STOP):
            self.control('close')
        elif action.getId() in(ACTION_SELECT_ITEM, ACTION_PLAYER_PLAY, ACTION_PLAYER_PLAYPAUSE, ACTION_PAUSE):
            self.control('pause')
        elif action.getId() in(ACTION_PLAYER_REWIND, ACTION_MOVE_LEFT, ACTION_REWIND):
            self.control('backward')
        elif action.getId() in(ACTION_PLAYER_FORWARD, ACTION_MOVE_RIGHT, ACTION_FORWARD):
            self.control('forward')
        elif action.getId() == ACTION_MOVE_UP:
            self.control('up')
        elif action.getId() == ACTION_MOVE_DOWN:
            self.control('down')
        else:
            generic_utility.log('unknown action: ' + str(action.getId()))
Esempio n. 12
0
    def playInternal (self, video_id, series_id):
        xbmc.audioSuspend()
        self.disable_screensaver()

        if generic_utility.get_setting('disable_lirc') == 'true':
            xbmc.executebuiltin('LIRC.Stop')

        try:
            self.launch_browser('http://netflix.com/watch/%s' % video_id)
        except:
            generic_utility.log(traceback.format_exc(), xbmc.LOGERROR)
            generic_utility.notification('Error launching browser. See logfile')

        self.enable_screensaver()
        xbmc.audioResume()
        if generic_utility.get_setting('disable_lirc') == 'true':
            xbmc.executebuiltin('LIRC.Start')

        if generic_utility.get_setting('sync_viewstate') == 'true':
            try:
                self.update_playcount(video_id)
            except:
                generic_utility.log(traceback.format_exc(), xbmc.LOGERROR)
                generic_utility.notification('Cannot update playcount. See logfile')
        self.close()
def load_match(thread_id, lock, rets, metadata, is_episode = False, viewing_activity = False):
#    utility.log('loading '+unicode(video_id))
    ret = None

    custom_title = None
    series_title = None
    if viewing_activity==True:
        video_id = metadata['id']
        custom_title = metadata['title']
        series_title = metadata['series_title']
    else:
        video_id = metadata
    success = False
    while (success == False):
        try:
            ret = video(video_id, is_episode, lock, custom_title = custom_title, series_title = series_title)
            success = True
        except requests.exceptions.HTTPError, e:
            if e.response.status_code == 429:
                time.sleep(2)
            else:
                generic_utility.log('error loading video ' + unicode(video_id) + '\n' + traceback.format_exc(), xbmc.LOGERROR)
                break
        except Exception as e:
            generic_utility.log('error loading video ' + unicode(video_id) + '\n' + traceback.format_exc(), xbmc.LOGERROR)
            break
Esempio n. 14
0
def cache():
    try:
        xbmcvfs.rmdir(generic_utility.cache_dir(), force=True)
        generic_utility.log('Cache folder deleted.')
        generic_utility.notification(generic_utility.get_string(30309))
    except Exception:
        pass
def load_match(thread_id, lock, rets, metadata, viewing_activity=False):
    #    utility.log('loading '+unicode(video_id))
    ret = None

    custom_title = None
    series_title = None
    if viewing_activity == True:
        video_id = metadata['id']
        custom_title = metadata['title']
        series_title = metadata['series_title']
    else:
        video_id = metadata
    success = False
    while (success == False):
        try:
            ret = video(video_id,
                        lock,
                        custom_title=custom_title,
                        series_title=series_title)
            success = True
        except requests.exceptions.HTTPError, e:
            if e.response.status_code == 429:
                time.sleep(2)
            else:
                generic_utility.log(
                    'error loading video ' + unicode(video_id) + '\n' +
                    traceback.format_exc(), xbmc.LOGERROR)
                break
        except Exception as e:
            generic_utility.log(
                'error loading video ' + unicode(video_id) + '\n' +
                traceback.format_exc(), xbmc.LOGERROR)
            break
Esempio n. 16
0
def add_series(series_id, series_title, season, single_update=True):
    series_file = get_series_dir(series_title)
    if not xbmcvfs.exists(series_file+os.sep):
        xbmcvfs.mkdir(series_file+os.sep)
    content = get.series_info(series_id)
    generic_utility.log(str(content))
    content = json.loads(content)['video']['seasons']
    for test in content:
        episode_season = unicode(test['seq'])
        if episode_season == season or season == '':
            season_dir = generic_utility.create_pathname(series_file.decode('utf-8'), test['title'])
            if not xbmcvfs.exists(season_dir+os.sep):
                xbmcvfs.mkdir(season_dir+os.sep)
            for item in test['episodes']:
                episode_id = unicode(item['episodeId'])
                episode_nr = unicode(item['seq'])
                episode_title = item['title']
                if len(episode_nr) == 1:
                    episode_nr = '0' + episode_nr
                season_nr = episode_season
                if len(season_nr) == 1:
                    season_nr = '0' + season_nr
                filename = 'S' + season_nr + 'E' + episode_nr + ' - ' + episode_title + '.V' + episode_id + 'V'+ '.strm'
                filename = generic_utility.clean_filename(filename, ' .')
                file_handler = xbmcvfs.File(generic_utility.create_pathname(season_dir, filename), 'w')
                file_handler.write(
                    generic_utility.encode('plugin://%s/?mode=play_video&url=%s' % (
                    generic_utility.addon_id, episode_id)))
                file_handler.close()
    if generic_utility.get_setting('update_db') and single_update:
        xbmc.executebuiltin('UpdateLibrary(video)')
Esempio n. 17
0
def addon():
    dialog = xbmcgui.Dialog()
    if dialog.yesno(generic_utility.addon_name + ':', generic_utility.get_string(30307)):
        try:
            xbmcvfs.rmdir(generic_utility.data_dir(), force=True)
            generic_utility.log('Addon userdata folder deleted.')
            generic_utility.notification(generic_utility.get_string(30308))
        except Exception:
            pass
Esempio n. 18
0
def addon():
    dialog = xbmcgui.Dialog()
    if dialog.yesno(generic_utility.addon_name + ':',
                    generic_utility.get_string(30307)):
        try:
            xbmcvfs.rmdir(generic_utility.data_dir(), force=True)
            generic_utility.log('Addon userdata folder deleted.')
            generic_utility.notification(generic_utility.get_string(30308))
        except Exception:
            pass
def clear_netflix_cookies(conn):
    try:
        sql = 'DELETE FROM cookies where host_key = ?'
        cur = conn.cursor()
        cur.execute(sql, ('.netflix.com', ))
        conn.commit()
    except:
        generic_utility.log(
            'Error clearing Chrome-Cookie: ' + traceback.format_exc(),
            xbmc.LOGERROR)
Esempio n. 20
0
def read_headers():
    if test == False:
        headers_file = generic_utility.headers_file()
    else:
        headers_file = 'headers'
    content = file_utility.read(headers_file)
    if len(content) > 0:
        return pickle.loads(content)
    else:
        generic_utility.log('warning, read empty headers-file')
        return None
Esempio n. 21
0
def read_headers():
    if test == False:
        headers_file = generic_utility.headers_file()
    else:
        headers_file = 'headers'
    content = file_utility.read(headers_file)
    if len(content) > 0:
        return pickle.loads(content)
    else:
        generic_utility.log('warning, read empty headers-file')
        return None
Esempio n. 22
0
def read_cookies():
    if test == False:
        file_name = generic_utility.cookies_file()
    else:
        file_name = 'cookies'
    content = file_utility.read(file_name)
    if len(content) > 0:
        return requests.utils.cookiejar_from_dict(pickle.loads(content))
    else:
        generic_utility.log('warning, read empty cookies-file')
        return None
Esempio n. 23
0
def read_cookies():
    if test == False:
        file_name = generic_utility.cookies_file()
    else:
        file_name = 'cookies'
    content = file_utility.read(file_name)
    if len(content) > 0:
        return requests.utils.cookiejar_from_dict(pickle.loads(content))
    else:
        generic_utility.log('warning, read empty cookies-file')
        return None
def parse_duration_playcount(match):
    duration = get_value(match, 'runtime', 0)

    playcount = 0
    try:
        offset = match['bookmarkPosition']
#        generic_utility.log('duration: ' + str(duration)+' offset: '+str(offset))
        if (duration > 0 and float(offset) / float(duration)) >= 0.8:
            playcount = 1
    except Exception:
        generic_utility.log('cannot parse playcount. match: '+str(match))
        pass
    return duration, playcount
def parse_duration_playcount(match):
    duration = get_value(match, 'runtime', 0)

    playcount = 0
    try:
        offset = match['bookmarkPosition']
        #        generic_utility.log('duration: ' + str(duration)+' offset: '+str(offset))
        if (duration > 0 and float(offset) / float(duration)) >= 0.8:
            playcount = 1
    except Exception:
        generic_utility.log('cannot parse playcount. match: ' + str(match))
        pass
    return duration, playcount
Esempio n. 26
0
def add_movie(movie_id, title, single_update=True):
    generic_utility.log(title)
    movie_dir, title = get_movie_dir(title)
    if not xbmcvfs.exists(movie_dir+os.sep):
        xbmcvfs.mkdir(movie_dir+os.sep)

    movie_file = generic_utility.clean_filename(title + '.V' + movie_id + 'V' + '.strm', ' .').strip(' .')
    file_handler = xbmcvfs.File(generic_utility.create_pathname(movie_dir.decode('utf-8'), movie_file), 'w')
    file_handler.write(
        generic_utility.encode('plugin://%s/?mode=play_video&url=%s' % (generic_utility.addon_id, movie_id)))
    file_handler.close()
    if generic_utility.get_setting('update_db') and single_update:
        xbmc.executebuiltin('UpdateLibrary(video)')
Esempio n. 27
0
def load_tmdb_cover_fanart(title, video_id, video_type_temp, year):
    year_temp = year
    title_temp = title
    if ' - ' in title_temp:
        title_temp = title_temp[title_temp.index(' - '):]
    filename = video_id + '.jpg'
    filename_none = video_id + '.none'
    cover_file = xbmc.translatePath(generic_utility.cover_cache_dir() + filename)
    cover_file_none = xbmc.translatePath(generic_utility.cover_cache_dir() + filename_none)
    if not (xbmcvfs.exists(cover_file) or xbmcvfs.exists(cover_file_none)):
        generic_utility.log('Downloading cover art. type: %s, video_id: %s, title: %s, year: %s' % (video_type_temp,
                                                                                                    video_id, title_temp,
                                                                                                    year_temp), xbmc.LOGDEBUG)
        get.cover_and_fanart(video_type_temp, video_id, title_temp, year_temp)
Esempio n. 28
0
def read_cookies():
    if not test:
        file_name = generic_utility.cookies_file()
    else:
        file_name = 'cookies'
    content = file_utility.read(file_name)
    if len(content) > 0:
        loaded = pickle.loads(content)
        if type(loaded) == requests.cookies.RequestsCookieJar:
            return loaded
        else:
            return None
    else:
        generic_utility.log('warning, read empty cookies-file')
        return None
Esempio n. 29
0
def read_cookies():
    if not test:
        file_name = generic_utility.cookies_file()
    else:
        file_name = 'cookies'
    content = file_utility.read(file_name)
    if len(content) > 0:
        loaded = pickle.loads(content)
        if type(loaded) == requests.cookies.RequestsCookieJar:
            return loaded
        else:
            return None
    else:
        generic_utility.log('warning, read empty cookies-file')
        return None
Esempio n. 30
0
def update_playcount(video_id, playcount, conn = None):
    should_close = False
    if conn == None:
        conn = get_connection()
        should_close = True
    id_file = get_file_id(conn, video_id)
    if id_file:
        c = conn.cursor()
        c.execute('UPDATE files SET playCount=? WHERE idFile = ?', (None if playcount == 0 else playcount, id_file))
        c.close()

    if should_close:
        generic_utility.log('close it!')
        conn.commit()
        conn.close()
Esempio n. 31
0
def update_playcount(video_id, playcount, conn=None):
    should_close = False
    if conn == None:
        conn = get_connection()
        should_close = True
    id_file = get_file_id(conn, video_id)
    if id_file:
        c = conn.cursor()
        c.execute('UPDATE files SET playCount=? WHERE idFile = ?',
                  (None if playcount == 0 else playcount, id_file))
        c.close()

    if should_close:
        generic_utility.log('close it!')
        conn.commit()
        conn.close()
def set_netflix_cookies(cookies):
    try:
        conn = connect()

        for cookie in cookies:
            expires = cookie.expires
            if(expires == None):
                expires_date = datetime.datetime.now() + datetime.timedelta(days=5)
            else:
                expires_date = datetime.datetime.utcfromtimestamp(expires)
            set_cookie(conn, cookie.name, cookie.value, expires_date)

        conn.commit()
        conn.close()
    except Exception as e:
        generic_utility.log('Error setting Chrome-Cookie: ' +traceback.format_exc(), xbmc.LOGERROR)
def parse_duration_playcount(match):
    duration = get_value(match, 'runtime', 0)
    playcount = 0

    offset = get_value(match, 'bookmarkPosition', None)
    watched = get_value(match, 'watched', None)

    try:
        if offset:
            if (duration > 0 and duration > 0 and float(offset) / float(duration)) >= 0.8:
                playcount = 1
        elif watched:
            playcount = 1
    except Exception:
        generic_utility.log('cannot parse playcount. match: '+str(match))
    return duration, playcount
Esempio n. 34
0
def set_netflix_cookies(cookies):
    try:
        conn = connect()
        generic_utility.log('cookies: '+str(cookies))
        clear_netflix_cookies(conn)
        for cookie in cookies:
            expires = cookie.expires
            if not expires:
                expires_date = datetime.datetime.now() + datetime.timedelta(days=5)
            else:
                expires_date = datetime.datetime.utcfromtimestamp(expires)
            set_cookie(conn, cookie.name, cookie.value, expires_date)

        conn.commit()
        conn.close()
    except Exception as e:
        generic_utility.log('Error setting Chrome-Cookie: ' +traceback.format_exc(), xbmc.LOGERROR)
Esempio n. 35
0
def parse_duration_playcount(match):
    duration = get_value(match, 'runtime', 0)

    playcount = 0

    offset = get_value(match, 'bookmarkPosition', None)
    watched = get_value(match, 'watched', None)

    try:
        if offset:
            if (duration > 0 and duration > 0 and float(offset) / float(duration)) >= 0.8:
                playcount = 1
        elif watched:
            playcount = 1
    except Exception:
        generic_utility.log('cannot parse playcount. match: '+str(match))
    return duration, playcount
Esempio n. 36
0
    def playInternal (self, video_id, series_id):
        xbmc.audioSuspend()
        self.disable_screensaver()

        try:
            self.launch_browser('https://www.netflix.com/watch/%s' % video_id)
        except:
            generic_utility.log(traceback.format_exc(), xbmc.LOGERROR)
            generic_utility.notification('Error launching browser. See logfile')

        self.enable_screensaver()
        xbmc.audioResume()
        try:
            self.update_playcount(video_id)
        except:
            generic_utility.log(traceback.format_exc(), xbmc.LOGERROR)
            generic_utility.notification('Cannot update playcount. See logfile')
        self.close()
Esempio n. 37
0
    def playInternal(self, video_id, series_id):
        xbmc.audioSuspend()
        self.disable_screensaver()

        try:
            self.launch_browser('https://www.netflix.com/watch/%s' % video_id)
        except:
            generic_utility.log(traceback.format_exc(), xbmc.LOGERROR)
            generic_utility.notification(
                'Error launching browser. See logfile')

        self.enable_screensaver()
        xbmc.audioResume()
        try:
            self.update_playcount(video_id)
        except:
            generic_utility.log(traceback.format_exc(), xbmc.LOGERROR)
            generic_utility.notification(
                'Cannot update playcount. See logfile')
        self.close()
Esempio n. 38
0
def extended_artwork(title,year,type,id):
    result = {}
    if not type in ["movie","show"]:
        return {}
    
    #gets extended metadata and artwork from the skinhelper service json interface
    if xbmc.getCondVisibility("System.HasAddon(script.skin.helper.service)"):
        #use win properties as cache
        try:
            win = xbmcgui.Window(10000)
            cache = win.getProperty(id)
            if cache: 
                result = eval(cache)
            else:
                url = 'http://localhost:52307/getartwork&year=%s&title=%s&type=%s' %(year,title,type)
                res = requests.get(url)
                result = json.loads(res.content.decode('utf-8','replace'))
                win.setProperty(id,repr(result))
        except: generic_utility.log('Error while requesting extended artwork !')
            
    return result
Esempio n. 39
0
    def onAction(self, action):
        ACTION_NAV_BACK = 92
        ACTION_PREVIOUS_MENU = 10
        ACTION_STOP = 13

        ACTION_SELECT_ITEM = 7
        ACTION_PLAYER_PLAY = 79
        ACTION_PLAYER_PLAYPAUSE = 229
        ACTION_PAUSE = 12

        ACTION_PLAYER_REWIND = 78
        ACTION_MOVE_LEFT = 1
        ACTION_REWIND = 17

        ACTION_PLAYER_FORWARD = 77
        ACTION_MOVE_RIGHT = 2
        ACTION_FORWARD = 16

        ACTION_MOVE_UP = 3
        ACTION_MOVE_DOWN = 4

        if action.getId() in (ACTION_NAV_BACK, ACTION_PREVIOUS_MENU,
                              ACTION_STOP):
            self.control('close')
        elif action.getId() in (ACTION_SELECT_ITEM, ACTION_PLAYER_PLAY,
                                ACTION_PLAYER_PLAYPAUSE, ACTION_PAUSE):
            self.control('pause')
        elif action.getId() in (ACTION_PLAYER_REWIND, ACTION_MOVE_LEFT,
                                ACTION_REWIND):
            self.control('backward')
        elif action.getId() in (ACTION_PLAYER_FORWARD, ACTION_MOVE_RIGHT,
                                ACTION_FORWARD):
            self.control('forward')
        elif action.getId() == ACTION_MOVE_UP:
            self.control('up')
        elif action.getId() == ACTION_MOVE_DOWN:
            self.control('down')
        else:
            generic_utility.log('unknown action: ' + str(action.getId()))
def choose():
    profiles = []
    content = connect.load_netflix_site(generic_utility.profile_url, login_process=True)
#    generic_utility.log('choose: '+content)
    match = json.loads(content)['profiles']
    for item in match:
        profile = {'name': item['firstName'], 'token': item['guid'], 'is_kid': item['experience'] == 'jfk'}
        profiles.append(profile)
    if len(match) > 0:
        dialog = xbmcgui.Dialog()
        nr = dialog.select(generic_utility.get_string(30103), [profile['name'] for profile in profiles])
        if nr >= 0:
            selected_profile = profiles[nr]
        else:
            selected_profile = profiles[0]

        switch_profile(selected_profile['token'])

        generic_utility.set_setting('selected_profile', selected_profile['token'])
        generic_utility.set_setting('is_kid', 'true' if selected_profile['is_kid'] else 'false')
        generic_utility.set_setting('profile_name', selected_profile['name'])
    else:
        generic_utility.log('Choose profile: no profiles were found!', loglevel=xbmc.LOGERROR)
Esempio n. 41
0
def load_other_site(url):
    generic_utility.log('loading-other: ' + url)
    session = create_session()
    content = load_site_internal(url, session)
    return content
Esempio n. 42
0
    elif mode == 'delete_cookies':
        delete.cookies()
    elif mode == 'delete_cache':
        delete.cache()
    elif mode == 'reset_addon':
        delete.addon()
    elif mode == 'play_video':
        #    utility.log('play_video: '+url)
        play.video(url, series_id)
    elif mode == 'play_video_main':
        #    utility.log('play_video_main: '+url)
        play.video(url, series_id)
    elif mode == 'relogin':
        connect.do_login()
    else:
        general.index()


try:
    handle_request()
except:
    generic_utility.log('parameters: ' + sys.argv[2])
    generic_utility.log(traceback.format_exc(), xbmc.LOGERROR)
    dialog = xbmcgui.Dialog()
    do_fresh_login = dialog.yesno(generic_utility.get_string(50002),
                                  generic_utility.get_string(50003),
                                  generic_utility.get_string(50004))
    if do_fresh_login:
        if connect.do_login() == True:
            generic_utility.notification(generic_utility.get_string(50006))
Esempio n. 43
0
def load():
    profile_id = generic_utility.get_setting('selected_profile')
    if profile_id:
        switch_profile(profile_id)
    else:
        generic_utility.log('Load profile: no stored profile found!', loglevel=xbmc.LOGERROR)
def load_other_site(url):
    generic_utility.log('loading-other: ' + url)
    session = create_session()
    content = load_site_internal(url, session)
    return content
Esempio n. 45
0
    elif mode == 'search':
        search.netflix(video_type)
    elif mode == 'delete_cookies':
        delete.cookies()
    elif mode == 'delete_cache':
        delete.cache()
    elif mode == 'reset_addon':
        delete.addon()
    elif mode == 'play_video':
        #    utility.log('play_video: '+url)
        play.video(url, series_id);
    elif mode == 'play_video_main':
        #    utility.log('play_video_main: '+url)
        play.video(url, series_id);
    elif mode == 'relogin':
        connect.do_login()
    else:
        general.index()


try:
    handle_request()
except:
    generic_utility.log('parameters: ' + sys.argv[2])
    generic_utility.log(traceback.format_exc(), xbmc.LOGERROR)
    dialog = xbmcgui.Dialog()
    do_fresh_login = dialog.yesno(generic_utility.get_string(50002), generic_utility.get_string(50003), generic_utility.get_string(50004))
    if do_fresh_login:
        if connect.do_login()==True:
            generic_utility.notification('Login refreshed. please try again.')