updates fetched from Aciidisco
[plugin.video.netflix.git] / resources / lib / utils.py
index afb056f7994fa7c5a9483bd1a06ca70fad3029c8..a1b1a2db38adef45120768bc957ca92ee002073f 100644 (file)
@@ -3,6 +3,8 @@
 # Module: utils
 # Created on: 13.01.2017
 
+import platform
+
 # Takes everything, does nothing, classic no operation function
 def noop (**kwargs):
     return True
@@ -27,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'