X-Git-Url: http://git.code-monkey.de/?p=plugin.video.netflix.git;a=blobdiff_plain;f=resources%2Flib%2FNavigation.py;h=d4d3f7f3593f8b10f0b208cedf53df94bc3d7e08;hp=16c0a6d0b26ae20c581c7cbe1198094d55428d69;hb=86455dfff7e4878e5192dd97991f2e96a3021739;hpb=1d6e187c2cce9b254fc16dc32e30f98924f4b729 diff --git a/resources/lib/Navigation.py b/resources/lib/Navigation.py index 16c0a6d..d4d3f7f 100644 --- a/resources/lib/Navigation.py +++ b/resources/lib/Navigation.py @@ -3,11 +3,9 @@ # Module: Navigation # Created on: 13.01.2017 -import urllib -import time +from urllib import urlencode, unquote from urlparse import parse_qsl -from utils import noop -from utils import log +from utils import noop, log class Navigation: """Routes to the correct subfolder, dispatches actions & acts as a controller for the Kodi view & the Netflix model""" @@ -69,7 +67,7 @@ class Navigation: return False if 'action' not in params.keys(): # show the profiles - self.show_profiles() + return self.show_profiles() elif params['action'] == 'video_lists': # list lists that contain other lists (starting point with recommendations, search, etc.) return self.show_video_lists() @@ -95,7 +93,7 @@ class Navigation: return self.add_to_list(video_id=params['id']) elif params['action'] == 'export': # adds a title to the users list on Netflix - alt_title = self.kodi_helper.show_add_to_library_title_dialog(original_title=urllib.unquote(params['title']).decode('utf8')) + alt_title = self.kodi_helper.show_add_to_library_title_dialog(original_title=unquote(params['title']).decode('utf8')) return self.export_to_library(video_id=params['id'], alt_title=alt_title) elif params['action'] == 'remove': # adds a title to the users list on Netflix @@ -157,10 +155,11 @@ class Navigation: if self.netflix_session._is_size_key(key=key) == False: has_search_results = search_results_raw['value']['search'][key]['titles']['length'] > 0 if has_search_results == False: - for entry in search_results_raw['value']['search'][key]['suggestions']: - if self.netflix_session._is_size_key(key=entry) == False: - if search_results_raw['value']['search'][key]['suggestions'][entry]['relatedvideos']['length'] > 0: - has_search_results = True + if search_results_raw['value']['search'][key].get('suggestions', False) != False: + for entry in search_results_raw['value']['search'][key]['suggestions']: + if self.netflix_session._is_size_key(key=entry) == False: + if search_results_raw['value']['search'][key]['suggestions'][entry]['relatedvideos']['length'] > 0: + has_search_results = True # display that we haven't found a thing @@ -252,7 +251,7 @@ class Navigation: # sort seasons by index by default (they´re coming back unsorted from the api) seasons_sorted = [] for season_id in season_list: - seasons_sorted.append(int(season_list[season_id]['id'])) + seasons_sorted.append(int(season_list[season_id]['idx'])) seasons_sorted.sort() return self.kodi_helper.build_season_listing(seasons_sorted=seasons_sorted, season_list=season_list, build_url=self.build_url) @@ -542,4 +541,4 @@ class Navigation: str Url + querystring based on the param """ - return self.base_url + '?' + urllib.urlencode(query) + return self.base_url + '?' + urlencode(query)