Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>71575729
- Alright I got that, but for whatever reason I can't get set it to display the new title on the osd-bar.
- [code]
- mp.set_property('media-title', decoded)
- [/code]
- does nothing. Maybe someone else can help you out with that part.
- As for the rest, here's the script:
- [code]
- mp = require 'mp'
- local decode_needed = false
- function decode(title)
- local res = io.popen(string.format('%s "%s" | %s',
- 'echo', title, 'iconv -f="windows-1251" -t="utf-8"'))
- return res:read('*all')
- end
- function on_title_changed(name, title)
- if decode_needed then --and not ignore_next_call then
- local decoded = decode(title)
- print(title, '->', decoded)
- mp.osd_message(decoded)
- mp.set_property('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)
- [/code]
- It'll run on every page with "ru" in the name, see
- [code]
- string.find(filename, 'ru')
- [/code]
- Obviously, you should delete the
- [code]
- mp.osd_message(decoded)
- [/code]
- part after you figured why
- [code]
- mp.set_property('media-title', decoded)
- [/code]
- doesn't work.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement