# 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):
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'