# encoding: UTF-8
# api: streamtuner2
# title: radiolist.net
# description: Station list by categories
# url: http://radiolist.net/
# version: 0.6
# type: channel
# category: radio
# priority: obsolete
# png:
# iVBORw0KGgoAAAANSUhEUgAAABgAAAAYBAMAAAASWSDLAAAAFVBMVEVKb61qibyDnMegs9S6yeDV4O37/vyx66abAAAAAWJLR0QAiAUdSAAAAAlwSFlzAAALEwAACxMB
# AJqcGAAAAAd0SU1FB+ECDBAgLJqgZW4AAADoSURBVBjTNdBNj4MgEAbgqdLeZdo9C5NwFmo5Y7Wedauc1y/+/09YdLskkDwJmZl3IOxnON4A8frQhdc/7mG2cv3gx29X
# rdUfZuVHQ3JHEzZ7GSuNXxFV/FYYwryO6MOiZqEdnQPUC/fsXZaMuxa6MFfOVYN7kIWpHZClyJGLFjbbC617KaRUEJ4r4fU7IqNYrW5f2kgU5gZInG6MZ086eejcyIvO
# 1KwoLayoJjqnuWO5giW8msxVmBQXD5PttSlRm8TG2fDNZS3rRO/opeSCMnPa82xSmNgkfRxJ5yZxlPrPDmLu+7GqX4lERq4G0UEyAAAAAElFTkSuQmCC
# extraction-method: regex
#
# ⚠ Requires a [Channel → Reload category tree] after updating.
#
# Radio station list, now categorized.
# Search would be possible now, but isn't implemented.
import re
import action
import ahttp
from config import *
from channels import *
# radiolist.net
#
# · Only fetches titles/urls.
#
class radiolist (ChannelPlugin):
# module attributes
listformat = "pls"
has_search = False
categories = []
catmap = []
titles = dict( genre="Genre", title="Station", playing="Location", bitrate="Bitrate", listeners=False )
# countries would still be available, but there seems to be no /country/ url map
"""<option value="4" >Albania</option><option value="7" >Andorra</option><option value="11" >Argentina</option><option value="12" >Armenia</option><option value="14" >Australia</option><option value="15" >Austria</option><option value="16" >Azerbaijan</option><option value="21" >Belarus</option><option value="22" >Belgium</option><option value="28" >Bosnia and Herzegovina</option><option value="30" >Brazil</option><option value="32" >Bulgaria</option><option value="38" >Canada</option><option value="43" >Chile</option><option value="45" >Colombia</option><option value="52" >Croatia</option><option value="54" >Cyprus</option><option value="55" >Czech Republic</option><option value="58" >Denmark</option><option value="67" >Estonia</option><option value="70" >Faroe Islands</option><option value="72" >Finland</option><option value="73" >France</option><option value="79" >Germany</option><option value="82" >Greece</option><option value="96" >Hungary</option><option value="97" >Iceland</option><option value="98" >India</option><option value="102" >Ireland</option><option value="104" >Israel</option><option value="105" >Italy</option><option value="107" >Japan</option><option value="118" >Latvia</option><option value="123" >Liechtenstein</option><option value="124" >Lithuania</option><option value="125" >Luxembourg</option><option value="126" >Macedonia</option><option value="132" >Malta</option><option value="138" >Mexico</option><option value="140" >Moldova</option><option value="141" >Monaco</option><option value="143" >Montenegro</option><option value="153" >Netherlands</option><option value="155" >New Zealand</option><option value="160" >Norway</option><option value="170" >Poland</option><option value="171" >Portugal</option><option value="175" >Romania</option><option value="176" >Russian Federation</option><option value="183" >San Marino</option><option value="187" >Serbia</option><option value="192" >Slovakia</option><option value="193" >Slovenia</option><option value="197" >Spain</option><option value="202" >Sweden</option><option value="203" >Switzerland</option><option value="215" >Turkey</option><option value="220" >Ukraine</option><option value="222" >United Kingdom</option><option value="223" >United States</option><option value="227" >Venezuela</option>"""
"""<option value="671" >00</option><option value="288" >00s</option><option value="377" >10s</option><option value="621" >20s</option><option value="433" >30s</option><option value="431" >40s</option><option value="970" >47/5000 balada</option><option value="976" >50</option><option value="363" >50s</option><option value="252" >60s</option><option value="678" >60s 70s 80s</option><option value="665" >60s 70s 80s 90s 00s</option><option value="257" >70s</option><option value="714" >80 s</option><option value="245" >80s</option><option value="715" >90 s</option><option value="244" >90s</option><option value="727" >90s classic</option><option value="550" >90s.pop</option><option value="721" >90s105.9</option><option value="772" >acid house</option><option value="287" >acid jazz</option><option value="420" >acoustic</option><option value="335" >active rock</option><option value="794" >adult comtemporary</option><option value="657" >adult contempopary</option><option value="695" >adult contemporar</option><option value="272" >adult contemporary</option><option value="861" >adult contemprory</option><option value="249" >african</option><option value="769" >afropop</option><option value="840" >air traffic</option><option value="545" >albanian</option><option value="878" >aldan cruz</option><option value="251" >alternative</option><option value="318" >alternative metal</option><option value="328" >alternative rock</option><option value="435" >alternatve</option><option value="871" >amateur radio</option><option value="283" >ambient</option><option value="381" >american</option><option value="369" >anime</option><option value="340" >aor</option><option value="248" >arabic</option><option value="569" >arabic-pop</option><option value="586" >armenian</option><option value="458" >asian</option><option value="371" >astrology</option><option value="255" >azerbaijani</option><option value="268" >b</option><option value="870" >b.hip-hop</option><option value="514" >b.oldies</option><option value="917" >bach</option><option value="510" >bachata</option><option value="398" >balada</option><option value="596" >balcan</option><option value="816" >banda</option><option value="898" >banda.bachata</option><option value="783" >bangladeshi</option><option value="427" >baroque</option><option value="685" >base</option><option value="853" >baseball</option><option value="302" >bass</option><option value="523" >beatles</option><option value="831" >beethoven</option><option value="925" >bengali</option><option value="528" >beyonce</option><option value="451" >bhangra</option><option value="338" >black metal</option><option value="430" >bluegrass</option><option value="246" >blues</option><option value="507" >bob marley</option><option value="566" >bolero</option><option value="730" >bolivian</option><option value="460" >bollywood</option><option value="975" >boogie</option><option value="708" >bosnian</option><option value="347" >bossa nova</option><option value="487" >brazilian</option><option value="491" >brazilian pop</option><option value="308" >breakbeat</option><option value="324" >britpop</option><option value="782" >buddhist</option><option value="291" >business</option><option value="937" >c</option><option value="922" >c-pop</option><option value="558" >cabaret</option><option value="906" >cajun</option><option value="885" >calypso</option><option value="862" >cantonese</option><option value="452" >caribbean</option><option value="720" >caribean</option><option value="582" >caribian</option><option value="723" >catalan</option><option value="534" >catolic</option><option value="526" >católica</option><option value="802" >caucasian</option><option value="442" >celtic</option><option value="271" >chanson</option><option value="568" >charanga</option><option value="546" >charts</option><option value="351" >chil out</option><option value="297" >children</option><option value="404" >chill-house</option><option value="270" >chill-out</option><option value="445" >chinese</option><option value="740" >choir</option><option value="698" >chr</option><option value="295" >christian</option><option value="462" >christian contemporary</option><option value="459" >christian pop</option><option value="471" >christian rock</option><option value="911" >christian talk</option><option value="969" >christiana</option><option value="881" >christianl</option><option value="434" >christmas</option><option value="454" >chutney</option><option value="502" >clasical rock</option><option value="247" >classic</option><option value="577" >classic jazz</option><option value="441" >classic metal</option><option value="312" >classic rock</option><option value="799" >classico</option><option value="455" >classik rock</option><option value="380" >classsic</option><option value="649" >classsic rock</option><option value="265" >club</option><option value="355" >club house</option><option value="943" >colombian</option><option value="953" >combia</option><option value="277" >comedy</option><option value="439" >community</option><option value="835" >contemporary jazz</option><option value="655" >cool jazz</option><option value="739" >corelli</option><option value="916" >countru</option><option value="309" >country</option><option value="965" >criollas</option><option value="675" >croatian</option><option value="952" >croosover</option><option value="950" >crosover</option><option value="903" >crossover</option><option value="949" >crossover. gospel</option><option value="951" >crossover.community</option><option value="797" >cuambia</option><option value="808" >cubaton</option><option value="296" >culture</option><option value="509" >cumbia</option><option value="498" >dacnce</option><option value="242" >dance</option><option value="733" >dance hall</option><option value="887" >dance l</option><option value="378" >dance pop</option><option value="337" >dance rock</option><option value="372" >dance.trance</option><option value="801" >dancec</option><option value="479" >dancehall</option><option value="770" >dancehip-hop</option><option value="521" >dances</option><option value="397" >danse</option><option value="735" >danсe</option><option value="804" >dark metal</option><option value="417" >david bowie</option><option value="814" >dean martin</option><option value="327" >death metal</option><option value="315" >deathcore</option><option value="610" >decades</option><option value="292" >deep electronic</option><option value="264" >deep house</option><option value="548" >deep techno</option><option value="553" >depeche mode</option><option value="964" >deportes</option><option value="672" >depp</option><option value="849" >desi</option><option value="624" >deutsch</option><option value="928" >devotional</option><option value="755" >disc</option><option value="258" >disco</option><option value="692" >disco polo</option><option value="940" >disco. oldies</option><option value="615" >discofox</option><option value="541" >disсo</option><option value="307" >dj</option><option value="332" >doom</option><option value="832" >doowop</option><option value="276" >downtempo</option><option value="706" >drama</option><option value="647" >drum´n bass</option><option value="301" >drum&#39</option><option value="684" >drum&amp</option><option value="753" >dsnce</option><option value="294" >dub techno</option><option value="298" >dubstep</option><option value="682" >dutch</option><option value="274" >easy listening</option><option value="629" >ebm</option><option value="367" >eclectic</option><option value="592" >eclectique</option><option value="415" >economic</option><option value="873" >ecuadorian</option><option value="494" >edm</option><option value="349" >education</option><option value="643" >ekectro</option><option value="779" >elcectic</option><option value="641" >elecreo</option><option value="652" >elecrto</option><option value="547" >electric</option><option value="359" >electro house</option><option value="339" >electro rock</option><option value="711" >electro trance</option><option value="595" >electro-pop</option><option value="250" >electronic</option><option value="511" >eletro</option><option value="499" >eletronic</option><option value="646" >elrctro</option><option value="680" >elvis presley</option><option value="687" >emergency</option><option value="658" >english</option><option value="360" >enterntainment</option><option value="341" >entertainment</option><option value="634" >entertainmenthits</option><option value="539" >entertaintment</option><option value="503" >entretainment</option><option value="742" >entrtainment</option><option value="368" >ethnic</option><option value="465" >eurodance</option><option value="674" >evergreen</option><option value="869" >fank</option><option value="855" >filipino</option><option value="638" >fisco</option><option value="529" >flamenco</option><option value="497" >flash back</option><option value="841" >fock</option><option value="241" >folk</option><option value="744" >folk pop rock</option><option value="389" >folk rock</option><option value="631" >folk. deutsch</option><option value="967" >folkl</option><option value="411" >football</option><option value="493" >forró</option><option value="771" >foul</option><option value="617" >fox</option><option value="482" >frace</option><option value="813" >frank sinatra</option><option value="677" >freestyle</option><option value="424" >french</option><option value="300" >funk</option><option value="336" >funk rock</option><option value="525" >funk. sertanea</option><option value="793" >fusion</option><option value="966" >gaitas</option><option value="374" >games music</option><option value="304" >garage</option><option value="560" >garage rock</option><option value="780" >garage.r&#39</option><option value="518" >gauchesca</option><option value="622" >german</option><option value="746" >gits</option><option value="700" >glam</option><option value="609" >goa</option><option value="948" >golpel</option><option value="894" >golspel</option><option value="348" >gospel</option><option value="905" >gospel jazz</option><option value="329" >gothic</option><option value="345" >grange</option><option value="738" >grecian</option><option value="659" >greece</option><option value="467" >greek</option><option value="784" >greekg</option><option value="775" >grime</option><option value="575" >groove</option><option value="323" >grunge</option><option value="806" >grupera</option><option value="927" >gujarati</option><option value="915" >gurbani</option><option value="826" >haitian</option><option value="850" >halloween</option><option value="892" >hamradio</option><option value="623" >hands up</option><option value="625" >handsup</option><option value="437" >hard</option><option value="563" >hard core</option><option value="313" >hard rock</option><option value="868" >hard roock</option><option value="628" >hard style</option><option value="924" >hard-rave</option><option value="426" >hardcore</option><option value="747" >hardr rock</option><option value="824" >hardstep</option><option value="594" >hardstyle</option><option value="904" >hatian</option><option value="751" >hause</option><option value="477" >hawaiian</option><option value="396" >health</option><option value="616" >heavy</option><option value="311" >heavy metal</option><option value="608" >heavy rock</option><option value="447" >hindu</option><option value="847" >hinduism</option><option value="899" >hip hp</option><option value="701" >hip-hip</option><option value="254" >hip-hop</option><option value="766" >hip-hop r&#39</option><option value="585" >hit</option><option value="278" >hits</option><option value="584" >hits 60s</option><option value="591" >hitsб 80s</option><option value="909" >hot adult contemporary</option><option value="286" >house</option><option value="908" >http://visiondeselus.com</option><option value="446" >iindie</option><option value="938" >indi</option><option value="707" >india</option><option value="421" >indian</option><option value="321" >indie</option><option value="331" >indie rock</option><option value="788" >indie-folk</option><option value="787" >indie-pop</option><option value="406" >indigo</option><option value="500" >industrial</option><option value="688" >info trafic</option><option value="432" >information</option><option value="607" >informations</option><option value="910" >inspirational</option><option value="741" >instreumental</option><option value="306" >instrumental</option><option value="557" >instrumental.pop</option><option value="366" >international</option><option value="486" >international / jazz / punk</option><option value="842" >interview podcasts</option><option value="810" >iranian</option><option value="613" >irish</option><option value="353" >islamic</option><option value="416" >islamik</option><option value="601" >israeli</option><option value="663" >italan</option><option value="564" >italian</option><option value="670" >itallian</option><option value="466" >italodance</option><option value="918" >j-metal</option><option value="391" >j-pop</option><option value="920" >japan</option><option value="390" >japanese</option><option value="956" >japanesse</option><option value="243" >jazz</option><option value="764" >jazz funk</option><option value="709" >jazz piano</option><option value="805" >jazz-rock</option><option value="939" >jesus</option><option value="485" >jewish</option><option value="578" >johnny hallyday</option><option value="605" >jpop</option><option value="606" >jrock</option><option value="383" >judaism</option><option value="551" >jungle</option><option value="379" >k-pop</option><option value="929" >kannada</option><option value="926" >kashmiri</option><option value="854" >kirtan</option><option value="827" >kizomba</option><option value="933" >kollywood</option><option value="864" >kompa</option><option value="889" >konpa</option><option value="422" >korean</option><option value="834" >kumbia</option><option value="627" >kurdish</option><option value="778" >l</option><option value="654" >laika</option><option value="974" >lain</option><option value="791" >language</option><option value="376" >latin</option><option value="971" >latin folk</option><option value="567" >latin jazz</option><option value="913" >latin pop</option><option value="732" >latinvariety</option><option value="761" >laurence olivier</option><option value="691" >led zeppelin</option><option value="587" >lgbt</option><option value="425" >lifestyle</option><option value="645" >limp bizkit</option><option value="669" >live</option><option value="803" >live shows</option><option value="962" >llanera</option><option value="554" >lnew age</option><option value="821" >local</option><option value="819" >local news</option><option value="387" >longe</option><option value="273" >lounge</option><option value="728" >love</option><option value="537" >love song</option><option value="364" >love songs</option><option value="765" >love sungs</option><option value="666" >malayalam</option><option value="866" >malayalam music</option><option value="697" >manele</option><option value="829" >mantra</option><option value="790" >maori</option><option value="930" >mappila</option><option value="865" >marathi</option><option value="818" >marengue</option><option value="833" >mariachi</option><option value="901" >marimba</option><option value="316" >mathcore</option><option value="620" >medieval</option><option value="305" >meditation</option><option value="639" >melodic rock</option><option value="959" >merenga</option><option value="845" >merenge</option><option value="589" >merengue</option><option value="314" >metal</option><option value="633" >metal core</option><option value="580" >metal rock</option><option value="319" >metalcore</option><option value="712" >mexican</option><option value="495" >michael jackson</option><option value="473" >military</option><option value="718" >milonga</option><option value="293" >minimal</option><option value="696" >mix</option><option value="436" >modern rock</option><option value="583" >motown</option><option value="880" >movie</option><option value="863" >movie news</option><option value="828" >mozart</option><option value="483" >multilingual</option><option value="428" >music</option><option value="785" >muslim</option><option value="748" >n&#34</option><option value="267" >n&#39</option><option value="867" >national news</option><option value="505" >nature</option><option value="637" >nb</option><option value="932" >ndian</option><option value="468" >neapolitan music</option><option value="679" >nederlands</option><option value="410" >neo soul</option><option value="538" >nes</option><option value="648" >netherlands</option><option value="480" >new</option><option value="358" >new age</option><option value="852" >new school</option><option value="320" >new wave</option><option value="668" >newage</option><option value="238" >news</option><option value="544" >news. sport</option><option value="896" >news.talk</option><option value="858" >nits</option><option value="809" >nostalgie</option><option value="963" >noticias</option><option value="350" >nu disco</option><option value="317" >nu metal</option><option value="403" >nu-jazz</option><option value="667" >nu-soul</option><option value="579" >nudisco</option><option value="792" >nz music</option><option value="756" >o dance</option><option value="635" >ock</option><option value="902" >odies</option><option value="773" >odlies</option><option value="470" >old</option><option value="619" >old school</option><option value="650" >oldie</option><option value="262" >oldies</option><option value="703" >oldies rock</option><option value="662" >oldies. hits</option><option value="934" >oldies.pop</option><option value="686" >oldies.top40</option><option value="743" >oldis</option><option value="763" >oldschool</option><option value="776" >oldskool</option><option value="823" >oos</option><option value="382" >opera</option><option value="811" >organ</option><option value="960" >pachanga</option><option value="490" >pagode</option><option value="476" >paranormal</option><option value="851" >paranormal talk</option><option value="632" >party</option><option value="734" >persian</option><option value="501" >pink floyd</option><option value="676" >piraten</option><option value="478" >poetry</option><option value="893" >poker</option><option value="822" >police</option><option value="690" >polish</option><option value="795" >politic</option><option value="574" >political talk</option><option value="357" >politics</option><option value="555" >polka</option><option value="236" >pop</option><option value="573" >pop 80s</option><option value="722" >pop dance</option><option value="726" >pop indie</option><option value="936" >pop ingles</option><option value="530" >pop teen</option><option value="269" >pop-rock</option><option value="689" >pop. 90s</option><option value="630" >pop. news</option><option value="972" >pop. rock. folk</option><option value="593" >pop.60s</option><option value="400" >pop.talk</option><option value="561" >pop.talk.news</option><option value="543" >pop.top40</option><option value="571" >pop70s</option><option value="527" >popo</option><option value="540" >popular</option><option value="457" >portuguese</option><option value="419" >post-rock</option><option value="886" >postrock</option><option value="334" >power metal</option><option value="472" >power rock</option><option value="542" >ppop</option><option value="409" >prayer</option><option value="699" >preaching</option><option value="259" >progressive</option><option value="290" >progressive house</option><option value="333" >progressive metal</option><option value="330" >progressive rock</option><option value="281" >progressive trance</option><option value="279" >psy trance</option><option value="749" >psychedelic</option><option value="611" >psychill</option><option value="752" >psychobilly</option><option value="653" >psytrance</option><option value="443" >public</option><option value="817" >public safety</option><option value="786" >pundjabi</option><option value="464" >punjabi</option><option value="326" >punk</option><option value="798" >punk electronic</option><option value="407" >punk-rock</option><option value="636" >punkrock</option><option value="516" >queen</option><option value="656" >r &#39</option><option value="429" >r`n`b</option><option value="266" >r&#39</option><option value="789" >racing</option><option value="588" >ragga</option><option value="777" >raggae</option><option value="872" >rail</option><option value="844" >railroad</option><option value="731" >ranchera</option><option value="299" >rap</option><option value="923" >rave</option><option value="626" >rawstyle</option><option value="310" >reading</option><option value="895" >reageton</option><option value="888" >reagge</option><option value="438" >regae</option><option value="947" >regaeton</option><option value="935" >regeaton</option><option value="384" >reggae</option><option value="508" >reggaeton</option><option value="725" >reggaeton.bachata</option><option value="524" >reggateon</option><option value="724" >reggaton</option><option value="604" >reggeae</option><option value="736" >reggeaton</option><option value="944" >reggeton</option><option value="710" >regueaton</option><option value="745" >regueton</option><option value="954" >reguetoon</option><option value="275" >relax</option><option value="506" >religion</option><option value="393" >religious</option><option value="361" >religous</option><option value="618" >remix</option><option value="846" >rescue</option><option value="914" >resque</option><option value="261" >retro</option><option value="599" >rn&#39</option><option value="897" >road</option><option value="549" >roc</option><option value="253" >rock</option><option value="857" >rock &amp</option><option value="800" >rock news</option><option value="702" >rock pop</option><option value="512" >rock`n roll</option><option value="891" >rock. rock&#39</option><option value="683" >rock.oldies</option><option value="664" >rock.talk</option><option value="642" >rock‘n‘roll</option><option value="385" >rock&#39</option><option value="325" >rockabilly</option><option value="651" >rocknews</option><option value="877" >rockбr&#39</option><option value="532" >rok</option><option value="737" >rok&#39</option><option value="386" >roll</option><option value="346" >romance</option><option value="704" >romanian</option><option value="343" >romantic</option><option value="830" >romatic</option><option value="946" >romаntica</option><option value="562" >roots</option><option value="912" >rpm</option><option value="418" >rturkish</option><option value="961" >ruben blades</option><option value="565" >rumba</option><option value="263" >russian</option><option value="942" >salasa</option><option value="520" >salsa</option><option value="489" >samba</option><option value="815" >sammy davis</option><option value="492" >sartanejo</option><option value="533" >saundtrack</option><option value="754" >schanson</option><option value="463" >schlagers</option><option value="496" >school</option><option value="519" >seraneja</option><option value="705" >serbian</option><option value="488" >sertaneja</option><option value="531" >sertaneja religious</option><option value="513" >sertanejо</option><option value="504" >setanejo</option><option value="860" >sex education</option><option value="760" >sherlock holmes</option><option value="448" >sikh</option><option value="931" >sindhi</option><option value="388" >ska</option><option value="681" >ski</option><option value="408" >slow</option><option value="719" >smooth</option><option value="344" >smooth jazz</option><option value="673" >smooth jazz .lounge . house</option><option value="825" >smooth rock</option><option value="453" >soca</option><option value="405" >soft</option><option value="693" >soft jazz</option><option value="375" >soft pop</option><option value="322" >soft rock</option><option value="729" >songs</option><option value="413" >sort</option><option value="768" >sou</option><option value="392" >soudtrack</option><option value="284" >soul</option><option value="600" >soul.r&#39</option><option value="603" >soulful</option><option value="342" >soundtrack</option><option value="919" >sountracks</option><option value="874" >southern gospel</option><option value="469" >spanish</option><option value="955" >spanish rock</option><option value="758" >speed</option><option value="399" >spiritual</option><option value="522" >spo</option><option value="240" >sports</option><option value="517" >sports б entertainment</option><option value="957" >spots</option><option value="536" >srorts</option><option value="474" >student radio</option><option value="907" >swamp pop</option><option value="303" >swing</option><option value="481" >swing jazz</option><option value="285" >symphonic</option><option value="759" >symphonic metal</option><option value="362" >synth-pop</option><option value="644" >synthie pop</option><option value="614" >synthpop</option><option value="535" >taalk</option><option value="456" >tak</option><option value="239" >talk</option><option value="973" >talk pop</option><option value="836" >talk.adult contemporary</option><option value="713" >talk.news</option><option value="661" >talk.top40</option><option value="450" >tamil</option><option value="475" >tamil pop</option><option value="612" >tango</option><option value="945" >tangо</option><option value="812" >tech</option><option value="354" >tech house</option><option value="280" >tech trance</option><option value="289" >techno</option><option value="796" >techno. folk</option><option value="843" >technology</option><option value="807" >tejano</option><option value="900" >telugu</option><option value="757" >thrash</option><option value="694" >thrash metal</option><option value="484" >tip40</option><option value="921" >to-40</option><option value="640" >to40</option><option value="884" >today</option><option value="556" >top</option><option value="837" >top 40s</option><option value="660" >top hits</option><option value="572" >top-40</option><option value="882" >top0</option><option value="237" >top40</option><option value="774" >top40 pop</option><option value="876" >tourism</option><option value="449" >traditional</option><option value="440" >traffic</option><option value="414" >trafik</option><option value="260" >trance</option><option value="395" >transe</option><option value="559" >trap</option><option value="590" >trash metal</option><option value="875" >travel</option><option value="781" >tribal</option><option value="461" >trip</option><option value="402" >trip-hop</option><option value="838" >trop rock</option><option value="890" >tropic</option><option value="365" >tropical</option><option value="859" >tropics</option><option value="597" >tubes</option><option value="423" >turk</option><option value="401" >turkish</option><option value="412" >turkish pop</option><option value="839" >u2</option><option value="581" >ukrainian</option><option value="352" >underground</option><option value="282" >uplifting trance</option><option value="394" >urban</option><option value="820" >urban contemporary</option><option value="570" >urdu</option><option value="941" >vallenata</option><option value="716" >vallenato</option><option value="717" >valse</option><option value="958" >variada</option><option value="598" >varietes</option><option value="256" >variety</option><option value="767" >various</option><option value="968" >variуен</option><option value="879" >video game</option><option value="856" >vietnamese</option><option value="373" >vocal</option><option value="356" >vocal house</option><option value="370" >weather</option><option value="444" >world</option><option value="602" >world music</option><option value="883" >yesterday</option><option value="848" >yoga</option><option value="552" >zen</option><option value="576" >zouk</option><option value="750" >поп</option><option value="515" >сhristian</option><option value="762" >сountry</option> """
# just a static list for now
def update_categories(self):
c = []
rx_sel = re.compile(r"""<select name="genre"(.+)</select>""", re.S)
rx_gen = re.compile(r"""<option value="(\d+)"\s*>([\w\s\-]+)</option>""", re.S)
html = ahttp.get("http://radiolist.net/")
html = re.findall(rx_sel, html)[0]
for id,title in re.findall(rx_gen, html):
c.append(title)
self.catmap[title] = id
self.categories = c
# extraction rules
recipe = {
"block": """(<div\s+class="wp-radio-listing[^>]*>.+?)\n</div>""",
"split": None,
"fields": {
"title": 'alt="(.+?)"',
"genre": '<div class="genres">(.+?)</div>',
"url": 'data-url="(http.+?)"',
"homepage": '<a href="(.+?)"',
"favicon": '<img[^>]+src="(.+?)"',
"description": '<p[^>]*>(.+?)</p>'
}
}
# extract stream urls
def update_streams(self, cat):
entries = []
html = ""
for i in range(1, int(int(conf.max_streams)/50)+1):
html = html + ahttp.get("http://radiolist.net/genre/{}?paginate={}".format(cat.lower(), i))
if not html.find('?paginate={}">Next'.format(i+1)) >= 0:
break
for block in re.findall(self.recipe["block"], html, re.S|re.M):
#log.HTML(block)
e = {"genre":"-", "playing":cat, "format":"audio/mpeg"}
for id,rx in self.recipe["fields"].iteritems():
uu = re.findall(rx, block)
#log.RX(id,rx,uu)
if uu:
if id == "genre":
uu[0] = uu[0].replace("<a", " <a")
e[id] = unhtml(uu[0])
if "url" in e and "title" in e:
entries.append(e)
# done
#[log.DATA(e) for e in entries]
return entries