avoid passing nil to string.sub

This commit is contained in:
Artem Tarasov 2024-06-01 09:17:10 +02:00
parent d58ed66d0a
commit cb150775ec
1 changed files with 4 additions and 1 deletions

View File

@ -50,10 +50,13 @@ function playerctl:watch(timeout, callback, widget)
position = position,
length = length,
album = words[7],
year = string.sub(words[8], 0, 4),
progress = progress,
}
if words[8] ~= nil then
metadata.year = string.sub(words[8], 0, 4)
end
callback(widget, metadata)
end