chore(performance): Speeds up display of main menu, genre and recommendation list
authorSebastian Golasch <public@asciidisco.com>
Fri, 17 Mar 2017 09:10:52 +0000 (10:10 +0100)
committerSebastian Golasch <public@asciidisco.com>
Fri, 17 Mar 2017 09:10:52 +0000 (10:10 +0100)
addon.xml
resources/language/English/strings.po
resources/language/German/strings.po
resources/language/Slovak/strings.po
resources/language/Spanish/strings.po
resources/lib/Navigation.py
resources/lib/NetflixHttpSubRessourceHandler.py
resources/lib/NetflixSession.py

index a725770cc2b80f251014c33c40ba435280d5dd05..44635ecc9fbb0da9f742cc97fc510cda0c3abed1 100644 (file)
--- a/addon.xml
+++ b/addon.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<addon id="plugin.video.netflix" name="Netflix" version="0.11.5" provider-name="libdev + jojo + asciidisco">
+<addon id="plugin.video.netflix" name="Netflix" version="0.11.6" provider-name="libdev + jojo + asciidisco">
   <requires>
     <import addon="xbmc.python" version="2.24.0"/>
     <import addon="script.module.beautifulsoup4" version="4.3.2"/>
@@ -28,7 +28,7 @@
     <license>MIT</license>
     <forum>http://www.kodinerds.net/index.php/Thread/55607-Inputstream-Agile-Betatest-Netflix/</forum>
     <source>https://github.com/asciidisco/plugin.video.netflix</source>
-    <news>v0.11.5 (2017-3-16)
-    - Remove flawed debugging code</news>
+    <news>v0.11.5 (2017-3-17)
+    - Speed up display of main menu, genre and recommendation list</news>
   </extension>
 </addon>
index b682e9f705e578e1b5ed23667c3c30830bada0ff..98150a6d0526512c831be4176d88c1eb4e66425c 100644 (file)
@@ -1,7 +1,7 @@
 # Kodi Media Center language file
 # Addon Name: Netflix
 # Addon id: plugin.video.netflix
-# Addon version: 0.11.5
+# Addon version: 0.11.6
 # Addon Provider: libdev + jojo + asciidisco
 msgid ""
 msgstr ""
index e0821560a1e99b223566423688998067c2f7b0e6..64662b3b618a366a239478d41618515dd28af4a0 100644 (file)
@@ -1,7 +1,7 @@
 # Kodi Media Center language file
 # Addon Name: Netflix
 # Addon id: plugin.video.netflix
-# Addon version: 0.11.5
+# Addon version: 0.11.6
 # Addon Provider: libdev + jojo + asciidisco
 msgid ""
 msgstr ""
index f16be5c9a52c8ba2f6da958d6b0e8c48651b8a20..243b72e4280f736f6d70555ad8959633fc5ff988 100644 (file)
@@ -1,7 +1,7 @@
 # Kodi Media Center language file
 # Addon Name: Netflix
 # Addon id: plugin.video.netflix
-# Addon version: 0.11.5
+# Addon version: 0.11.6
 # Addon Provider: libdev + jojo + asciidisco
 msgid ""
 msgstr ""
index 4b1cae95c8c1a046784d7121d2a36eb6147880b6..0fb62f6c9801fbae28d97037b0812b3be84a2323 100644 (file)
@@ -1,7 +1,7 @@
 # Kodi Media Center language file
 # Addon Name: Netflix
 # Addon id: plugin.video.netflix
-# Addon version: 0.11.5
+# Addon version: 0.11.6
 # Addon Provider: libdev + jojo + asciidisco
 msgid ""
 msgstr ""
