Index: channels/filtermusic.py ================================================================== --- channels/filtermusic.py +++ channels/filtermusic.py @@ -1,10 +1,10 @@ # encoding: UTF-8 # api: streamtuner2 # title: filtermusic # description: Daily refreshed list of electronic+dance music streams. -# version: 0.2 +# version: 0.3 # type: channel # url: http://filtermusic.net/ # category: radio # config: - # png: @@ -26,11 +26,10 @@ from config import * from channels import * import ahttp import re -import xml.etree.ElementTree as ET # filtermusic.net class filtermusic (ChannelPlugin): @@ -38,11 +37,11 @@ has_search = False listformat = "srv" audioformat = "audio/mpeg" titles = dict(listeners=False, bitrate=False, playing="Description") categories = ["Top Radio Stations", "House / Dance", "Lounge Grooves", "Rock / Metal", "Breaks / Drum'n'Bass", "Various / Independent", "Downtempo / Ambient", "60's / 70's / 80's / 90's", "Hits / Mainstream", "Electronica / Industrial", "Techno / Trance", "HipHop / RnB", "Classical", "Eclectic", "Funk / Soul / Disco", "Reggae / Dub / Dancehall", "International / Ethnic", "Jazz", "Latin / Salsa / Tango"] - + img_resize = 32 # static def update_categories(self): pass @@ -49,25 +48,32 @@ # Refresh station list def update_streams(self, cat, search=None): return self.from_web(cat) - # Extract directly from filtermusic.net html def from_web(self, cat): ucat = re.sub("\W+", "-", cat.lower().replace("'", "")) html = ahttp.get("http://filtermusic.net/{}".format(ucat)) rx_station = re.compile(""" -

((?!Support\s+filtermusic).*?)

\s* -

(.*?)

.*? - data-listen='(.*?)' +
]+ about="/([\w\-]+)" .*? + ]+ src="(http.+?)" .*? + data-listen="(.*?)" .*? + ]*>(.+?) .*? +

(.*?)

""", re.X|re.S ) ls = re.findall(rx_station, html) log.DATA(ls) r = [ - dict(genre=cat, title=unhtml(title), playing=unhtml(descr), url=url) - for title,descr,url in ls + dict( + genre=cat, + title=unhtml(strip_tags(title)), + playing=unhtml(strip_tags(descr)), + img=img, + homepage="https://filtermusic.net/{}".format(id), id=id, url=url + ) + for id, img, url, title, descr in ls ] return r