Skip to content

Conversation

@guidocella
Copy link
Contributor

When a track information is longer than the terminal width, clip it and add ellipsis. Useful for long URLs.

Fixes #10975 along with #17021.

@guidocella
Copy link
Contributor Author

Note that track metadata comes after URLs so that will get clipped too. Not sure if that is worth it or the issue should be a wontfix. ${term-clip-cc} will not work for clipping only the URL indipendently of the rest of the line.

@llyyr
Copy link
Contributor

llyyr commented Nov 14, 2025

I haven't read the previous PRs closely, but wouldn't it be better if we stripped the parameters from URL filenames? The current behavior for an URL like https://example.com/some/path/image.jpg?some=param&other=param is that we use filename image.jpg?some=param&other=param for %F

edit: disregard this, it fails if the url is instead https://example.com/?file=some_anime_girl.png

@guidocella guidocella changed the title loadfile: clip long track lines loadfile: clip long track titles Nov 14, 2025
@guidocella
Copy link
Contributor Author

Actually I don't think track lines necessarily have to fit exactly on 1 line. Changed it to just clip track titles longer than 99 characters.

@guidocella guidocella force-pushed the track-clip branch 2 times, most recently from 8447aae to 449715b Compare November 14, 2025 16:13
@mrfragger
Copy link

I just checked...I have many tracks that are close to 200 characters or more...I think many OS's do a fine job of limiting it to 255 or so. I just have a tooltip to show entire track name in uosc. Useful when fuzzy searching for particular terms otherwise user wouldn't be able to see certain matches. Does this patch just clip tracks for the built-in mpv playlist..if so no big deal.

@guidocella
Copy link
Contributor Author

No, the track title itself is clipped. Which is also useful to not hide metadata in the track menu.

@guidocella
Copy link
Contributor Author

Are you confusing tracks and playlist items? External track titles are usually just something like "en.srt".

@mrfragger
Copy link

yea it I was thinking audio tracks as in chapters in audio.....sub tracks... ok. Still not quite sure if I can limit them to 99 but will try but think there definitely are cases where they exceeed. Just don't want it to affect autoloading subs. Also I have usoc to display 3 or 4 lines or whatever it takes to show all files in a playlist in this case only OS affects length of filenames, subs.

@guidocella
Copy link
Contributor Author

This has no relation to the playlist.

if (title.len)

const unsigned char *cut_pos = NULL;
term_disp_width(title, 90, &cut_pos);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should users only see 90 characters on a 4k window with small font size? #17034 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because external track URLs are not as important as the main filename or media-title. Long track URLs are usually garbage like the example in #10975, and actually hide the metadata information in the right column of the track menu, which is actually worth seeing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because external track URLs are not as important as the main filename or media-title.

External filenames can end with useful metadata like S01E01.(DiRECTOR.CUT.ENGLiSH).srt. And because in this PR the truncating is applied to the title property rather than for display only, a script that searches through track titles containing certain text will no longer match them.

and actually hide the metadata information in the right column of the track menu, which is actually worth seeing.

There is only an issue because the terminal display decides to place title before metadata. The order can be changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S01E01.(DiRECTOR.CUT.ENGLiSH).srt gets shortened to (DiRECTOR.CUT.ENGLiSH).srt which is just 26 characters, nowhere near 90 which is when this would start causing issues. But we can also clip URLs only.

I was talking about the select.lua menu, lines are wrapped in terminal output so it doesn't have this issue.

@kasper93
Copy link
Member

Isn't this terminal emulator job to display long lines correctly? I don't like the idea of arbitrary shortening output here.

@kasper93 kasper93 added the priority:on-ice may be revisited later label Jan 21, 2026
@guidocella
Copy link
Contributor Author

Well the idea is to keep it simple by clipping title URLs (which won't have important information after 90 characters) in one place and make it work for terminal output, show-text and select.lua at once. If you don't like it all of those have to be modified and UTF-8 aware functions have to be implemented in select.lua.

@kasper93
Copy link
Member

which won't have important information after 90 characters

well, hardcoded 90 is both arbitrary and bad design. Maybe it covers most of the cases, but probably should be an option at least...

@guidocella
Copy link
Contributor Author

Implemented --osd-max-track-title-url-length though the name is awkwardly long. The osd prefix is also dubious since it also affects the terminal, but this is already the case for --osd-duration and --osd-playlist-entry.

@kasper93
Copy link
Member

I think --osd-track-title-url-max-length sound better, still not shorter though.

@guidocella guidocella force-pushed the track-clip branch 2 times, most recently from d8a543a to c64df44 Compare January 21, 2026 13:45
When a track title is a URL longer than 90 characters, truncate it to
not make track information too verbose.

This uses term_disp_width() which is convenient even for ASS output
because it avoids cutting in the middle of UTF-8 characters. So wide
unicode characters will count as 2 characters.

Long track URLs like reported in mpv-player#10975 no longer flood the terminal
with useless information.

Long track URLs also no longer push track metadata beyond the track
menu, without having to implement UTF-8 aware functions in select.lua to
avoid cutting titles in the middle of UTF-8 characters.

The full URLs are always available in track-list/N/external-filename.

--osd-track-url-title-max-length configures this behavior.
@guidocella
Copy link
Contributor Author

Renamed to --osd-track-url-title-max-length

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:on-ice may be revisited later

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Display long URLs in a user-friendly and informative way

5 participants