index 1c9a9ab97aa08ff4cb2b99db803512e244e9af66..894fc81e93240bbba264561abd35d693599fb65b 100644 (file)
@@ -163,13 +163,7 @@ class Navigation:
         """
         # determine if we´re in kids mode
         user_data = self.call_netflix_service({'method': 'get_user_data'})
-        profiles = self.call_netflix_service({'method': 'list_profiles'})
-        is_kids = profiles.get(user_data['guid']).get('isKids', False)
-        # fetch video lists
-        if is_kids == True:
-            video_list_ids = self.call_netflix_service({'method': 'fetch_video_list_ids_for_kids'})
-        else:
-            video_list_ids = self.call_netflix_service({'method': 'fetch_video_list_ids', 'type': type})
+        video_list_ids = self.call_netflix_service({'method': 'fetch_video_list_ids', 'guid': user_data['guid'], 'cache': True})
         # check for any errors
         if self._is_dirty_response(response=video_list_ids):
             return False
@@ -246,16 +240,8 @@ class Navigation:
 
     def show_video_lists (self):
         """List the users video lists (recommendations, my list, etc.)"""
-        # determine if we´re in Kids profile mode
         user_data = self.call_netflix_service({'method': 'get_user_data'})
-        profiles = self.call_netflix_service({'method': 'list_profiles'})
-        is_kids = profiles.get(user_data['guid']).get('isKids', False)
-        # fetch video lists
-        if is_kids == True:
-            video_list_ids = self.call_netflix_service({'method': 'fetch_video_list_ids_for_kids', 'guid': user_data['guid'], 'cache': True})
-        else:
-            video_list_ids = self.call_netflix_service({'method': 'fetch_video_list_ids', 'guid': user_data['guid'], 'cache': True})
-
+        video_list_ids = self.call_netflix_service({'method': 'fetch_video_list_ids', 'guid': user_data['guid'], 'cache': True})
         # check for any errors
         if self._is_dirty_response(response=video_list_ids):
             return False
index 5123ceb5d1f7b184a2c3e9d35aefd78656602249..b1bad7a518d5534e8159ef2b9b9135121acb473e 100644 (file)
@@ -154,28 +154,11 @@ class NetflixHttpSubRessourceHandler:
             self.kodi_helper.log('Serving cached list for user: ' + self.netflix_session.user_data['guid'])
             return cached_list
         video_list_ids_raw = self.netflix_session.fetch_video_list_ids()
+
         if 'error' in video_list_ids_raw:
             return video_list_ids_raw
         return self.netflix_session.parse_video_list_ids(response_data=video_list_ids_raw)
 
-    def fetch_video_list_ids_for_kids (self, params):
-        """Video list ids proxy function (thanks to Netflix that we need to use a different API for Kids profiles)
-
-        Parameters
-        ----------
-        params : :obj:`dict` of :obj:`str`
-            Request params
-
-        Returns
-        -------
-        :obj:`list`
-            Transformed response of the remote call
-        """
-        if self.lolomo == None:
-            self.lolomo = self.netflix_session.get_lolomo_for_kids()
-        response = self.netflix_session.fetch_lists_for_kids(lolomo=self.lolomo)
-        return response
-
     def fetch_video_list (self, params):
         """Video list proxy function
 
index 377866765cb4803d0dc0c560c3ae4817f2889cdd..f4c9be3fda59bc99b8c5805fcda5e45b9f8e08e8 100644 (file)
@@ -446,6 +446,11 @@ class NetflixSession:
         for key in self.video_list_keys:
             video_list_ids[key] = {}
 
+        # check if the list items are hidden behind a `value` sub key
+        # this is the case when we fetch the lists via POST, not via a GET preflight request
+        if 'value' in response_data.keys():
+            response_data = response_data['value']
+
         # subcatogorize the lists by their context
         video_lists = response_data['lists']
         for video_list_id in video_lists.keys():
@@ -1270,8 +1275,9 @@ class NetflixSession:
         response = self._session_get(component='browse')
         return BeautifulSoup(response.text, 'html.parser')
 
-    def fetch_video_list_ids (self, list_from=0, list_to=50):
+    def fetch_video_list_ids_via_preflight (self, list_from=0, list_to=50):
         """Fetches the JSON with detailed information based on the lists on the landing page (browse page) of Netflix
+           via the preflight (GET) request
 
         Parameters
         ----------
@@ -1298,14 +1304,11 @@ class NetflixSession:
         response = self._session_get(component='video_list_ids', params=payload, type='api')
         return self._process_response(response=response, component=self._get_api_url_for(component='video_list_ids'))
 
-    def fetch_search_results (self, search_str, list_from=0, list_to=10):
-        """Fetches the JSON which contains the results for the given search query
+    def fetch_video_list_ids (self, list_from=0, list_to=50):
+        """Fetches the JSON with detailed information based on the lists on the landing page (browse page) of Netflix
 
         Parameters
         ----------
-        search_str : :obj:`str`
-            String to query Netflix search for
-
         list_from : :obj:`int`
             Start entry for pagination
 
@@ -1317,42 +1320,20 @@ class NetflixSession:
         :obj:`dict` of :obj:`dict` of :obj:`str`
             Raw Netflix API call response or api call error
         """
