#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_demux.h>
+#include <vlc_url.h>
+#ifdef WIN32
+# include <ctype.h>
+#endif
#include "playlist.h"
add_bool( "playlist-autostart", true, NULL,
AUTOSTART_TEXT, AUTOSTART_LONGTEXT, false )
- add_integer( "parent-item", 0, NULL, NULL, NULL, true )
- change_internal ()
+ add_obsolete_integer( "parent-item" ) /* removed since 1.1.0 */
add_bool( "playlist-skip-ads", true, NULL,
SKIP_ADS_TEXT, SKIP_ADS_LONGTEXT, false )
set_description( N_("M3U playlist import") )
add_shortcut( "playlist" )
add_shortcut( "m3u" )
+ add_shortcut( "m3u8" )
add_shortcut( "m3u-open" )
set_capability( "demux", 10 )
set_callbacks( Import_M3U, Close_M3U )
}
else
{
- if( asprintf( &psz_path,"%s", p_demux->psz_path ) == -1 )
+ psz_path = strdup( p_demux->psz_path );
+ if( psz_path == NULL )
return NULL;
}
* PB: on some file systems, ':' are valid characters though */
/* Simple cases first */
- if( !psz_mrl || !*psz_mrl ) return NULL;
- if( !psz_prefix || !*psz_prefix ) return strdup( psz_mrl );
+ if( !psz_mrl || !*psz_mrl )
+ return NULL;
+ if( !psz_prefix || !*psz_prefix )
+ goto uri;
/* Check if the line specifies an absolute path */
- if( *psz_mrl == '/' || *psz_mrl == '\\' ) return strdup( psz_mrl );
-
- /* Check if the line specifies an mrl/url
- * (and on win32, contains a drive letter) */
- if( strchr( psz_mrl, ':' ) ) return strdup( psz_mrl );
+ /* FIXME: that's wrong if the playlist is not a local file */
+ if( *psz_mrl == DIR_SEP_CHAR )
+ goto uri;
+#ifdef WIN32
+ /* Drive letter (this assumes URL scheme are not a single character) */
+ if( isalpha(psz_mrl[0]) && psz_mrl[1] == ':' )
+ goto uri;
+#endif
+ if( strstr( psz_mrl, "://" ) )
+ return strdup( psz_mrl );
/* This a relative path, prepend the prefix */
char *ret;
- if( asprintf( &ret, "%s%s", psz_prefix, psz_mrl ) == -1 )
+ char *postfix = encode_URI_component( psz_mrl );
+ /* FIXME: postfix may not be encoded correctly (esp. slashes) */
+ if( postfix == NULL
+ || asprintf( &ret, "%s%s", psz_prefix, postfix ) == -1 )
ret = NULL;
+ free( postfix );
return ret;
+
+uri:
+ return make_URI( psz_mrl );
}