summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2023-08-10 23:27:28 -0500
committerDudemanguy <random342@airmail.cc>2023-08-13 19:58:20 +0000
commite8a77e5279c2682a1554ba8fd47b99c6bf6f4d52 (patch)
tree43931c6983b6a8614bc2f147b5595b15b10b7a2f /common
parenta177fb6188e735da3536109105ec55a51b3b863c (diff)
downloadmpv-e8a77e5279c2682a1554ba8fd47b99c6bf6f4d52.tar.bz2
mpv-e8a77e5279c2682a1554ba8fd47b99c6bf6f4d52.tar.xz
player: add playlist-path properties
A bit of a long standing pain with scripting is that when opening a file that gets interpreted as a playlist (like an m3u), the original path of the file gets thrown away later. Workarounds basically consist of getting the filename before mpv expands the path, but that's not really reliable. Instead of throwing it away, save the original playlist path by copying to the playlist entries when applicable (demuxer playlist and the playlist option). Then expose these as properties: playlist-path for the currently playing entry and playlist/N/playlist-path for each specific entry. Closes #8508, #7605.
Diffstat (limited to 'common')
-rw-r--r--common/playlist.c8
-rw-r--r--common/playlist.h2
2 files changed, 10 insertions, 0 deletions
diff --git a/common/playlist.c b/common/playlist.c
index ad5253bdd5..1ba8a58f32 100644
--- a/common/playlist.c
+++ b/common/playlist.c
@@ -142,6 +142,14 @@ void playlist_add_file(struct playlist *pl, const char *filename)
playlist_add(pl, playlist_entry_new(filename));
}
+void playlist_populate_playlist_path(struct playlist *pl, const char *path)
+{
+ for (int n = 0; n < pl->num_entries; n++) {
+ struct playlist_entry *e = pl->entries[n];
+ e->playlist_path = talloc_strdup(e, path);
+ }
+}
+
void playlist_shuffle(struct playlist *pl)
{
for (int n = 0; n < pl->num_entries; n++)
diff --git a/common/playlist.h b/common/playlist.h
index 5f84e3b413..64d1cd45f0 100644
--- a/common/playlist.h
+++ b/common/playlist.h
@@ -33,6 +33,7 @@ struct playlist_entry {
uint64_t id;
char *filename;
+ char *playlist_path;
struct playlist_param *params;
int num_params;
@@ -93,6 +94,7 @@ void playlist_move(struct playlist *pl, struct playlist_entry *entry,
struct playlist_entry *at);
void playlist_add_file(struct playlist *pl, const char *filename);
+void playlist_populate_playlist_path(struct playlist *pl, const char *path);
void playlist_shuffle(struct playlist *pl);
void playlist_unshuffle(struct playlist *pl);
struct playlist_entry *playlist_get_first(struct playlist *pl);