Index: channels/__init__.py ================================================================== --- channels/__init__.py +++ channels/__init__.py @@ -2,20 +2,20 @@ # api: streamtuner2 # type: class # category: ui # title: Channel plugins # description: Base implementation for channels and feature plugins -# version: 1.3 +# version: 1.5 # license: public domain # author: mario # url: http://fossil.include-once.org/streamtuner2/ # pack: # bookmarks.py configwin.py streamedit.py history.py search.py links.py # icast.py internet_radio.py itunes.py jamendo.py live365.py global_key.py # modarchive.py myoggradio.py punkcast.py radiobrowser.py radiotray.py # shoutcast.py surfmusik.py timer.py tunein.py xiph.py youtube.py -# exportcat.py useragentswitcher.py somafm.py +# exportcat.py useragentswitcher.py somafm.py dnd.py # config: - # priority: core # # GenericChannel implements the basic GUI functions and defines # the default channel data structure. It implements fallback logic @@ -102,11 +102,11 @@ @property def current(self): return self.__current @current.setter def current(self, newcat): - print "{}.current:={} ← from {}".format(self.module, newcat, [inspect.stack()[x][3] for x in range(1,4)]) + __print__(dbg.PROC, "{}.current:={} ← from {}".format(self.module, newcat, [inspect.stack()[x][3] for x in range(1,4)])) self.__current = newcat return self.__current #--------------------------- initialization -------------------------------- @@ -254,11 +254,10 @@ new_streams = self.empty_stub else: 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 len(set(["", None]) & set([row.get("title"), row.get("url")])): @@ -276,32 +275,24 @@ self.streams[category] = new_streams # save in cache self.save() - # invalidate gtk list cache - #if (self.liststore.has_key(category)): - # del self.liststore[category] - else: # parse error self.status("Category parsed empty.") self.streams[category] = self.nothing_found __print__(dbg.INFO, "Oooops, parser returned nothing for category " + category) # assign to treeview model - #if (self.liststore.has_key(category)): # was already loded before - # self.gtk_list.set_model(self.liststore[category]) - #else: # currently list is new, had not been converted to gtk array before - # self.liststore[category] = \ uikit.do(lambda:uikit.columns(self.gtk_list, self.datamap, self.prepare(self.streams[category]))) # set pointer self.current = category self.status("") self.status(1.0) - pass + # store current streams data def save(self): conf.save("cache/" + self.module, self.streams, gz=1) @@ -326,17 +317,11 @@ # # - 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"))): streams[i]["favourite"] = 1 # state icon: INFO or DELETE @@ -343,17 +328,13 @@ if (not row.get("state")): if row.get("favourite"): streams[i]["state"] = gtk.STOCK_ABOUT if conf.retain_deleted and row.get("deleted"): streams[i]["state"] = gtk.STOCK_DELETE - - # guess homepage url - #self.postprocess(row) # favicons? if conf.show_favicons: - # entry provides its own image if "img" in row: favicon_url = row["img"] streams[i]["favicon"] = favicon.localcopy(favicon_url) @@ -361,34 +342,27 @@ elif "homepage" in row: homepage_url = row.get("homepage") # 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 # by looking for www.xyz.com domain names 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"] = http.fix_url(url) - return row # reload current stream from web directory