summaryrefslogtreecommitdiffstats
path: root/playlist.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-08-07 03:07:13 +0200
committerwm4 <wm4@nowhere>2012-08-07 03:14:53 +0200
commit796599bcc21e0447eedb9770561ea8da08fe8595 (patch)
treef3ca1f290ddbd39344b247b9bfff81f58ace0a4f /playlist.c
parentb27bc9e3c9adca3fad0f35a6f6f0480b69e013f7 (diff)
downloadmpv-796599bcc21e0447eedb9770561ea8da08fe8595.tar.bz2
mpv-796599bcc21e0447eedb9770561ea8da08fe8595.tar.xz
playlist: do not add playlist base path to URLs
The entries of a playlist file usually refer either to local files (in the same directory as the playlist), or absolute paths like URLs. In the first case, you want to add the base path of the playlist file to the files, so that mplayer can find the files. In the second case, the URLs should not be changed. Unfortunately, mp_path_join() recognizes URLs as relative paths, and changes them. E.g. it tried to play /path/to/playlist/http://entry. Add some code to deal with this properly. The added code uses the same approach as m_option_type_custom_url in m_option.c, but because it's so short and trivial, it's perhaps better not to rely on the option parser code. It's also unclear whether mp_path_join() should contain this logic, but maybe it's better to keep the logic of that function clean.
Diffstat (limited to 'playlist.c')
-rw-r--r--playlist.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/playlist.c b/playlist.c
index 27877cb8b3..55a0e5cf4a 100644
--- a/playlist.c
+++ b/playlist.c
@@ -162,14 +162,21 @@ struct playlist_entry *playlist_get_next(struct playlist *pl, int direction)
return pl->current_was_replaced ? pl->current : pl->current->next;
}
+static bool might_be_an_url(bstr f)
+{
+ return bstr_find0(f, "://") >= 0;
+}
+
void playlist_add_base_path(struct playlist *pl, bstr base_path)
{
if (base_path.len == 0 || bstrcmp0(base_path, ".") == 0)
return;
for (struct playlist_entry *e = pl->first; e; e = e->next) {
- char *new_file = mp_path_join(e, base_path, bstr0(e->filename));
- talloc_free(e->filename);
- e->filename = new_file;
+ if (!might_be_an_url(bstr0(e->filename))) {
+ char *new_file = mp_path_join(e, base_path, bstr0(e->filename));
+ talloc_free(e->filename);
+ e->filename = new_file;
+ }
}
}