Check-in [c5e06b031a]
Overview
Comment: | Reuse mime_guess+list_guess functions from action.heuristic_funcs |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
c5e06b031a36f2dc495ac040fa236f97 |
User & Date: | mario on 2017-02-26 21:45:10 |
Other Links: | manifest | tags |
Context
2017-02-26
| ||
21:45 | ... and also bump version check-in: b068c34740 user: mario tags: trunk | |
21:45 | Reuse mime_guess+list_guess functions from action.heuristic_funcs check-in: c5e06b031a user: mario tags: trunk | |
21:44 | Collect audio format form URL guessing into new class heuristic_funcs check-in: 7a1577bf74 user: mario tags: trunk | |
Changes
Modified contrib/radiolist.py from [4692e7b068] to [22b5dbfc08].
︙ | ︙ | |||
42 43 44 45 46 47 48 | # extraction afterwards (instead of a block match). # # Β· Entries may contain more than one streaming url. Each accompanied by a # bitrate. β Therefore the .best_url() sorting method. # # Β· Later versions might of course use multi-urls againβ¦ # | | | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | # extraction afterwards (instead of a block match). # # Β· Entries may contain more than one streaming url. Each accompanied by a # bitrate. β Therefore the .best_url() sorting method. # # Β· Later versions might of course use multi-urls againβ¦ # class radiolist (ChannelPlugin, action.heuristic_funcs): # module attributes listformat = "pls" has_search = False categories = ["Europe", "America", "Canada", "Oceania", "Asia"] catmap = {"Europe":"", "America":"world", "Canada":"world/canada", "Oceania":"world/oceania", "Asia":"world/asia"} titles = dict( genre="Genre", title="Station", playing="Location", bitrate="Bitrate", listeners=False ) |
︙ | ︙ | |||
89 90 91 92 93 94 95 | if ut and uu and lg: url, br = self.best_url(uu) entries.append(dict( homepage = ut[0][0], title = unhtml(ut[0][1]), url = url, bitrate = br, | | | < < < < < < < | < < < < < < < < | 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | if ut and uu and lg: url, br = self.best_url(uu) entries.append(dict( homepage = ut[0][0], title = unhtml(ut[0][1]), url = url, bitrate = br, format = self.mime_guess(url, "audio/mpeg"), listformat = self.list_guess(url), playing = lg[0], genre = lg[1] )) # done [log.DATA(e) for e in entries] return entries # pick highest rated URL from [(url,bitrate),β¦] tuples def best_url(self, urls): r = dict([(u, to_int(b)) for u,b in urls]) # {url: bitrate, β¦} best = sorted(r, key=r.get, reverse=True) return best[0], r[best[0]] |