Check-in [3ab6b3fa94]
Overview
Comment: | safeguard wiki/links retrieval |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
3ab6b3fa947f5d62d76732c003c59695 |
User & Date: | mario on 2020-05-21 11:54:41 |
Other Links: | manifest | tags |
Context
2020-05-21
| ||
11:55 | refine dependency list check-in: 8aa9e67d20 user: mario tags: trunk | |
11:54 | safeguard wiki/links retrieval check-in: 3ab6b3fa94 user: mario tags: trunk | |
11:54 | Add more detailed user-agent string, introduce conf.version (from pmd) check-in: d9a4e95fc9 user: mario tags: trunk | |
Changes
Modified channels/links.py from [5eb14dba9a] to [19c2330877].
︙ | ︙ | |||
79 80 81 82 83 84 85 | "homepage": channel.meta.get("url", ""), "format": "text/html", }) except Exception as e: log.ERR("links: adding entry failed:", e) # Add wiki or built-in link list | > | < > > | | < < < < < | | 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 | "homepage": channel.meta.get("url", ""), "format": "text/html", }) except Exception as e: log.ERR("links: adding entry failed:", e) # Add wiki or built-in link list try: self.from_wiki() except Exception as e: log.ERR("Failure to retrieve /wiki/links\n", e) for genre, title, homepage in self.default: self.streams.append(dict(genre=genre, title=title, homepage=homepage, type="text/html")) # add to bookmarks return self.streams # retrieve links from repository wiki page (via JSON API /json/wiki/get/…) def from_wiki(self): src = ahttp.get("https://fossil.include-once.org/streamtuner2/json/wiki/get/links", timeout=2.0) if not src: return wiki = json.loads(src) if not wiki or not wiki.get("payload"): return wiki = wiki["payload"]["content"] pairs = re.findall("(?:(\w+)\s*\|\s*)?\[([\w\s(&,;!:#+\-)]+)\]\((http[^)\s]+)\)", wiki) if not pairs: return self.default = [(cat if cat else "site", title, url) for cat,title,url in pairs] |