Skip to content

Check only title in track title replacement - #1281

Merged
flyingmutant merged 3 commits into
cmus:masterfrom
mrHeavenli:filename-if-no-title-adjustment
Aug 23, 2023
Merged

flyingmutant merged 3 commits into
cmus:masterfrom
mrHeavenli:filename-if-no-title-adjustment

Conversation

@mrHeavenli

Copy link
Copy Markdown
Contributor

We only need to check if title is null to replace it with the filename in the track info.

@mrHeavenli
mrHeavenli marked this pull request as draft August 18, 2023 09:50
@mrHeavenli
mrHeavenli marked this pull request as ready for review August 18, 2023 09:50
@mrHeavenli

Copy link
Copy Markdown
Contributor Author

@flyingmutant
I see Mr. Gaskin is very busy, can you review this?

@flyingmutant

Copy link
Copy Markdown
Member

Can you please explain why is this change required?

@gavtroy

gavtroy commented Aug 18, 2023

Copy link
Copy Markdown
Collaborator

Normally if a track doesn't have tags then altformat_* are used, which by default either show the full path (%f) or the basename (%F) depending on context. This breaks with your change, and I'm not sure what it attempts to fix in return. If you just want the track window formatting to align you just need to match altformat_trackwin to format_trackwin and match altformat_playlist to format_playlist, except replacing %t with %F.

@mrHeavenli

Copy link
Copy Markdown
Contributor Author

Can you please explain why is this change required?

Sure. When I was doing something with playerctl, tracks that had no title tag just gave nothing. So I looked at the code and found that the title would be filled in with the filename if there was no title tag, but that didn't show in the metadata that playerctl gave me. So I deleted that bit in the PR, and it actually gave me the filename in the metadata. I didn't really understand what the condition was there for, but now @gavtroy is telling me that it breaks something when removed. I guess this could also be done in mpris.c without breaking something?
by adding something in this region:

if (ti->title) {
			char corrected[u_str_print_size(ti->title)];
			u_to_utf8(corrected, ti->title);
			CK(mpris_msg_append_ss_dict(reply,
					"xesam:title", corrected));
		}

@mrHeavenli

Copy link
Copy Markdown
Contributor Author

@gavtroy What do you think of this?

mpris.c

#include "path.h"
...
if (ti->title) {
	char corrected[u_str_print_size(ti->title)];
	u_to_utf8(corrected, ti->title);
	CK(mpris_msg_append_ss_dict(reply,
			"xesam:title", corrected));
}else{
	char corrected[u_str_print_size(path_basename(ti->filename))];
	u_to_utf8(corrected, path_basename(ti->filename));
	CK(mpris_msg_append_ss_dict(reply,
			"xesam:title", corrected));
}

@gavtroy

gavtroy commented Aug 21, 2023

Copy link
Copy Markdown
Collaborator

With spaces around the else tidied up, looks good to me.

@mrHeavenli

Copy link
Copy Markdown
Contributor Author

@flyingmutant now gavtroy approves, can this be put in?

@flyingmutant
flyingmutant merged commit 1849b0a into cmus:master Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants