Index: channels/__init__.py ================================================================== --- channels/__init__.py +++ channels/__init__.py @@ -342,10 +342,11 @@ do_save = False # get data from cache or download if force or not category in self.streams: log.PROC("load", "update_streams") + self.progress(None) self.status("Updating streams...") self.status(-0.1) if category == "empty": new_streams = self.empty_stub else: @@ -446,10 +447,24 @@ if ("url" in row and (row.get("url") not in new)): row["deleted"] = 1 diff.append(row) return diff + # sets updating progress bar for .update_streams or .reload_categores + def progress(self, max, i=None): + if not max: + self.status() + self.status(1.0) + self.progress_state = 1 + return + if isinstance(max, (list, dict)): + max = len(max) + if not i: + i = self.progress_state + self.status( float(int(i)) / (float(int(max)) + 1.5) ) + self.progress_state = self.progress_state + 1 + progress_state = 1 # Display .current category, once notebook/channel tab is first opened def first_show(self): Index: channels/dirble.py ================================================================== --- channels/dirble.py +++ channels/dirble.py @@ -81,10 +81,11 @@ self.categories = cats # Fetch entries def update_streams(self, cat, search=None): + self.progress(1) return [ self.unpack(r) for r in self.api("category/{}/stations".format(self.catmap.get(cat, 0)), all=1)# per_page=200 won't work ] Index: channels/radionomy.py ================================================================== --- channels/radionomy.py +++ channels/radionomy.py @@ -86,10 +86,11 @@ html = ahttp.get(req, ajax=1, referer=1) # https://www.radionomy.com/de/OnAir/Update self.onair_update(req) # collect additional pages for i in range(0, int(conf.radionomy_pages) - 1): + self.progress(conf.radionomy_pages) add = ahttp.get(req, { "scrollOffset": i }, post=1, ajax=1, referer=1) if add.find("browseRadio") < 0: break html += add self.onair_update(req) Index: channels/reddit.py ================================================================== --- channels/reddit.py +++ channels/reddit.py @@ -238,10 +238,11 @@ # collect links data = [] after = None for i in range(1, int(conf.reddit_pages) + 1): + self.progress(conf.reddit_pages) try: j = ahttp.get( "http://www.reddit.com/r/{}/new.json".format(cat.lower()), { "sort": "new", "after": after } ) Index: channels/surfmusik.py ================================================================== --- channels/surfmusik.py +++ channels/surfmusik.py @@ -127,10 +127,11 @@ path = path_genre # country else: path = path_country + self.status(-1.0) if path is not None: ucat = cat.replace(" ", "+").lower() html = ahttp.get(base_url + path + ucat + ".html") html = re.sub("&#x?\d+;", "", html) Index: contrib/streema.py ================================================================== --- contrib/streema.py +++ contrib/streema.py @@ -1,8 +1,8 @@ # api: streamtuner2 # title: Streema -# description: +# description: Directory and app for over 70.000 stations # type: channel # category: radio # version: 0.2 # url: http://www.streema.com/ # png: @@ -44,15 +44,18 @@ # takes a while to load def update_categories(self): self.categories = [] html = ahttp.get(self.base) - for cat in re.findall('', html): + main_cats = re.findall('', html) + for cat in main_cats: + self.progress(main_cats) html = ahttp.get(self.base + "/main-genre/" + cat) sub = re.findall('', html) self.categories.append(cat) self.categories.append(sub) + self.progress(0) return self.categories # get streems def update_streams(self, cat, search=None): @@ -89,11 +92,11 @@ listeners = to_int(listeners[0]) )) except: pass #some field missing - # done + # done return r # load page and get first download url (there's four, but usually identical) def resolve_urn(self, row):