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

⌈⌋ ⎇ branch:  streamtuner2


Check-in [68bbdda1e4]

Overview
Comment:Add .click() counting callback.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 68bbdda1e445a50f27fe7c22bfeb9c412b8ef46c
User & Date: mario on 2020-05-13 18:59:34
Other Links: manifest | tags
Context
2020-05-14
23:05
Add binary JPEG detection \xFF\xD8\xFF magic bytes. check-in: a888486bae user: mario tags: trunk
2020-05-13
18:59
Add .click() counting callback. check-in: 68bbdda1e4 user: mario tags: trunk
17:46
Utilize PyQuery .make_links_absolute(), to shorten img src extraction. check-in: 857f6e2745 user: mario tags: trunk
Changes

Modified channels/radiobrowser.py from [1e7e0eb9e5] to [984872dde3].

1
2
3
4
5

6
7
8
9
10
11
12
1
2
3
4

5
6
7
8
9
10
11
12




-
+







# encoding: UTF-8
# api: streamtuner2
# title: RadioBrowser
# description: Community collection of stations; votes, clicks, homepage links.
# version: 0.4
# version: 0.5
# type: channel
# url: http://www.radio-browser.info/
# category: radio
# priority: optional
# config:
#   { name: radiobrowser_cat, type: select, value: tags, select="tags|countries|languages", description: Which category types to list. }
#   { name: radiobrowser_srv, type: select, value: all, select:"all|de1|fr1|nl1|old", description: API server to utilize. }
79
80
81
82
83
84
85

86
87
88
89
90
91
92
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93







+







    catmap = { "tags": "bytag", "countries": "bycountry", "languages": "bylanguage" }
    tagmap = { "tags": "tag", "countries": "country", "languages": "language" }

    # hook menu
    def init2(self, parent):
        if parent:
            uikit.add_menu([parent.streammenu, parent.streamactions], "Share in Radio-Browser", self.submit, insert=5)
            parent.hooks["play"].append(self.click)

    # votes, and tags, no countries or languages
    def update_categories(self):
        params = {"order":"name", "reverse":"false", "hidebroken":"true"} 
        self.categories = list(self.pricat) + [grp["name"] for grp in filter(
            lambda grp: grp["stationcount"] >= conf.radiobrowser_min,
            self.api(conf.radiobrowser_cat, params)
157
158
159
160
161
162
163












164
165
166
167
168
169
170
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183







+
+
+
+
+
+
+
+
+
+
+
+







        # request + json decode
        j = ahttp.get(srv + method, params, post=post, **kwargs)
        try:
            return json.loads(j, strict=False)   # some entries contain invalid character encodings
        except:
            return []


    # callback for general stream play event
    def click(self, row, channel):
        if not channel == self:
            return
        # fetch uuid, then register click
        uuid = self.api("stations/byurl", {"url": row.get("url")})
        if uuid:
            if isinstance(uuid, list): # just vote on the first entry
                uuid = uuid[0]
            log.PROC_CLICK_COUNT(self.api("url/{}".format(uuid["stationuuid"])))


    # Add radio station to RBI
    def submit(self, *w):
        cn = self.parent.channel()
        row = cn.row()
        # convert row from channel
        data = dict(