]> git.sesse.net Git - vlc/blob - modules/demux/playlist/playlist.c
demux/playlist/: New "video portals" playlist demux. You feed it a url from a popular...
[vlc] / modules / demux / playlist / playlist.c
1 /*****************************************************************************
2  * playlist.c :  Playlist import module
3  *****************************************************************************
4  * Copyright (C) 2004 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include <vlc/vlc.h>
28 #include <vlc_demux.h>
29 #include <vlc_playlist.h>
30
31 #include "playlist.h"
32
33 /*****************************************************************************
34  * Module descriptor
35  *****************************************************************************/
36 #define AUTOSTART_TEXT N_( "Auto start" )
37 #define AUTOSTART_LONGTEXT N_( "Automatically start playing the playlist " \
38                 "content once it's loaded." )
39
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." )
43
44 vlc_module_begin();
45     add_shortcut( "playlist" );
46     set_category( CAT_INPUT );
47     set_subcategory( SUBCAT_INPUT_DEMUX );
48
49     add_bool( "playlist-autostart", 1, NULL,
50               AUTOSTART_TEXT, AUTOSTART_LONGTEXT, VLC_FALSE );
51
52     add_integer( "parent-item", 0, NULL, NULL, NULL, VLC_TRUE );
53         change_internal();
54
55     set_shortname( _("Playlist") );
56     set_description( _("Playlist") );
57     add_submodule();
58         set_description( _("M3U playlist import") );
59         add_shortcut( "m3u-open" );
60         set_capability( "demux2", 10 );
61         set_callbacks( E_(Import_M3U), E_(Close_M3U) );
62     add_submodule();
63         set_description( _("PLS playlist import") );
64         add_shortcut( "pls-open" );
65         set_capability( "demux2", 10 );
66         set_callbacks( E_(Import_PLS), E_(Close_PLS) );
67     add_submodule();
68         set_description( _("B4S playlist import") );
69         add_shortcut( "b4s-open" );
70         add_shortcut( "shout-b4s" );
71         set_capability( "demux2", 10 );
72         set_callbacks( E_(Import_B4S), E_(Close_B4S) );
73     add_submodule();
74         set_description( _("DVB playlist import") );
75         add_shortcut( "dvb-open" );
76         set_capability( "demux2", 10 );
77         set_callbacks( E_(Import_DVB), E_(Close_DVB) );
78     add_submodule();
79         set_description( _("Podcast parser") );
80         add_shortcut( "podcast" );
81         set_capability( "demux2", 10 );
82         set_callbacks( E_(Import_podcast), E_(Close_podcast) );
83     add_submodule();
84         set_description( _("XSPF playlist import") );
85         add_shortcut( "xspf-open" );
86         set_capability( "demux2", 10 );
87         set_callbacks( E_(Import_xspf),E_(Close_xspf) );
88     add_submodule();
89         set_description( _("New winamp 5.2 shoutcast import") );
90         add_shortcut( "shout-winamp" );
91         set_capability( "demux2", 10 );
92         set_callbacks( E_(Import_Shoutcast), E_(Close_Shoutcast) );
93         add_bool( "shoutcast-show-adult", VLC_FALSE, NULL,
94                    SHOW_ADULT_TEXT, SHOW_ADULT_LONGTEXT, VLC_FALSE );
95     add_submodule();
96         set_description( _("ASX playlist import") );
97         add_shortcut( "asx-open" );
98         set_capability( "demux2", 10 );
99         set_callbacks( E_(Import_ASX), E_(Close_ASX) );
100     add_submodule();
101         set_description( _("Kasenna MediaBase parser") );
102         add_shortcut( "sgimb" );
103         set_capability( "demux2", 10 );
104         set_callbacks( E_(Import_SGIMB), E_(Close_SGIMB) );
105     add_submodule();
106         set_description( _("QuickTime Media Link importer") );
107         add_shortcut( "qtl" );
108         set_capability( "demux2", 10 );
109         set_callbacks( E_(Import_QTL), E_(Close_QTL) );
110     add_submodule();
111         set_description( _("Google Video Playlist importer") );
112         add_shortcut( "gvp" );
113         set_capability( "demux2", 10 );
114         set_callbacks( E_(Import_GVP), E_(Close_GVP) );
115     add_submodule();
116         set_description( _("Dummy ifo demux") );
117         set_capability( "demux2", 12 );
118         set_callbacks( E_(Import_IFO), E_(Close_IFO) );
119     add_submodule();
120         set_description( _("Video portal url converter") );
121         add_shortcut( "videoportal" );
122         set_capability( "demux2", 10 );
123         set_callbacks( E_(Import_VideoPortal), E_(Close_VideoPortal) );
124 vlc_module_end();
125
126
127 /**
128  * Find directory part of the path to the playlist file, in case of
129  * relative paths inside
130  */
131 char *E_(FindPrefix)( demux_t *p_demux )
132 {
133     char *psz_name;
134     char *psz_path = strdup( p_demux->psz_path );
135
136 #ifndef WIN32
137     psz_name = strrchr( psz_path, '/' );
138 #else
139     psz_name = strrchr( psz_path, '\\' );
140     if( !psz_name ) psz_name = strrchr( psz_path, '/' );
141 #endif
142     if( psz_name ) psz_name[1] = '\0';
143     else *psz_path = '\0';
144
145     return psz_path;
146 }
147
148 /**
149  * Add the directory part of the playlist file to the start of the
150  * mrl, if the mrl is a relative file path
151  */
152 char *E_(ProcessMRL)( char *psz_mrl, char *psz_prefix )
153 {
154     /* Check for a protocol name.
155      * for URL, we should look for "://"
156      * for MRL (Media Resource Locator) ([[<access>][/<demux>]:][<source>]),
157      * we should look for ":", so we end up looking simply for ":"
158      * PB: on some file systems, ':' are valid characters though */
159
160     /* Simple cases first */
161     if( !psz_mrl || !*psz_mrl ) return NULL;
162     if( !psz_prefix || !*psz_prefix ) return strdup( psz_mrl );
163
164     /* Check if the line specifies an absolute path */
165     if( *psz_mrl == '/' || *psz_mrl == '\\' ) return strdup( psz_mrl );
166
167     /* Check if the line specifies an mrl/url
168      * (and on win32, contains a drive letter) */
169     if( strchr( psz_mrl, ':' ) ) return strdup( psz_mrl );
170
171     /* This a relative path, prepend the prefix */
172     asprintf( &psz_mrl, "%s%s", psz_prefix, psz_mrl );
173     return psz_mrl;
174 }