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

⌈⌋ branch:  streamtuner2


Check-in [0c7040e314]

Overview
Comment:Add more .progress() indication
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:0c7040e314bde79c7acce0c323ac9c64906a1c1d
User & Date: mario on 2016-12-18 14:04:19
Other Links: manifest | tags
Context
2016-12-18
20:32
os.access(gtk_dir, os.W_OK) in installhandler() not working on Windows (10). Incorrectly returns true for ProgramFiles paths, thus dll copying failed. Finally more cleanup code to remove the zip file, as well as dll - after successful extraction. → clear_theme() and clear_dll() are the new corresponding functions. check-in: 0ef1977fd2 user: Oliver tags: trunk
14:04
Add more .progress() indication check-in: 0c7040e314 user: mario tags: trunk
14:03
More details to overview, extract some flags, add dirname. List feature plugins in separate table. check-in: 14be328ff7 user: mario tags: trunk
Changes

Modified channels/__init__.py from [96d271c529] to [296d8f3610].

340
341
342
343
344
345
346

347
348
349
350
351
352
353
...
444
445
446
447
448
449
450














451
452
453
454
455
456
457
            return
        self.current = category
        do_save = False

        # get data from cache or download
        if force or not category in self.streams:
            log.PROC("load", "update_streams")

            self.status("Updating streams...")
            self.status(-0.1)
            if category == "empty":
                new_streams = self.empty_stub
            else:
                new_streams = self.update_streams(category)
  
................................................................................
        new = [row.get("url","http://example.com/") for row in new]
        for row in old:
            if ("url" in row and (row.get("url") not in new)):
                row["deleted"] = 1
                diff.append(row)
        return diff
















        
    # Display .current category, once notebook/channel tab is first opened
    def first_show(self):

        # Already processed
        if (self.shown == 55555):







>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>







340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
...
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
            return
        self.current = category
        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:
                new_streams = self.update_streams(category)
  
................................................................................
        new = [row.get("url","http://example.com/") for row in new]
        for row in old:
            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):

        # Already processed
        if (self.shown == 55555):

Modified channels/dirble.py from [0aa81f09de] to [3e36e0af87].

79
80
81
82
83
84
85

86
87
88
89
90
91
92
                for c in row["children"]:
                    self.catmap[c["title"]] = c["id"]
        self.categories = cats


    # Fetch entries
    def update_streams(self, cat, search=None):

        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
        ]

    







>







79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
                for c in row["children"]:
                    self.catmap[c["title"]] = c["id"]
        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
        ]

    

Modified channels/radionomy.py from [05a66c0287] to [04a11c793d].

84
85
86
87
88
89
90

91
92
93
94
95
96
97

        # https://www.radionomy.com/de/style/GENRE
        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):

            add = ahttp.get(req, { "scrollOffset": i }, post=1, ajax=1, referer=1)
            if add.find("browseRadio") < 0:
                break
            html += add
            self.onair_update(req)
        
        # extractzz







>







84
85
86
87
88
89
90
91
92
93
94
95
96
97
98

        # https://www.radionomy.com/de/style/GENRE
        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)
        
        # extractzz

Modified channels/reddit.py from [cfb66a69eb] to [828a881eea].

236
237
238
239
240
241
242

243
244
245
246
247
248
249
        elif cat.find("→") > 0:
            return self.placeholder

        # collect links
        data = []
        after = None
        for i in range(1, int(conf.reddit_pages) + 1):

            try:
                j = ahttp.get(
                    "http://www.reddit.com/r/{}/new.json".format(cat.lower()),
                    { "sort": "new", "after": after }
                )
                j = json.loads(j)
            except Exception as e:







>







236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
        elif cat.find("→") > 0:
            return self.placeholder

        # 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 }
                )
                j = json.loads(j)
            except Exception as e:

Modified channels/surfmusik.py from [ef6ef15c63] to [088560b929].

125
126
127
128
129
130
131

