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

⌈⌋ branch:  streamtuner2


Diff

Differences From Artifact [55defe1856]:

To Artifact [13bc7ee950]:

  • File channels/jamendo.py — part of check-in [7149d92fe1] at 2015-04-18 17:19:38 on branch trunk — Updated Jamendo plugin audioformat and listformat descriptors. Attempted to use v3.0 API for playlist tracks. Still no playlist API endpoint. So using a separate track requests now. Implemented a new action/playlist_convert URL extractor, which shall henceforth be known as "jamj" (JamJibberish). Fixed XML url extraction in regex mode, trivial backslash deescaping for JSON formats; and fixed multiply URL bug by copying row{} dict during conversion. (user: mario, size: 13306) [annotate] [blame] [check-ins using]

53
54
55
56
57
58
59

60
61
62
63
64
65
66
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67







+






# Seem to resolve to OGG Vorbis each.
#
class jamendo (ChannelPlugin):

    # control flags
    has_search = True
    base = "http://www.jamendo.com/en/"
    audioformat = "ogg"
    listformat = "srv"
    api_base = "http://api.jamendo.com/v3.0/"
    cid = "49daa4f5"
    categories = []
    titles = dict( title="Title", playing="Album/Artist/User", bitrate=False, listeners=False )

256
257
258
259
260
261
262
263

264
265
266
267
268
269
270

271
272
273
274
275
276
277
278
279

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
257
258
259
260
261
262
263

264
265
266
267
268
269
270

271
272
273
274
275
276
277
278
279

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
316
317
318
319
320







-
+






-
+








-
+




-
-
-
+
+
+
+
+
+
+
+
+
+

















-
+
+








    # retrieve category or search
    def update_streams(self, cat, search=None):

        entries = []
        fmt = self.stream_mime(conf.jamendo_stream_format)
        
                
        # Static list of Radios
        if cat == "radios":
            for radio in ["BestOf", "Pop", "Rock", "Lounge", "Electro", "HipHop", "World", "Jazz", "Metal", "Soundtrack", "Relaxation", "Classical"]:
                entries.append({
                    "genre": radio,
                    "title": radio,
                    "url": "http://streaming.radionomy.com/Jam" + radio,
                    "url": "http://streaming.radionomy.com/Jam" + radio,  # optional +".m3u"
                    "playing": "various artists",
                    "format": "audio/mpeg",
                    "homepage": "http://www.jamendo.com/en/radios",
                    "img": "http://imgjam1.jamendo.com/new_jamendo_radios/%s30.jpg" % radio.lower(),
                })
        
        # Playlist
        elif cat == "playlists":
            for e in self.api(method = cat, order = "creationdate_desc"):
            for e in self.api(method="playlists", order="creationdate_desc"):
                entries.append({
                    "title": e["name"],
                    "playing": e["user_name"],
                    "homepage": e["shareurl"],
                    #"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/?playlist_id=%s&n=all&order=random&from=app-%s" % (e["id"], self.cid),
                    "format": "application/xspf+xml",
                    "extra": e["creationdate"],
                    "format": "audio/mpeg",
                    #"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=mp32&id={}".format(self.cid, e["id"]),
                })

        # Albums
        elif cat in ["albums", "newest"]:
            if cat == "albums":
                order = "popularity_week"
            else:
                order = "releasedate_desc"
            for e in self.api(method = "albums/musicinfo", order = order, include = "musicinfo"):
                entries.append({
                    "genre": " ".join(e["musicinfo"]["tags"]),
                    "title": e["name"],
                    "playing": e["artist_name"],
                    "img": e["image"],
                    "homepage": e["shareurl"],
                    #"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": "application/xspf+xml",
                    "format": "audio/ogg",
                    "listformat": "xspf",
                })
		
        # Genre list, or Search
        else:
            if cat:
                data = self.api(method = "tracks", order = "popularity_week", include = "musicinfo",
                                fuzzytags = cat, audioformat = conf.jamendo_stream_format)
321
322
323
324
325
326
327
328


329
330
331
332
333
334
335
330
331
332
333
334
335
336

337
338
339
340
341
342
343
344
345







-
+
+






                    "extra": ", ".join(e["musicinfo"]["tags"]["vartags"]),
                    "title": e["name"],
                    "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": self.stream_mime(fmt),
                    "format": fmt,
                    "listformat": "srv",
                })
 
        # done    
        return entries

    
    # Collect data sets from Jamendo API
361
362
363
364
365
366
367
368
369

370
371
372
371
372
373
374
375
376
377


378


379







-
-
+
-
-
    # audio/*
    def stream_mime(self, name):
        map = {
            "ogg": "audio/ogg", "ogg2": "audio/ogg",
            "mp3": "audio/mpeg", "mp31": "audio/mpeg", "mp32": "audio/mpeg",
            "flac": "audio/flac"
        }
        if name in map:
            return map[name]
        return map.get(name) or map["mp3"]
        else:
            return map["mp3"]