ambevar-dotfiles/.config/demlo/scripts/xray.lua

32 lines
869 B
Lua
Raw Normal View History

2014-07-01 09:16:10 +02:00
-- X-Ray Dog
2014-10-31 15:11:37 +01:00
-- WARNING: Untested.
2014-07-01 09:16:10 +02:00
-- Remove all default tags.
2014-10-31 15:11:37 +01:00
tags = {}
2014-07-01 09:16:10 +02:00
2014-10-31 15:11:37 +01:00
tags.artist = 'X-Ray Dog'
2014-07-01 09:16:10 +02:00
-- Albums actually have years, but is it relevent since they have a code?
2014-10-31 15:11:37 +01:00
tags.date = ''
2014-07-01 09:16:10 +02:00
-- Genre could be Soundtrack, or Trailer Music. We choose '' for now.
2014-10-31 15:11:37 +01:00
tags.genre = ''
2014-07-01 09:16:10 +02:00
-- Extract album code, assuming parent folder is 'XRCD## - $album'.
2016-01-11 08:22:25 +01:00
XRCD = output.filename:match('/[^/]*(XRCD\d*)[^/]*/[^/]*$')
2014-07-01 09:16:10 +02:00
-- Append the album code to the constants array, other it will be capitalized.
2014-10-31 15:11:37 +01:00
constants [XRCD:upper()] = XRCD
2014-07-01 09:16:10 +02:00
2016-01-11 08:22:25 +01:00
tags.album = not empty (o.album) and o.album:gsub ('XRCD - (\d+)', 'XRCD$1 - ') or 'Unknown album'
2014-07-01 09:16:10 +02:00
2014-10-31 15:11:37 +01:00
tags.title = o.title
if empty(tags.title) then
2016-01-11 08:22:25 +01:00
tags.title = output.filename:match('[^/]+$'):gsub('\..+$', ''):gsub('X-Ray Dog[\s*?]*', '')
2014-07-01 09:16:10 +02:00
end
2014-10-31 15:11:37 +01:00
tags.track = o.track
if empty(tags.track) then
2016-01-11 08:22:25 +01:00
tags.track = o.title:match('\d+')
2014-07-01 09:16:10 +02:00
end
2014-10-31 15:11:37 +01:00
output.tags = tags