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 *****************************************************************************/
31 #include <vlc_common.h>
32 #include <vlc_plugin.h>
33 #include <vlc_demux.h>
42 /*****************************************************************************
44 *****************************************************************************/
45 #define AUTOSTART_TEXT N_( "Auto start" )
46 #define AUTOSTART_LONGTEXT N_( "Automatically start playing the playlist " \
47 "content once it's loaded." )
49 #define SHOW_ADULT_TEXT N_( "Show shoutcast adult content" )
50 #define SHOW_ADULT_LONGTEXT N_( "Show NC17 rated video streams when " \
51 "using shoutcast video playlists." )
53 #define SKIP_ADS_TEXT N_( "Skip ads" )
54 #define SKIP_ADS_LONGTEXT N_( "Use playlist options usually used to prevent " \
55 "ads skipping to detect ads and prevent adding them to the playlist." )
58 add_shortcut( "playlist" )
59 set_category( CAT_INPUT )
60 set_subcategory( SUBCAT_INPUT_DEMUX )
62 add_bool( "playlist-autostart", true,
63 AUTOSTART_TEXT, AUTOSTART_LONGTEXT, false )
65 add_obsolete_integer( "parent-item" ) /* removed since 1.1.0 */
67 add_bool( "playlist-skip-ads", true,
68 SKIP_ADS_TEXT, SKIP_ADS_LONGTEXT, false )
70 set_shortname( N_("Playlist") )
71 set_description( N_("Playlist") )
73 set_description( N_("M3U playlist import") )
74 add_shortcut( "playlist", "m3u", "m3u8", "m3u-open" )
75 set_capability( "demux", 10 )
76 set_callbacks( Import_M3U, Close_M3U )
78 set_description( N_("RAM playlist import") )
79 add_shortcut( "playlist", "ram-open" )
80 set_capability( "demux", 10 )
81 set_callbacks( Import_RAM, Close_RAM )
83 set_description( N_("PLS playlist import") )
84 add_shortcut( "playlist", "pls-open" )
85 set_capability( "demux", 10 )
86 set_callbacks( Import_PLS, Close_PLS )
88 set_description( N_("B4S playlist import") )
89 add_shortcut( "playlist", "b4s-open", "shout-b4s" )
90 set_capability( "demux", 10 )
91 set_callbacks( Import_B4S, Close_B4S )
93 set_description( N_("DVB playlist import") )
94 add_shortcut( "playlist", "dvb-open" )
95 set_capability( "demux", 10 )
96 set_callbacks( Import_DVB, Close_DVB )
98 set_description( N_("Podcast parser") )
99 add_shortcut( "playlist", "podcast" )
100 set_capability( "demux", 10 )
101 set_callbacks( Import_podcast, Close_podcast )
103 set_description( N_("XSPF playlist import") )
104 add_shortcut( "playlist", "xspf-open" )
105 set_capability( "demux", 10 )
106 set_callbacks( Import_xspf, Close_xspf )
108 set_description( N_("New winamp 5.2 shoutcast import") )
109 add_shortcut( "playlist", "shout-winamp" )
110 set_capability( "demux", 10 )
111 set_callbacks( Import_Shoutcast, Close_Shoutcast )
112 add_bool( "shoutcast-show-adult", false,
113 SHOW_ADULT_TEXT, SHOW_ADULT_LONGTEXT, false )
115 set_description( N_("ASX playlist import") )
116 add_shortcut( "playlist", "asx-open" )
117 set_capability( "demux", 10 )
118 set_callbacks( Import_ASX, Close_ASX )
120 set_description( N_("Kasenna MediaBase parser") )
121 add_shortcut( "playlist", "sgimb" )
122 set_capability( "demux", 10 )
123 set_callbacks( Import_SGIMB, Close_SGIMB )
125 set_description( N_("QuickTime Media Link importer") )
126 add_shortcut( "playlist", "qtl" )
127 set_capability( "demux", 10 )
128 set_callbacks( Import_QTL, Close_QTL )
130 set_description( N_("Google Video Playlist importer") )
131 add_shortcut( "playlist", "gvp" )
132 set_capability( "demux", 10 )
133 set_callbacks( Import_GVP, Close_GVP )
135 set_description( N_("Dummy ifo demux") )
136 add_shortcut( "playlist" )
137 set_capability( "demux", 12 )
138 set_callbacks( Import_IFO, Close_IFO )
140 set_description( N_("iTunes Music Library importer") )
141 add_shortcut( "playlist", "itml" )
142 set_capability( "demux", 10 )
143 set_callbacks( Import_iTML, Close_iTML )
145 set_description( N_("WPL playlist import") )
146 add_shortcut( "playlist", "wpl" )
147 set_capability( "demux", 10 )
148 set_callbacks( Import_WPL, Close_WPL )
150 set_description( N_("ZPL playlist import") )
151 add_shortcut( "playlist", "zpl" )
152 set_capability( "demux", 10 )
153 set_callbacks( Import_ZPL, Close_ZPL )
156 input_item_t * GetCurrentItem(demux_t *p_demux)
158 input_thread_t *p_input_thread = demux_GetParentInput( p_demux );
159 input_item_t *p_current_input = input_GetItem( p_input_thread );
160 vlc_gc_incref(p_current_input);
161 vlc_object_release(p_input_thread);
162 return p_current_input;
166 * Find directory part of the path to the playlist file, in case of
167 * relative paths inside
169 char *FindPrefix( demux_t *p_demux )
173 if( asprintf( &psz_url, "%s://%s", p_demux->psz_access,
174 p_demux->psz_location ) == -1 )
177 char *psz_file = strrchr( psz_url, '/' );
178 assert( psz_file != NULL );
185 * Add the directory part of the playlist file to the start of the
186 * mrl, if the mrl is a relative file path
188 char *ProcessMRL( const char *psz_mrl, const char *psz_prefix )
190 /* Check for a protocol name.
191 * for URL, we should look for "://"
192 * for MRL (Media Resource Locator) ([[<access>][/<demux>]:][<source>]),
193 * we should look for ":", so we end up looking simply for ":"
194 * PB: on some file systems, ':' are valid characters though */
196 /* Simple cases first */
197 if( !psz_mrl || !*psz_mrl )
199 if( !psz_prefix || !*psz_prefix )
202 /* Check if the line specifies an absolute path */
203 /* FIXME: that's wrong if the playlist is not a local file */
204 if( *psz_mrl == DIR_SEP_CHAR )
207 /* Drive letter (this assumes URL scheme are not a single character) */
208 if( isalpha(psz_mrl[0]) && psz_mrl[1] == ':' )
211 if( strstr( psz_mrl, "://" ) )
212 return strdup( psz_mrl );
214 /* This a relative path, prepend the prefix */
216 char *postfix = encode_URI_component( psz_mrl );
217 /* FIXME: postfix may not be encoded correctly (esp. slashes) */
219 || asprintf( &ret, "%s%s", psz_prefix, postfix ) == -1 )
225 return make_URI( psz_mrl, NULL );