Check-in [215234ddad]
Overview
Comment: | Dead-end update for radiolist.net channel (only titles+homepages now). |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
215234ddad5ad5cd814f9009d9aa86e8 |
User & Date: | mario on 2019-07-16 07:48:37 |
Other Links: | manifest | tags |
Context
2020-05-04
| ||
17:50 | Fix string-remnant option type error (conf.max_streams comparison) From ticket @4163057c375e check-in: 4ac8c4bcb9 user: joostden tags: trunk | |
2019-07-16
| ||
07:48 | Dead-end update for radiolist.net channel (only titles+homepages now). check-in: 215234ddad user: mario tags: trunk | |
07:47 | fix for runtime error (dictionary changed size during iteration) on plugin alias: detection check-in: daf3f873bd user: mario tags: trunk | |
Changes
Modified contrib/radiolist.py from [1e251d9dec] to [eff6434142].
1 2 3 4 5 | # encoding: UTF-8 # api: streamtuner2 # title: radiolist.net # description: Station list by continent+country # url: http://radiolist.net/ | | | < > | > | < < < < < < < < < < < < < < | | | | < > | > | > | | > > > > > > > > > > > > > > < < < | | > > | < | | | > | < < < < < < < < < < < < < < | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | # encoding: UTF-8 # api: streamtuner2 # title: radiolist.net # description: Station list by continent+country # url: http://radiolist.net/ # version: 0.5 # type: channel # category: radio # priority: obsolete # png: # iVBORw0KGgoAAAANSUhEUgAAABgAAAAYBAMAAAASWSDLAAAAFVBMVEVKb61qibyDnMegs9S6yeDV4O37/vyx66abAAAAAWJLR0QAiAUdSAAAAAlwSFlzAAALEwAACxMB # AJqcGAAAAAd0SU1FB+ECDBAgLJqgZW4AAADoSURBVBjTNdBNj4MgEAbgqdLeZdo9C5NwFmo5Y7Wedauc1y/+/09YdLskkDwJmZl3IOxnON4A8frQhdc/7mG2cv3gx29X # rdUfZuVHQ3JHEzZ7GSuNXxFV/FYYwryO6MOiZqEdnQPUC/fsXZaMuxa6MFfOVYN7kIWpHZClyJGLFjbbC617KaRUEJ4r4fU7IqNYrW5f2kgU5gZInG6MZ086eejcyIvO # 1KwoLayoJjqnuWO5giW8msxVmBQXD5PttSlRm8TG2fDNZS3rRO/opeSCMnPa82xSmNgkfRxJ5yZxlPrPDmLu+7GqX4lERq4G0UEyAAAAAElFTkSuQmCC # extraction-method: regex # # Radio station list grouped by continents and countries. # # NO LONGER LISTS STREAMING URLS (~ 2019), thus isn't interesting # enough anymore for extended support. import re import action import ahttp from config import * from channels import * # radiolist.net # # · Groups stations by continents and countries. # # · Only fetches titles/homepages henceforth. # class radiolist (ChannelPlugin): # module attributes listformat = "href" has_search = False categories = ["Europe", "America", "Canada", "Australia"] catmap = {"Albania": "albania", "America": "us", "Andorra": "andorra", "Australia": "au", "Austria": "austria", "Belarus": "belarus", "Belgium": "belgium", "Bulgaria": "bulgaria", "Canada": "can", "Croatia": "croatia", "Denmark": "denmark", "Estonia": "estonia", "Europe": "", "Finland": "finland", "France": "france", "Germany": "germany", "Greece": "greece", "Hungary": "hungary", "Iceland": "iceland", "Ireland": "ireland", "Italy": "italy", "Latvia": "latvia", "Liechtenstein": "liechtenstein", "Lithuania": "lithuania", "Luxembourg": "luxembourg", "Macedonia": "macedonia", "Malta": "malta", "Moldova": "moldova", "Monaco": "monaco", "Montenegro": "montenegro", "Netherlands": "netherlands", "New Zealand": "nz", "Norway": "norway", "Poland": "poland", "Portugal": "portugal", "Romania": "romania", "Russia": "russia", "Serbia": "serbia", "Slovakia": "slovakia", "Slovenia": "slovenia", "South America": "sa", "Spain": "spain", "Sweden": "sweden", "Switzerland": "switzerland", "Ukraine": "ukraine"} titles = dict( genre="Genre", title="Station", playing="Location", bitrate="Bitrate", listeners=False ) # just a static list for now def update_categories(self): self.catmap = {"Europe":"", "America":"us", "Canada":"ca", "Australia":"au", "New Zealand":"nz", "South America":"sa"} c = []# rx_links = re.compile(r""" <li \s+ id="item[\d-]+"> \s+ <!--[^>]+--> \s+ <a\s+href="(?:https?://radiolist.net)?/((?:\w{2,3}/)?\w+)" .+? <h3[^>]*>\s*([\w\s-]+?)\s*< """, re.X|re.S) for title in self.catmap.keys(): c.append(title) html = ahttp.get("http://www.radiolist.net/" + self.catmap[title]) sub = [] for p,t in re.findall(rx_links, html): log.I(p,t) if t in ["Terms", "About Us", "Donation", "United States"]: continue sub.append(t) self.catmap[t] = p c.append(sorted(sub)) self.categories = c # extraction rules recipe = { "block": """<li\s+id="item-\d+-\d+">(.+?)</li>""", "split": None, "fields": { "title": 'data-item-title="(.+?)"', "url": 'data-item-link="(http.+?)"', "homepage": 'data-item-link="(.+?)"', "favicon": '<img[^>]+src="(.+?)"', "description": '<p\sclass="ca-sub">(.+?)</p>' } } # extract stream urls def update_streams(self, cat): entries = [] html = ahttp.get("http://radiolist.net/" + self.catmap[cat]) for block in re.findall(self.recipe["block"], html, re.S): log.HTML(block) e = {"genre":"-", "playing":cat, "format":"text/html"} for id,rx in self.recipe["fields"].iteritems(): uu = re.findall(rx, block) log.RX(id,rx,uu) if uu: 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 |