Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

player: set playlist title to media title if not set already #10453

Merged
merged 1 commit into from
Feb 26, 2023

Conversation

christoph-heinrich
Copy link
Contributor

@christoph-heinrich christoph-heinrich commented Jul 26, 2022

The title in the playlist should get set when we get a title and the playlist title isn't set already.

#8548 has essentially the same goal, but this has the advantage that

  1. It actually works (maybe the handling of media-title has changed since that was implemented)
  2. The title gets stored in the playlist item instead of only showing the media-title as the playlist-item title when the playlist property gets accessed, so printing the playlist will show the title too.
  3. The media-title does not shadow the playlist-item title if it actually has one set.
  4. Any playlist item that has been opened will have a title if it didn't already have one from the playlist file, not only the current one

Somewhat closes #4780, but still only shows titles for files/urls that have been opened before. I don't think we should make a bunch of requests just to get the titles.

@christoph-heinrich christoph-heinrich changed the title [RFC] player: set playlist title to media title if not set already player: set playlist title to media title if not set already Feb 21, 2023
The playlist title only got set when it was specified in the
playlist file.
If there is a title after opening a file, that should also be reflected
in the playlist.

ref. mpv-player#4780
@Dudemanguy
Copy link
Member

Seems pretty good. The only nit I can find is that the ytdl_hook will sometimes override the media title anyways (which it does on master as well). I think that's just the logic in the script though and not anything to do with this. Dunno if you want to tackle that or not (in a separate commit). But otherwise LGTM.

@christoph-heinrich
Copy link
Contributor Author

I don't see a problem with ytdl_hook setting force-media-title. This works fine with it in my testing.

@Dudemanguy
Copy link
Member

If I set --force-media-title via cli or something, I would expect the ytdl_hook to not override it and respect what I set. It at least happens to me in some cases (for example, mpv --force-media-title="test-title" someurl). That has absolutely nothing to do with this PR though; it's just logic in the script.

christoph-heinrich added a commit to christoph-heinrich/mpv that referenced this pull request Feb 26, 2023
ytdl_hook always set force-media-title, making users unable to force
a media-title via options.

Now the title gets set as tag when possible, and multi-arc videos check
if force-media-title is already set to avoid overwriting it.

ref.
mpv-player#10453 (comment)
christoph-heinrich added a commit to christoph-heinrich/mpv that referenced this pull request Feb 26, 2023
ytdl_hook always set force-media-title, making users unable to force
a media-title via options.

To prevent that, check if force-media-title is already set to avoid
overwriting it.

ref.
mpv-player#10453 (comment)
@Dudemanguy Dudemanguy merged commit 048d4d8 into mpv-player:master Feb 26, 2023
christoph-heinrich added a commit to christoph-heinrich/mpv that referenced this pull request Feb 26, 2023
ytdl_hook always set force-media-title, making users unable to force
a media-title via options.

To prevent that, check if force-media-title is already set to avoid
overwriting it.

A better solution would be to use tags like is already done for some
metadata, however that doesn't work when `all_formats=yes` is used.
See cbb8f53
A comment was added to hint at why it isn't done via tags.

ref.
mpv-player#10453 (comment)
Dudemanguy pushed a commit that referenced this pull request Feb 27, 2023
ytdl_hook always set force-media-title, making users unable to force
a media-title via options.

To prevent that, check if force-media-title is already set to avoid
overwriting it.

A better solution would be to use tags like is already done for some
metadata, however that doesn't work when `all_formats=yes` is used.
See cbb8f53
A comment was added to hint at why it isn't done via tags.

ref.
#10453 (comment)
if (!name || !name[0]){
name = pe->title;
} else if (!pe->title) {
pe->title = talloc_strdup(pe, name);
Copy link
Member

Choose a reason for hiding this comment

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

This is the property handler for media-title.

  1. why does this modify a playlist entry?
  2. how does this work if nobody touches media-title?

Copy link
Contributor Author

@christoph-heinrich christoph-heinrich Feb 27, 2023

Choose a reason for hiding this comment

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

The way I understood it is that this handler runs every time the media-title might change because of

E(MP_EVENT_METADATA_UPDATE, "metadata", "filtered-metadata", "media-title"),
media-title is filename if there is no other title available, and setting the playlist title to filename doesn't really make sense. The simplest way of setting it only when media-title is something other then the filename is in the media-title handler itself.

Copy link
Member

@Dudemanguy Dudemanguy Feb 27, 2023

Choose a reason for hiding this comment

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

If we want to set the playlist title to the media title in certain cases, it needs to be done in the media-title property handler not the playlist one since it would need to update itself anytime the media-title changes.

Copy link
Member

Choose a reason for hiding this comment

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

The way I understood it is that this handler runs every time the media-title might change

No, it runs everytime one of the mp_property_actions happens on the property, such as getting, setting, incrementing it.

The code that causes MP_EVENT_METADATA_UPDATE to happen would be in player/loadfile.c

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, I thought it was fine because the handler usually gets a ton of calls, but handler never gets called when running mpv --no-config --no-terminal --no-osc --title=foo <some file>.

Any suggestions on a better way of implementing that?

Copy link
Member

Choose a reason for hiding this comment

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

Not sure, maybe in update_demuxer_properties or some other place that deals with playlist changes.

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.

youtube titles in playlist (osd)
3 participants