Index: ahttp.py ================================================================== --- ahttp.py +++ ahttp.py @@ -13,11 +13,11 @@ # And can normalize URLs to always carry a trailing slash # after the domain name. from config import * -import requests +import requests, platform #-- extra debugging, http://stackoverflow.com/questions/10588644/how-can-i-see-the-entire-http-request-thats-being-sent-by-my-python-application if conf.debug >= 2: import logging import httplib @@ -29,16 +29,16 @@ requests_log.propagate = True #-- ssl try: import certifi - from requests.packages.urllib3.exceptions import InsecureRequestWarning ca_certs = certifi.where() - requests.packages.urllib3.disable_warnings(InsecureRequestWarning) except Exception as e: log.WARN("No SSL support. Try `sudo pip install urllib3[secure] certifi`", e) ca_certs = False + from requests.packages.urllib3.exceptions import InsecureRequestWarning + requests.packages.urllib3.disable_warnings(InsecureRequestWarning) #-- hooks to progress meter and status bar in main window feedback = None # Sets either text or percentage of main windows' status bar. @@ -55,18 +55,25 @@ # send to main win if feedback: try: [feedback(d, timeout=timeout) for d in args] except: pass +#-- more detailed U-A string +def user_agent(): + desc = {"Darwin":"MacOS", "Windows":"NT", "Linux":"X11"}.get(platform.system(), "X11") + return "streamtuner2/{} ({}; {} {}; Python/{}; rv:{}) like WinAmp/2.1".format( + conf.version, desc, platform.system(), platform.machine(), platform.python_version(), "72.0" + ) # prepare default query object session = requests.Session() -session.verify = ca_certs +#if ca_certs: +# session.certs = certifi #log.SESS(session.__dict__) # default HTTP headers for requests session.headers.update({ - "User-Agent": "streamtuner2/2.2 (X11; Linux amd64; rv:52.0) like WinAmp/2.1", + "User-Agent": user_agent(), "Accept": "*/*", "Accept-Language": "en-US,en,de,es,fr,it,*;q=0.1", "Accept-Encoding": "gzip, deflate", "Accept-Charset": "UTF-8, ISO-8859-1;q=0.5, *;q=0.1", }) Index: channels/useragentswitcher.py ================================================================== --- channels/useragentswitcher.py +++ channels/useragentswitcher.py @@ -25,11 +25,11 @@ class useragentswitcher(): module = 'useragentswitcher' meta = plugin_meta() map = { - "default": "streamtuner2/2.2 (X11; Linux amd64; rv:62.0) like WinAmp/2.1", + "default": ahttp.user_agent(), "vlc": "vlc 1.1.0-git-20100330-0003", "firefox": "Mozilla/5.0 (Windows NT 6.3; rv:62.0) Gecko/20100101 Firefox/62.0", "chrome": "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36", "android": "Mozilla/5.0 (Linux; U; Android 4.2; en-us; Nexus 10 Build/JVP15I) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30", "msie": "Mozilla/5.0 (compatible, MSIE 11, Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko", Index: config.py ================================================================== --- config.py +++ config.py @@ -100,10 +100,14 @@ self.migrate() # store defaults in file else: self.save("settings") self.firstrun = 1 + try: + self.version = plugin_meta(frame=3).get("version", "2.2") + except Exception as e: + self.version = "2.2" # temporary files if not os.path.exists(self.tmp): os.mkdir(self.tmp)