Merge pull request #66 from matejmosko/patch-2
[plugin.video.netflix.git] / resources / lib / NetflixSession.py
index 09938afff46e6c8824fc4e20bb6ef62c4c83ae11..ca4bd5cc0272449d88bfaaf71a96ce508b17acb4 100644 (file)
@@ -149,7 +149,7 @@ class NetflixSession:
             :obj:`list` of :obj:`dict`
                 List of all the serialized data pulled out of the pagws <script/> tags
         """
-        scripts = page_soup.find_all('script', attrs={'src': None});
+        scripts = page_soup.find_all('script', attrs={'src': None})
         self.log(msg='Trying sloppy inline data parser')
         inline_data = self._sloppy_parse_inline_data(scripts=scripts)
         if self._verfify_auth_and_profiles_data(data=inline_data) != False:
@@ -1240,6 +1240,11 @@ class NetflixSession:
           },
         }
         """
+        mpaa = ''
+        if episode.get('maturity', None) is not None:
+            if episode['maturity'].get('board', None) is not None and episode['maturity'].get('value', None) is not None:
+                mpaa = str(episode['maturity'].get('board', '').encode('utf-8')) + '-' + str(episode['maturity'].get('value', '').encode('utf-8'))
+
         return {
             episode['summary']['id']: {
                 'id': episode['summary']['id'],
@@ -1250,7 +1255,7 @@ class NetflixSession:
                 'title': episode['info']['title'],
                 'year': episode['info']['releaseYear'],
                 'genres': self.parse_genres_for_video(video=episode, genres=genres),
-                'mpaa': str(episode['maturity']['rating']['board']) + ' ' + str(episode['maturity']['rating']['value']),
+                'mpaa': mpaa,
                 'maturity': episode['maturity'],
                 'playcount': (0, 1)[episode['watched']],
                 'rating': episode['userRating'].get('average', 0) if episode['userRating'].get('average', None) != None else episode['userRating'].get('predicted', 0),
@@ -1360,7 +1365,7 @@ class NetflixSession:
         response = self._path_request(paths=paths)
         return self._process_response(response=response, component='Search results')
 
-    def fetch_video_list (self, list_id, list_from=0, list_to=20):
+    def fetch_video_list (self, list_id, list_from=0, list_to=26):
         """Fetches the JSON which contains the contents of a given video list
 
         Parameters
@@ -2294,11 +2299,29 @@ class NetflixSession:
             :obj:`str` of :obj:`str
             ESN, something like: NFCDCH-MC-D7D6F54LOPY8J416T72MQXX3RD20ME
         """
-        esn = ''
+        # we generate an esn from device strings for android
+        import subprocess
+        manufacturer = subprocess.check_output(["/system/bin/getprop", "ro.product.manufacturer"])
+
+        if manufacturer :
+            esn = 'NFANDROID1-PRV-'
+            input = subprocess.check_output(["/system/bin/getprop", "ro.nrdp.modelgroup"])
+            if not input:
+                esn = esn + 'T-L3-'
+            else:
+                esn = esn + input.strip(' \t\n\r') + '-'
+            esn = esn + '{:5}'.format(manufacturer.strip(' \t\n\r').upper())
+            input = subprocess.check_output(["/system/bin/getprop" ,"ro.product.model"])
+            esn = esn + input.strip(' \t\n\r').replace(' ', '=').upper()
+            self.log(msg='Android generated ESN:' + esn)
+            return esn
+
         # values are accessible via dict (sloppy parsing successfull)
         if type(netflix_page_data) == dict:
             return netflix_page_data.get('esn', '')
 
+        esn = ''
+
         # values are stored in lists (returned from JS parser)
         for item in netflix_page_data:
             if 'esnGeneratorModel' in dict(item).keys():