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

⌈⌋ branch:  streamtuner2


Check-in [4c67a494e7]

Overview
Comment:More special case handling on Windows: file encoding, backslashes, url quoting
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4c67a494e77b075b75bb234a522104b626efac2f
User & Date: Oliver on 2017-01-22 16:45:23
Other Links: manifest | tags
Context
2017-01-22
16:46
new plugin: recording options which hijacks the record button, provides streamripper/fPls/youtube-dl specific command-line flags in a GUI. check-in: 64de51eb48 user: mario tags: trunk
16:45
More special case handling on Windows: file encoding, backslashes, url quoting check-in: 4c67a494e7 user: Oliver tags: trunk
16:43
Add `urlquote` check-in: fc5214876f user: Oliver tags: trunk
Changes

Modified contrib/file.py from [11aaabcfaa] to [72ed9c3d2c].

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

44
45
46

47
48
49
50
51
52
53
# an optional plugin, and not overly well integrated.
#
# Bugs:
# Only loads directories on startup. Doesn't work when post-activated
# per pluginmanager2 for instance. And LANG=C breaks it on startup,
# if media directories contain anything but ASCII filenames.
#
# Currently does not play files with UTF characters on Windows.
#
# If your player doesn't play local files try unchecking "Convert file path to 'file:///' style URL". (Might happen on Windows when not using VLC.exe).
# When using VLC however it must be checked.
#
# After checking/unchecking restart Streamtuner2 for recollecting the local files.

# modules
import os
import re


from channels import *
from config import *


# ID3 libraries
try:
    from mutagen import File as get_meta
except:
    try:
        from ID3 import ID3







<
<

<






>



>







27
28
29
30
31
32
33


34

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# an optional plugin, and not overly well integrated.
#
# Bugs:
# Only loads directories on startup. Doesn't work when post-activated
# per pluginmanager2 for instance. And LANG=C breaks it on startup,
# if media directories contain anything but ASCII filenames.
#


# If your player doesn't play local files try unchecking "Convert file path to 'file:///' style URL". (Might happen on Windows when not using VLC.exe).

#
# After checking/unchecking restart Streamtuner2 for recollecting the local files.

# modules
import os
import re
import sys

from channels import *
from config import *
from compat2and3 import urlquote

# ID3 libraries
try:
    from mutagen import File as get_meta
except:
    try:
        from ID3 import ID3
243
244
245
246
247
248
249
250
251

252
253
254
255
256



257
258
259
260
261
262
263
                self.streams[main] = self.streams[main_base]


    # extract meta data
    def file_entry(self, fn, dir):
        # basic data
        url = ("%s/%s" % (dir, fn))
        url = url.replace("\\", "/")
        if conf.file_browser_converttourl:

            url = url.replace(" ", "%20")
            if url.startswith("/"):
                url = "file://" + url
            else:
                url = "file:///" + url



        meta = {
            "title": "",
            "filename": fn,
            "url": url,
            "genre": "",
            "album": "",
            "artist": "",







|

>
|




>
>
>







242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
                self.streams[main] = self.streams[main_base]


    # extract meta data
    def file_entry(self, fn, dir):
        # basic data
        url = ("%s/%s" % (dir, fn))
        url = url.replace("\\", "/") 
        if conf.file_browser_converttourl:
            url = urlquote(url.encode('utf-8'),":/") # needed also in VLC 2.0.8 on Ubuntu 12.04
            #url = url.replace(" ", "%20") # for better readability on Ubuntu..., but not working with VLC 2.08
            if url.startswith("/"):
                url = "file://" + url
            else:
                url = "file:///" + url
        else:
            if conf.windows:
                url=url.replace("/","\\",1) #1st slash must be backslash for VLC on Windows
        meta = {
            "title": "",
            "filename": fn,
            "url": url,
            "genre": "",
            "album": "",
            "artist": "",
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
        try:
            streaminfo = get_meta(dir + "/" + fn)
            # add streaminfo
            if streaminfo.info: # no streaminfo.info, maybe ID3 available
                try:
                    if not streaminfo.info.bitrate == 0:
                        meta.update({"bitrate": streaminfo.info.bitrate/1000})
                except: #FLAC and M4A do not have bitrate property
                    pass
                if not streaminfo.info.length == 0.0: #FLAC sometimes have it...
                    meta.update({"length": ddhhmmss(int(streaminfo.info.length))})
            # add ID3
            meta.update(mutagen_postprocess(streaminfo) or {})
            
        except: # not supported by Mutagen







|







273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
        try:
            streaminfo = get_meta(dir + "/" + fn)
            # add streaminfo
            if streaminfo.info: # no streaminfo.info, maybe ID3 available
                try:
                    if not streaminfo.info.bitrate == 0:
                        meta.update({"bitrate": streaminfo.info.bitrate/1000})
                except: #FLAC bitrate available in Mutagen 1.36; for M4A not available
                    pass
                if not streaminfo.info.length == 0.0: #FLAC sometimes have it...
                    meta.update({"length": ddhhmmss(int(streaminfo.info.length))})
            # add ID3
            meta.update(mutagen_postprocess(streaminfo) or {})
            
        except: # not supported by Mutagen