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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284 | 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": "",
"length": "n/a",
"bitrate": 0,
"format": mime_fmt(self.fnext(fn)),
"editable": False,
}
# add ID3 tag infos
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 |
|
>
|
>
>
>
|
| 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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287 | 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": "",
"length": "n/a",
"bitrate": 0,
"format": mime_fmt(self.fnext(fn)),
"editable": False,
}
# add ID3 tag infos
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 |