1 /*****************************************************************************
2 * playlist.c : Playlist import module
3 *****************************************************************************
4 * Copyright (C) 2004 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
28 #include <vlc_demux.h>
29 #include <vlc_playlist.h>
33 /*****************************************************************************
35 *****************************************************************************/
36 #define AUTOSTART_TEXT N_( "Auto start" )
37 #define AUTOSTART_LONGTEXT N_( "Automatically start playing the playlist " \
38 "content once it's loaded." )
40 #define SHOW_ADULT_TEXT N_( "Show shoutcast adult content" )
41 #define SHOW_ADULT_LONGTEXT N_( "Show NC17 rated video streams when " \
42 "using shoutcast video playlists." )
44 #define SKIP_ADS_TEXT N_( "Skip ads" )
45 #define SKIP_ADS_LONGTEXT N_( "Use playlist options usually used to prevent " \
46 "ads skipping to detect ads and prevent adding them to the playlist." )
48 #define EXTVLCOPT_TEXT N_( "Enable parsing of EXTVLCOPT: options" )
49 #define EXTVLCOPT_LONGTEXT N_( "Enable parsing of EXTVLCOPT: options in m3u " \
50 "playlists. This option is default disabled to prevent untrusted sources " \
51 "using VLC options without the user's knowledge." )
54 add_shortcut( "playlist" );
55 set_category( CAT_INPUT );
56 set_subcategory( SUBCAT_INPUT_DEMUX );
58 add_bool( "playlist-autostart", 1, NULL,
59 AUTOSTART_TEXT, AUTOSTART_LONGTEXT, VLC_FALSE );
61 add_integer( "parent-item", 0, NULL, NULL, NULL, VLC_TRUE );
64 add_bool( "playlist-skip-ads", 1, NULL,
65 SKIP_ADS_TEXT, SKIP_ADS_LONGTEXT, VLC_FALSE );
67 set_shortname( _("Playlist") );
68 set_description( _("Playlist") );
70 set_description( _("M3U playlist import") );
71 add_shortcut( "m3u-open" );
72 set_capability( "demux2", 10 );
73 add_bool( "m3u-extvlcopt", VLC_FALSE, NULL,
74 EXTVLCOPT_TEXT, EXTVLCOPT_LONGTEXT, VLC_FALSE );
75 set_callbacks( E_(Import_M3U), E_(Close_M3U) );
77 set_description( _("PLS playlist import") );
78 add_shortcut( "pls-open" );
79 set_capability( "demux2", 10 );
80 set_callbacks( E_(Import_PLS), E_(Close_PLS) );
82 set_description( _("B4S playlist import") );
83 add_shortcut( "b4s-open" );
84 add_shortcut( "shout-b4s" );
85 set_capability( "demux2", 10 );
86 set_callbacks( E_(Import_B4S), E_(Close_B4S) );
88 set_description( _("DVB playlist import") );
89 add_shortcut( "dvb-open" );
90 set_capability( "demux2", 10 );
91 set_callbacks( E_(Import_DVB), E_(Close_DVB) );
93 set_description( _("Podcast parser") );
94 add_shortcut( "podcast" );
95 set_capability( "demux2", 10 );
96 set_callbacks( E_(Import_podcast), E_(Close_podcast) );
98 set_description( _("XSPF playlist import") );
99 add_shortcut( "xspf-open" );
100 set_capability( "demux2", 10 );
101 set_callbacks( E_(Import_xspf),E_(Close_xspf) );
103 set_description( _("New winamp 5.2 shoutcast import") );
104 add_shortcut( "shout-winamp" );
105 set_capability( "demux2", 10 );
106 set_callbacks( E_(Import_Shoutcast), E_(Close_Shoutcast) );
107 add_bool( "shoutcast-show-adult", VLC_FALSE, NULL,
108 SHOW_ADULT_TEXT, SHOW_ADULT_LONGTEXT, VLC_FALSE );
110 set_description( _("ASX playlist import") );
111 add_shortcut( "asx-open" );
112 set_capability( "demux2", 10 );
113 set_callbacks( E_(Import_ASX), E_(Close_ASX) );
115 set_description( _("Kasenna MediaBase parser") );
116 add_shortcut( "sgimb" );
117 set_capability( "demux2", 10 );
118 set_callbacks( E_(Import_SGIMB), E_(Close_SGIMB) );
120 set_description( _("QuickTime Media Link importer") );
121 add_shortcut( "qtl" );
122 set_capability( "demux2", 10 );
123 set_callbacks( E_(Import_QTL), E_(Close_QTL) );
125 set_description( _("Google Video Playlist importer") );
126 add_shortcut( "gvp" );
127 set_capability( "demux2", 10 );
128 set_callbacks( E_(Import_GVP), E_(Close_GVP) );
130 set_description( _("Dummy ifo demux") );
131 set_capability( "demux2", 12 );
132 set_callbacks( E_(Import_IFO), E_(Close_IFO) );
134 set_description( _("iTunes Music Library importer") );
135 add_shortcut( "itml" );
136 set_capability( "demux2", 10 );
137 set_callbacks( E_(Import_iTML), E_(Close_iTML) );
142 * Find directory part of the path to the playlist file, in case of
143 * relative paths inside
145 char *E_(FindPrefix)( demux_t *p_demux )
148 char *psz_path = strdup( p_demux->psz_path );
151 psz_name = strrchr( psz_path, '/' );
153 psz_name = strrchr( psz_path, '\\' );
154 if( !psz_name ) psz_name = strrchr( psz_path, '/' );
156 if( psz_name ) psz_name[1] = '\0';
157 else *psz_path = '\0';
163 * Add the directory part of the playlist file to the start of the
164 * mrl, if the mrl is a relative file path
166 char *E_(ProcessMRL)( char *psz_mrl, char *psz_prefix )
168 /* Check for a protocol name.
169 * for URL, we should look for "://"
170 * for MRL (Media Resource Locator) ([[<access>][/<demux>]:][<source>]),
171 * we should look for ":", so we end up looking simply for ":"
172 * PB: on some file systems, ':' are valid characters though */
174 /* Simple cases first */
175 if( !psz_mrl || !*psz_mrl ) return NULL;
176 if( !psz_prefix || !*psz_prefix ) return strdup( psz_mrl );
178 /* Check if the line specifies an absolute path */
179 if( *psz_mrl == '/' || *psz_mrl == '\\' ) return strdup( psz_mrl );
181 /* Check if the line specifies an mrl/url
182 * (and on win32, contains a drive letter) */
183 if( strchr( psz_mrl, ':' ) ) return strdup( psz_mrl );
185 /* This a relative path, prepend the prefix */
186 asprintf( &psz_mrl, "%s%s", psz_prefix, psz_mrl );