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

⌈⌋ ⎇ branch:  streamtuner2


Check-in [3c94abea16]

Overview
Comment:Skip new_streams with undefined title or url
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3c94abea16ac5d21af3e5a12a98caea522aeff9f
User & Date: mario on 2014-05-10 21:40:48
Other Links: manifest | tags
Context
2014-05-11
01:21
load Jamendo images in favour of favicons check-in: 6d065627b5 user: mario tags: trunk
2014-05-10
21:40
Skip new_streams with undefined title or url check-in: 3c94abea16 user: mario tags: trunk
2014-05-09
00:01
Support /get2/ URLs for albums and playlists now. Genres are queried for /tracks. check-in: 590edd0877 user: mario tags: trunk
Changes

Modified channels/_generic.py from [f4b3b96251] to [d2e1c8074b].

181
182
183
184
185
186
187

188
189
190
191


192
193







194
195
196
197
198
199
200
        # 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):

                new_streams = self.update_streams(category)
      
                if new_streams:
                


                    # modify
                    [self.postprocess(row) for row in new_streams]







      
                    # 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
      







>



|
>
>
|
|
>
>
>
>
>
>
>







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:

                    # 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
                if ("url" in row and (row.get("url") not in new)):
                    row["deleted"] = 1
                    diff.append(row)
            return diff

        
        # prepare data for display




        def prepare(self, 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"))):







>
>
>
>

>
>







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
                    # 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        




        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







|
>
>
>
>







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
        #
        # - 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