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

⌈⌋ ⎇ branch:  streamtuner2


Check-in [539c433d31]

Overview
Comment:Disable xiph plugin per default, introduce requests.Session() support for implicit cookies
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 539c433d318044c4dd8706c883caff78984f378c
User & Date: mario on 2014-04-28 02:05:34
Other Links: manifest | tags
Context
2014-04-28
02:13
changelog for 2.1.0 check-in: 5005ad1f3b user: mario tags: trunk, 2.1.0
02:05
Disable xiph plugin per default, introduce requests.Session() support for implicit cookies check-in: 539c433d31 user: mario tags: trunk
02:05
Update for 2.1.0 files check-in: 7863a3ff19 user: mario tags: trunk
Changes

Modified ahttp.py from [cfbb6a842e] to [54ba22823f].

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#  And a function to add trailings slashes on http URLs.
#
#


from config import conf, __print__, dbg
import requests
import copy



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

# Sets either text or percentage of main windows' status bar.







|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#  And a function to add trailings slashes on http URLs.
#
#


from config import conf, __print__, dbg
import requests




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

# Sets either text or percentage of main windows' status bar.
35
36
37
38
39
40
41


42
43
44
45
46
47
48
49
50
51
52
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
82
83
84
85
  if feedback:
    try: [feedback(d) for d in args]
    except: pass






# default HTTP headers for requests
default_headers = {
    "User-Agent": "streamtuner2/2.1 (X11; U; Linux AMD64; en; rv:1.5.0.1) like WinAmp/2.1 but not like Googlebot/2.1", #"Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.6) Gecko/20100628 Ubuntu/10.04 (lucid) Firefox/3.6.6",
    "Accept": "*/*;q=0.5, audio/*, url/*",
    "Accept-Language": "en-US,en,de,es,fr,it,*;q=0.1",
    "Accept-Encoding": "gzip,deflate",
    "Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.1",
    "Keep-Alive": "115",
    "Connection": "keep-alive",
    "Pragma": "no-cache",
    "Cache-Control": "no-cache",
}



#-- Retrieve data via HTTP
#
#  Well, it says "get", but it actually does POST and AJAXish GET requests too.
#
def get(url, params={}, referer="", post=0, ajax=0, binary=0, feedback=None):
    __print__( dbg.HTTP, "GET", url)

    # statusbar info
    progress_feedback(url, 0.1)
    
    # combine headers
    headers = copy.copy(default_headers)
    if ajax:
        headers["X-Requested-With"] = "XMLHttpRequest"
    if referer:
        headers["Referer"] = (referer if referer else url)
    
    # read
    if post:
        r = requests.post(url, params=params, headers=headers)
    else:    
        r = requests.get(url, params=params, headers=headers)
        
    # result
    progress_feedback(0.9)
    content = (r.content if binary else r.text)
    
    # finish, clean statusbar
    progress_feedback()







>
>

|









|














|







|

|







35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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
82
83
84
85
86
87
  if feedback:
    try: [feedback(d) for d in args]
    except: pass




# prepare default query object
session = requests.Session()
# default HTTP headers for requests
session.headers.update({
    "User-Agent": "streamtuner2/2.1 (X11; U; Linux AMD64; en; rv:1.5.0.1) like WinAmp/2.1 but not like Googlebot/2.1", #"Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.6) Gecko/20100628 Ubuntu/10.04 (lucid) Firefox/3.6.6",
    "Accept": "*/*;q=0.5, audio/*, url/*",
    "Accept-Language": "en-US,en,de,es,fr,it,*;q=0.1",
    "Accept-Encoding": "gzip,deflate",
    "Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.1",
    "Keep-Alive": "115",
    "Connection": "keep-alive",
    "Pragma": "no-cache",
    "Cache-Control": "no-cache",
})



#-- Retrieve data via HTTP
#
#  Well, it says "get", but it actually does POST and AJAXish GET requests too.
#
def get(url, params={}, referer="", post=0, ajax=0, binary=0, feedback=None):
    __print__( dbg.HTTP, "GET", url)

    # statusbar info
    progress_feedback(url, 0.1)
    
    # combine headers
    headers = {}
    if ajax:
        headers["X-Requested-With"] = "XMLHttpRequest"
    if referer:
        headers["Referer"] = (referer if referer else url)
    
    # read
    if post:
        r = session.post(url, params=params, headers=headers)
    else:    
        r = session.get(url, params=params, headers=headers)
        
    # result
    progress_feedback(0.9)
    content = (r.content if binary else r.text)
    
    # finish, clean statusbar
    progress_feedback()

