Internet radio browser GUI for music/video streams from various directory services.

⌈⌋ branch:  streamtuner2


Check-in [d9a4e95fc9]

Overview
Comment:Add more detailed user-agent string, introduce conf.version (from pmd)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:d9a4e95fc91c083da13cf09c8e9733cde0e2a0a7
User & Date: mario on 2020-05-21 11:54:03
Other Links: manifest | tags
Context
2020-05-21
11:54
safeguard wiki/links retrieval check-in: 3ab6b3fa94 user: mario tags: trunk
11:54
Add more detailed user-agent string, introduce conf.version (from pmd) check-in: d9a4e95fc9 user: mario tags: trunk
2020-05-20
07:02
Remove *.js remnants again from help/html/ check-in: 6d04cfab23 user: mario tags: trunk
Changes

Modified ahttp.py from [e3550d5d4c] to [70322b0ca9].

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
..
27
28
29
30
31
32
33
34
35
36
37
38
39


40
41
42
43
44
45
46
..
53
54
55
56
57
58
59






60
61
62
63

64
65
66
67
68
69
70
71
72
73
74
# Provides a http "GET" method, but also does POST and AJAX-
# simulating requests too. Hooks into mains gtk.statusbar().
# And can normalize URLs to always carry a trailing slash
# after the domain name.


from config import *
import requests

#-- 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
    httplib.HTTPConnection.debuglevel = 1
    logging.basicConfig() 
................................................................................
    requests_log = logging.getLogger("requests.packages.urllib3")
    requests_log.setLevel(logging.DEBUG)
    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



#-- hooks to progress meter and status bar in main window
feedback = None

# Sets either text or percentage of main windows' status bar.
#
# Can either take a float parameter (e.g. 0.99 for % indicator)
................................................................................
  timeout = kwargs.get("timeout", 50)

  # send to main win
  if feedback:
    try: [feedback(d, timeout=timeout) for d in args]
    except: pass








# prepare default query object
session = requests.Session()
session.verify = ca_certs

#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",
    "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",
})









|







 







<

<



>
>







 







>
>
>
>
>
>



|
>



|







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
..
27
28
29
30
31
32
33

34

35
36
37
38
39
40
41
42
43
44
45
46
..
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Provides a http "GET" method, but also does POST and AJAX-
# simulating requests too. Hooks into mains gtk.statusbar().
# And can normalize URLs to always carry a trailing slash
# after the domain name.


from config import *
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
    httplib.HTTPConnection.debuglevel = 1
    logging.basicConfig() 
................................................................................
    requests_log = logging.getLogger("requests.packages.urllib3")
    requests_log.setLevel(logging.DEBUG)
    requests_log.propagate = True

#-- ssl
try:
    import certifi

    ca_certs = certifi.where()

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.
#
# Can either take a float parameter (e.g. 0.99 for % indicator)
................................................................................
  timeout = kwargs.get("timeout", 50)

  # 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()
#if ca_certs:
#    session.certs = certifi
#log.SESS(session.__dict__)
# default HTTP headers for requests
session.headers.update({
    "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",
})


Modified channels/useragentswitcher.py from [71f46e84c4] to [f18e75e82e].

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

# override ahttp.session headers, hooks into config dialog
class useragentswitcher():

    module = 'useragentswitcher'
    meta = plugin_meta()
    map = {
       "default": "streamtuner2/2.2 (X11; Linux amd64; rv:62.0) like WinAmp/2.1",
       "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",
       "itunes": "iTunes/9.0.3 (Macintosh; U; Intel Mac OS X 10_6_2; en-ca)",
       "googlebot": "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",







|







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

# override ahttp.session headers, hooks into config dialog
class useragentswitcher():

    module = 'useragentswitcher'
    meta = plugin_meta()
    map = {
       "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",
       "itunes": "iTunes/9.0.3 (Macintosh; U; Intel Mac OS X 10_6_2; en-ca)",
       "googlebot": "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",

Modified config.py from [0fccb051e3] to [f8ba9ac1af].

98
99
100
101
102
103
104




105
106
107
108
109
110
111
                del last["share"]
            self.update(last)
            self.migrate()
        # store defaults in file
        else:
            self.save("settings")
            self.firstrun = 1





        # temporary files
        if not os.path.exists(self.tmp):
            os.mkdir(self.tmp)
        
        # add argv
        self.args = self.init_args(argparse.ArgumentParser())







>
>
>
>







98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
                del last["share"]
            self.update(last)
            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)
        
        # add argv
        self.args = self.init_args(argparse.ArgumentParser())