Internet radio browser GUI for music/video streams from various directory services.

⌈⌋ branch:  streamtuner2


Diff

Differences From Artifact [f4b3b96251]:

To Artifact [d2e1c8074b]:


181
182
183
184
185
186
187

188
189
190
191
192
193












194
195
196
197
198
199
200
181
182
183
184
185
186
187
188
189
190
191



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210







+



-
-
-
+
+
+
+
+
+
+
+
+
+
+
+






        # switch stream category,
        # load data,
        # update treeview content
        def load(self, category, force=False):
        
            # get data from cache or download
            if (force or not category in self.streams):
                __print__(dbg.PROC, "load", "update_streams")
                new_streams = self.update_streams(category)
      
                if new_streams:
                
                    # modify
                    [self.postprocess(row) for row in new_streams]

                    # check and modify entry;
                    # assert that title and url are present
                    modified = []
                    for row in new_streams:
                        if None in [row.get("title"), row.get("url")]:
                            next
                        try:
                            modified.append( self.postprocess(row) )
                        except Exception as e:
                            __print__(e, dbg.ERR, row)
                    new_streams = modified
      
                    # 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
      
241
242
243
244
245
246
247




248


249
250
251
252
253
254
255
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271







+
+
+
+

+
+






                if ("url" in row and (row.get("url") not in new)):
                    row["deleted"] = 1
                    diff.append(row)
            return diff

        
        # prepare data for display
        #
        #  - favourite icon
        #  - or deleted icon
        #
        def prepare(self, streams):
            __print__(dbg.PROC, "prepare", streams)

            for i,row in enumerate(streams):
                                            # oh my, at least it's working
                                            # at start the bookmarks module isn't fully registered at instantiation in parent.channels{} - might want to do that step by step rather
                                            # then display() is called too early to take effect - load() & co should actually be postponed to when a notebook tab gets selected first
                                            # => might be fixed now, 1.9.8
                # state icon: bookmark star
                if (conf.show_bookmarks and "bookmarks" in self.parent.channels and self.parent.bookmarks.is_in(streams[i].get("url", "file:///tmp/none"))):
271
272
273
274
275
276
277
278





279
280
281
282
283
284
285
287
288
289
290
291
292
293

294
295
296
297
298
299
300
301
302
303
304
305







-
+
+
+
+
+






                    # check for availability of PNG file, inject local icons/ filename
                    if homepage_url and favicon.available(homepage_url):
                        streams[i]["favicon"] = favicon.file(homepage_url)
                
            return streams

    
        # data preparations directly after reload        
        # data preparations directly after reload
        #
        # - drop shoutcast homepage links
        # - or find homepage name in title
        #
        def postprocess(self, row):

            # remove non-homepages from shoutcast
            if row.get("homepage") and row["homepage"].find("//yp.shoutcast.")>0:
                row["homepage"] = ""
                
            # deduce homepage URLs from title