Skip to content

Conversation

@guidocella
Copy link
Contributor

@guidocella guidocella commented Oct 7, 2025

demux_playlist: add base paths when adding playlist entries

Currently entries in playlist files like m3u are first added to the playlist, and then if they were relative paths the playlist file's dirname is prepended to them.

Change it to directly add entries with the correct path. This will be needed to normalize playlist entries as soon as they are added, else normalization would prepend the working directory to entries with relative paths.

demux_cue, demux_edl and demux_mkv_timeline don't need to be modified to work with the next commit.

common/playlist: store normalized playlist filenames

This normalizes the playlist/N/filename sub-property, making it consistent with path. As a consequence playlist-path and stream-path are also normalized.

This will allow simplifying the code by not normalizing playlist filenames in several places, similar to 23b57e9 for tracks.

various: don't normalize playlist filenames again

Since the previous commit normalized playlist filenames when they are stored, the code normalizing them can be simplified back to how it was before implement normalization.

Revert "{osc,select}.lua: show playlist entries with trailing /"

This reverts commit ee05804. Only the select.lua part since osc.lua list formatting was removed.

Since playlist/N/filename is now normalized, it is never going to have trailing slashes so there is no need to strip them.

Depends on #16892

@guidocella guidocella force-pushed the normalize-playlist branch 3 times, most recently from fdcea13 to 06e99db Compare October 7, 2025 21:32
@github-actions
Copy link

github-actions bot commented Oct 7, 2025

@kasper93
Copy link
Member

kasper93 commented Oct 7, 2025

Does all directory open modes work? They depend on matching filename between playlists.

@guidocella
Copy link
Contributor Author

I'm not sure if you mean --directory-mode=recursive? That works.

What breaks is m3u files with relative paths in a different directory (while EDL files work). ytdl_hook URLs work. #15165 is the opposite, ytdl_hook URLs break but m3u files work.

- is fixed in both by #16892.

So we need to fix 1 of the 2 to simplify all the code.

@guidocella guidocella marked this pull request as draft October 8, 2025 06:31
@guidocella guidocella marked this pull request as ready for review October 8, 2025 17:19
@guidocella
Copy link
Contributor Author

Fixed playlist files

Currently entries in playlist files like m3u are first added to the
playlist, and then if they were relative paths the playlist file's
dirname is prepended to them.

Change it to directly add entries with the correct path. This will be
needed to normalize playlist entries as soon as they are added, else
normalization would prepend the working directory to entries with
relative paths.

demux_cue, demux_edl and demux_mkv_timeline don't need to be modified to
work with the next commit.
This normalizes the playlist/N/filename sub-property, making it
consistent with path. As a consequence playlist-path and stream-path are
also normalized.

This will allow simplifying the code by not normalizing playlist
filenames in several places, similar to 23b57e9 for tracks.
@kasper93 kasper93 added this to the Release v0.41.0 milestone Oct 10, 2025
Since the previous commit normalized playlist filenames when they are
stored, the code normalizing them can be simplified back to how it was
before implement normalization.
This reverts commit ee05804. Only the
select.lua part since osc.lua list formatting was removed.

Since playlist/N/filename is now normalized, it is never going to have
trailing slashes so there is no need to strip them.
guidocella added a commit to guidocella/mpv that referenced this pull request Nov 7, 2025
When the path is a URL, use the whole path as basename. The dirname will
be "." in this case.

This simplifies various checks throughout the codebase. In particular,
it avoids returning an empty string for URLs ending with /.

The filename property will return full URLs, which is desirable because
the domain and path segments before the last are useful information.
This fixes half of mpv-player#10975. The empty string check in
mp_property_filename() can be removed because it only happened with the
basename of URLs ending with /. mp_property_filename() will not be
called with directories with trailing slashes because mpv expands them
immediately when they are the current playlist entry; I tested it by
observing filename. Also mpv-player#16896 will prevent directories with trailing
slashes anyway.

This also fixes the issue described in mpv-player#17015 of %f in
--screenshot-template being evaluated to an empty string for URLs ending
with /, which can inadvertently make it use an absolute path.

Alternative to mpv-player#16932 and mpv-player#17021.
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.

2 participants