summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2015-05-10 20:15:06 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2015-05-10 20:15:06 +0200
commit1e6ac8e86fb8e91f4606fb1ae519024d6cb52b12 (patch)
treecb81d3056223f37665f9f52a2c07841be24e2756 /scripts
parentb2720858f841530581e009ae380e39b4267a3d5d (diff)
downloadcontext-1e6ac8e86fb8e91f4606fb1ae519024d6cb52b12.tar.gz
2015-05-10 20:10:00
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/lua/mtx-flac.lua42
1 files changed, 24 insertions, 18 deletions
diff --git a/scripts/context/lua/mtx-flac.lua b/scripts/context/lua/mtx-flac.lua
index 4e01abc99..eb3b48591 100644
--- a/scripts/context/lua/mtx-flac.lua
+++ b/scripts/context/lua/mtx-flac.lua
@@ -107,29 +107,34 @@ function flac.savecollection(pattern,filename)
local music = { }
table.sort(files)
for i=1,#files do
- local data = flac.getmetadata(files[i])
+ local name = files[i]
+ local data = flac.getmetadata(name)
if data then
local tags = data.tags
local info = data.info
- local artist = tags.artist or "no-artist"
- local album = tags.album or "no-album"
- local albums = music[artist]
- if not albums then
- albums = { }
- music[artist] = albums
- end
- local albumx = albums[album]
- if not albumx then
- albumx = {
- year = tags.date,
- tracks = { },
+ if tags and info then
+ local artist = tags.artist or "no-artist"
+ local album = tags.album or "no-album"
+ local albums = music[artist]
+ if not albums then
+ albums = { }
+ music[artist] = albums
+ end
+ local albumx = albums[album]
+ if not albumx then
+ albumx = {
+ year = tags.date,
+ tracks = { },
+ }
+ albums[album] = albumx
+ end
+ albumx.tracks[tonumber(tags.tracknumber) or 0] = {
+ title = tags.title,
+ length = math.round((info.samples_in_stream/info.sample_rate_in_hz)),
}
- albums[album] = albumx
+ else
+ flac.report("unable to read file",name)
end
- albumx.tracks[tonumber(tags.tracknumber) or 0] = {
- title = tags.title,
- length = math.round((info.samples_in_stream/info.sample_rate_in_hz)),
- }
end
end
-- inspect(music)
@@ -153,6 +158,7 @@ function flac.savecollection(pattern,filename)
return ya < yb
end
end)
+ nofalbums = nofalbums + #list
for nofalbums=1,#list do
local album = list[nofalbums]
local data = albums[album]