Jump to content


Member Since 6 Dec 2011
Offline Last Active 15 Jan 2023 18:09

Topics I've Started

WebRadio plugin

29 September 2015 - 23:52

Anyone else looked at making additional links for the webradio plugin?  There seems to be some flakiness in the plugin around what Genre vs Genre_2 means, as well as crashing on editing (Genre not translated or so?) and it seems to crash when there are multiple wbrFS_fav files in the /etc/ConfFS dir (thus not sure if you can have favourites lists other than just the one called 'sample'?).  However, I've managed to add all the radio stations from 181.fm using python and BeautifulSoup to parse the 181.fm webpage... I then just paste my results into the top of the sample.wbrFS_fav file using vi.


I'm looking for anyone else that's interested in generating links for the web radio plugin, or who perhaps knows more about the plugin...


Anyway here's the script I wrote:


import urllib2
from bs4 import BeautifulSoup

def write_station(fil, href, genre='Unknown'):
    start_pos = href.find("station=")
    start_pos = start_pos + 8
    if "/player/" in href:
        end_pos = len(href)
        end_pos = href.find("&", start_pos)
    station = href[start_pos : end_pos]
    descr = itm.text
    fil.write('[181.FM - ' + descr + ']\n')
    fil.write('description = ' + descr + '\n')
    if "/player/" in href:
        fil.write('url = http://icyrelay.181.fm/' + station + '_128k.mp3\n')
        fil.write('typ = mp3\n')
        fil.write('url = http://www.181.fm/winamp.pls?station='+ station + '&style=&description=' + descr + '&file=' + station + '.pls\n')
        fil.write('typ = pls\n')
    fil.write('genre_2 = ' + genre + '\n')
    fil.write('volume = 0\n')
    fil.write('genre = Artists\n')
    fil.write('bitrate = 128\n')
    fil.write('defekt = 0\n')

try :
    web_page = urllib2.urlopen("http://181.fm").read()
    fil = open('181_links.txt', 'w')
    soup = BeautifulSoup(web_page)
    tds = soup.find_all('td')
    for td in tds:
        if 'class' in td.attrs:
            cls = td['class']
            if cls[0] == 'menu_left_title':
                genre = td.text
            elif cls[0] == 'off':
                cnt = td.contents
                for itm in cnt:
                    write_station(fil, itm['href'], genre)
except urllib2.HTTPError :
except urllib2.URLError :

Kind regards,