bundle/requests/packages/chardet/chardetect.py became a regular file with contents [925391857a].

Modified config.py from [9c4bf2dcba] to [8c6d57fc14].

70
71
72
73
74
75
76

77
78
79
80
81
82
83
            self.record = {
               "*/*": "x-terminal-emulator -e streamripper %srv",
                    #  x-terminal-emulator -e streamripper %srv -d /home/***USERNAME***/Musik
            }
            self.plugins = {
                "bookmarks": 1,  # built-in plugins, cannot be disabled
                "shoutcast": 1,

                "punkcast": 0,   # disable per default
                "basicch": 0,   # ceased
                "tv": 0,   # no longer working
            }
            self.tmp = os.environ.get("TEMP", "/tmp")
            self.max_streams = "120"
            self.show_bookmarks = 1







>







70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
            self.record = {
               "*/*": "x-terminal-emulator -e streamripper %srv",
                    #  x-terminal-emulator -e streamripper %srv -d /home/***USERNAME***/Musik
            }
            self.plugins = {
                "bookmarks": 1,  # built-in plugins, cannot be disabled
                "shoutcast": 1,
                "xiph": 0,     # way too slow on first start
                "punkcast": 0,   # disable per default
                "basicch": 0,   # ceased
                "tv": 0,   # no longer working
            }
            self.tmp = os.environ.get("TEMP", "/tmp")
            self.max_streams = "120"
            self.show_bookmarks = 1

Modified st2.py from [bd7fd6c62b] to [7776cafb92].

89
90
91
92
93
94
95


96
97
98
99
100
101
102
from config import __print__, dbg
import ahttp
import action  # needs workaround... (action.main=main)
from channels import *
import favicon





# this represents the main window
# and also contains most application behaviour
main = None
class StreamTunerTwo(gtk.Builder):









>
>







89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
from config import __print__, dbg
import ahttp
import action  # needs workaround... (action.main=main)
from channels import *
import favicon


__version__ = "2.1.0"


# this represents the main window
# and also contains most application behaviour
main = None
class StreamTunerTwo(gtk.Builder):


528
529
530
531
532
533
534
535
536
537
538
539
540
541
542


# auxiliary window: about dialog
class AboutStreamtuner2:
        # about us
        def __init__(self):
            a = gtk.AboutDialog()
            a.set_version("2.0.9.5")
            a.set_name("streamtuner2")
            a.set_license("Public Domain\n\nNo Strings Attached.\nUnrestricted distribution,\nmodification, use.")
            a.set_authors(["Mario Salzer <http://mario.include-once.org/>\n\nConcept based on streamtuner 0."+"99."+"99 from\nJean-Yves Lefort, of which some code remains\nin the Google stations plugin.\n<http://www.nongnu.org/streamtuner/>\n\nMyOggRadio plugin based on cooperation\nwith Christian Ehm. <http://ehm-edv.de/>"])
            a.set_website("http://milki.include-once.org/streamtuner2/")
            a.connect("response", lambda a, ok: ( a.hide(), a.destroy() ) )
            a.show()
            







|







530
531
532
533
534
535
536
537
538
539
540
541
542
543
544


# auxiliary window: about dialog
class AboutStreamtuner2:
        # about us
        def __init__(self):
            a = gtk.AboutDialog()
            a.set_version(__version__)
            a.set_name("streamtuner2")
            a.set_license("Public Domain\n\nNo Strings Attached.\nUnrestricted distribution,\nmodification, use.")
            a.set_authors(["Mario Salzer <http://mario.include-once.org/>\n\nConcept based on streamtuner 0."+"99."+"99 from\nJean-Yves Lefort, of which some code remains\nin the Google stations plugin.\n<http://www.nongnu.org/streamtuner/>\n\nMyOggRadio plugin based on cooperation\nwith Christian Ehm. <http://ehm-edv.de/>"])
            a.set_website("http://milki.include-once.org/streamtuner2/")
            a.connect("response", lambda a, ok: ( a.hide(), a.destroy() ) )
            a.show()