00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <stdlib.h>
00028
00029 #include <vlc/vlc.h>
00030 #include <vlc/intf.h>
00031
00032 #include <errno.h>
00033
00034
00035
00036
00037 int Export_M3U ( vlc_object_t * );
00038
00039
00040
00041
00042 int Export_M3U( vlc_object_t *p_this )
00043 {
00044 playlist_t *p_playlist = (playlist_t*)p_this;
00045 playlist_export_t *p_export = (playlist_export_t *)p_playlist->p_private;
00046 int i, j;
00047
00048 msg_Dbg(p_playlist, "Saving using M3U format");
00049
00050
00051 fprintf( p_export->p_file, "#EXTM3U\n" );
00052
00053
00054 for( i = 0; i< p_playlist->i_size ; i++)
00055 {
00056 if( (p_playlist->pp_items[i]->i_flags & PLAYLIST_SAVE_FLAG) == 0 )
00057 {
00058 continue;
00059 }
00060
00061
00062 if( p_playlist->pp_items[i]->input.psz_name &&
00063 strcmp( p_playlist->pp_items[i]->input.psz_name,
00064 p_playlist->pp_items[i]->input.psz_uri ) )
00065 {
00066 char *psz_artist =
00067 vlc_input_item_GetInfo( &p_playlist->pp_items[i]->input,
00068 _("Meta-information"), _("Artist") );
00069 if( psz_artist && *psz_artist )
00070 {
00071
00072 fprintf( p_export->p_file, "#EXTINF:%i,%s - %s\n",
00073 (int)(p_playlist->pp_items[i]->input.i_duration/1000000),
00074 psz_artist,
00075 p_playlist->pp_items[i]->input.psz_name );
00076 }
00077 else
00078 {
00079
00080 fprintf( p_export->p_file, "#EXTINF:%i,%s\n",
00081 (int)(p_playlist->pp_items[i]->input.i_duration/1000000),
00082 p_playlist->pp_items[i]->input.psz_name );
00083 }
00084 if( psz_artist )
00085 free( psz_artist );
00086 }
00087
00088
00089 for( j = 0; j < p_playlist->pp_items[i]->input.i_options; j++ )
00090 {
00091 fprintf( p_export->p_file, "#EXTVLCOPT:%s\n",
00092 p_playlist->pp_items[i]->input.ppsz_options[j][0] == ':' ?
00093 p_playlist->pp_items[i]->input.ppsz_options[j] + 1 :
00094 p_playlist->pp_items[i]->input.ppsz_options[j] );
00095 }
00096
00097 fprintf( p_export->p_file, "%s\n",
00098 p_playlist->pp_items[i]->input.psz_uri );
00099 }
00100 return VLC_SUCCESS;
00101 }