40
47
/*****************************************************************************
41
48
* Export_M3U: main export function
42
49
*****************************************************************************/
43
int Export_M3U( vlc_object_t *p_this )
50
static void DoChildren( playlist_t *p_playlist, playlist_export_t *p_export,
51
playlist_item_t *p_root )
45
playlist_t *p_playlist = (playlist_t*)p_this;
46
playlist_export_t *p_export = (playlist_export_t *)p_playlist->p_private;
49
msg_Dbg(p_playlist, "saving using M3U format");
52
fprintf( p_export->p_file, "#EXTM3U\n" );
54
55
/* Go through the playlist and add items */
55
for( i = 0; i< p_playlist->i_size ; i++)
56
for( i = 0; i< p_root->i_children ; i++)
57
if( (p_playlist->pp_items[i]->i_flags & PLAYLIST_SAVE_FLAG) == 0 )
58
playlist_item_t *p_current = p_root->pp_children[i];
61
if( p_current->i_flags & PLAYLIST_SAVE_FLAG )
64
if( p_current->i_children >= 0 )
66
DoChildren( p_playlist, p_export, p_current );
63
if( p_playlist->pp_items[i]->input.psz_name &&
64
strcmp( p_playlist->pp_items[i]->input.psz_name,
65
p_playlist->pp_items[i]->input.psz_uri ) )
72
char *psz_uri = input_item_GetURI( p_current->p_input );
76
char *psz_name = input_item_GetName( p_current->p_input );
77
if( psz_name && strcmp( psz_uri, psz_name ) )
68
vlc_input_item_GetInfo( &p_playlist->pp_items[i]->input,
69
_(VLC_META_INFO_CAT), _(VLC_META_ARTIST) );
79
char *psz_artist = input_item_GetArtist( p_current->p_input );
80
if( psz_artist == NULL ) psz_artist = strdup( "" );
81
mtime_t i_duration = input_item_GetDuration( p_current->p_input );
70
82
if( psz_artist && *psz_artist )
72
84
/* write EXTINF with artist */
73
85
fprintf( p_export->p_file, "#EXTINF:%i,%s - %s\n",
74
(int)(p_playlist->pp_items[i]->input.i_duration/1000000),
76
p_playlist->pp_items[i]->input.psz_name );
86
(int)( i_duration / 1000000 ), psz_artist, psz_name);
80
90
/* write EXTINF without artist */
81
91
fprintf( p_export->p_file, "#EXTINF:%i,%s\n",
82
(int)(p_playlist->pp_items[i]->input.i_duration/1000000),
83
p_playlist->pp_items[i]->input.psz_name );
92
(int)( i_duration / 1000000 ), psz_name);
89
98
/* VLC specific options */
90
for( j = 0; j < p_playlist->pp_items[i]->input.i_options; j++ )
99
vlc_mutex_lock( &p_current->p_input->lock );
100
for( j = 0; j < p_current->p_input->i_options; j++ )
92
102
fprintf( p_export->p_file, "#EXTVLCOPT:%s\n",
93
p_playlist->pp_items[i]->input.ppsz_options[j][0] == ':' ?
94
p_playlist->pp_items[i]->input.ppsz_options[j] + 1 :
95
p_playlist->pp_items[i]->input.ppsz_options[j] );
103
p_current->p_input->ppsz_options[j][0] == ':' ?
104
p_current->p_input->ppsz_options[j] + 1 :
105
p_current->p_input->ppsz_options[j] );
107
vlc_mutex_unlock( &p_current->p_input->lock );
98
fprintf( p_export->p_file, "%s\n",
99
p_playlist->pp_items[i]->input.psz_uri );
109
fprintf( p_export->p_file, "%s\n", psz_uri );
114
int Export_M3U( vlc_object_t *p_this )
116
playlist_t *p_playlist = (playlist_t*)p_this;
117
playlist_export_t *p_export = (playlist_export_t *)p_playlist->p_private;
119
msg_Dbg(p_playlist, "saving using M3U format");
122
fprintf( p_export->p_file, "#EXTM3U\n" );
124
DoChildren( p_playlist, p_export, p_export->p_root );
101
125
return VLC_SUCCESS;