131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151 | 131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153 |
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
|
# add default options values to config.conf.* dict
conf.add_plugin_defaults(self.meta, self.module)
# Only if streamtuner2 is run in graphical mode
if (parent):
# Update/display stream processors
if not self.prepare_filters:
self.prepare_filters += [
self.prepare_filter_icons,
]
self.postprocess_filters += [
self.postprocess_filter_required_fields,
self.postprocess_filter_homepage,
]
self.prepare_filters += [
self.prepare_filter_icons,
]
if not self.postprocess_filters:
self.postprocess_filters += [
self.postprocess_filter_required_fields,
self.postprocess_filter_homepage,
]
# Load cache, instantiate Gtk widgets
self.cache()
self.gui(parent)
# Stub for ST2 main window / dispatcher
else:
self.parent = stub_parent(None) |
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316 | 304
305
306
307
308
309
310
311
312
313
314
315
316
317
318 |
-
+
| new_streams = self.update_streams(category)
# Postprocess new list of streams (e.g. assert existing title and url)
if new_streams:
try:
new_streams = self.postprocess(new_streams)
except Exception as e:
log.ERR(e, "Updating new streams, postprocessing failed:", row)
log.ERR("Updating new streams, postprocessing failed:", e)
# don't lose forgotten streams
if conf.retain_deleted:
self.streams[category] = new_streams + self.deleted_streams(new_streams, self.streams.get(category,[]))
else:
self.streams[category] = new_streams
|
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398 | 363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403 |
+
-
-
+
+
-
+
+
-
+
+
-
+
|
# Prepare stream list for display
prepare_filters = []
def prepare(self, streams):
for f in self.prepare_filters:
map(f, streams)
return streams
# state icon: bookmark star, or deleted mark
def prepare_filter_icons(self, row):
if conf.show_bookmarks:# and "bookmarks" in self.parent.channels:
row["favourite"] = self.parent.bookmarks.is_in(row.get("url", "file:///tmp/none"))
if not row.get("state"):
if row.get("favourite"):
row["state"] = gtk.STOCK_ABOUT
if row.get("deleted"):
row["state"] = gtk.STOCK_DELETE
# Stream list prepareations directly after reload,
# can remove entries, or just update fields.
# Stream list preparations - invoked directly after reload(),
# callbacks can remove entries, or just update fields.
postprocess_filters = []
def postprocess(self, streams):
for f in self.postprocess_filters:
streams = filter(f, streams)
streams = [row for row in streams if f(row, self)]
return streams
# Filter entries without title or url
def postprocess_filter_required_fields(self, row):
def postprocess_filter_required_fields(self, row, channel):
return not len(set(["", None]) & set([row.get("title"), row.get("url")]))
# Deduce homepage URLs from title
# by looking for www.xyz.com domain names
def postprocess_filter_homepage(self, row):
def postprocess_filter_homepage(self, row, channel):
if not row.get("homepage"):
url = self.rx_www_url.search(row.get("title", ""))
if url:
url = url.group(0).lower().replace(" ", "")
url = (url if url.find("www.") == 0 else "www."+url)
row["homepage"] = ahttp.fix_url(url)
print row |