def __init__(self, url='http://www.radio24.ch/ext/webradio/onair_small.php', stream='http://dms-cl-011.skypro-media.net/radio24-hi'): base.StationBase.__init__(self, url) def parse(self): """Cuts the content and extracts informations""" # get the soup soup = base.Soup(self.pagecontent) # now the hacking begins (some trouble with BeautifulSoup) # select an element point = base.select(soup, 'tr td i')[0] # get its parent parent = point.parent # get all texts texts = parent.findAll(text=True) # convert and save these artist = texts[1].strip() title = texts[-1].strip() self.artist = self.capstext(artist) self.title = self.capstext(title) def current_track(self): """Returns the current playing artist""" return u"%s - %s" % (self.artist, self.title) Parser = Radio24Parser if __name__ == '__main__': base.test_parser(Parser, 'radio24.html')
class GoTvParser(base.StationBase): """GoTv""" __station__ = 'GoTv' def __init__(self, url='http://www.gotv.at/titel_main.php'): base.StationBase.__init__(self, url) def parse(self): """Call feed first""" track = self.cut_content("('VideoJetzt').innerHTML != '", "')")[0] # remove eventually contained excape backslashes track = track.replace('\\', '') # remove eventual html tags rex = re.compile("<.*?>") track = rex.sub('', track) # set informations self.artist, self.title = track.split(' - ') def current_track(self): return u"%s - %s" % (self.artist, self.title) Parser = GoTvParser if __name__ == '__main__': base.test_parser(Parser, 'gotv.html')
import base class SWR3Parser(base.StationBase): """Parser for SWR 3""" __station__ = 'SWR3' def __init__(self, url='http://www.swr3.de/musik/musikrecherche/-/id=47424/nid=47424/did=202234/1213ds4/index.html', stream='rtsp://195.52.221.172/farm/*/encoder/swr3/livestream.rm'): base.StationBase.__init__(self, url) def parse(self): """Call feed first""" soup = base.Soup(self.pagecontent) elements = [element.string for element in base.select(soup, 'table tr a')] artists = elements[0::2] titles = elements[1::2] combined = zip(artists, titles) artist, self.title = combined[0] self.artist = self.uncommafy(artist) def current_track(self): return u"%s - %s" % (self.artist, self.title) Parser = SWR3Parser if __name__ == '__main__': base.test_parser(Parser, 'last13html.html')
import base class AntenneParser(base.StationBase): """Parser for Antenne Bayern""" __station__ = 'AntenneBayern' def __init__(self, url='http://webradio.antenne.de/antenne/webradio/new_channels/ant_infos.php', stream='http://webradio.antenne.de/antenne/webradio/new_channels/player_ant_mp3_url.m3u'): base.StationBase.__init__(self, url) def parse(self): """Call feed first""" artists = self.cut_content('<b>', '</b>') self.artist = artists[1] titles = self.cut_content('</b>, ', '</a>') self.title = titles[0] def current_track(self): if self.title != '': return u"%s - %s" % (self.capstext(self.artist), self.capstext(self.title)) else: # no title - means "News" or things like this return self.artist Parser = AntenneParser if __name__ == '__main__': base.test_parser(Parser, 'ant_infos.html')
#!/usr/bin/env python # -*- encoding: UTF-8 -*- import base class FFHParser(base.StationBase): """Parser for Hitradio FFH""" __station__ = 'FFH' def __init__(self, url='http://www.ffh.de/api/webradio.php'): base.StationBase.__init__(self, url) def parse(self): """Call feed first""" artists = self.cut_content('<h5>', '</h5>') self.artist = self.capstext(artists[0]) titles = self.cut_content('<h6>', '</h6>') self.title = self.capstext(titles[0]) def current_track(self): return u"%s - %s" % (self.artist, self.title) Parser = FFHParser if __name__ == '__main__': base.test_parser(Parser, 'ffh.html')
class ProjectReloadedParser(base.StationBase): """Parser for Project-Reloaded Homepage: http://www.project-reloaded.com/ Stream : http://62.26.4.172:8010/;stream.nsv rtsp://62.26.161.89/projectreloaded$livestream.wma""" __station__ = 'Project Reloaded' def __init__(self, url=None): if url is None: url = time.strftime('http://schueler.homeip.net/project-reloaded/search.php?day=%d&month=%m&hour=%H&minute=%M') # call the parent base.StationBase.__init__(self, url) def parse(self): try: self.artist = re.findall('<td class="artist" .*?>(.*?)</td>', self.pagecontent)[-1] self.title = re.findall('<td class="title" .*?>(.*?)</td>', self.pagecontent)[-1] except IndexError: self.artist, self.title = (None,) * 2 def current_track(self): if self.artist is not None and self.title is not None: return u"%s - %s" % (self.artist, self.title) else: raise ValueError('No song at the moment') Parser = ProjectReloadedParser if __name__ == '__main__': base.test_parser(Parser, 'projectreloaded.html')
But then we loose the ability to parse OE3 as well""" __station__ = 'FM4' def __init__(self, url='http://hop.orf.at/img-trackservice/fm4.html', stream='mms://stream1.orf.at/fm4_live'): base.StationBase.__init__(self, url) def parse(self): """Call feed first""" # get the titles and the artists soup = base.Soup(self.pagecontent) titles = [node.string for node in base.select(soup, 'span.tracktitle')] artists = [node.string for node in base.select(soup, 'span.artist')] # combine these combined = zip(artists, titles) # get the last artist and title self.artist, self.title = combined[-1] def current_track(self): return u"%s - %s" % (self.artist, self.title) Parser = FM4Parser if __name__ == '__main__': base.test_parser(Parser, 'fm4.html')
#!/usr/bin/env python # -*- encoding: UTF-8 -*- """This plugin depends on the VirginRadio plugin, as it uses its parser internally""" import base, virgin class VirginXtremeParser(virgin.VirginParser): """Virgin Radio Xtreme: new music - no limits""" __station__ = 'VirginXtreme' def __init__(self, url='http://mangle.smgradio.com/vx.js'): virgin.VirginParser.__init__(self, url) Parser = VirginXtremeParser if __name__ == '__main__': base.test_parser(Parser, 'vx.js')
#!/usr/bin/env python # -*- encoding: UTF-8 -*- import base class EnergyMucParser(base.StationBase): """Energy in Munich listen to it on 93.3 MHz""" __station__ = 'EnergyMunich' def __init__(self, url='http://www.energy.de/static/ticker/ticker.php?sender=muenchen'): base.StationBase.__init__(self, url) def parse(self): """Call feed first""" self.title = self.cut_content('&song_mue=', '&&artist_mue=')[0] self.artist = self.capstext(self.cut_content('&&artist_mue=', '&')[0]) def current_track(self): return u"%s - %s" % (self.artist, self.title) Parser = EnergyMucParser if __name__ == '__main__': base.test_parser(Parser, 'energy_mue.html')
#!/usr/bin/env python # -*- encoding: UTF-8 -*- """This plugin depends on the HR3 plugin, as it uses its parser internally""" import base, hr3 class YouFmParser(hr3.HR3Parser): """YouFM""" __station__ = 'YouFM' def __init__(self, url='http://www3.admin.hr-online.de/playlist/playlist.php?tpl=youfm', stream='mms://212.211.137.135/3219youfm_live.wmv?cid=56564&dummy=.wmv'): hr3.HR3Parser.__init__(self, url) Parser = YouFmParser if __name__ == '__main__': base.test_parser(Parser, 'youfm.html')
"""NJoy""" __station__ = 'NJoy' def __init__(self, url='http://www1.n-joy.de/pages_special/0,,SPM2156,00.html'): base.StationBase.__init__(self, url) def parse(self): """Call feed first""" # get rid of annoying linebreaks self.pagecontent = self.pagecontent.replace('\n', '') artists = self.cut_content('<td headers="headerB">', '</td>') titles = self.cut_content('<td headers="headerC">', '</td>') both = zip(artists, titles) try: self.artist, self.title = both[-1] self.artist = self.capstext(self.artist) except IndexError: raise ValueError('There is currently no song') def current_track(self): return u"%s - %s" % (self.artist, self.title) Parser = NJoyParser if __name__ == '__main__': base.test_parser(Parser, 'njoy.html')
#!/usr/bin/env python # -*- encoding: UTF-8 -*- """This plugin depends on the VirginRadio plugin, as it uses its parser internally""" import base, virgin class VirginGrooveParser(virgin.VirginParser): """Virgin Radio Groove: non-stop disco and Motown""" __station__ = 'VirginGroove' def __init__(self, url='http://mangle.smgradio.com/gr.js'): virgin.VirginParser.__init__(self, url) Parser = VirginGrooveParser if __name__ == '__main__': base.test_parser(Parser, 'gr.js')
#!/usr/bin/env python # -*- encoding: UTF-8 -*- import base class DRS3Parser(base.StationBase): """DRS3""" __station__ = 'DRS3' def __init__(self, url='http://www.drs.ch/webradioplayer/r04musicSearchForm.cfm?prg=DRS3'): base.StationBase.__init__(self, url) def parse(self): """Call feed first""" tracks = self.cut_content('<td class="maintext">', '</td>') self.artist = self.capstext(self.cut_content('', '<br>', tracks[0])[0]) self.title = self.capstext(self.cut_content('<b>', '</b>', tracks[0])[0]) def current_track(self): return "%s - %s" % (self.artist, self.title) Parser = DRS3Parser if __name__ == '__main__': base.test_parser(Parser, 'drs3.html')
#!/usr/bin/env python # -*- encoding: UTF-8 -*- import base class Antenne1Parser(base.StationBase): """Parser for Antenne 1""" __station__ = 'Antenne1' def __init__(self, url='http://antenne1.de/index_start.php'): base.StationBase.__init__(self, url) def parse(self): """Call feed first""" track = self.cut_content_simple('height="5"><br>', '</td>') self.artist, self.title = [part.strip() for part in track[0].split('-')] def current_track(self): if self.title != '': return "%s - %s" % (self.capstext(self.artist), self.capstext(self.title)) else: # no title - means "News" or things like this return self.artist Parser = Antenne1Parser if __name__ == '__main__': base.test_parser(Parser, 'antenne1.html')
def __init__(self, url='http://www.einslive.de/musik/playlists/'): base.StationBase.__init__(self, url) def parse(self): """Call feed first""" # create the soup and convert HTML entities soup = base.Soup(self.pagecontent, convertEntities='html') # list of artists and their tracks tracks = list() # get all elements which are td.bold (that's the artists) artists = base.select(soup, 'td.bold') for artist in artists: # find the next element (being hopefully the title) title = artist.findNextSibling() # append the artists name and title to the list tracks.append((artist.string, title.string)) self.artist, self.title = tracks[0] def current_track(self): return u"%s - %s" % (self.artist, self.title) Parser = EinsLiveParser if __name__ == '__main__': base.test_parser(Parser, 'einslive.html')
__station__ = 'PSR' def __init__(self, url='http://www.radiopsr.de/www/webradio/e98cb037f376fa53b314c166766ef55e.php'): base.StationBase.__init__(self, url) def parse(self): """Call feed first""" chunks = self.cut_content('<td>', '</td>') tracks = [track for track in chunks if not track.startswith('<')] current = tracks[0] try: self.artist, self.title = current.split(' - ') except ValueError, e: self.artist = current self.title = None def current_track(self): if self.title != None: return u"%s - %s" % (self.artist, self.title) else: # no title - means "News" or things like this return self.artist Parser = PSRParser if __name__ == '__main__': base.test_parser(Parser, 'psr_ad.html')
soup = base.Soup(self.pagecontent) heading_last = base.select(soup, "h2")[-1] track_table = heading_last.findNextSibling() tds = track_table.findAll("td") useful = list() for td in tds: if not td.findAll("a"): # filter out non breaking spaces if td.string == " ": continue # filter out dates if timestamp.match(td.string): continue useful.append(td) # group them into (title, artist) tracks = [(useful[a], useful[a + 1]) for a in range(0, len(useful), 2)] self.title = self.capstext(tracks[0][0].string) self.artist = self.capstext(tracks[0][1].string) def current_track(self): return u"%s - %s" % (self.artist, self.title) Parser = PlanetRadioParser if __name__ == "__main__": base.test_parser(Parser, "planetradio.html")
#!/usr/bin/env python # -*- encoding: UTF-8 -*- import base, hr3 class HR1Parser(hr3.HR3Parser): """HR1""" __station__ = 'HR1' def __init__(self, url='http://www3.admin.hr-online.de/playlist/playlist.php?tpl=hr1'): base.StationBase.__init__(self, url) Parser = HR1Parser if __name__ == '__main__': base.test_parser(Parser, 'hr1.html')
#!/usr/bin/env python # -*- encoding: UTF-8 -*- import base, fm4 class OE3Parser(fm4.FM4Parser): """Ö3 parser http://oe3.orf.at""" __station__ = 'OE3' def __init__(self, url='http://hop.orf.at/img-trackservice/oe3.html'): base.StationBase.__init__(self, url) Parser = OE3Parser if __name__ == '__main__': base.test_parser(Parser, 'oe3.html')
#!/usr/bin/env python # -*- encoding: UTF-8 -*- import base class JumpParser(base.StationBase): """Parser for Jump Radio""" __station__ = 'Jump' def __init__(self, url='http://www.jumpradio.de/navi/onair.xml'): base.StationBase.__init__(self, url) def parse(self): """Parses the XML-files provided by the radio station""" # first, cut out the artist (escape the CDATA parts) self.artist = self.cut_content('<interpret><![CDATA[', ']')[0] self.title = self.cut_content('<titel><![CDATA[', ']')[0] def current_track(self): """Returns the current playing artist""" return u"%s - %s" % (self.artist, self.title) Parser = JumpParser if __name__ == '__main__': base.test_parser(Parser, 'jump.xml')
#!/usr/bin/env python # -*- encoding: UTF-8 -*- import base class AntenneThueringenParser(base.StationBase): """Parser for Antenne Thueringen""" __station__ = 'AntenneThueringen' def __init__(self, url='http://www.antennethueringen.de/sammler/kaufen.php'): base.StationBase.__init__(self, url) def parse(self): """Call feed first""" track = self.cut_content('keyword=', '" target')[0] self.artist, self.title = track.split(' - ') def current_track(self): return "%s - %s" % (self.artist, self.title) Parser = AntenneThueringenParser if __name__ == '__main__': base.test_parser(Parser, 'at_buy.html')
def __init__(self, url='http://www.br-online.de/bayern3/global/utils/homepage/nowonair.jsp'): base.StationBase.__init__(self, url) def parse(self): """Call feed first""" titles = self.cut_content('„', '“') self.title = titles[0] artists_rex = re.compile(r'(?<=<br/>).*(?=\t</div>)', re.DOTALL) artist = artists_rex.findall(self.pagecontent)[0] artist = artist.replace('\n', '').replace('\t', '') if ',' in artist: chunked = artist.split(', ') self.artist = ' '.join(reversed(chunked)) else: self.artist = artist def current_track(self): if self.artist != '': return u"%s - %s" % (self.artist, self.title) else: # no title - means "News" or things like this return self.title Parser = Bayern3Parser if __name__ == '__main__': base.test_parser(Parser, 'b3now.html')
#!/usr/bin/env python # -*- encoding: UTF-8 -*- import base class LandesWelleParser(base.StationBase): """Parser for LandesWelle""" __station__ = 'Landeswelle' def __init__(self, url='http://www.landeswelle.de/lwt/components/flash/index_lwt.php'): base.StationBase.__init__(self, url) def parse(self): """Call feed first""" divided = self.pagecontent.split('#') self.title = self.capstext(divided[1].split('=')[1]) self.artist = self.capstext(divided[2].split('=')[1]) def current_track(self): return u"%s - %s" % (self.artist, self.title) Parser = LandesWelleParser if __name__ == '__main__': base.test_parser(Parser, 'lwt.html')
#!/usr/bin/env python # -*- encoding: UTF-8 -*- import base, urllib class GongParser(base.StationBase): """The parser for Gong""" __station__ = 'Gong' def __init__(self, url='http://www.radiogong.de/gongphp/header.php'): base.StationBase.__init__(self, url) def parse(self): """Call feed first""" track = self.cut_content_simple('%2C+', '+%2A')[0] artist, title = track.split('%2C+') self.artist = self.capstext(urllib.unquote_plus(artist)) self.title = urllib.unquote_plus(title) def current_track(self): return u"%s - %s" % (self.artist, self.title) Parser = GongParser if __name__ == '__main__': base.test_parser(Parser, 'justone.html')
#!/usr/bin/env python # -*- encoding: UTF-8 -*- import base class EnergySaxParser(base.StationBase): """Energy in Saxonia""" __station__ = 'EnergySaxonia' def __init__(self, url='http://www.energy.de/static/ticker/ticker.php?sender=sachsen'): base.StationBase.__init__(self, url) def parse(self): """Call feed first""" track = self.cut_content_simple('&song_sac=JETZT: ', '&&artist_sac=')[0] artist, title = track.split(' - ', 1) self.artist = self.capstext(artist) self.title = self.capstext(title) def current_track(self): return u"%s - %s" % (self.artist, self.title) Parser = EnergySaxParser if __name__ == '__main__': base.test_parser(Parser, 'sach.html')