| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
#ifdef HAVE_CONFIG_H |
|---|
| 29 |
# include "config.h" |
|---|
| 30 |
#endif |
|---|
| 31 |
|
|---|
| 32 |
#include <vlc_common.h> |
|---|
| 33 |
#include <vlc_interface.h> |
|---|
| 34 |
#include <vlc_playlist.h> |
|---|
| 35 |
#include <vlc_input.h> |
|---|
| 36 |
#include <vlc_meta.h> |
|---|
| 37 |
|
|---|
| 38 |
#include <errno.h> |
|---|
| 39 |
|
|---|
| 40 |
#include <assert.h> |
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
int Export_M3U ( vlc_object_t * ); |
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
static void DoChildren( playlist_t *p_playlist, playlist_export_t *p_export, |
|---|
| 51 |
playlist_item_t *p_root ) |
|---|
| 52 |
{ |
|---|
| 53 |
int i, j; |
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
for( i = 0; i< p_root->i_children ; i++) |
|---|
| 57 |
{ |
|---|
| 58 |
playlist_item_t *p_current = p_root->pp_children[i]; |
|---|
| 59 |
assert( p_current ); |
|---|
| 60 |
|
|---|
| 61 |
if( p_current->i_flags & PLAYLIST_SAVE_FLAG ) |
|---|
| 62 |
continue; |
|---|
| 63 |
|
|---|
| 64 |
if( p_current->i_children >= 0 ) |
|---|
| 65 |
{ |
|---|
| 66 |
DoChildren( p_playlist, p_export, p_current ); |
|---|
| 67 |
continue; |
|---|
| 68 |
} |
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
char *psz_uri = input_item_GetURI( p_current->p_input ); |
|---|
| 73 |
|
|---|
| 74 |
assert( psz_uri ); |
|---|
| 75 |
|
|---|
| 76 |
char *psz_name = input_item_GetName( p_current->p_input ); |
|---|
| 77 |
if( psz_name && strcmp( psz_uri, psz_name ) ) |
|---|
| 78 |
{ |
|---|
| 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 ); |
|---|
| 82 |
if( psz_artist && *psz_artist ) |
|---|
| 83 |
{ |
|---|
| 84 |
|
|---|
| 85 |
fprintf( p_export->p_file, "#EXTINF:%i,%s - %s\n", |
|---|
| 86 |
(int)( i_duration / 1000000 ), psz_artist, psz_name); |
|---|
| 87 |
} |
|---|
| 88 |
else |
|---|
| 89 |
{ |
|---|
| 90 |
|
|---|
| 91 |
fprintf( p_export->p_file, "#EXTINF:%i,%s\n", |
|---|
| 92 |
(int)( i_duration / 1000000 ), psz_name); |
|---|
| 93 |
} |
|---|
| 94 |
free( psz_artist ); |
|---|
| 95 |
} |
|---|
| 96 |
free( psz_name ); |
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
vlc_mutex_lock( &p_current->p_input->lock ); |
|---|
| 100 |
for( j = 0; j < p_current->p_input->i_options; j++ ) |
|---|
| 101 |
{ |
|---|
| 102 |
fprintf( p_export->p_file, "#EXTVLCOPT:%s\n", |
|---|
| 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] ); |
|---|
| 106 |
} |
|---|
| 107 |
vlc_mutex_unlock( &p_current->p_input->lock ); |
|---|
| 108 |
|
|---|
| 109 |
fprintf( p_export->p_file, "%s\n", psz_uri ); |
|---|
| 110 |
free( psz_uri ); |
|---|
| 111 |
} |
|---|
| 112 |
} |
|---|
| 113 |
|
|---|
| 114 |
int Export_M3U( vlc_object_t *p_this ) |
|---|
| 115 |
{ |
|---|
| 116 |
playlist_t *p_playlist = (playlist_t*)p_this; |
|---|
| 117 |
playlist_export_t *p_export = (playlist_export_t *)p_playlist->p_private; |
|---|
| 118 |
|
|---|
| 119 |
msg_Dbg(p_playlist, "saving using M3U format"); |
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
fprintf( p_export->p_file, "#EXTM3U\n" ); |
|---|
| 123 |
|
|---|
| 124 |
DoChildren( p_playlist, p_export, p_export->p_root ); |
|---|
| 125 |
return VLC_SUCCESS; |
|---|
| 126 |
} |
|---|