Check-in [ad370f17b0]
Overview
Comment: | radiobrowser: Initial transition to new Rust API and new server names. Added more configuration options, such as minimum count of stations per category (to hide fringe tags). |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
ad370f17b09af04c99bbc0ec9107da43 |
User & Date: | mario on 2020-05-13 06:44:03 |
Other Links: | manifest | tags |
Context
2020-05-13
| ||
17:43 | Add new radio-browser icon. check-in: 1c189d72bc user: mario tags: trunk | |
06:44 | radiobrowser: Initial transition to new Rust API and new server names. Added more configuration options, such as minimum count of stations per category (to hide fringe tags). check-in: ad370f17b0 user: mario tags: trunk | |
06:42 | Fix integer handling in config dialog (once more). See also: ticket #4163057c37 check-in: 369203acfe user: mario tags: trunk | |
Changes
Modified channels/radiobrowser.py from [b21d774715] to [47c5a4d574].
1 2 3 4 | # encoding: UTF-8 # api: streamtuner2 # title: RadioBrowser # description: Community collection of stations; votes, clicks, homepage links. | | | > > | | | | < < | < < < < < > > | | | | > > > | | > | > > | | < | | < < < > | > > > > > | | > > > > | > | > > | | | > > > > > > > | | < > > | | | > | > > > > > > > > | | 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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | # encoding: UTF-8 # api: streamtuner2 # title: RadioBrowser # description: Community collection of stations; votes, clicks, homepage links. # version: 0.4 # type: channel # url: http://www.radio-browser.info/ # category: radio # priority: optional # config: # { name: radiobrowser_cat, type: select, value: tags, select="tags|countries|languages", description: Which category types to list. } # { name: radiobrowser_srv, type: select, value: all, select:"all|de1|fr1|nl1|old", description: API server to utilize. } # { name: radiobrowser_min, type: int, value: 20, description: Minimum stations to list a category/tag. } # documentation: http://www.radio-browser.info/#ui-tabs-7 # png: # iVBORw0KGgoAAAANSUhEUgAAABAAAAAMCAMAAABcOc2zAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAACQ1BMVEWNYNOIWNFyOsZtNcFx # N8hxN8hxN8hxN8hxN8hxN8hxN8dtNcFuNcJ+Ss2NX9N6T7uNX9NxPL9jMLBtNcBkMbFqNLuCT89wRq6MXtOATc17Rsp8SMl6Rcl6RctrQqmpht1qQ6PUxex6WqnXye18XarYyu3QyNzp5u739/jh3Ojd # 2OX4+Pl7XKrYy+3i3eh8Y6Dg2+i2q8ecjrGqm8Krm8LTzN+ikbunl8D5+fl7W6rZy+7z8fTk4Or29fjAuM3Dv8rx7vTs6vHy8PTh3Ojy8PX5+fl6Wqraze75+fn5+vn6+vn6+vn6+vl6WqrMuOl1U6iR # bMmNbb2NbryOb72PcL6Qcb+Rcr+SdMCTdcGUdsGVd8KWeMOXesSZfMWMa71cNpSLW9JxN8hxN8hxN8hxN8hxN8hrNL2NX9OMXdJ+Ss1/S85/S85/S85+Ss18SMqHV9GMXdK/p+W/p+W+peW+peS9pOS9 # o+S8ouS7oeO6oOO5nuO4neK3m+K3m+Kqidv5+fn5+vn5+fn5+fn5+fn5+fn5+fn4+fn4+Pn4+Pn4+Pn4+Pn5+fnl3vD5+fn5+fn7+/r6+vn5+fn5+vn5+vn5+vn5+fn6+/r6+vr5+fn6+/rp4/H6+vn0 # 8/X08vbz8vX08/b29vf6+/ro4vH7+/r6+/ro4vH6+vn6+vrn4fH6+/n6+vr6+/r6+vn6+/r6+vn6+vn7+/ro4fHt6PXu6fXu6vXv6vXv6/Xw6/bw7Pbw7fbx7fbx7vby7vby7/fz8ffd0+7///+qD5Mw # AAAAYHRSTlPJ4/Hz8/Lx7+3s6ufi08N9/fve8/bo//T8/vb6/fr67eL02vbc9/Tt//3v/N34/5aO/MWeoM7Rbene+f7E0PykaWqx3K333/v//Pv7/eD34Z/m7O3v8fL09vf5+vv8/9Pw7ECfAAAAAWJL # R0TAE2Hf+AAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB98EARcyBebz0PQAAADXSURBVAjXAcwAM/8AAAECAwQFBgcICQoLDA0ODwAQYBESE2FiY2RlZhQVFmcXABhoGRobaWprbG1uHB1vcB4A # H3Fyc3R1dnd4eXp7fH1+IAAhf4CBgoOEhYaHiImKi4wiACONjo+QkZKTlJWWl5iZmiQAJZucJiconZ6foCkqK6GiLAAtoy4vMDEyMzQ1Njc4pKU5ADqmOzw9Pj9AQUJDREWnqEYAR6mqq6xISUpLTK2u # r7CxTQBOsrO0tba3uLm6u7y9vr9PAFBRUlNUVVZXWFlaW1xdXl9emUehk/NThwAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxNS0wNC0wMlQwMTo0OTozOSswMjowMH98i/gAAAAldEVYdGRhdGU6bW9kaWZ5 # ADIwMTUtMDQtMDJUMDE6NDk6MTcrMDI6MDAcO09kAAAAAElFTkSuQmCC # x-icon-src: openclipart:tape.png # x-service-by: segler_alex # extraction-method: json # # # Radio-Browser is a community-collected list of internet radios. # Currently lists ≥25000 streaming stations, and tracks favourited # entries. Furthermore includes station homepage links! # # If you change the categories between tags/countries/languages, # please apply [Channel]→[Reload Category Tree] afterwards. # # Also has an awesome JSON API, has an excellent documentation, # thus is quite pleasant to support. It's also used by Rhythmbox / # VLC / Clementine / Kodi / RadioDroid / etc. import re import json from config import * from channels import * from uikit import uikit import ahttp # API endpoints: # https://de1.api.radio-browser.info/#General # # ENTRY sets: # { # "stationuuid":"960e57c5-0601-11e8-ae97-52543be04c81", "name":"SRF 1", # "url":"http://stream.srg-ssr.ch/m/drs1/mp3_128", "homepage":"http://ww.srf.ch/radio-srf-1", # "favicon":"https://upload.wikimedia.org/wikipedia/commons/thumb/d/d3/Radio_SRF_1.svg/205px-Radio_SRF_1.svg.png", # "tags":"srg ssr,public radio", # "country":"Switzerland", "countrycode":"CH", "state":"", "language":"german", "votes":0, # "lastchangetime":"2019-12-12 18:37:02", "codec":"MP3", "bitrate":128, "hls":0, "lastcheckok":1, # "lastlocalchecktime":"2020-01-08 23:18:38", "clickcount":0, # } # class radiobrowser (ChannelPlugin): # control flags has_search = True listformat = "pls" titles = dict(listeners="Votes", bitrate="Bitrate", playing="Country") api_old = "http://www.radio-browser.info/webservice/json/" api_url = "http://{}.api.radio-browser.info/json/" # de1, nl1, all (from conf.radiobrowser_srv) categories = ["topvote", "topclick", "60s", "70s", "80s", "90s", "adult contemporary", "alternative", "ambient", "catholic", "chillout", "christian", "classic hits", "classic rock", "classical", "college radio", "commercial", "community radio", "country", "dance", "electronic", "folk", "hiphop", "hits", "house", "indie", "information", "jazz", "local music", "local news", "lounge", "metal", "music", "news", "noticias", "npr", "oldies", "pop", "public radio", "religion", "rock", "soul", "sport", "talk", "techno", "top 40", "university radio", "variety", "world music"] pricat = ("topvote", "topclick") catmap = { "tags": "bytag", "countries": "bycountry", "languages": "bylanguage" } tagmap = { "tags": "tag", "countries": "country", "languages": "language" } # hook menu def init2(self, parent): if parent: uikit.add_menu([parent.streammenu, parent.streamactions], "Share in Radio-Browser", self.submit, insert=5) # votes, and tags, no countries or languages def update_categories(self): params = {"order":"name", "reverse":"false", "hidebroken":"true"} self.categories = list(self.pricat) + [grp["name"] for grp in filter( lambda grp: grp["stationcount"] >= conf.radiobrowser_min, self.api(conf.radiobrowser_cat, params) )] # Direct mapping def update_streams(self, cat, search=None): # title search if search: data = self.api( "stations/search", {"search": search, "limit": conf.max_streams} ) # topclick, topvote elif cat in self.pricat: data = self.api( "stations/{}/{}".format(cat, conf.max_streams), {"limit": conf.max_streams} ) # empty category #elif cat in ("tags", "countries", "languages"): # return [ # dict(genre="-", title="Placeholder category", url="offline:") # ] # search by tag, country, or language else: data = self.api( "stations/search", { self.tagmap[conf.radiobrowser_cat]: cat, "hidebroken": "true", "order": "click", "limit": conf.max_streams * 2 } ) #data = self.api("stations/" + self.catmap[conf.radiobrowser_cat] + "/" + cat) if len(data) >= 5000: data = data[0:5000] r = [] for e in data: r.append(dict( genre = e["tags"], url = e["url"], format = mime_fmt(e["codec"]), title = e["name"], homepage = ahttp.fix_url(e["homepage"]), playing = e["country"], listeners = int(e["votes"]), bitrate = int(e["bitrate"]), favicon = e["favicon"] )) return r # fetch multiple pages def api(self, method, params={}, post=False, **kwargs): # api/srv switcheroo if not "radiobrowser_srv" in conf: conf.radiobrowser_srv = "all" if conf.radiobrowser_srv == "old": srv = self.api_old else: srv = self.api_url.format(conf.radiobrowser_srv) # request + json decode j = ahttp.get(srv + method, params, post=post, **kwargs) try: return json.loads(j, strict=False) # some entries contain invalid character encodings except: return [] # Add radio station to RBI |
︙ | ︙ | |||
150 151 152 153 154 155 156 | if _from in cn.titles and cn.titles[_from].lower() == _val: data[_to] = _from # API submit j = self.api("add", data, post=1) log.SUBMIT_RBI(j) if j and "ok" in j and j["ok"] == "true" and "id" in j: self.parent.status("Submitted successfully to Radio-Browser.info, new station id #%s." % j["id"], timeout=15) | > | 179 180 181 182 183 184 185 186 | if _from in cn.titles and cn.titles[_from].lower() == _val: data[_to] = _from # API submit j = self.api("add", data, post=1) log.SUBMIT_RBI(j) if j and "ok" in j and j["ok"] == "true" and "id" in j: self.parent.status("Submitted successfully to Radio-Browser.info, new station id #%s." % j["id"], timeout=15) |