132
133
134
135
136
137
138
        # genre 
        elif cat in self.categories[self.categories.index("Genres") + 1]:
            path = path_genre
        # country
        else:
            path = path_country
        

        if path is not None:
            ucat = cat.replace(" ", "+").lower()
            html = ahttp.get(base_url + path + ucat + ".html")
            html = re.sub("&#x?\d+;", "", html)
        
            rx_radio = re.compile(r"""
                <td\s+class="home1"><a[^>]*\s+href="(.+?)"[^>]*> .*?







>







125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
        # genre 
        elif cat in self.categories[self.categories.index("Genres") + 1]:
            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)
        
            rx_radio = re.compile(r"""
                <td\s+class="home1"><a[^>]*\s+href="(.+?)"[^>]*> .*?

Modified contrib/streema.py from [13e4a521b2] to [f01c00621d].

1
2
3
4
5
6
7
8
9
10
..
42
43
44
45
46
47
48
49


50
51
52
53

54
55
56
57
58
59
60
..
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# api: streamtuner2
# title: Streema
# description: 
# type: channel
# category: radio
# version: 0.2
# url: http://www.streema.com/
# png:
#   iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABF0lEQVR42oWTMWsCURCE/Y/Bxh+QLrUIloKdELCxTOOBRSSgpZVYhCAWCtcEETGQJmCTkG7k47HcereeA4vnu32zszt7jceRFMXDQGoN
#   pd40RXci9d+kpxep+VzkNaLLXBzMpe1R+vu/jq8fabxKOSEBL6YfqgVEnSwgsMoen9+JcJlL5990xv9QAYf5qbhMC/RrQf/trLgctoA8A/0yPCO38PkVApPpAdFsndyoJeDlaKFarPZ3FJj3i12qHIEh
................................................................................
    base = "http://streema.com/radios"
    

    # takes a while to load
    def update_categories(self):
        self.categories = []
        html = ahttp.get(self.base)
        for cat in re.findall('<a href="/radios/main-genre/(\w+)">', html):


            html = ahttp.get(self.base + "/main-genre/" + cat)
            sub = re.findall('<a href="/radios/genre/(\w+)">', html)
            self.categories.append(cat)
            self.categories.append(sub)

        return self.categories


    # get streems
    def update_streams(self, cat, search=None):
        r = []
        if cat:
................................................................................
                   playing = playing[0],
                   genre = unhtml(genre[0]),
                   listeners = to_int(listeners[0])
                ))
            except:
                pass #some field missing
        
        # done    
        return r


    # load page and get first download url (there's four, but usually identical)
    def resolve_urn(self, row):
        if row.get("url", "-").find("urn:streema:") != 0:
            return


|







 







|
>
>




>







 







|







1
2
3
4
5
6
7
8
9
10
..
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
..
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# api: streamtuner2
# title: Streema
# description: Directory and app for over 70.000 stations
# type: channel
# category: radio
# version: 0.2
# url: http://www.streema.com/
# png:
#   iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABF0lEQVR42oWTMWsCURCE/Y/Bxh+QLrUIloKdELCxTOOBRSSgpZVYhCAWCtcEETGQJmCTkG7k47HcereeA4vnu32zszt7jceRFMXDQGoN
#   pd40RXci9d+kpxep+VzkNaLLXBzMpe1R+vu/jq8fabxKOSEBL6YfqgVEnSwgsMoen9+JcJlL5990xv9QAYf5qbhMC/RrQf/trLgctoA8A/0yPCO38PkVApPpAdFsndyoJeDlaKFarPZ3FJj3i12qHIEh
................................................................................
    base = "http://streema.com/radios"
    

    # takes a while to load
    def update_categories(self):
        self.categories = []
        html = ahttp.get(self.base)
        main_cats = re.findall('<a href="/radios/main-genre/(\w+)">', html)
        for cat in main_cats:
            self.progress(main_cats)
            html = ahttp.get(self.base + "/main-genre/" + cat)
            sub = re.findall('<a href="/radios/genre/(\w+)">', html)
            self.categories.append(cat)
            self.categories.append(sub)
        self.progress(0)
        return self.categories


    # get streems
    def update_streams(self, cat, search=None):
        r = []
        if cat:
................................................................................
                   playing = playing[0],
                   genre = unhtml(genre[0]),
                   listeners = to_int(listeners[0])
                ))
            except:
                pass #some field missing
        
        # done
        return r


    # load page and get first download url (there's four, but usually identical)
    def resolve_urn(self, row):
        if row.get("url", "-").find("urn:streema:") != 0:
            return