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

⌈⌋ branch:  streamtuner2


Check-in [79ef6e5f2a]

Overview
Comment:Some more comments and log messages.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 79ef6e5f2ab94387791cb7cde1862f9d03a2662a
User & Date: mario on 2015-04-23 19:04:21
Other Links: manifest | tags
Context
2015-04-23
19:31
Use distinct /tmp/streamtuner2/ directory for temporary pls/m3u/xspf files (also for DND). And have action. module reuse them, based on numeric row{} hash. check-in: 7411543862 user: mario tags: trunk
19:04
Some more comments and log messages. check-in: 79ef6e5f2a user: mario tags: trunk
19:04
Add uikit.tree() instantiation for bookmarks tab. check-in: dbfe218f76 user: mario tags: trunk
Changes

Modified ahttp.py from [1c2ab28748] to [eff0a41e0b].

70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#srcout    raise Exception("Simulated HTTP error")
#endif
    
    # read
    if post:
        r = session.post(url, params=params, headers=headers, timeout=7.5)
    else:    
        r = session.get(url, params=params, headers=headers, timeout=9.75)

    log.HTTP(r.request.headers );
    log.HTTP(r.headers );
            
    # finish, clean statusbar
    #progress_feedback(0.9)
    #progress_feedback("")

    # result
    log.INFO("Content-Length", len(r.content) )







|

|
|







70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#srcout    raise Exception("Simulated HTTP error")
#endif
    
    # read
    if post:
        r = session.post(url, params=params, headers=headers, timeout=7.5)
    else:    
        r = session.get(url, params=params, headers=headers, verify=False, timeout=9.75)

    log.HTTP(">>>", r.request.headers );
    log.HTTP("<<<", r.headers );
            
    # finish, clean statusbar
    #progress_feedback(0.9)
    #progress_feedback("")

    # result
    log.INFO("Content-Length", len(r.content) )

Modified channels/internet_radio.py from [69d9499a8c] to [1cd93c503e].

37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

# streams and gui
class internet_radio (ChannelPlugin):

    # control data
    listformat = "pls"
    categories = []
    base_url = "http://www.internet-radio.com/"


    # load genres
    def update_categories(self):
    
        html = http.get(self.base_url)
        rx = re.compile("""="/stations/[-+&.\w\s%]+/">([^<]+)<""")







|







37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

# streams and gui
class internet_radio (ChannelPlugin):

    # control data
    listformat = "pls"
    categories = []
    base_url = "https://www.internet-radio.com/"


    # load genres
    def update_categories(self):
    
        html = http.get(self.base_url)
        rx = re.compile("""="/stations/[-+&.\w\s%]+/">([^<]+)<""")
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97

98
99
100
101
102
103
104
                    "/" + ("page"+str(page) if page>1 else "")
                )
            )

            # Is there a next page?
            if str(page+1) not in rx_pages.findall(html[-1]):
                break
            self.parent.status(float(page)/float(max_pages+1))

        # Alternatively try regex or pyquery parsing
        #log.HTTP(html)
        for use_rx in [not conf.pyquery, conf.pyquery]:
            try:
                entries = (self.with_regex(html) if use_rx else self.with_dom(html))
                if len(entries):
                    break
            except Exception as e:
                log.ERR(e)
                continue
            
        # fin

        return entries


    # Regex extraction
    def with_regex(self, html):
        log.PROC("internet-radio, regex")
        r = []







|













>







77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
                    "/" + ("page"+str(page) if page>1 else "")
                )
            )

            # Is there a next page?
            if str(page+1) not in rx_pages.findall(html[-1]):
                break
#            self.parent.status(float(page)/float(max_pages+1))

        # Alternatively try regex or pyquery parsing
        #log.HTTP(html)
        for use_rx in [not conf.pyquery, conf.pyquery]:
            try:
                entries = (self.with_regex(html) if use_rx else self.with_dom(html))
                if len(entries):
                    break
            except Exception as e:
                log.ERR(e)
                continue
            
        # fin
        log.FINISHED("internet_radio.update_streams")
        return entries


    # Regex extraction
    def with_regex(self, html):
        log.PROC("internet-radio, regex")
        r = []

Modified channels/youtube.py from [16920f30fd] to [7b3bfc3dfd].

70
71
72
73
74
75
76
77

78
79
80
81
82
83
84
    listformat = "url/youtube"
    has_search = True
    audioformat = "video/youtube"
    titles = dict( genre="Channel", title="Title", playing="Playlist", bitrate=False, listeners=False )

    # API config
    service = {
        2: [ "http://gdata.youtube.com/",

            {
                "v": 2,
                "alt": "json",
                "max-results": 50,
            }
        ],
        3: [ "https://www.googleapis.com/youtube/v3/",







|
>







70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
    listformat = "url/youtube"
    has_search = True
    audioformat = "video/youtube"
    titles = dict( genre="Channel", title="Title", playing="Playlist", bitrate=False, listeners=False )

    # API config
    service = {
        2: [ "http://gdata.youtube.com/", 
            # deprecated on 2015-04-20, no /v3/ alternative, pertains "mostPopular" category only
            {
                "v": 2,
                "alt": "json",
                "max-results": 50,
            }
        ],
        3: [ "https://www.googleapis.com/youtube/v3/",

Modified cli.py from [9a0f511a31] to [de8c726472].

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
    plugins = {} # only populated sparsely by .stream()
    
    
    # start
    def __init__(self, actions):

        # fake init    
        action.action.main = empty_parent()
        action.action.main.current_channel = self.current_channel

        # check if enough arguments, else  help
        if not actions:
            a = self.help
        # first cmdline arg == action
        else:
            command = actions[0]







|
|







36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
    plugins = {} # only populated sparsely by .stream()
    
    
    # start
    def __init__(self, actions):

        # fake init    
        action.main = empty_parent()
        action.main.current_channel = self.current_channel

        # check if enough arguments, else  help
        if not actions:
            a = self.help
        # first cmdline arg == action
        else:
            command = actions[0]

Modified config.py from [b88512db4c] to [fe8ee86843].

475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
        self.method = name
        return self.log_print
    
    # Printer
    def log_print(self, *args, **kwargs):
        # debug level
        method = self.method.upper()
        if not method == "ERR":
            if "debug" in conf and not conf.debug:
                return
        # color/prefix
        method = r"[{}[{}]".format(self.colors.get(method, "47m"), method)
        # output
        print(method + " " + " ".join([str(a) for a in args]), file=sys.stderr)








|







475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
        self.method = name
        return self.log_print
    
    # Printer
    def log_print(self, *args, **kwargs):
        # debug level
        method = self.method.upper()
        if method != "ERR":
            if "debug" in conf and not conf.debug:
                return
        # color/prefix
        method = r"[{}[{}]".format(self.colors.get(method, "47m"), method)
        # output
        print(method + " " + " ".join([str(a) for a in args]), file=sys.stderr)