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