-        # properly encode the search string
-        encoded_search_string = quote(search_str)
-
         paths = [
-            ['search', encoded_search_string, 'titles', {'from': list_from, 'to': list_to}, ['summary', 'title']],
-            ['search', encoded_search_string, 'titles', {'from': list_from, 'to': list_to}, 'boxarts', '_342x192', 'jpg'],
-            ['search', encoded_search_string, 'titles', ['id', 'length', 'name', 'trackIds', 'requestId']],
-            ['search', encoded_search_string, 'suggestions', 0, 'relatedvideos', {'from': list_from, 'to': list_to}, ['summary', 'title']],
-            ['search', encoded_search_string, 'suggestions', 0, 'relatedvideos', {'from': list_from, 'to': list_to}, 'boxarts', '_342x192', 'jpg'],
-            ['search', encoded_search_string, 'suggestions', 0, 'relatedvideos', ['id', 'length', 'name', 'trackIds', 'requestId']]
+            ['lolomo', {'from': list_from, 'to': list_to}, ['displayName', 'context', 'id', 'index', 'length']]
         ]
-        response = self._path_request(paths=paths)
-        return self._process_response(response=response, component='Search results')
-
-    def get_lolomo_for_kids (self):
-        """Fetches the lolomo ID for Kids profiles
 
-        Returns
-        -------
-        :obj:`str`
-            Kids Lolomo ID
-        """
-        response = self._session_get(component='kids')
-        for cookie in response.cookies:
-            if cookie.name.find('lhpuuidh-browse-' + self.user_data['guid']) != -1 and cookie.name.rfind('-T') == -1:
-                start = unquote(cookie.value).rfind(':')
-                return unquote(cookie.value)[start+1:]
-        return None
+        response = self._path_request(paths=paths)
+        return self._process_response(response=response, component='Video list ids')
 
-    def fetch_lists_for_kids (self, lolomo, list_from=0, list_to=50):
-        """Fetches the JSON which contains the contents of a the video list for kids users
+    def fetch_search_results (self, search_str, list_from=0, list_to=10):
+        """Fetches the JSON which contains the results for the given search query
 
         Parameters
         ----------
-        lolomo : :obj:`str`
-            Lolomo ID for the Kids profile
+        search_str : :obj:`str`
+            String to query Netflix search for
 
         list_from : :obj:`int`
             Start entry for pagination
@@ -1365,13 +1346,19 @@ class NetflixSession:
         :obj:`dict` of :obj:`dict` of :obj:`str`
             Raw Netflix API call response or api call error
         """
+        # properly encode the search string
+        encoded_search_string = quote(search_str)
+
         paths = [
-            ['lists', lolomo, {'from': list_from, 'to': list_to}, ['displayName', 'context', 'genreId', 'id', 'index', 'length']]
+            ['search', encoded_search_string, 'titles', {'from': list_from, 'to': list_to}, ['summary', 'title']],
+            ['search', encoded_search_string, 'titles', {'from': list_from, 'to': list_to}, 'boxarts', '_342x192', 'jpg'],
+            ['search', encoded_search_string, 'titles', ['id', 'length', 'name', 'trackIds', 'requestId']],
+            ['search', encoded_search_string, 'suggestions', 0, 'relatedvideos', {'from': list_from, 'to': list_to}, ['summary', 'title']],
+            ['search', encoded_search_string, 'suggestions', 0, 'relatedvideos', {'from': list_from, 'to': list_to}, 'boxarts', '_342x192', 'jpg'],
+            ['search', encoded_search_string, 'suggestions', 0, 'relatedvideos', ['id', 'length', 'name', 'trackIds', 'requestId']]
         ]
-
         response = self._path_request(paths=paths)
-        res = self._process_response(response=response, component='Kids lists')
-        return self.parse_video_list_ids(response_data=res['value'])
+        return self._process_response(response=response, component='Search results')
 
     def fetch_video_list (self, list_id, list_from=0, list_to=20):
         """Fetches the JSON which contains the contents of a given video list