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

⌈⌋ branch:  streamtuner2


Check-in [af2c52cdca]

Overview
Comment:Refetch ZIP/CSV only once per day, and extract each category from CSV separately.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:af2c52cdcad972162c3b551121545c4f9dcb282d
User & Date: mario on 2016-04-11 00:55:19
Other Links: manifest | tags
Context
2016-04-11
00:55
fix comment check-in: 65905824a7 user: mario tags: trunk
00:55
Refetch ZIP/CSV only once per day, and extract each category from CSV separately. check-in: af2c52cdca user: mario tags: trunk
00:54
Update UbuntuUsers wiki raw export URLs. check-in: 69a40e6b71 user: mario tags: trunk
Changes

Modified contrib/radiosure.py from [3b8ff7fe4d] to [c4096229db].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
..
73
74
75
76
77
78
79

80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# encoding: UTF-8
# api: streamtuner2
# title: RadioSure
# description: Huge radio station collection
# version: 0.2
# type: channel
# category: radio
# url: http://radiosure.com/
# config: -
# priority: extra
# png: 
#   iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAgMAAABinRfyAAAADFBMVEULDgpKTEmQko/19/S0inLcAAAAUklEQVQI12P4DwQMDvuBBIs92zcGHh2G
#   BQw+FvUPGDwq/n9gaPoj/5DB6b/TQwaH/18uMrjs/yPI4FP2R4kh1vBHPUO8SsAnBn8P9ocMYFNABADRrSa61FmXoAAAAABJRU5ErkJggg==
#
# RadioSure is a Windows freeware/shareware for playing internet
# stations. It comes with a huge database of streams.
#
# Fetches the ZIP/CSV at once. Extracts all stations in memory.
# RadioSure stream lists are just updated once per day.
#


from config import *
from channels import *
import re
import ahttp
import zipfile
................................................................................
    # categories are derived from the station list
    def update_categories(self):
        #self.categories = sorted(self.streams.keys())
        pass

    # import station list
    def update_streams(self, cat, search=None):

        # refresh zip file
        if not os.path.isfile(self.tmp) or os.path.getmtime(self.tmp) < (time.time() - 3600):
            with open(self.tmp, "w") as f:
                f.write(ahttp.get(self.zip, binary=1))
        # get first file
        zip = zipfile.ZipFile(self.tmp)
        csv = zip.read(zip.namelist()[0])
        self.status("Updating streams from RadioSure CSV database")
        #fields = ["title", "playing", "genre", "country", "language", "url"]
        for e in re.findall("^([^\t]+)\t([^\t]+)\t([^\t]+)\t([^\t]+)\t([^\t]+)\t([^\t]+(?:\t[^\t]{3,})*)", csv, re.M):
            genre = e[2]
            if not genre in self.streams:
                self.streams[genre] = []
            self.streams[genre].append(dict(
                title = e[0],
                playing = e[1],
                genre = e[2],
                country = e[3],
                language = e[4],
                url = e[5]#...
            ))
        return self.streams[cat]
        
        
        
        
        
        




|












|
|
<







 







>

|






|

|
<
<
|
|
|
|
|
|
|
|
|
|
|
<
<
<
<
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

20
21
22
23
24
25
26
..
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90


91
92
93
94
95
96
97
98
99
100
101




# encoding: UTF-8
# api: streamtuner2
# title: RadioSure
# description: Huge radio station collection
# version: 0.3
# type: channel
# category: radio
# url: http://radiosure.com/
# config: -
# priority: extra
# png: 
#   iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAgMAAABinRfyAAAADFBMVEULDgpKTEmQko/19/S0inLcAAAAUklEQVQI12P4DwQMDvuBBIs92zcGHh2G
#   BQw+FvUPGDwq/n9gaPoj/5DB6b/TQwaH/18uMrjs/yPI4FP2R4kh1vBHPUO8SsAnBn8P9ocMYFNABADRrSa61FmXoAAAAABJRU5ErkJggg==
#
# RadioSure is a Windows freeware/shareware for playing internet
# stations. It comes with a huge database of streams.
#
# Fetches and keeps the ZIP/CSV database at maximum once per day.
# (Not updated more frequently.)



from config import *
from channels import *
import re
import ahttp
import zipfile
................................................................................
    # categories are derived from the station list
    def update_categories(self):
        #self.categories = sorted(self.streams.keys())
        pass

    # import station list
    def update_streams(self, cat, search=None):
        streams = []
        # refresh zip file
        if not os.path.isfile(self.tmp) or os.path.getmtime(self.tmp) < (time.time() - 24*3600):
            with open(self.tmp, "w") as f:
                f.write(ahttp.get(self.zip, binary=1))
        # get first file
        zip = zipfile.ZipFile(self.tmp)
        csv = zip.read(zip.namelist()[0])
        self.status("Updating streams from RadioSure CSV database")
        # fields = ["title", "playing", "genre", "country", "language", "url"]
        for e in re.findall("^([^\t]+)\t([^\t]+)\t([^\t]+)\t([^\t]+)\t([^\t]+)\t([^\t]+(?:\t[^\t]{3,})*)", csv, re.M):
            if cat == e[2]:


                streams.append(dict(
                    title = e[0],
                    playing = e[1],
                    genre = e[2],
                    country = e[3],
                    language = e[4],
                    url = e[5]#...
                ))
        return streams