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

⌈⌋ ⎇ branch:  streamtuner2


Check-in [3e718937a3]

Overview
Comment:Implement jamendo APIs new `download_allowed` flags (as simple state icons here - purely visual, not actually affecting download button / not even sure if streamripper works on all entry types).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3e718937a3fd118c484203f382f7fdcfee7288b5
User & Date: mario on 2021-01-30 10:31:02
Other Links: manifest | tags
Context
2021-02-06
15:03
Update for changed itemtype= url (https) check-in: 0cfc0c113b user: mario tags: trunk
2021-01-30
10:31
Implement jamendo APIs new `download_allowed` flags (as simple state icons here - purely visual, not actually affecting download button / not even sure if streamripper works on all entry types). check-in: 3e718937a3 user: mario tags: trunk
2020-12-28
19:49
Update for recent change, but also implement JSON extraction while at it. check-in: 697df17183 user: mario tags: trunk
Changes

Modified channels/jamendo.py from [73c08be29f] to [2c513747d5].

1
2
3
4
5
6

7
8
9
10
11
12
13
1
2
3
4
5

6
7
8
9
10
11
12
13





-
+







# encoding: UTF-8
# api: streamtuner2
# title: Jamendo
# description: A license-free music collection and artist hub.
# type: channel
# version: 2.3
# version: 2.4
# category: radio
# url: http://jamendo.com/
# depends: json
# config: 
#    { name: jamendo_stream_format, value: ogg,  type: select,  select: "ogg=Vorbis, 112kbit/s|mp32=MP3, 192kbit/s|mp31=MP3, 96kbit/s|flac=FLAC, ≳600kbit/s",  description: "Audio format for tracks, albums, playlists." }
#    { name: jamendo_image_size,    value: 35,   type: select,  select: "25=25px|35=35px|50=50px|55=55px|60=60px|65=65px|70=70px|75=75px|85=85px|100=100px|130=130px|150=150px|200=200px|300=300px",  description: "Preview images size (height and width) for albums or tracks." }
#    { name: jamendo_count,         value: 1,    type: int,     description: "How many result sets (200 entries each) to retrieve." }
280
281
282
283
284
285
286
287


288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306

307
308
309
310
311
312
313
280
281
282
283
284
285
286

287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315







-
+
+



















+







                entries.append({
                    "genre": radio,
                    "title": j[0]["dispname"],
                    "url": j[0]["stream"], #"http://streaming.jamendo.com/Jam" + radio,  # optional +".m3u"
                    "playing": "various artists",
                    "format": "audio/mpeg",
                    "homepage": "http://www.jamendo.com/en/radios",
                    "img": j[0]["image"] #"http://imgjam1.jamendo.com/new_jamendo_radios/%s30.jpg" % radio.lower(),
                    "img": j[0]["image"], #"http://imgjam1.jamendo.com/new_jamendo_radios/%s30.jpg" % radio.lower(),
                    "state": "gtk-floppy",
                })
        
        # Playlist
        elif cat == "playlists":
            for e in self.api(method="playlists", order="creationdate_desc"):
                entries.append({
                    "title": e["name"],
                    "playing": e["user_name"],
                    "homepage": e["shareurl"],
                    "extra": e["creationdate"],
                    "format": fmt_mime,
                    #"listformat": "xspf", # deprecated
                    #"url": "http://api.jamendo.com/get2/stream/track/xspf/?playlist_id=%s&n=all&order=random&from=app-%s" % (e["id"], self.cid),
                    #"listformat": "href", # raw ZIP redirect
                    #"url": "http://api.jamendo.com/v3.0/playlists/file?client_id={}&audioformat=mp32&id={}".format(self.cid, e["id"]),
                    #"listformat": "href", # raw ZIP direct
                    #"url": e["zip"],
                    "listformat": "jamj",
                    "url": "http://api.jamendo.com/v3.0/playlists/tracks?client_id={}&audioformat={}&id={}".format(self.cid, fmt, e["id"]),
                    "state": self.download_icon(e),
                })

        # Albums
        elif cat in ["albums", "newest"]:
            if cat == "albums":
                order = "popularity_week"
            else:
322
323
324
325
326
327
328

329
330
331
332
333
334
335
336
337
338
339
340
341
342
343

344
345
346
347
348
349
350
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354







+















+







                    #"url": "http://api.jamendo.com/v3.0/playlists/file?client_id=%s&id=%s" % (self.cid, e["id"]),
                    #"url": "http://api.jamendo.com/get2/stream/track/xspf/?album_id=%s&streamencoding=ogg2&n=all&from=app-%s" % (e["id"], self.cid),
                    #"format": "audio/ogg",
                    #"listformat": "xspf",
                    "url": "http://api.jamendo.com/v3.0/tracks?client_id={}&audioformat={}&album_id={}".format(self.cid, fmt, e["id"]),
                    "listformat": "jamj",
                    "format": fmt_mime,
                    "state": self.download_icon(e),
                })

        # Feeds (News)
        elif cat == "feeds":
            for e in self.api(method="feeds", order="date_start_desc", target="notlogged"):
              if e.get("joinid") and e.get("subtitle"):
                entries.append({
                    "genre": e["type"],
                    "title": e["title"]["en"],
                    "playing": e["subtitle"]["en"],
                    "extra": e["text"]["en"],
                    "homepage": e["link"],
                    "format": fmt_mime,
                    "listformat": "jamj",
                    "url": "http://api.jamendo.com/v3.0/tracks?client_id={}&audioformat={}&album_id={}".format(self.cid, fmt, e["joinid"]),
                    "state": self.download_icon(e),
                })

        # Genre list, or Search
        else:
            if cat:
                data = self.api(method="tracks", order="popularity_week", include="musicinfo", fuzzytags=cat, audioformat=fmt)
            elif search:
360
361
362
363
364
365
366

367
368
369
370
371










372
373
374
375
376
377
378
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393







+





+
+
+
+
+
+
+
+
+
+







                    "playing": e["album_name"] + " / " + e["artist_name"],
                    "img": e["album_image"],
                    "homepage": e["shareurl"],
                    "url": e["audio"],
                    #"url": "http://storage-new.newjamendo.com/?trackid=%s&format=ogg2&u=0&from=app-%s" % (e["id"], self.cid),
                    "format": fmt_mime,
                    "listformat": "srv",
                    "state": self.download_icon(e),
                })
 
        # done    
        return entries

    # check for 'audiodownload_allowed' and whatever, set state icon
    def download_icon(self, e):
        #print(e['audiodownload_allowed'])
        if 'audiodownload_allowed' in e and not e['audiodownload_allowed']:
            return "gtk-stop" # gtk-close
        elif 'zip_allowed' in e and not e['zip_allowed']:
            return "gtk-delete" # gtk-cancel
        elif 'track_audiodownload_allowed' in e and not e['track_audiodownload_allowed']:
            return "gtk-print-paused" 
        return None # gtk-floppy
    
    # Collect data sets from Jamendo API
    def api(self, method, **params):
        r = []
        max = 200 * int(conf.jamendo_count)
        params = dict(
            list({