]> git.sesse.net Git - vlc/blob - modules/demux/playlist/playlist.c
Use gettext_noop() consistently
[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 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30
31 #include <vlc/vlc.h>
32 #include <vlc_plugin.h>
33 #include <vlc_demux.h>
34 #include <vlc_playlist.h>
35
36 #include "playlist.h"
37
38 /*****************************************************************************
39  * Module descriptor
40  *****************************************************************************/
41 #define AUTOSTART_TEXT N_( "Auto start" )
42 #define AUTOSTART_LONGTEXT N_( "Automatically start playing the playlist " \
43                 "content once it's loaded." )
44
45 #define SHOW_ADULT_TEXT N_( "Show shoutcast adult content" )
46 #define SHOW_ADULT_LONGTEXT N_( "Show NC17 rated video streams when " \
47                 "using shoutcast video playlists." )
48
49 #define SKIP_ADS_TEXT N_( "Skip ads" )
50 #define SKIP_ADS_LONGTEXT N_( "Use playlist options usually used to prevent " \
51     "ads skipping to detect ads and prevent adding them to the playlist." )
52
53 vlc_module_begin();
54     add_shortcut( "playlist" );
55     set_category( CAT_INPUT );
56     set_subcategory( SUBCAT_INPUT_DEMUX );
57
58     add_bool( "playlist-autostart", 1, NULL,
59               AUTOSTART_TEXT, AUTOSTART_LONGTEXT, false );
60
61     add_integer( "parent-item", 0, NULL, NULL, NULL, true );
62         change_internal();
63
64     add_bool( "playlist-skip-ads", 1, NULL,
65               SKIP_ADS_TEXT, SKIP_ADS_LONGTEXT, false );
66
67     set_shortname( N_("Playlist") );
68     set_description( N_("Playlist") );
69     add_submodule();
70         set_description( N_("M3U playlist import") );
71         add_shortcut( "m3u-open" );
72         set_capability( "demux", 10 );
73         set_callbacks( Import_M3U, Close_M3U );
74     add_submodule();
75         set_description( N_("PLS playlist import") );
76         add_shortcut( "pls-open" );
77         set_capability( "demux", 10 );
78         set_callbacks( Import_PLS, Close_PLS );
79     add_submodule();
80         set_description( N_("B4S playlist import") );
81         add_shortcut( "b4s-open" );
82         add_shortcut( "shout-b4s" );
83         set_capability( "demux", 10 );
84         set_callbacks( Import_B4S, Close_B4S );
85     add_submodule();
86         set_description( N_("DVB playlist import") );
87         add_shortcut( "dvb-open" );
88         set_capability( "demux", 10 );
89         set_callbacks( Import_DVB, Close_DVB );
90     add_submodule();
91         set_description( N_("Podcast parser") );
92         add_shortcut( "podcast" );
93         set_capability( "demux", 10 );
94         set_callbacks( Import_podcast, Close_podcast );
95     add_submodule();
96         set_description( N_("XSPF playlist import") );
97         add_shortcut( "xspf-open" );
98         set_capability( "demux", 10 );
99         set_callbacks( Import_xspf, Close_xspf );
100     add_submodule();
101         set_description( N_("New winamp 5.2 shoutcast import") );
102         add_shortcut( "shout-winamp" );
103         set_capability( "demux", 10 );
104         set_callbacks( Import_Shoutcast, Close_Shoutcast );
105         add_bool( "shoutcast-show-adult", false, NULL,
106                    SHOW_ADULT_TEXT, SHOW_ADULT_LONGTEXT, false );
107     add_submodule();
108         set_description( N_("ASX playlist import") );
109         add_shortcut( "asx-open" );
110         set_capability( "demux", 10 );
111         set_callbacks( Import_ASX, Close_ASX );
112     add_submodule();
113         set_description( N_("Kasenna MediaBase parser") );
114         add_shortcut( "sgimb" );
115         set_capability( "demux", 10 );
116         set_callbacks( Import_SGIMB, Close_SGIMB );
117     add_submodule();
118         set_description( N_("QuickTime Media Link importer") );
119         add_shortcut( "qtl" );
120         set_capability( "demux", 10 );
121         set_callbacks( Import_QTL, Close_QTL );
122     add_submodule();
123         set_description( N_("Google Video Playlist importer") );
124         add_shortcut( "gvp" );
125         set_capability( "demux", 10 );
126         set_callbacks( Import_GVP, Close_GVP );
127     add_submodule();
128         set_description( N_("Dummy ifo demux") );
129         set_capability( "demux", 12 );
130         set_callbacks( Import_IFO, Close_IFO );
131     add_submodule();
132         set_description( N_("iTunes Music Library importer") );
133         add_shortcut( "itml" );
134         set_capability( "demux", 10 );
135         set_callbacks( Import_iTML, Close_iTML );
136 vlc_module_end();
137
138
139 /**
140  * Find directory part of the path to the playlist file, in case of
141  * relative paths inside
142  */
143 char *FindPrefix( demux_t *p_demux )
144 {
145     char *psz_name;
146     char *psz_path = strdup( p_demux->psz_path );
147
148 #ifndef WIN32
149     psz_name = strrchr( psz_path, '/' );
150 #else
151     psz_name = strrchr( psz_path, '\\' );
152     if( !psz_name ) psz_name = strrchr( psz_path, '/' );
153 #endif
154     if( psz_name ) psz_name[1] = '\0';
155     else *psz_path = '\0';
156
157     return psz_path;
158 }
159
160 /**
161  * Add the directory part of the playlist file to the start of the
162  * mrl, if the mrl is a relative file path
163  */
164 char *ProcessMRL( char *psz_mrl, char *psz_prefix )
165 {
166     /* Check for a protocol name.
167      * for URL, we should look for "://"
168      * for MRL (Media Resource Locator) ([[<access>][/<demux>]:][<source>]),
169      * we should look for ":", so we end up looking simply for ":"
170      * PB: on some file systems, ':' are valid characters though */
171
172     /* Simple cases first */
173     if( !psz_mrl || !*psz_mrl ) return NULL;
174     if( !psz_prefix || !*psz_prefix ) return strdup( psz_mrl );
175
176     /* Check if the line specifies an absolute path */
177     if( *psz_mrl == '/' || *psz_mrl == '\\' ) return strdup( psz_mrl );
178
179     /* Check if the line specifies an mrl/url
180      * (and on win32, contains a drive letter) */
181     if( strchr( psz_mrl, ':' ) ) return strdup( psz_mrl );
182
183     /* This a relative path, prepend the prefix */
184     asprintf( &psz_mrl, "%s%s", psz_prefix, psz_mrl );
185     return psz_mrl;
186 }