/*****************************************************************************
* Preamble
*****************************************************************************/
+#define _GNU_SOURCE
#include <stdlib.h> /* malloc(), free() */
#include <ctype.h> /* isspace() */
#include <vlc/input.h>
#include <errno.h> /* ENOMEM */
+#include "charset.h"
#include "playlist.h"
#include "vlc_meta.h"
-#define FREE( p ) if( p ) { free( p ); (p) = NULL; }
-
struct demux_sys_t
{
char *psz_prefix;
int E_(Import_ASX)( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t *)p_this;
- uint8_t *p_peek;
+ uint8_t *p_peek, *p_peek_stop;
CHECK_PEEK( p_peek, 10 );
-
+
+ p_peek_stop = p_peek+6;
+
+ // skip over possible leading empty lines
+ while( (p_peek < p_peek_stop) && (*p_peek == '\n' || *p_peek == '\r')) ++p_peek;
+
if( POKE( p_peek, "<asx", 4 ) || isExtension( p_demux, ".asx" ) ||
isExtension( p_demux, ".wax" ) || isExtension( p_demux, ".wvx" ) ||
isDemux( p_demux, "asx-open" ) )
char *psz_base_asx = NULL;
char *psz_title_asx = NULL;
- char *psz_author_asx = NULL;
+ char *psz_artist_asx = NULL;
char *psz_copyright_asx = NULL;
char *psz_moreinfo_asx = NULL;
char *psz_abstract_asx = NULL;
char *psz_base_entry = NULL;
char *psz_title_entry = NULL;
- char *psz_author_entry = NULL;
+ char *psz_artist_entry = NULL;
char *psz_copyright_entry = NULL;
char *psz_moreinfo_entry = NULL;
char *psz_abstract_entry = NULL;
psz_backup = psz_parse+=8;
if( ( psz_parse = strcasestr( psz_parse, "</Author>" ) ) )
{
- StoreString( p_demux, (b_entry ? &psz_author_entry : &psz_author_asx), psz_backup, psz_parse );
+ StoreString( p_demux, (b_entry ? &psz_artist_entry : &psz_artist_asx), psz_backup, psz_parse );
psz_parse += 9;
}
else continue;
memcpy( psz_string, psz_backup, i_strlen );
psz_string[i_strlen] = '\0';
p_input = input_ItemNew( p_playlist, psz_string, psz_title_asx );
- vlc_input_item_CopyOptions( p_current->p_input, p_input );
+ input_ItemCopyOptions( p_current->p_input, p_input );
playlist_AddWhereverNeeded( p_playlist, p_input, p_current,
p_item_in_category, (i_parent_id > 0 )? VLC_TRUE : VLC_FALSE,
PLAYLIST_APPEND );
continue;
}
/* cleanup entry */
- FREE( psz_title_entry )
- FREE( psz_base_entry )
- FREE( psz_author_entry )
- FREE( psz_copyright_entry )
- FREE( psz_moreinfo_entry )
- FREE( psz_abstract_entry )
+ FREENULL( psz_title_entry )
+ FREENULL( psz_base_entry )
+ FREENULL( psz_artist_entry )
+ FREENULL( psz_copyright_entry )
+ FREENULL( psz_moreinfo_entry )
+ FREENULL( psz_abstract_entry )
b_entry = VLC_FALSE;
}
- else if( !strncasecmp( psz_parse, "<Entry>", 7 ) )
+ else if( !strncasecmp( psz_parse, "<Entry", 6 ) )
{
- psz_parse+=7;
+ psz_parse+=6;
if( b_entry )
{
msg_Err( p_demux, "We already are in an entry section" );
}
i_entry_count += 1;
b_entry = VLC_TRUE;
+ psz_parse = strcasestr( psz_parse, ">" );
}
else if( !strncasecmp( psz_parse, "<Ref ", 5 ) )
{
/* create the new entry */
asprintf( &psz_name, "%d %s", i_entry_count, ( psz_title_entry ? psz_title_entry : p_current->p_input->psz_name ) );
p_entry = input_ItemNew( p_playlist, psz_string, psz_name );
- FREE( psz_name );
+ FREENULL( psz_name );
- vlc_input_item_CopyOptions( p_current->p_input, p_entry );
+ input_ItemCopyOptions( p_current->p_input, p_entry );
p_entry->p_meta = vlc_meta_New();
if( psz_title_entry ) vlc_meta_SetTitle( p_entry->p_meta, psz_title_entry );
- if( psz_author_entry ) vlc_meta_SetAuthor( p_entry->p_meta, psz_author_entry );
+ if( psz_artist_entry ) vlc_meta_SetArtist( p_entry->p_meta, psz_artist_entry );
if( psz_copyright_entry ) vlc_meta_SetCopyright( p_entry->p_meta, psz_copyright_entry );
if( psz_moreinfo_entry ) vlc_meta_SetURL( p_entry->p_meta, psz_moreinfo_entry );
if( psz_abstract_entry ) vlc_meta_SetDescription( p_entry->p_meta, psz_abstract_entry );
vlc_mutex_lock( &p_current->p_input->lock );
if( !p_current->p_input->p_meta ) p_current->p_input->p_meta = vlc_meta_New();
if( psz_title_asx ) vlc_meta_SetTitle( p_current->p_input->p_meta, psz_title_asx );
- if( psz_author_asx ) vlc_meta_SetAuthor( p_current->p_input->p_meta, psz_author_asx );
+ if( psz_artist_asx ) vlc_meta_SetArtist( p_current->p_input->p_meta, psz_artist_asx );
if( psz_copyright_asx ) vlc_meta_SetCopyright( p_current->p_input->p_meta, psz_copyright_asx );
if( psz_moreinfo_asx ) vlc_meta_SetURL( p_current->p_input->p_meta, psz_moreinfo_asx );
if( psz_abstract_asx ) vlc_meta_SetDescription( p_current->p_input->p_meta, psz_abstract_asx );
vlc_mutex_unlock( &p_current->p_input->lock );
- FREE( psz_base_asx );
- FREE( psz_title_asx );
- FREE( psz_author_asx );
- FREE( psz_copyright_asx );
- FREE( psz_moreinfo_asx );
- FREE( psz_abstract_asx );
+ FREENULL( psz_base_asx );
+ FREENULL( psz_title_asx );
+ FREENULL( psz_artist_asx );
+ FREENULL( psz_copyright_asx );
+ FREENULL( psz_moreinfo_asx );
+ FREENULL( psz_abstract_asx );
psz_parse++;
}
else psz_parse++;