1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 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 110 111 112 113 114 115 116 117 118 119 120 121 122 123 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 152 153 154 155 156 157 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 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 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 312 313 314 315 316 317 318 319 320 321 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 351 352 353 354 355 356 357 358 359 360 361 362 363 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 394 395 396 397 398 399 400 401 402 403 404 405 406 407
|
# encoding: UTF-8
# api: streamtuner2
# title: Jamendo
# description: A license-free music collection and artist hub.
# type: channel
# version: 2.3
# 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." }
# priority: default
# png:
# iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAwNJREFUOI1lk0toXGUYhp/v/8+ZzDQzmdZMZ8YSkxIQCWTTYsALLsQsUsWFQgJeEJQqIigUvBK0FBQULIJKMEKrFjdOW9xoW1AbRdRCEYtd2GCxxUQbk8bMrTNnzpn//1xMLYLv6l2877N7oBcB0GMY
# IAUY/p9w/glCrVzby3+LVqaxM4dx+inQV7KIHcKYAbzG4FYgqcmudYBAF+jKnT2QAExPYysVHCdKRQgewwRT0B1FfQboYsLLeE7hk4Oo/iD3rFit4GQGRCsYwJMt7yQVfrS6Go3HUQtvskiwCWM82qlijGdbaUsbTV5G/X65+y+rCzgBRI+VbsSmvvltqVkuX78t6rvpKWtvuMsgOfHtJia66OPz
# 86564UtDkA2Lm/VJYF6mLgXo50X0xNAHy4cK2jk+diVe+1FVVX/57oIuL66qqmriVF23rZ1TjyTLH2YT/WJ4TY+XRgAMKqNgJ41vebbvTgeFneo6Tb567zPmHn+LxdPnCIxHTFrt2CtB/8BWqtVOAewDWgGDmHG0u1VtztjC7SLqRSUkM5Clsd5ibs/7nDzyLd51xfQPq82PKS5SsHfQAEMsIZG3
# khgvJqUqBhFBnSeTS1O/XOPou0eoVxuIsfgkRDsqxBIQgaEVXyIyTVdvGFdbQlD1LibpJDTWG9w8NcHsgRfIb8ni4qbIxhISGU87+Z00BMTuDPhfg47b4X4+oHZ4VxiksxRHi9x3y71M7p5EjAWE6OxBkj/OaSqTgyvJUUIQncuDDx6qRsHHLqpHuR0PW3vbbCj5EYyAAq7dgMVPfHRytt2Kkv7i
# 5vAw0n1wZuFvFcDq/kGP5/X1tnm+2aiTLQy59MiE00wZ49okK2fNxsWfgnRfmvJA8D3E98tztTWdBtG9IPuw+tqgI+RRTLin1miNJ3EkRhQFxIRcl8+tgj9EN35VXqrV9G2MPIPvWfgv5I1Bh/pNBOGtYCeALEKM6nlc52uUP+XFDfRpRN7psa/ZeBWSAmJ99qrQGaANeJA3AUjpXhLZ1zsD+g+5
# Cnd9pANrngAAAABJRU5ErkJggg==
# extraction-method: json, custom-mime
#
#
# Utilizes the Jamendo /v3.0/ API now completely. That means all tracks will
# be available as Ogg Vorbis per default.
#
# Radio stations are a fixed internal list. There's not much point in querying
# the API for them. (They're really just automated playlists, and MP3-only.)
#
# Genre lists for tracks are built-in, but give a good enough overview. There's
# no "related" lookup possibility yet in our station lists. (Might be feasible
# as plugin though, via [load more] button etc...)
#
# Per default Ogg Vorbis is used as streaming format. Track URLs can be played
# back directly. Playlists and albums now require a roundtrip over the action
# module to extract the JAMJson format into pls/m3u/xspf. (The previous v2 API
# retrieval is going to become inaccessible soon.)
import re
import ahttp
from config import *
from channels import *
import json
# jamendo CC music sharing site
#
#
# For the newer v3.0 streaming URLs there's a custom action.extract_playlist
# format now (JAMJSON), so that albums/feeds can be extracted into standard
# playlists as well.
#
# [+] http://api.jamendo.com/v3.0/playlists/file?client_id=&id=
# [+] http://storage-new.newjamendo.com/?trackid=792843&format=ogg2&u=0
# [+] http://api.jamendo.com/get2/stream/track/xspf/?playlist_id=171574&n=all&order=random
# [+] http://api.jamendo.com/get2/stream/track/xspf/?album_id=%s&streamencoding=ogg2&n=all
#
# Seem to resolve to OGG Vorbis each.
#
class jamendo (ChannelPlugin):
# control flags
has_search = True
base = "http://www.jamendo.com/en/"
audioformat = "audio/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 )
# refresh category list
def update_categories(self):
self.categories = [
"radios",
"playlists",
["feeds"], # should go below `albums`, but looks nicer here
"albums",
["newest"],
"tracks",
[
"pop",
"synthpop",
"trashpop",
"disco",
"eurodance",
"electropop",
"rock",
"hardrock",
"alternativerock",
"acousticrock",
"poprock",
"dance",
"dancehall",
"trance",
"psytrance",
"trancecore",
"hiphop",
"rap",
"rappers",
"dubstep",
"beat",
"beats",
"breakbeats",
"dub",
"club",
"edm",
"electronic",
"techno",
"electric",
"synthesizer",
"triphop",
"house",
"electrohouse",
"darkelectro",
"rnb",
"metal",
"heavymetal",
"thrashmetal",
"powermetal",
"groovemetal",
"jazz",
"acidjazz",
"smoothjazz",
"classicjazz",
"instrumental",
"acoustic",
"singersongwriter",
"vocal",
"vocals",
"voice",
"game",
"gamemusic",
"8bit",
"computer",
"classical", ###
"organ",
"orchestral",
"choral",
"ballad",
"piano",
"mozart",
"violin",
"cello",
"fiddle",
"ukelele",
"trumpet",
"saxophone",
"harmonica",
"accordion",
"soul",
"blues",
"deltablues",
"swing",
"boogie",
"funk",
"electrofunk",
"folk",
"folkrock",
"world", ###
"african",
"middleeastern",
"arabic",
"asian",
"oriental",
"latin",
"french",
"german",
"irish",
"celtic",
"country",
"reggae",
"emotion",
"romantic", ###
"love",
"slow",
"quiet",
"happy",
"angry",
"sad",
"mysterious",
"atmospheric",
"mellow",
"dark",
"dream"
"energic",
"downtempo",
"sexy",
"melancholic",
"progressive",
"experimental",
"evolutive",
"alternative",
"sampler",
"minimalism",
"avantgarde",
"elegant",
"vintage",
"retro",
"oldschool",
"traditional",
"adult",
"communication",
"advertising",
"indie",
"improvisation",
"lofi",
"newage",
"grunge",
"raw",
"industrial",
"bass",
"drum",
"epic",
"soundtrack",
"rhythmic",
"keyboard",
"drummachine",
"acousticguitar",
"bongo",
"rumba",
"pinkfloydian",
"gothic",
"space",
"didgeridoo",
"energetic",
"worldfusion",
"fusion",
"noise",
"jungle",
"lounge",
"relaxing",
"easylistening",
"ambient",
"meditative",
"psychedelic",
"chillout",
"soft",
]
]
return self.categories
# retrieve category or search
def update_streams(self, cat, search=None):
entries = []
fmt = conf.jamendo_stream_format
fmt_mime = self.stream_mime(fmt)
# Static list of Radios
if cat == "radios":
for radio in ["BestOf", "Pop", "Rock", "Lounge", "Electro", "HipHop", "World", "Jazz", "Metal", "Soundtrack", "Relaxation", "Classical"]:
j = self.api(method="radios/stream", name=radio.lower(), imagesize=30)
if not len(j):
continue
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(),
})
# 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"]),
})
# 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": "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,
})
# 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"]),
})
# Genre list, or Search
else:
if cat:
data = self.api(method="tracks", order="popularity_week", include="musicinfo", fuzzytags=cat, audioformat=fmt)
elif search:
data = self.api(method="tracks", order="popularity_week", include="musicinfo", search=search, audioformat=fmt)
else:
data = []
for e in data:
entries.append({
"lang": e["musicinfo"]["lang"],
"genre": " ".join(e["musicinfo"]["tags"]["genres"]),
"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": fmt_mime,
"listformat": "srv",
})
# done
return entries
# Collect data sets from Jamendo API
def api(self, method, **params):
r = []
max = 200 * int(conf.jamendo_count)
params = dict(
list({
"client_id": self.cid,
"format": "json",
"audioformat": "mp32",
"imagesize": conf.jamendo_image_size,
"offset": 0,
"limit": 200,
}.items()) + list(params.items())
)
while (params["offset"] < max) and (len(r) % 200 == 0):
data = ahttp.get(self.api_base + method, params, encoding="utf-8")
data = json.loads(data)
if data:
r += data["results"]
else:
return r
params["offset"] += 200;
self.parent.status(float(params["offset"])/float(max+17))
return r
# 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"
}
return map.get(name) or map["mp3"]
|