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 | "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
self.from_wiki()
for row in self.default:
(genre, title, homepage) = row
self.streams.append({
"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)
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]
|
>
|
<
>
>
|
|
<
<
<
<
<
|
| 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]
|