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

⌈⌋ ⎇ branch:  streamtuner2


Check-in [f269792f36]

Overview
Comment:Use new @use_rx decorator to switch and fall back between regex/pyquery modes.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f269792f36a71c71ca2d99dc42eac63275af7468
User & Date: mario on 2015-05-02 05:42:26
Other Links: manifest | tags
Context
2015-05-02
05:42
Remove redundant pq and compat2and3 imports. check-in: 8783b94a0a user: mario tags: trunk
05:42
Use new @use_rx decorator to switch and fall back between regex/pyquery modes. check-in: f269792f36 user: mario tags: trunk
05:41
Implement custom HTML .entitiy_decode, because SAX didn't honor any HTML; and HTMLParser would require customized/compat2and3 imports.

Colorize channel labels if #color: is specified in any plugins.

And provide @use_rx decorator to alternate between regex/pyquery extractors. check-in: 5588baf6dd user: mario tags: trunk

Changes

Modified channels/internet_radio.py from [8ca19cbde4] to [625824732f].

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
106
107
            # 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), timeout=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 = []
        html = "\n".join(html)
        







<
<
<
|
<
<
<
<





>
>
>
>
>
>
>
>
>







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
106
107
108
109
            # 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), timeout=1)

        # Alternatively try regex or pyquery parsing
        #log.HTTP(html)



        entries = self.from_html(html)




            
        # fin
        log.FINISHED("internet_radio.update_streams")
        return entries


    # Switch update method
    @use_rx
    def from_html(self, html, use_rx):
        if use_rx:
            return self.with_regex(html)
        else:
            return self.with_dom(html)


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