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>
37 /*****************************************************************************
39 *****************************************************************************/
40 #define AUTOSTART_TEXT N_( "Auto start" )
41 #define AUTOSTART_LONGTEXT N_( "Automatically start playing the playlist " \
42 "content once it's loaded." )
44 #define SHOW_ADULT_TEXT N_( "Show shoutcast adult content" )
45 #define SHOW_ADULT_LONGTEXT N_( "Show NC17 rated video streams when " \
46 "using shoutcast video playlists." )
48 #define SKIP_ADS_TEXT N_( "Skip ads" )
49 #define SKIP_ADS_LONGTEXT N_( "Use playlist options usually used to prevent " \
50 "ads skipping to detect ads and prevent adding them to the playlist." )
53 add_shortcut( "playlist" )
54 set_category( CAT_INPUT )
55 set_subcategory( SUBCAT_INPUT_DEMUX )
57 add_bool( "playlist-autostart", true, NULL,
58 AUTOSTART_TEXT, AUTOSTART_LONGTEXT, false )
60 add_integer( "parent-item", 0, NULL, NULL, NULL, true )
63 add_bool( "playlist-skip-ads", true, NULL,
64 SKIP_ADS_TEXT, SKIP_ADS_LONGTEXT, false )
66 set_shortname( N_("Playlist") )
67 set_description( N_("Playlist") )
69 set_description( N_("M3U playlist import") )
70 add_shortcut( "playlist" )
72 add_shortcut( "m3u8" )
73 add_shortcut( "m3u-open" )
74 set_capability( "demux", 10 )
75 set_callbacks( Import_M3U, Close_M3U )
77 set_description( N_("RAM playlist import") )
78 add_shortcut( "playlist" )
79 add_shortcut( "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" )
85 add_shortcut( "pls-open" )
86 set_capability( "demux", 10 )
87 set_callbacks( Import_PLS, Close_PLS )
89 set_description( N_("B4S playlist import") )
90 add_shortcut( "playlist" )
91 add_shortcut( "b4s-open" )
92 add_shortcut( "shout-b4s" )
93 set_capability( "demux", 10 )
94 set_callbacks( Import_B4S, Close_B4S )
96 set_description( N_("DVB playlist import") )
97 add_shortcut( "playlist" )
98 add_shortcut( "dvb-open" )
99 set_capability( "demux", 10 )
100 set_callbacks( Import_DVB, Close_DVB )
102 set_description( N_("Podcast parser") )
103 add_shortcut( "playlist" )
104 add_shortcut( "podcast" )
105 set_capability( "demux", 10 )
106 set_callbacks( Import_podcast, Close_podcast )
108 set_description( N_("XSPF playlist import") )
109 add_shortcut( "playlist" )
110 add_shortcut( "xspf-open" )
111 set_capability( "demux", 10 )
112 set_callbacks( Import_xspf, Close_xspf )
114 set_description( N_("New winamp 5.2 shoutcast import") )
115 add_shortcut( "playlist" )
116 add_shortcut( "shout-winamp" )
117 set_capability( "demux", 10 )
118 set_callbacks( Import_Shoutcast, Close_Shoutcast )
119 add_bool( "shoutcast-show-adult", false, NULL,
120 SHOW_ADULT_TEXT, SHOW_ADULT_LONGTEXT, false )
122 set_description( N_("ASX playlist import") )
123 add_shortcut( "playlist" )
124 add_shortcut( "asx-open" )
125 set_capability( "demux", 10 )
126 set_callbacks( Import_ASX, Close_ASX )
128 set_description( N_("Kasenna MediaBase parser") )
129 add_shortcut( "playlist" )
130 add_shortcut( "sgimb" )
131 set_capability( "demux", 10 )
132 set_callbacks( Import_SGIMB, Close_SGIMB )
134 set_description( N_("QuickTime Media Link importer") )
135 add_shortcut( "playlist" )
136 add_shortcut( "qtl" )
137 set_capability( "demux", 10 )
138 set_callbacks( Import_QTL, Close_QTL )
140 set_description( N_("Google Video Playlist importer") )
141 add_shortcut( "playlist" )
142 add_shortcut( "gvp" )
143 set_capability( "demux", 10 )
144 set_callbacks( Import_GVP, Close_GVP )
146 set_description( N_("Dummy ifo demux") )
147 add_shortcut( "playlist" )
148 set_capability( "demux", 12 )
149 set_callbacks( Import_IFO, Close_IFO )
151 set_description( N_("iTunes Music Library importer") )
152 add_shortcut( "playlist" )
153 add_shortcut( "itml" )
154 set_capability( "demux", 10 )
155 set_callbacks( Import_iTML, Close_iTML )
157 set_description( N_("WPL playlist import") )
158 add_shortcut( "playlist" )
159 add_shortcut( "wpl" )
160 set_capability( "demux", 10 )
161 set_callbacks( Import_WPL, Close_WPL )
163 set_description( N_("ZPL playlist import") )
164 add_shortcut( "playlist" )
165 add_shortcut( "zpl" )
166 set_capability( "demux", 10 )
167 set_callbacks( Import_ZPL, Close_ZPL )
170 input_item_t * GetCurrentItem(demux_t *p_demux)
172 input_thread_t *p_input_thread = demux_GetParentInput( p_demux );
173 input_item_t *p_current_input = input_GetItem( p_input_thread );
174 vlc_gc_incref(p_current_input);
175 vlc_object_release(p_input_thread);
176 return p_current_input;
180 * Find directory part of the path to the playlist file, in case of
181 * relative paths inside
183 char *FindPrefix( demux_t *p_demux )
188 if( p_demux->psz_access )
190 if( asprintf( &psz_path,"%s://%s", p_demux->psz_access, p_demux->psz_path ) == -1 )
195 psz_path = strdup( p_demux->psz_path );
196 if( psz_path == NULL )
201 psz_file = strrchr( psz_path, '\\' );
204 psz_file = strrchr( psz_path, '/' );
207 psz_prefix = strndup( psz_path, psz_file - psz_path + 1 );
209 psz_prefix = strdup( "" );
216 * Add the directory part of the playlist file to the start of the
217 * mrl, if the mrl is a relative file path
219 char *ProcessMRL( const char *psz_mrl, const char *psz_prefix )
221 /* Check for a protocol name.
222 * for URL, we should look for "://"
223 * for MRL (Media Resource Locator) ([[<access>][/<demux>]:][<source>]),
224 * we should look for ":", so we end up looking simply for ":"
225 * PB: on some file systems, ':' are valid characters though */
227 /* Simple cases first */
228 if( !psz_mrl || !*psz_mrl ) return NULL;
229 if( !psz_prefix || !*psz_prefix ) return strdup( psz_mrl );
231 /* Check if the line specifies an absolute path */
232 if( *psz_mrl == '/' || *psz_mrl == '\\' ) return strdup( psz_mrl );
234 /* Check if the line specifies an mrl/url
235 * (and on win32, contains a drive letter) */
236 if( strchr( psz_mrl, ':' ) ) return strdup( psz_mrl );
238 /* This a relative path, prepend the prefix */
240 if( asprintf( &ret, "%s%s", psz_prefix, psz_mrl ) == -1 )