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

⌈⌋ branch:  streamtuner2


Diff

Differences From Artifact [af89693d25]:

To Artifact [6b8a1b4500]:


1
2
3
4
5
6

7
8
9
10
11
12
13
1
2
3
4
5

6
7
8
9
10
11
12
13





-
+






# api: streamtuner2
# title: File browser
# description: Displays mp3/oggs or m3u/pls files from local media file directories.
# type: channel
# category: local
# version: 0.2
# version: 0.3.2
# priority: optional
# status: unsupported
# depends: python:mutagen, python:id3
# config:  
#   { name: file_browser_dir, type: text, value: "$XDG_MUSIC_DIR, ~/MP3", description: "List of directories to scan for audio files." },
#   { name: file_browser_ext, type: text, value: "mp3,ogg, m3u,pls,xspf, avi,flv,mpg,mp4", description: "File type/extension filter." },
# url: http://freshcode.club/projects/streamtuner2
189
190
191
192
193
194
195







196
197
198
199
200
201
202
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209







+
+
+
+
+
+
+






        src = open(fn, "r").read() if os.path.exists(fn) else ""
        env = re.findall('^(\w+)=[\"\']?(.+?)[\"\']?', src, re.M)  # pyxdg: Your move.
        return dict(env)

    
    # don't load cache file
    cache = lambda *x: None
    
    
    # override: set force=0 always, as otherwise list gets cleared (bug)
    # Called on switching genre/category, or loading a genre for the first time.
    def load(self, category, force=False, y=None):
        log.UI("no reloading for file plugin")
        ChannelPlugin.load(self, self.current, force=0)


    # read dirs
    def scan_dirs(self):
        self.categories = []
    
        # add main directory
226
227
228
229
230
231
232

233
234
235
236

237
238
239
240
241
242
243
233
234
235
236
237
238
239
240
241
242
243

244
245
246
247
248
249
250
251







+



-
+






            if self.streams.get(main_base):
                self.streams[main] = self.streams[main_base]


    # extract meta data
    def file_entry(self, fn, dir):
        # basic data
        url = ("%s/%s" % (dir, fn)).replace("\\", "/")
        meta = {
            "title": "",
            "filename": fn,
            "url": "file://" + dir + "/" + fn,
            "url": url,
            "genre": "",
            "album": "",
            "artist": "",
            "length": "n/a",
            "bitrate": "n/a",
#            "format": mime_fmt(fn[-3:]),
            "format": mime_fmt(fn[-(len(fn)-fn.rfind(".")-1):]),
270
271
272
273
274
275
276
277

278
279
280
281
278
279
280
281
282
283
284

285
286
287
288
289







-
+




    # same as init
    def update_categories(self):
        self.scan_dirs()

        
    # same as init
    def update_streams(self, cat, x=0):
    def update_streams(self, cat, *k, **kw):
        self.scan_dirs()
        return self.streams.get(os.path.basename(cat))