updates fetched from Aciidisco
[plugin.video.netflix.git] / resources / lib / utils.py
index 25cd28551f2f5dd77b3b5cf2af1f9c54d261a136..a1b1a2db38adef45120768bc957ca92ee002073f 100644 (file)
@@ -3,22 +3,7 @@
 # Module: utils
 # Created on: 13.01.2017
 
-# strips html from input
-# used the kick out the junk, when parsing the inline JS objects of the Netflix homepage
-from HTMLParser import HTMLParser
-class MLStripper(HTMLParser):
-    def __init__(self):
-        self.reset()
-        self.fed = []
-    def handle_data(self, d):
-        self.fed.append(d)
-    def get_data(self):
-        return ''.join(self.fed)
-
-def strip_tags(html):
-    s = MLStripper()
-    s.feed(html)
-    return s.get_data()
+import platform
 
 # Takes everything, does nothing, classic no operation function
 def noop (**kwargs):
@@ -44,3 +29,20 @@ def log(f, name=None):
         return result
     wrapped.__doc__ = f.__doc__
     return wrapped
+
+def get_user_agent_for_current_platform():
+    """Determines the user agent string for the current platform (to retrieve a valid ESN)
+
+    Returns
+    -------
+    :obj:`str`
+        User Agent for platform
+    """
+    system = platform.system()
+    if system == 'Darwin':
+        return 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36'
+    if system == 'Windows':
+        return 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36'
+    if platform.machine().startswith('arm'):
+        return 'Mozilla/5.0 (X11; CrOS armv7l 7647.78.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36'
+    return 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36'