Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. >>71575729
  2. Alright I got that, but for whatever reason I can't get set it to display the new title on the osd-bar.
  3. [code]
  4. mp.set_property('media-title', decoded)
  5. [/code]
  6. does nothing. Maybe someone else can help you out with that part.
  7.  
  8. As for the rest, here's the script:
  9. [code]
  10. mp = require 'mp'
  11.  
  12. local decode_needed = false
  13.  
  14. function decode(title)
  15. local res = io.popen(string.format('%s "%s" | %s',
  16. 'echo', title, 'iconv -f="windows-1251" -t="utf-8"'))
  17.  
  18. return res:read('*all')
  19. end
  20.  
  21. function on_title_changed(name, title)
  22. if decode_needed then --and not ignore_next_call then
  23. local decoded = decode(title)
  24. print(title, '->', decoded)
  25. mp.osd_message(decoded)
  26. mp.set_property('media-title', decoded)
  27. end
  28. end
  29.  
  30. mp.observe_property('media-title', 'string', on_title_changed)
  31. mp.add_hook('on_load', 50, function()
  32. local filename = mp.get_property('path', nil)
  33. decode_needed = string.find(filename, 'ru')
  34. end)
  35. [/code]
  36. It'll run on every page with "ru" in the name, see
  37. [code]
  38. string.find(filename, 'ru')
  39. [/code]
  40.  
  41. Obviously, you should delete the
  42. [code]
  43. mp.osd_message(decoded)
  44. [/code]
  45. part after you figured why
  46. [code]
  47. mp.set_property('media-title', decoded)
  48. [/code]
  49. doesn't work.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement