tomasklaen / uosc

Feature-rich minimalist proximity-based UI for MPV player.
GNU Lesser General Public License v2.1
1.77k stars 68 forks source link

Potential bug with subtitle reload. #976

Closed Sneakpeakcss closed 1 month ago

Sneakpeakcss commented 1 month ago

Reloading subtitles for local files shifts the menu width because a magical comma gets added:

https://github.com/user-attachments/assets/7ed26535-2d30-49df-a10d-8c8c3f329f24

When reloading subtitles from youtube it gets even better:

https://github.com/user-attachments/assets/f43d3a20-c310-45c1-994d-73a22ad13586

tomasklaen commented 1 month ago

I can't replicate the comma issue, but try this:

diff --git a/src/uosc/lib/menus.lua b/src/uosc/lib/menus.lua
index 936c93c..6cfadd7 100644
--- a/src/uosc/lib/menus.lua
+++ b/src/uosc/lib/menus.lua
@@ -236,7 +236,10 @@ function create_select_tracklist_type_menu_opener(opts)
                local hint_values = {}
                local track_selected = track.selected and track.id == track_prop_index
                local snd_selected = snd and track.id == snd_prop_index
-               local function h(value) hint_values[#hint_values + 1] = value end
+               local function h(value)
+                   value = trim(value)
+                   if #value > 0 then hint_values[#hint_values + 1] = value end
+               end

                if track.lang then h(track.lang) end
                if track['demux-h'] then

The second youtube example, I don't think we can do anything about it, we are just displaying the info we get:

title = (track.title and track.title or t('Track %s', track.id))

That's just what mpv reports. You probably need to complain there.

Sneakpeakcss commented 1 month ago

Nice, that fixed it. Here's a sample that i used if you want to check if you can reproduce it:

subtitle-reload.zip