47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
"search": [],
"scripts": [],
"timer": [],
"history": []
}
default = "favourite"
fixed_size = [32,24]
# cache list, to determine if a PLS url is bookmarked
urls = []
def gui(self, parent):
parent.notebook_channels.set_menu_label_text(parent.v_bookmarks, "bookmarks")
GenericChannel.gui(self, parent)
uikit.tree_column(self.gtk_cat, "Group")
# this channel does not actually retrieve/parse data from anywhere
def update_categories(self):
pass
# but category sub-plugins might provide a hook
category_plugins = {}
def update_streams(self, cat):
if cat in self.category_plugins:
return self.category_plugins[cat].update_streams(cat) or []
else:
return self.streams.get(cat, [])
# streams are already loaded at instantiation
|
>
>
|
|
>
>
>
<
|
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
"search": [],
"scripts": [],
"timer": [],
"history": []
}
default = "favourite"
fixed_size = [32,24]
reserved_names = ["favourite", "radiotray", "scripts", "search", "timer", "history", "links", "themes"] #+ self.parent.features.keys()
# cache list, to determine if a PLS url is bookmarked
urls = []
def gui(self, parent):
parent.notebook_channels.set_menu_label_text(parent.v_bookmarks, "bookmarks")
self.update_categories()
GenericChannel.gui(self, parent)
uikit.tree_column(self.gtk_cat, "Group")
# custom categories are shown as subfolder below `favourite`
def update_categories(self):
cust_cats = list(set(self.streams.keys()) - set(self.reserved_names))
if len(self.categories) < 2 or type(self.categories[1]) is not list:
self.categories.insert(1, [])
self.categories[1] = cust_cats
# but category sub-plugins might provide a hook
category_plugins = {}
def update_streams(self, cat):
if cat in self.category_plugins:
return self.category_plugins[cat].update_streams(cat) or []
else:
return self.streams.get(cat, [])
# streams are already loaded at instantiation
|
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
if (not self.urls):
self.urls = [str(row.get("url","urn:x-streamtuner2:no")) for row in self.streams["favourite"]]
return str(url) in self.urls
# called from main window / menu / context menu,
# when bookmark is to be added for a selected stream entry
def add(self, row):
# Add / copy some row attributes
row["favourite"] = 1
if not row.get("favicon"):
pass# row["favicon"] = favicon.file(row.get("homepage"))
if not row.get("listformat"):
row["listformat"] = self.parent.channel().listformat
if not len(row.get("extra", "")):
row["extra"] = self.parent.channel().module
# append to storage
self.streams["favourite"].append(row)
self.save()
self.load(self.default)
self.urls.append(row["url"])
# simplified gtk TreeStore display logic (just one category for the moment, always rebuilt)
def load(self, category, force=False, y=None):
|
|
|
|
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
if (not self.urls):
self.urls = [str(row.get("url","urn:x-streamtuner2:no")) for row in self.streams["favourite"]]
return str(url) in self.urls
# called from main window / menu / context menu,
# when bookmark is to be added for a selected stream entry
def add(self, row, target="favourite"):
# Add / copy some row attributes
row["favourite"] = 1
if not row.get("favicon"):
pass# row["favicon"] = favicon.file(row.get("homepage"))
if not row.get("listformat"):
row["listformat"] = self.parent.channel().listformat
if not len(row.get("extra", "")):
row["extra"] = self.parent.channel().module
# append to storage
self.streams[target].append(row)
self.save()
self.load(self.default)
self.urls.append(row["url"])
# simplified gtk TreeStore display logic (just one category for the moment, always rebuilt)
def load(self, category, force=False, y=None):
|