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

command: add playlist-next-playlist and playlist-prev-playlist #12526

Merged
merged 1 commit into from
Oct 9, 2023

Conversation

guidocella
Copy link
Contributor

playlist-prev-playlist goes to the beginning of the previous playlist because this seems more useful and symmetrical to playlist-next-playlist. It does not go to the beginning when the current playlist-path starts with the previous playlist-path, e.g. with mpv --loop-playlist foo/, which expands to foo/{1..9}.zip, the current playlist path foo/1.zip beings with the playlist-path foo/ of {2..9}.zip and thus playlist-prev-playlist goes to 9.zip rather than to 2.zip.

Closes #12495.

@github-actions
Copy link

github-actions bot commented Oct 1, 2023

Download the artifacts for this pull request:

Windows

common/playlist.h Outdated Show resolved Hide resolved
common/playlist.c Outdated Show resolved Hide resolved
common/playlist.c Outdated Show resolved Hide resolved
@guidocella guidocella force-pushed the playlist-next-playlist branch 3 times, most recently from 0f8fb31 to cc57ca2 Compare October 7, 2023 14:53
playlist-prev-playlist goes to the beginning of the previous playlist
because this seems more useful and symmetrical to
playlist-next-playlist. It does not go to the beginning when the current
playlist-path starts with the previous playlist-path, e.g. with mpv
--loop-playlist foo/, which expands to foo/{1..9}.zip, the current
playlist path foo/1.zip beings with the playlist-path foo/ of {2..9}.zip
and thus playlist-prev-playlist goes to 9.zip rather than to 2.zip.

Closes mpv-player#12495.
@guidocella
Copy link
Contributor Author

Rebased.

@Dudemanguy Dudemanguy merged commit 81dea90 into mpv-player:master Oct 9, 2023
15 checks passed
@guidocella guidocella deleted the playlist-next-playlist branch October 9, 2023 15:50
@debugzxcv
Copy link

mpv crashed after call playlist-prev-playlist

Reproduction steps

  1. mpv https://www.youtube.com/playlist?list=OLAK5uy_mwn8JPCdjhaRVc3PQa3OCm8SAj9z1EB2I
  2. open console enter:
    1. loadfile https://www.youtube.com/playlist?list=OLAK5uy_lJyd9QdMb84CCdEoT4ZnqfZ37Byz-M_kE append
    2. playlist-next-playlist
    3. playlist-prev-playlist

@guidocella
Copy link
Contributor Author

This was fixed months ago.

@debugzxcv
Copy link

Still able to reproduce the issue using https://github.com/zhongfly/mpv-winbuild/releases/tag/2024-02-18-3fd840f with --no-config --script-opts-add=ytdl_hook-try_ytdl_first=yes

@guidocella
Copy link
Contributor Author

I can't reproduce that.

@debugzxcv
Copy link

Looks like it's crashing here:

mpv/common/playlist.c

Lines 262 to 269 in 4a563a6

if (bstr_startswith(bstr0(current_playlist_path),
bstr0(talloc_strdup_append(playlist_path, "/")))
#if HAVE_DOS_PATHS
||
bstr_startswith(bstr0(current_playlist_path),
bstr0(talloc_strdup_append(playlist_path, "\\")))
#endif
)

I don't know how to fix it properly, but this patch works:

diff --git a/common/playlist.c b/common/playlist.c
index 5de8e627..e223a292 100644
--- a/common/playlist.c
+++ b/common/playlist.c
@@ -259,14 +259,14 @@ struct playlist_entry *playlist_get_first_in_same_playlist(
     // work in all cases.
     char* playlist_path = talloc_strdup(tmp, entry->playlist_path);
     mp_path_strip_trailing_separator(playlist_path);
-    if (bstr_startswith(bstr0(current_playlist_path),
+    if (!mp_is_url(bstr0(current_playlist_path)) && (bstr_startswith(bstr0(current_playlist_path),
                         bstr0(talloc_strdup_append(playlist_path, "/")))
 #if HAVE_DOS_PATHS
         ||
         bstr_startswith(bstr0(current_playlist_path),
                         bstr0(talloc_strdup_append(playlist_path, "\\")))
 #endif
-       )
+       ))
         goto exit;
 
     struct playlist_entry *prev = playlist_entry_get_rel(entry, -1);

@guidocella
Copy link
Contributor Author

It still doesn't crash for me and I don't understand why you should skip that check with URLs.

@Dudemanguy
Copy link
Member

I also cannot reproduce. Dunno, check if there's something weird in your config causing this although I don't know what that would be.

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.

Support next-archive or next-nonrecursive playlist controls (and/or next-directory)
3 participants