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 index(): add.directory(generic_utility.get_string(30100), '', 'main', '', 'movie', login_context=True) add.directory(generic_utility.get_string(30101), '', 'main', '', 'show', login_context=True) add.directory(generic_utility.get_string(30102), '', 'main', '', 'dynamic', login_context=True) if not generic_utility.get_setting('single_profile') == 'true': add.item(generic_utility.get_string(30103) + ' - [COLOR FF8E0000]' + generic_utility.get_setting('profile_name') + '[/COLOR]', 'choose_profile', login_context=True) xbmcplugin.endOfDirectory(plugin_handle)
def videos(url, video_type, offset, run_as_widget=False): if '' == offset: page = 0 else: page = int(offset) loading_progress = show_loading_progress(run_as_widget) xbmcplugin.setContent(plugin_handle, 'movies') list_id = None genre_id = None if 'genre' in url: genre_id = url.split('?')[1] elif 'list?' in url: data = url.split('?')[1] if 'mylist' in data: root_list = lolomos.get_root_list() list_id = lolomos.get_mylist(root_list)[0] else: list_id = data video_metadata = None if list_id: video_metadata = get.videos_in_list(list_id, page) elif genre_id: video_metadata = get.videos_in_genre(genre_id, page) if video_metadata: add_videos_to_directory(loading_progress, run_as_widget, video_metadata, video_type, page, url) if generic_utility.get_setting('force_view') == 'true' and not run_as_widget: xbmc.executebuiltin('Container.SetViewMode(' + generic_utility.get_setting('view_id_videos') + ')') xbmcplugin.endOfDirectory(plugin_handle)
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 add_context_menu_show(entries, removable, thumb_url, title, video_id): if generic_utility.get_setting('browse_tv_shows') == 'true': entries.append((generic_utility.get_string(30151), 'RunPlugin(plugin://%s/?mode=play_video_main&url=%s&thumb=%s)' % ( generic_utility.addon_id, urllib.quote_plus(video_id), urllib.quote_plus(thumb_url)))) else: entries.append((generic_utility.get_string(30152), 'Container.Update(plugin://%s/?mode=list_seasons&url=%s&thumb=%s)' % ( generic_utility.addon_id, urllib.quote_plus(video_id), urllib.quote_plus(thumb_url)))) if generic_utility.get_setting('is_kid') == 'false': if removable: entries.append((generic_utility.get_string(30154), 'RunPlugin(plugin://%s/?mode=remove_from_queue&url=%s)' % ( generic_utility.addon_id, urllib.quote_plus(video_id)))) else: entries.append((generic_utility.get_string(30155), 'RunPlugin(plugin://%s/?mode=add_to_queue&url=%s)' % ( generic_utility.addon_id, urllib.quote_plus(video_id)))) series_dir = library.get_series_dir(title.strip()) # generic_utility.log('series-dir: '+series_dir) if xbmcvfs.exists(series_dir + os.sep) == False: entries.append((generic_utility.get_string(30150), 'RunPlugin(plugin://%s/?mode=add_series_to_library&url=&name=%s&series_id=%s)' % ( generic_utility.addon_id, urllib.quote_plus(generic_utility.encode(title.strip())), urllib.quote_plus(video_id)))) else: entries.append((generic_utility.get_string(301501), 'RunPlugin(plugin://%s/?mode=remove_series_from_library&url=&name=%s)' % ( generic_utility.addon_id, urllib.quote_plus(generic_utility.encode(title.strip())))))
def videos_matches(video_type, page, url): post_data = '' if not xbmcvfs.exists(generic_utility.cookies_file()): login.login() items_per_page = int(generic_utility.get_setting('items_per_page')) off_from = page * items_per_page off_to = off_from + items_per_page - 2 if 'genre' in url: post_data = generic_utility.genre % ( url.split('?')[1], off_from, off_to, generic_utility.get_setting('authorization_url')) elif 'list?' in url: data = url.split('?')[1] if ('mylist' in data): list_id = data.split('&')[0] else: list_id = data post_data = generic_utility.list_paths % ( list_id, off_from, off_to, generic_utility.get_setting('authorization_url')) target_url = generic_utility.evaluator() response = connect.load_netflix_site(target_url, post=post_data) # utility.log('response: '+response) video_ids = extract_other_video_ids(response, video_type) return video_ids
def index(): add.directory(generic_utility.get_string(30100), '', 'main', '', 'movie', login_context=True) add.directory(generic_utility.get_string(30101), '', 'main', '', 'tv', login_context=True) add.directory(generic_utility.get_string(30102), '', 'wi_home', '', 'both', login_context=True) if not generic_utility.get_setting('single_profile') == 'true': add.item( generic_utility.get_string(30103) + ' - [COLOR FF8E0000]' + generic_utility.get_setting('profile_name') + '[/COLOR]', 'choose_profile', login_context=True) xbmcplugin.endOfDirectory(plugin_handle)
def profile_selection(): if generic_utility.get_setting('single_profile') == 'false': if not generic_utility.get_setting('selected_profile') or generic_utility.get_setting('show_profiles') == 'true': profiles.choose() else: profiles.load() profiles.update_displayed()
def login(): if not test: login_progress = xbmcgui.DialogProgress() login_progress.create('Netflix', generic_utility.get_string(30200) + '...') generic_utility.progress_window(login_progress, 25, generic_utility.get_string(30201)) content = connect.load_netflix_site(generic_utility.main_url + 'Login', new_session=True, login_process=True) if not 'Sorry, Netflix ' in content: match = re.compile('locale: "(.+?)"', re.DOTALL|re.UNICODE).findall(content) locale = None if(len(match)) == 0: match = re.compile('"pageName":"login","locale":"(.+?)"', re.DOTALL|re.UNICODE).findall(content) if(len(match)) == 0: generic_utility.error('Cannot find locale on page. content: '+content) login_url = 'Login' else: locale = match[0] login_url = 'Login?locale=' + locale else: locale = match[0] login_url = 'Login?locale=' + locale generic_utility.set_setting('language', locale) post_data = {'authURL': generic_utility.get_setting('authorization_url'), 'email': generic_utility.get_setting('username'), 'password': generic_utility.get_setting('password'), 'RememberMe': 'on'} if not test: generic_utility.progress_window(login_progress, 50, generic_utility.get_string(30202)) content = connect.load_netflix_site( generic_utility.main_url + login_url, post=post_data, login_process=True) if 'id="page-LOGIN"' in content: if not test: generic_utility.notification(generic_utility.get_string(30303)) return False parse_data_set_cookies(content) if not test: generic_utility.progress_window(login_progress, 75, generic_utility.get_string(30203)) profile_selection() if login_progress: if not test: if not generic_utility.progress_window(login_progress, 100, generic_utility.get_string(30204)): return False xbmc.sleep(500) login_progress.close() return True else: if not test: generic_utility.notification(generic_utility.get_string(30300)) if login_progress: login_progress.close() return False
def genre_info(video_type): post_data = '' if video_type == 'show': post_data = generic_utility.series_genre % generic_utility.get_setting('authorization_url') elif video_type == 'movie': post_data = generic_utility.movie_genre % generic_utility.get_setting('authorization_url') else: pass content = connect.load_netflix_site(generic_utility.evaluator(), post=post_data, headers={"Content-Type":"application/json"}) return content
def episodes(series_id, season): xbmcplugin.setContent(plugin_handle, 'episodes') episodes = get.episodes_data(season, series_id) for episode in episodes: add.episode(episode) if generic_utility.get_setting('force_view'): xbmc.executebuiltin('Container.SetViewMode(' + generic_utility.get_setting('view_id_episodes') + ')') xbmcplugin.addSortMethod(plugin_handle, xbmcplugin.SORT_METHOD_EPISODE) xbmcplugin.endOfDirectory(plugin_handle)
def episodes(series_id, season): xbmcplugin.setContent(plugin_handle, 'episodes') episodes = get.episodes_data(season, series_id) for episode in episodes: add.episode(episode) if generic_utility.get_setting('force_view'): xbmc.executebuiltin('Container.SetViewMode(' + generic_utility.get_setting('view_id_episodes') + ')') xbmcplugin.endOfDirectory(plugin_handle)
def genre_info(video_type): post_data = '' if video_type == 'tv': post_data = generic_utility.series_genre % generic_utility.get_setting('authorization_url') elif video_type == 'movie': post_data = generic_utility.movie_genre % generic_utility.get_setting('authorization_url') else: pass content = connect.load_netflix_site(generic_utility.evaluator(), post=post_data) return content
def profile_selection(): if generic_utility.get_setting('single_profile') == 'false': if not generic_utility.get_setting( 'selected_profile') or generic_utility.get_setting( 'show_profiles') == 'true': profiles.choose() else: profiles.load() profiles.update_displayed()
def login(): login_progress = xbmcgui.DialogProgress() login_progress.create('Netflix', generic_utility.get_string(30200) + '...') generic_utility.progress_window(login_progress, 25, generic_utility.get_string(30201)) content = connect.load_netflix_site(generic_utility.main_url + 'Login', new_session=True) if not 'Sorry, Netflix ' in content: match = re.compile('name="authURL" value="(.+?)"', re.DOTALL | re.UNICODE).findall(content) # utility.log('Setting authorization url: ' + match[0]) generic_utility.set_setting('authorization_url', match[0]) match = re.compile('locale: "(.+?)"', re.DOTALL | re.UNICODE).findall(content) generic_utility.set_setting('language', match[0]) post_data = { 'authURL': generic_utility.get_setting('authorization_url'), 'email': generic_utility.get_setting('username'), 'password': generic_utility.get_setting('password'), 'RememberMe': 'on' } generic_utility.progress_window(login_progress, 50, generic_utility.get_string(30202)) content = connect.load_netflix_site( generic_utility.main_url + 'Login?locale=' + generic_utility.get_setting('language'), post=post_data) # utility.log(content) if 'id="page-LOGIN"' in content: generic_utility.notification(generic_utility.get_string(30303)) return False match = re.compile('"apiUrl":"(.+?)",', re.UNICODE).findall(content) generic_utility.set_setting('api_url', match[0]) connect.set_chrome_netflix_cookies() generic_utility.progress_window(login_progress, 75, generic_utility.get_string(30203)) profile_selection() if login_progress: if not generic_utility.progress_window( login_progress, 100, generic_utility.get_string(30204)): return False xbmc.sleep(500) login_progress.close() return True else: generic_utility.notification(generic_utility.get_string(30300)) if login_progress: login_progress.close() return False
def profile_selection(): if generic_utility.get_setting("single_profile") == "false": if ( not generic_utility.get_setting("selected_profile") or generic_utility.get_setting("show_profiles") == "true" ): profiles.choose() else: profiles.load() profiles.update_displayed()
def viewing_activity(video_type, run_as_widget=False): loading_progress = show_loading_progress(run_as_widget) xbmcplugin.setContent(plugin_handle, 'movies') metadata = get.viewing_activity_matches(video_type) if len(metadata) > 0: add_videos_to_directory(loading_progress, run_as_widget, metadata, video_type, viewing_activity=True) else: generic_utility.notification(generic_utility.get_string(30306)) if generic_utility.get_setting('force_view') and not run_as_widget: xbmc.executebuiltin('Container.SetViewMode(' + generic_utility.get_setting('view_id_activity') + ')') xbmcplugin.endOfDirectory(plugin_handle)
def search(search_string, video_type, run_as_widget=False): loading_progress = None if not run_as_widget: loading_progress = xbmcgui.DialogProgress() loading_progress.create('Netflix', generic_utility.get_string(30205) + '...') generic_utility.progress_window(loading_progress, 0, '...') xbmcplugin.setContent(plugin_handle, 'movies') metadatas = get.videos_in_search(search_string) # video_ids = get.search_matches(search_string, video_type) add_videos_to_directory(loading_progress, run_as_widget, metadatas, video_type, 0, '') if generic_utility.get_setting('force_view') and not run_as_widget: xbmc.executebuiltin('Container.SetViewMode(' + generic_utility.get_setting('view_id_videos') + ')') xbmcplugin.endOfDirectory(plugin_handle)
def videos(url, video_type, offset, run_as_widget=False): if '' == offset: page = 0 else: page = int(offset) loading_progress = show_loading_progress(run_as_widget) xbmcplugin.setContent(plugin_handle, 'movies') video_ids = get.videos_matches(video_type, page, url) load_videos_to_directory(loading_progress, run_as_widget, video_ids, video_type, page, url) if generic_utility.get_setting('force_view') == 'true' and not run_as_widget: xbmc.executebuiltin('Container.SetViewMode(' + generic_utility.get_setting('view_id_videos') + ')') xbmcplugin.endOfDirectory(plugin_handle)
def load_videos_to_directory(loading_progress, run_as_widget, metadatas, video_type, page=None, url=None, viewing_activity=False): video_metadatas = multiprocessor.load_data(metadatas, video_type, run_as_widget, loading_progress, url, viewing_activity) removable = url != None and 'my-list' in url sorted_video_metadata = sorted(video_metadatas, key=lambda t: t['title'], reverse=viewing_activity) for video_metadata in sorted_video_metadata: if (video_metadata != None): video_add(video_metadata, removable, viewing_activity) # generic_utility.log(url) items_per_page = int(generic_utility.get_setting('items_per_page')) if ((url == None or 'list_viewing_activity' not in url) and len(video_metadatas) == items_per_page): add.add_next_item('Next', page + 1, url, video_type, 'list_videos', '') if len(video_metadatas) == 0: generic_utility.notification(generic_utility.get_string(30306)) add_sort_methods()
def switch_profile(profile_id): auth_id = generic_utility.get_setting('authorization_url') profile_switch_url = generic_utility.profile_switch( ) + 'switchProfileGuid=' + profile_id + '&authURL=' + auth_id ret = connect.load_netflix_site(profile_switch_url) # generic_utility.log('switch-profile: '+ret) connect.set_chrome_netflix_cookies()
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 viewing_activity_info(): content = connect.load_netflix_site( generic_utility.activity_url % (generic_utility.api_url, generic_utility.endpoints()['/viewingactivity'], generic_utility.get_setting('authorization_url'))) return content
def parse_video(custom_title, jsn, series_title, video_id): if custom_title != None: title = custom_title else: title = get_value(jsn, 'title') year = get_value(jsn, 'releaseYear', '1900') thumb_url = extract_thumb_url(jsn) mpaa = get_mpaa(jsn) episode, season = parse_episode_seasion(jsn) type = parse_type(jsn) # series has no playcount if type != 'show': duration, playcount = parse_duration_playcount(jsn) else: playcount = 0 duration = '' if generic_utility.get_setting('use_tmdb') == 'true': type_tmdb = 'movie' if type == 'movie' else 'tv' title_tmdb = series_title if series_title != None else title load_tmdb_cover_fanart(title_tmdb, video_id, type_tmdb, year) description = get_decription(jsn) director = parse_director(jsn) genre = parse_genre(jsn) rating = parse_rating(jsn) movie_metadata = {'title': title, 'video_id': video_id, 'thumb_url': thumb_url, 'type': type, 'description': description, 'duration': duration, 'year': year, 'mpaa': mpaa, \ 'director': director, 'genre': genre, 'rating': rating, 'playcount': playcount, 'episode': episode, 'season': season} return movie_metadata
def main(video_type): add.directory(generic_utility.get_string(30105), '', 'list_viewing_activity', '', video_type) if video_type == 'show': add.directory(generic_utility.get_string(30107), 'genre?83', 'list_videos', '', video_type) add.directory(generic_utility.get_string(30108), '', 'list_genres', '', video_type) elif video_type == 'movie': add.directory(generic_utility.get_string(30108), '', 'list_genres', '', video_type) elif video_type == 'dynamic': add_dynamic_lists() if video_type != 'dynamic' and generic_utility.get_setting( 'is_kid') == 'false': try: root_list = lolomos.get_root_list() except AttributeError: if connect.do_login(): root_list = lolomos.get_root_list() else: raise Exception("Cannot login") mylist = lolomos.get_mylist(root_list) add.directory(child('displayName', mylist[1]), 'list?&mylist', 'list_videos', '', video_type) add.directory(generic_utility.get_string(30109), '', 'search', '', video_type) xbmcplugin.endOfDirectory(plugin_handle, cacheToDisc=False)
def remove_movie(title): movie_dir = get_movie_dir(title)[0] xbmcvfs.rmdir(movie_dir+os.sep, force=True) if generic_utility.get_setting('update_db') == 'true': xbmc.executebuiltin('CleanLibrary(video)') else: xbmc.executebuiltin("Container.Refresh")
def add_or_remove(video_id, is_add): content = connect.load_netflix_site("https://www.netflix.com/") falkor_cache = generic_utility.parse_falkorcache(content) root_list, my_list = generic_utility.extract_mylist_id(falkor_cache) auth = generic_utility.get_setting('authorization_url') track_id = get_track_id(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) 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)
def read_lists(jsn, root_list): filter_empty(jsn) rets = [] llms = child('lolomos', jsn) rlst = child(root_list, llms) if generic_utility.get_setting('is_kid') == 'false': mylist = child('mylist', rlst) mylist_idx = deref(mylist, jsn)[0] else: mylist_idx = -1 mylist_id = None for list_ref_idx in rlst: list_ref = rlst[list_ref_idx] idx, elem = deref(list_ref, jsn) if list_ref_idx == mylist_idx: mylist_id = idx if 'displayName' in elem: display_name = unicode(elem['displayName']) ret = {'id': idx, 'name': display_name} rets.append(ret) return mylist_id, rets
def remove_series(series_title): series_file = get_series_dir(series_title) xbmcvfs.rmdir(series_file+os.sep, force=True) if generic_utility.get_setting('update_db') == 'true': xbmc.executebuiltin('CleanLibrary(video)') else: xbmc.executebuiltin("Container.Refresh")
def add_context_menu_show(entries, removable, thumb_url, title, video_id): if generic_utility.get_setting('browse_tv_shows') == 'true': entries.append((generic_utility.get_string(30151), 'RunPlugin(plugin://%s/?mode=play_video_main&url=%s&thumb=%s)' % ( generic_utility.addon_id, urllib.quote_plus(video_id), urllib.quote_plus(thumb_url)))) else: entries.append((generic_utility.get_string(30152), 'Container.Update(plugin://%s/?mode=list_seasons&url=%s&thumb=%s)' % ( generic_utility.addon_id, urllib.quote_plus(video_id), urllib.quote_plus(thumb_url)))) if removable: entries.append((generic_utility.get_string(30154), 'RunPlugin(plugin://%s/?mode=remove_from_queue&url=%s)' % ( generic_utility.addon_id, urllib.quote_plus(video_id)))) else: entries.append((generic_utility.get_string(30155), 'RunPlugin(plugin://%s/?mode=add_to_queue&url=%s)' % ( generic_utility.addon_id, urllib.quote_plus(video_id)))) series_dir = library.get_series_dir(title.strip()) # generic_utility.log('series-dir: '+series_dir) if xbmcvfs.exists(series_dir + os.sep) == False: entries.append((generic_utility.get_string(30150), 'RunPlugin(plugin://%s/?mode=add_series_to_library&url=&name=%s&series_id=%s)' % ( generic_utility.addon_id, urllib.quote_plus(generic_utility.encode(title.strip())), urllib.quote_plus(video_id)))) else: entries.append((generic_utility.get_string(301501), 'RunPlugin(plugin://%s/?mode=remove_series_from_library&url=&name=%s)' % ( generic_utility.addon_id, urllib.quote_plus(generic_utility.encode(title.strip())))))
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)')
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)
def search_results(search_string): post_data = '{"paths":[["search","%s",{"from":0,"to":48},["summary","title"]],["search","%s",["id","length",' \ '"name","trackIds","requestId"]]],"authURL":"%s"}' % (search_string, search_string, generic_utility.get_setting('authorization_url')) content = connect.load_netflix_site(generic_utility.evaluator(), post=post_data) return content
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]
def add_videos_to_directory(loading_progress, run_as_widget, video_metadatas, video_type, page = None, url=None, viewing_activity = False): removable = url != None and 'mylist' in url if not viewing_activity: sorted_video_metadata = sorted(video_metadatas, key=lambda t: t['title'], reverse = viewing_activity) else: sorted_video_metadata = video_metadatas allowed_types = calc_allowed_types(video_type, viewing_activity) filtered_video_metadata = [] for video_metadata in sorted_video_metadata: if video_metadata['type'] in allowed_types: filtered_video_metadata.append(video_metadata) add.videos(filtered_video_metadata, removable, viewing_activity=viewing_activity) items_per_page = int(generic_utility.get_setting('items_per_page')) if (not url or 'list_viewing_activity' not in url) and len(video_metadatas) == items_per_page: add.add_next_item('zzz[Next]zzz', page + 1, url, video_type, 'list_videos', '') if len(video_metadatas) == 0: generic_utility.notification(generic_utility.get_string(30306)) if not viewing_activity: add_sort_methods()
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]
def add_context_menu_movie(entries, removable, title, type, video_id, year): entries.append((generic_utility.get_string(30156), 'Container.Update(plugin://%s/?mode=list_videos&url=%s&type=movie)' % ( generic_utility.addon_id, urllib.quote_plus( generic_utility.main_url + 'WiMovie/' + video_id)))) entries.append( (generic_utility.get_string(30157), 'Container.Update(plugin://%s/?mode=list_videos&url=%s&type=tv)' % ( generic_utility.addon_id, urllib.quote_plus(generic_utility.main_url + 'WiMovie/' + video_id)))) if generic_utility.get_setting('is_kid') == 'false': if removable: entries.append((generic_utility.get_string(30154), 'RunPlugin(plugin://%s/?mode=remove_from_queue&url=%s)' % ( generic_utility.addon_id, urllib.quote_plus(video_id)))) else: entries.append((generic_utility.get_string(30155), 'RunPlugin(plugin://%s/?mode=add_to_queue&url=%s)' % ( generic_utility.addon_id, urllib.quote_plus(video_id)))) title_utf8 = title.strip() + ' (' + str(year) + ')' title = urllib.quote_plus(title_utf8.encode('utf-8')) movie_dir = library.get_movie_dir(title_utf8)[0] if xbmcvfs.exists(movie_dir + os.sep) == False: entries.append((generic_utility.get_string(30150), 'RunPlugin(plugin://%s/?mode=add_movie_to_library&url=%s&name=%s)' % ( generic_utility.addon_id, urllib.quote_plus(video_id), title))) else: entries.append((generic_utility.get_string(301501), 'RunPlugin(plugin://%s/?mode=remove_movie_from_library&url=&name=%s)' % ( generic_utility.addon_id, title)))
def video_playback_info(video_ids): ids_str = '' for video_id in video_ids: ids_str+='"'+video_id+'",' ids_str = ids_str[:-1] post_data = generic_utility.video_playback_info % (ids_str, generic_utility.get_setting('authorization_url')) content = connect.load_netflix_site(generic_utility.evaluator(), post=post_data) return content
def read_browser(self): self.browser = generic_utility.get_setting('browser') if self.browser not in(BROWSER_CHROME, BROWSER_CHROME_LAUNCHER, BROWSER_EDGE, BROWSER_INTERNET_EXPLORER, BROWSER_SAFARI, BROWSER_CHROMIUM, BROWSER_ANDROID): generic_utility.notification(generic_utility.get_string(50001)) xbmc.sleep(2000) self.valid_browser = False generic_utility.open_setting() self.valid_browser = True
def switch_profile(profile_id, login_process = True): auth_id = generic_utility.get_setting('authorization_url') profile_switch_url = generic_utility.profile_switch() + 'switchProfileGuid=' + profile_id + '&authURL=' + auth_id ret = connect.load_netflix_site(profile_switch_url, login_process=login_process) # generic_utility.log('switch-profile: '+ret) content = connect.load_netflix_site('http://www.netflix.com/browse') connect.set_chrome_netflix_cookies()
def create_video_listitem(removable, video_metadata, viewing_activity): title = video_metadata['title'] video_id = video_metadata['video_id'] thumb_url = video_metadata['thumb_url'] type = video_metadata['type'] description = video_metadata['description'] duration = video_metadata['duration'] year = video_metadata['year'] mpaa = video_metadata['mpaa'] director = video_metadata['director'] genre = video_metadata['genre'] rating = video_metadata['rating'] playcount = video_metadata['playcount'] next_mode = 'play_video_main' if viewing_activity == False and generic_utility.get_setting( 'browse_tv_shows') == 'true' and (type == 'show'): next_mode = 'list_seasons' entries = [] cover_file, fanart_file = generic_utility.cover_fanart(video_id) if xbmcvfs.exists(cover_file): thumb_url = cover_file url = sys.argv[0] url += '?url=' + urllib.quote_plus(video_id) url += '&mode=' + next_mode url += '&name=' + urllib.quote_plus(generic_utility.encode(title)) url += '&thumb=' + urllib.quote_plus(thumb_url) list_item = xbmcgui.ListItem(title) list_item.setArt({'icon': 'DefaultTVShows.png', 'thumb': thumb_url}) list_item.setInfo(type='video', infoLabels={ 'title': title, 'plot': description, 'duration': unicode(duration), 'year': int(year), 'mpaa': mpaa, 'director': director, 'genre': genre, 'rating': rating, 'playcount': playcount }) list_item.setProperty('IsPlayable', 'true') if xbmcvfs.exists(fanart_file): list_item.setProperty('fanart_image', fanart_file) elif xbmcvfs.exists(cover_file): list_item.setProperty('fanart_image', cover_file) else: list_item.setProperty('fanart_image', thumb_url) if type == 'show': add_context_menu_show(entries, removable, thumb_url, title, video_id) else: add_context_menu_movie(entries, removable, title, type, video_id, year) list_item.addContextMenuItems(entries) folder = True if next_mode == 'play_video_main': folder = False # utility.log(u) return url, list_item, folder
def refresh_data(): content = connect.load_netflix_site('https://www.netflix.com/browse') parse_api_url(content) profl = generic_utility.get_setting('selected_profile') if not profl: if login(): profl = generic_utility.get_setting('selected_profile') if not profl: raise CannotRefreshDataException try: profiles.switch_profile(profl) except ValueError as vex: raise CannotRefreshDataException(vex) content = connect.load_netflix_site(generic_utility.main_url) parse_data_set_cookies(content)
def login(): login_progress = xbmcgui.DialogProgress() login_progress.create('Netflix', generic_utility.get_string(30200) + '...') generic_utility.progress_window(login_progress, 25, generic_utility.get_string(30201)) content = connect.load_netflix_site(generic_utility.main_url + 'Login', new_session=True) if not 'Sorry, Netflix ' in content: match = re.compile('name="authURL" value="(.+?)"', re.DOTALL| re.UNICODE).findall(content) # utility.log('Setting authorization url: ' + match[0]) generic_utility.set_setting('authorization_url', match[0]) match = re.compile('locale: "(.+?)"', re.DOTALL|re.UNICODE).findall(content) generic_utility.set_setting('language', match[0]) post_data = {'authURL': generic_utility.get_setting('authorization_url'), 'email': generic_utility.get_setting('username'), 'password': generic_utility.get_setting('password'), 'RememberMe': 'on'} generic_utility.progress_window(login_progress, 50, generic_utility.get_string(30202)) content = connect.load_netflix_site( generic_utility.main_url + 'Login?locale=' + generic_utility.get_setting('language'), post=post_data) # utility.log(content) if 'id="page-LOGIN"' in content: generic_utility.notification(generic_utility.get_string(30303)) return False match = re.compile('"apiUrl":"(.+?)",', re.UNICODE).findall(content) generic_utility.set_setting('api_url', match[0]) connect.set_chrome_netflix_cookies() generic_utility.progress_window(login_progress, 75, generic_utility.get_string(30203)) profile_selection() if login_progress: if not generic_utility.progress_window(login_progress, 100, generic_utility.get_string(30204)): return False xbmc.sleep(500) login_progress.close() return True else: generic_utility.notification(generic_utility.get_string(30300)) if login_progress: login_progress.close() return False
def video(video_metadata, removable = False, viewing_activity = False): # utility.log(str(video_metadata)) title = video_metadata['title'] video_id = video_metadata['video_id'] thumb_url = video_metadata['thumb_url'] type = video_metadata['type'] description = video_metadata['description'] duration = video_metadata['duration'] year = video_metadata['year'] mpaa = video_metadata['mpaa'] director = video_metadata['director'] genre = video_metadata['genre'] rating = video_metadata['rating'] playcount = video_metadata['playcount'] next_mode = 'play_video_main' if viewing_activity == False and generic_utility.get_setting('browse_tv_shows') == 'true' and (type == 'show'): next_mode = 'list_seasons' entries = [] cover_file, fanart_file = generic_utility.cover_fanart(video_id) if xbmcvfs.exists(cover_file): thumb_url = cover_file u = sys.argv[0] u += '?url=' + urllib.quote_plus(video_id) u += '&mode=' + next_mode u += '&name=' + urllib.quote_plus(generic_utility.encode(title)) u += '&thumb=' + urllib.quote_plus(thumb_url) list_item = xbmcgui.ListItem(title) list_item.setArt({'icon': 'DefaultTVShows.png', 'thumb': thumb_url}) list_item.setInfo(type='video', infoLabels={'title': title, 'plot': description, 'duration': unicode(duration), 'year': int(year), 'mpaa': mpaa, 'director': director, 'genre': genre, 'rating': rating, 'playcount': playcount}) list_item.setProperty('IsPlayable', 'true'); if xbmcvfs.exists(fanart_file): list_item.setProperty('fanart_image', fanart_file) elif xbmcvfs.exists(cover_file): list_item.setProperty('fanart_image', cover_file) else: list_item.setProperty('fanart_image', thumb_url) if type == 'show': add_context_menu_show(entries, removable, thumb_url, title, video_id) else: add_context_menu_movie(entries, removable, title, type, video_id, year) list_item.addContextMenuItems(entries) folder = True if next_mode == 'play_video_main': folder = False # utility.log(u) directory_item = xbmcplugin.addDirectoryItem(handle=plugin_handle, url=u, listitem=list_item, isFolder=folder) return directory_item
def season(item): entries = [] u = sys.argv[0] u += '?url=' + urllib.quote_plus(unicode(item.get("season"))) u += '&mode=list_episodes' u += '&series_id=' + urllib.quote_plus(item.get("series_id")) if generic_utility.get_setting('use_tmdb') == 'true': extended_info = get.extended_artwork(item.get("tvshowtitle"),item.get("tvshowyear"),"show",item.get("series_id")) else: extended_info = {} list_item = xbmcgui.ListItem(item.get("name")) artwork = { 'icon': 'DefaultTVShows.png', 'thumb': extended_info.get("poster", item.get("seriesthumb","")), 'landscape': extended_info.get("landscape",item.get("seriesthumb","")), 'poster': extended_info.get("poster",""), 'clearlogo': extended_info.get("clearlogo",""), 'clearart': extended_info.get("clearart",""), 'fanart': extended_info.get("fanart",""), 'characterart': extended_info.get("characterart",""), 'discart': extended_info.get("discart",""), 'banner': extended_info.get("banner","") } list_item.setArt(artwork) list_item.setInfo(type='video',infoLabels={ 'title': item.get("name",""), 'year': item.get("year"), 'playcount': item.get("playcount"), 'tvshowtitle':item.get("tvshowtitle"), 'castandrole': eval(extended_info.get("castandrole","[]")), 'trailer': extended_info.get("trailer",""), 'genre': extended_info.get("genre",""), 'studio': extended_info.get("studio",""), 'plot': extended_info.get("plot",item.get("description","")), 'plotoutline': item.get("description",""), 'director': extended_info.get("director",""), 'writer': extended_info.get("writer",""), 'rating': float(extended_info.get("rating","0")), }) list_item.setProperty("totalepisodes", str(item.get("total_episodes",""))) list_item.setProperty("watchedepisodes", str(item.get("watched_episodes",""))) list_item.setProperty("unwatchedepisodes", str(item.get("unwatched_episodes",""))) entries.append((generic_utility.get_string(30150), 'RunPlugin(plugin://%s/?mode=add_series_to_library&url=%s&name=%s&series_id=%s)' % ( generic_utility.addon_id, urllib.quote_plus(unicode(item.get("season"))), urllib.quote_plus(generic_utility.encode(item.get("tvshowtitle").strip())), item.get("series_id")))) list_item.addContextMenuItems(entries) directory_item = xbmcplugin.addDirectoryItem(handle=plugin_handle, url=u, listitem=list_item, isFolder=True) return directory_item
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)')
def videos_matches(video_type, page, url): post_data = '' items_per_page = int(generic_utility.get_setting('items_per_page')) off_from = page * items_per_page off_to = off_from + items_per_page - 2 if 'genre' in url: post_data = generic_utility.genre % (url.split('?')[1], off_from, off_to, generic_utility.get_setting('authorization_url')) elif 'list?' in url: data = url.split('?')[1] if('mylist' in data): list_id = data.split('&')[0] else: list_id = data post_data = generic_utility.list_paths % (list_id, off_from, off_to, generic_utility.get_setting('authorization_url')) target_url = generic_utility.evaluator() response = connect.load_netflix_site(target_url, post=post_data) # utility.log('response: '+response) video_ids = extract_other_video_ids(response, video_type) return video_ids