Skip to content

Commit 58d937b

Browse files
committed
loadfile: clip long track titles
When a track title is taken from its filename and is longer than 99 characters, clip it to not make track information too verbose. Fixes #10975 along with #17021.
1 parent 2e5e293 commit 58d937b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

player/loadfile.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,8 +909,13 @@ int mp_add_external_file(struct MPContext *mpctx, char *filename,
909909
bstr title = bstr0(mp_basename(disp_filename));
910910
bstr_eatstart(&title, parent);
911911
bstr_eatstart(&title, bstr0("."));
912-
if (title.len)
912+
if (title.len > 99) {
913+
char *title2 = bstrto0(t, bstr_splice(title, 0, 99));
914+
t->title = talloc_asprintf(t, "%s…", title2);
915+
talloc_free(title2);
916+
} else if (title.len) {
913917
t->title = bstrdup0(t, title);
918+
}
914919
}
915920
t->external_filename = mp_normalize_user_path(t, mpctx->global, filename);
916921
t->no_default = sh->type != filter;

0 commit comments

Comments
 (0)