Commit b4c56206 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Export: add support for normal M3U, move UTF-8 mode to M3U8

parent 9d88d50a
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
* Prototypes * Prototypes
***************************************************************************/ ***************************************************************************/
int Export_M3U ( vlc_object_t *p_intf ); int Export_M3U ( vlc_object_t *p_intf );
int Export_M3U8 ( vlc_object_t *p_intf );
int Export_Old ( vlc_object_t *p_intf ); int Export_Old ( vlc_object_t *p_intf );
int Export_HTML ( vlc_object_t *p_intf ); int Export_HTML ( vlc_object_t *p_intf );
int xspf_export_playlist( vlc_object_t *p_intf ); int xspf_export_playlist( vlc_object_t *p_intf );
...@@ -52,6 +53,12 @@ vlc_module_begin () ...@@ -52,6 +53,12 @@ vlc_module_begin ()
set_capability( "playlist export" , 0 ) set_capability( "playlist export" , 0 )
set_callbacks( Export_M3U , NULL ) set_callbacks( Export_M3U , NULL )
add_submodule ()
set_description( N_("M3U8 playlist export") )
add_shortcut( "export-m3u8" )
set_capability( "playlist export" , 0 )
set_callbacks( Export_M3U , NULL )
add_submodule () add_submodule ()
set_description( N_("Old playlist export") ) set_description( N_("Old playlist export") )
add_shortcut( "export-old" ) add_shortcut( "export-old" )
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <vlc_playlist.h> #include <vlc_playlist.h>
#include <vlc_input.h> #include <vlc_input.h>
#include <vlc_meta.h> #include <vlc_meta.h>
#include <vlc_charset.h>
#include <assert.h> #include <assert.h>
...@@ -40,11 +41,13 @@ ...@@ -40,11 +41,13 @@
* Local prototypes * Local prototypes
*****************************************************************************/ *****************************************************************************/
int Export_M3U ( vlc_object_t * ); int Export_M3U ( vlc_object_t * );
int Export_M3U8( vlc_object_t * );
/***************************************************************************** /*****************************************************************************
* Export_M3U: main export function * Export_M3U: main export function
*****************************************************************************/ *****************************************************************************/
static void DoChildren( playlist_export_t *p_export, playlist_item_t *p_root ) static void DoChildren( playlist_export_t *p_export, playlist_item_t *p_root,
int (*pf_fprintf) (FILE *, const char *, ...) )
{ {
int i, j; int i, j;
...@@ -59,7 +62,7 @@ static void DoChildren( playlist_export_t *p_export, playlist_item_t *p_root ) ...@@ -59,7 +62,7 @@ static void DoChildren( playlist_export_t *p_export, playlist_item_t *p_root )
if( p_current->i_children >= 0 ) if( p_current->i_children >= 0 )
{ {
DoChildren( p_export, p_current ); DoChildren( p_export, p_current, pf_fprintf );
continue; continue;
} }
...@@ -78,14 +81,14 @@ static void DoChildren( playlist_export_t *p_export, playlist_item_t *p_root ) ...@@ -78,14 +81,14 @@ static void DoChildren( playlist_export_t *p_export, playlist_item_t *p_root )
if( psz_artist && *psz_artist ) if( psz_artist && *psz_artist )
{ {
/* write EXTINF with artist */ /* write EXTINF with artist */
fprintf( p_export->p_file, "#EXTINF:%i,%s - %s\n", pf_fprintf( p_export->p_file, "#EXTINF:%"PRIu64",%s - %s\n",
(int)( i_duration / 1000000 ), psz_artist, psz_name); i_duration / CLOCK_FREQ, psz_artist, psz_name);
} }
else else
{ {
/* write EXTINF without artist */ /* write EXTINF without artist */
fprintf( p_export->p_file, "#EXTINF:%i,%s\n", pf_fprintf( p_export->p_file, "#EXTINF:%"PRIu64",%s\n",
(int)( i_duration / 1000000 ), psz_name); i_duration / CLOCK_FREQ, psz_name);
} }
free( psz_artist ); free( psz_artist );
} }
...@@ -95,10 +98,10 @@ static void DoChildren( playlist_export_t *p_export, playlist_item_t *p_root ) ...@@ -95,10 +98,10 @@ static void DoChildren( playlist_export_t *p_export, playlist_item_t *p_root )
vlc_mutex_lock( &p_current->p_input->lock ); vlc_mutex_lock( &p_current->p_input->lock );
for( j = 0; j < p_current->p_input->i_options; j++ ) for( j = 0; j < p_current->p_input->i_options; j++ )
{ {
fprintf( p_export->p_file, "#EXTVLCOPT:%s\n", pf_fprintf( p_export->p_file, "#EXTVLCOPT:%s\n",
p_current->p_input->ppsz_options[j][0] == ':' ? p_current->p_input->ppsz_options[j][0] == ':' ?
p_current->p_input->ppsz_options[j] + 1 : p_current->p_input->ppsz_options[j] + 1 :
p_current->p_input->ppsz_options[j] ); p_current->p_input->ppsz_options[j] );
} }
vlc_mutex_unlock( &p_current->p_input->lock ); vlc_mutex_unlock( &p_current->p_input->lock );
...@@ -114,8 +117,21 @@ int Export_M3U( vlc_object_t *p_this ) ...@@ -114,8 +117,21 @@ int Export_M3U( vlc_object_t *p_this )
msg_Dbg( p_export, "saving using M3U format"); msg_Dbg( p_export, "saving using M3U format");
/* Write header */ /* Write header */
fprintf( p_export->p_file, "#EXTM3U\n" ); fputs( "#EXTM3U\n", p_export->p_file );
DoChildren( p_export, p_export->p_root ); DoChildren( p_export, p_export->p_root, utf8_fprintf );
return VLC_SUCCESS;
}
int Export_M3U8( vlc_object_t *p_this )
{
playlist_export_t *p_export = (playlist_export_t *)p_this;
msg_Dbg( p_export, "saving using M3U8 format");
/* Write header */
fputs( "#EXTM3U\n", p_export->p_file );
DoChildren( p_export, p_export->p_root, fprintf );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment