TheAMM/mpv_script_libs

text_measurer.lua "Failed to parse character widths! " error in a script

trappedinspacetime opened this issue · 1 comments

First of all, thank you for providing these useful libraries.
I used to use mpv-youtube-search script on Ubuntu 16.04 successfully last year.
I installed Ubuntu 20.04 recently. I built mpv and added that script again but I get a crash this time. The script hasn't had any update since then.

      [  11.467][w][youtube_search] stack traceback:
      [  11.467][w][youtube_search] 	[string "/home/kenn/.config/mpv/scripts/youtube-sear..."]:872: in function 'parse_characters'
      [  11.467][w][youtube_search] 	[string "/home/kenn/.config/mpv/scripts/youtube-sear..."]:893: in function 'create_character_map'
      [  11.467][w][youtube_search] 	[string "/home/kenn/.config/mpv/scripts/youtube-sear..."]:910: in function 'calculate_width'
      [  11.467][w][youtube_search] 	[string "/home/kenn/.config/mpv/scripts/youtube-sear..."]:1386: in function 'get_ass'
      [  11.467][w][youtube_search] 	[string "/home/kenn/.config/mpv/scripts/youtube-sear..."]:1679: in function 'handler'
      [  11.467][w][youtube_search] 	mp.defaults:500: in function 'call_event_handlers'
      [  11.468][w][youtube_search] 	mp.defaults:534: in function 'dispatch_events'
      [  11.468][w][youtube_search] 	mp.defaults:493: in function <mp.defaults:492>
      [  11.468][w][youtube_search] 	[C]: in ?
      [  11.468][w][youtube_search] 	[C]: in ?
      [  11.468][f][youtube_search] Lua error: [string "/home/kenn/.config/mpv/scripts/youtube-sear..."]:872: attempt to perform arithmetic on field '?' (a nil value)

If I flip "no" to "yes" in this line, it provides more info:

      [youtube_search] Failed to parse character widths! 
      [youtube_search] 
      [youtube_search] stack traceback:
      [youtube_search] 	[string "/home/kenn/.config/mpv/scripts/youtube-sear..."]:911: in function 'calculate_width'
      [youtube_search] 	[string "/home/kenn/.config/mpv/scripts/youtube-sear..."]:1386: in function 'get_ass'
      [youtube_search] 	[string "/home/kenn/.config/mpv/scripts/youtube-sear..."]:1679: in function 'handler'
      [youtube_search] 	mp.defaults:500: in function 'call_event_handlers'
      [youtube_search] 	mp.defaults:534: in function 'dispatch_events'
      [youtube_search] 	mp.defaults:493: in function <mp.defaults:492>
      [youtube_search] 	[C]: in ?
      [youtube_search] 	[C]: in ?
      [youtube_search] Lua error: [string "/home/kenn/.config/mpv/scripts/youtube-sear..."]:911: attempt to index local 'width_map' (a nil value)

I think changes in mpv broke these functions.
I need help with it.

what caused that error was the changes in mpv-gallery-view.
So, using earlier commit of it fixes the error.