X-Git-Url: http://git.code-monkey.de/?p=plugin.video.netflix.git;a=blobdiff_plain;f=resources%2Flib%2Futils.py;h=a1b1a2db38adef45120768bc957ca92ee002073f;hp=25cd28551f2f5dd77b3b5cf2af1f9c54d261a136;hb=ff2b5ac70453c86580956b4e0f6b16bb514c9566;hpb=85447a5fdfc7dff80e2272d77a5f94c0eddff1af diff --git a/resources/lib/utils.py b/resources/lib/utils.py index 25cd285..a1b1a2d 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -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'