Merge pull request #66 from matejmosko/patch-2
[plugin.video.netflix.git] / resources / lib / NetflixSession.py
index eed11b3aff82e0697fd83a62a498671e1403c6f7..ca4bd5cc0272449d88bfaaf71a96ce508b17acb4 100644 (file)
@@ -150,8 +150,6 @@ class NetflixSession:
                 List of all the serialized data pulled out of the pagws <script/> tags
         """
         scripts = page_soup.find_all('script', attrs={'src': None})
-        self.log(msg='Debug output for HTML contents:')
-        self.log(msg=page_soup)
         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:
@@ -1242,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'],
@@ -1252,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']).encode('utf-8') + ' ' + str(episode['maturity']['rating']['value']).encode('utf-8'),
+                '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),
@@ -2296,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():