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

⌈⌋ ⎇ branch:  streamtuner2


Check-in [61a51c29f9]

Overview
Comment:Shoutcast: retry regex/dom really alternatively now (not just on exceptions, but also empty result sets)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 61a51c29f9c7c26c536f9ec9834e7424503a405e
User & Date: mario on 2014-05-26 20:21:17
Other Links: manifest | tags
Context
2014-05-26
21:18
Reorganized Jamendo plugin to simplify API calls. check-in: ca359689bf user: mario tags: trunk
20:21
Shoutcast: retry regex/dom really alternatively now (not just on exceptions, but also empty result sets) check-in: 61a51c29f9 user: mario tags: trunk
19:59
Retry regex after PyQuery extraction mode (or other way round). check-in: 696a0ab060 user: mario tags: trunk
Changes

Modified channels/jamendo.py from [75f35740e6] to [c602d9f7b7].

1
2
3
4
5

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15



16
17
18
19
20
21
22





+









-
-
-








# api: streamtuner2
# title: Jamendo
# description: A license-free music collection and artist hub.
# type: channel
# version: 2.2
# category: radio
# depends: json
# priority: default
#
# Now utilizes the Jamendo /v3.0/ API.
#
# Radio station lists are fixed for now. Querying the API twice per station
# doesn't seem overly sensible.
#
# Albums and Playlists are limited to 200 entries. Adding a cursor is
# feasible however.
#
# Tracks are queried by genre, where currently there's just a small built-in
# tag list in ST2.
#
#
# The v3.0 streaming URLs don't seem to work. Therefore some /get2 URLs will
# be used.
#

Modified channels/shoutcast.py from [ab1cca6f24] to [a7dc35c676].

124
125
126
127
128
129
130

131
132
133

134
135
136
137

138
139

140
141
142

143

144
145
146
147
148
149
150
124
125
126
127
128
129
130
131
132
133

134
135
136
137

138
139

140
141

142
143

144
145
146
147
148
149
150
151







+


-
+



-
+

-
+

-

+
-
+







            """

            # With the new shallow <td> lists it doesn't make much sense to use
            # the pyquery DOM traversal. There aren't any sensible selectors to
            # extract values; it's just counting the tags.
            # And there's a bug in PyQuery 1.2.4 and CssSelector. So make two
            # attempts, alternate between regex and DOM; user preference first.
            entries = []
            use_regex = not conf.get("pyquery") or not pq
            retry = 2
            while retry:
            while retry and not entries:
               retry -= 1
               try:
                  if use_regex:
                      return self.with_regex(html)
                      entries = self.with_regex(html)
                  else:
                      return self.with_dom(html)
                      entries = self.with_dom(html)
               except Exception as e:
                  use_regex ^= 1
                  __print__(dbg.ERR, e)
               use_regex ^= 1
            return []
            return entries


        # Extract using regex
        def with_regex(self, html):
            __print__(dbg.PROC, "channels.shoutcast.update_streams: regex scraping mode")
            rx_stream = re.compile(
                """