Artifact [9694d3b314]
Artifact 9694d3b3140fdf83521f3774537539e3c74f1ac0:
- File
channels/musicgoal.py
— part of check-in
[ac8632bc29]
at
2014-06-03 00:29:43
on branch trunk
— Search dialog offers (x) all channels or (x) just current for server+cache scan
again. Removed search="" parameter from channels that don't implement it.
(To remove extraneous .has_search channel attribute again somewhen..)
External: Xiph IO cache ?search= should be changed to work on station titles instead of genres. (user: mario, size: 3702) [annotate] [blame] [check-ins using]
# # api: streamtuner2 # title: MUSICGOAL # description: Broad list of radio stations and podcasts. Provides a sane API, but only 5 results each. # type: channel # category: radio # version: 0.1 # priority: optional # status: experimental # # Musicgoal.com is a radio and podcast directory. This plugin tries to use # the new API for accessing listing data. # # # st2 modules from config import conf from mygtk import mygtk import ahttp as http from channels import * # python modules import re import json # I wonder what that is for --------------------------------------- class musicgoal (ChannelPlugin): # desc module = "musicgoal" title = "MUSICGOAL" homepage = "http://www.musicgoal.com/" base_url = homepage listformat = "url/direct" # settings config = [ ] api_podcast = "http://www.musicgoal.com/api/?todo=export&todo2=%s&cat=%s&format=json&id=1000259223&user=streamtuner&pass=tralilala" api_radio = "http://www.musicgoal.com/api/?todo=playlist&format=json&genre=%s&id=1000259223&user=streamtuner&pass=tralilala" # categories are hardcoded podcast = ["Arts", "Management", "Recreation", "Knowledge", "Nutrition", "Books", "Movies & TV", "Music", "News", "Business", "Poetry", "Politic", "Radio", "Science", "Science Fiction", "Religion", "Sport", "Technic", "Travel", "Health", "New"] radio = ["Top radios", "Newcomer", "Alternative", "House", "Jazz", "Classic", "Metal", "Oldies", "Pop", "Rock", "Techno", "Country", "Funk", "Hip hop", "R&B", "Reggae", "Soul", "Indian", "Top40", "60s", "70s", "80s", "90s", "Sport", "Various", "Radio", "Party", "Christmas", "Firewall", "Auto DJ", "Audio-aacp", "Audio-ogg", "Video", "MyTop", "New", "World", "Full"] categories = ["podcasts/", podcast, "radios/", radio] #catmap = {"podcast": dict((i+1,v) for enumerate(self.podcast)), "radio": dict((i+1,v) for enumerate(self.radio))} # nop def update_categories(self): pass # request json API def update_streams(self, cat): # category type: podcast or radio if cat in self.podcast: grp = "podcast" url = self.api_podcast % (grp, self.podcast.index(cat)+1) elif cat in self.radio: grp = "radio" url = self.api_radio % cat.lower().replace(" ","").replace("&","") else: return [] # retrieve API data data = http.get(url, params=None, ajax=1) data = json.loads(data) # tranform datasets if grp == "podcast": return [{ "genre": cat, "title": row["titel"], "homepage": row["url"], "playing": str(row["typ"]), #"id": row["id"], #"listeners": int(row["2"]), #"listformat": "text/html", "url": "", } for row in data] else: return [{ "format": self.mime_fmt(row["ctype"]), "genre": row["genre"] or cat, "url": "http://%s:%s/%s" % (row["host"], row["port"], row["pfad"]), "listformat": "url/direct", "id": row["id"], "title": row["name"], "playing": row["song"], "homepage": row.get("homepage") or row.get("url"), } for row in data]