Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mp = require 'mp'
- function decode(title)
- local ret = io.popen(string.format('%s "%s" | %s',
- 'echo', title, 'iconv -f="windows-1251" -t="utf-8"')):read('*all')
- return ret:gsub("^%s*(.-)%s*$", "%1") -- trim the result
- end
- local decode_needed = false
- function on_title_changed(name, title)
- if decode_needed then
- local decoded = decode(title)
- -- print(title, '->', decoded) -- debug, uncomment if needed
- decoded = decoded:gsub("% %- 0:00", "") -- remove the " - 0:00" part
- mp.set_property('force-media-title', decoded)
- end
- end
- mp.observe_property('metadata/icy-title', 'string', on_title_changed)
- mp.add_hook('on_load', 50, function()
- local filename = mp.get_property('path', '')
- decode_needed = string.find(filename, 'ru')
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement