Check-in [5e18bfece0]
Overview
Comment: | Make API requests more resilient |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
5e18bfece0e730585a77e32d6c59105a |
User & Date: | mario on 2014-08-12 16:42:12 |
Other Links: | manifest | tags |
Context
2014-08-12
| ||
16:42 | IO/xiph/cache fixed (agian) to return JSON array only check-in: 706904e073 user: mario tags: trunk | |
16:42 | Make API requests more resilient check-in: 5e18bfece0 user: mario tags: trunk | |
16:41 | Use r"" string for literal ANSI escapes check-in: 0cb24d59af user: mario tags: trunk | |
Changes
Modified channels/dirble.py from [e316404f38] to [8fa0a0e272].
1 2 3 | # encoding: UTF-8 # api: streamtuner2 # title: Dirble | | | 1 2 3 4 5 6 7 8 9 10 11 | # encoding: UTF-8 # api: streamtuner2 # title: Dirble # description: Open radio station directory. # version: 0.2 # type: channel # category: radio # priority: optional # documentation: http://dirble.com/developer/api # # Provides a nice JSON API, so is easy to support. |
︙ | ︙ | |||
96 97 98 99 100 101 102 | )) return r # Request homepage for stations, else try to deduce Dirble page def get_homepage(self, id, name): if conf.dirble_fetch_homepage: | > | | > | | | < > | 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 | )) return r # Request homepage for stations, else try to deduce Dirble page def get_homepage(self, id, name): if conf.dirble_fetch_homepage: try: return self.api("station", "id", id)["website"] except: None name = re.sub("[^\w\s]+", "", name) name = re.sub("\s", "-", name) return "http://dirble.com/station/" + name.lower(); # Patch API url together, send request, decode JSON and whathaveyou def api(self, *params): method = params[0] try: j = http.get((self.base % (method, self.cid)) + "/".join([str(e) for e in params[1:]])) r = json.loads(j); except: r = [] return r |