Commit bd808941 authored by Rémi Duraffort's avatar Rémi Duraffort

podcast: factorize.

parent 72741d68
/*****************************************************************************
* podcast.c : podcast playlist imports
*****************************************************************************
* Copyright (C) 2005 the VideoLAN team
* Copyright (C) 2005-2009 the VideoLAN team
* $Id$
*
* Authors: Antoine Cellerier <dionoea -at- videolan -dot- org>
......@@ -127,11 +127,13 @@ static int Demux( demux_t *p_demux )
}
while( xml_ReaderNodeType( p_xml_reader ) == XML_READER_NONE )
{
if( xml_ReaderRead( p_xml_reader ) != 1 )
{
msg_Err( p_demux, "invalid file (no root node)" );
return -1;
}
}
if( xml_ReaderNodeType( p_xml_reader ) != XML_READER_STARTELEM ||
( psz_elname = xml_ReaderName( p_xml_reader ) ) == NULL ||
......@@ -142,7 +144,7 @@ static int Demux( demux_t *p_demux )
free( psz_elname );
return -1;
}
free( psz_elname ); psz_elname = NULL;
FREENULL( psz_elname );
while( (i_ret = xml_ReaderRead( p_xml_reader )) == 1 )
{
......@@ -183,29 +185,32 @@ static int Demux( demux_t *p_demux )
free( psz_elname );
return -1;
}
if( !strcmp( psz_elname, "enclosure" ) &&
!strcmp( psz_name, "url" ) )
if( !strcmp( psz_elname, "enclosure" ) )
{
if( !strcmp( psz_name, "url" ) )
{
free( psz_item_mrl );
psz_item_mrl = strdup( psz_value );
}
else if( !strcmp( psz_elname, "enclosure" ) &&
!strcmp( psz_name, "length" ) )
else if( !strcmp( psz_name, "length" ) )
{
free( psz_item_size );
psz_item_size = strdup( psz_value );
}
else if( !strcmp( psz_elname, "enclosure" ) &&
!strcmp( psz_name, "type" ) )
else if( !strcmp( psz_name, "type" ) )
{
free( psz_item_type );
psz_item_type = strdup( psz_value );
}
else
{
msg_Dbg( p_demux,"unhandled attribure %s in element %s",
psz_name, psz_elname );
}
else
msg_Dbg( p_demux,"unhandled attribure %s in element %s",
psz_name, psz_elname );
free( psz_name );
free( psz_value );
}
......@@ -213,26 +218,27 @@ static int Demux( demux_t *p_demux )
}
case XML_READER_TEXT:
{
#define SET_DATA( field, name ) else if( b_item == true \
&& !strcmp( psz_elname, name ) ) \
char *psz_text = xml_ReaderValue( p_xml_reader );
#define SET_DATA( field, name ) \
else if( !strcmp( psz_elname, name ) ) \
{ \
field = strdup( psz_text ); \
}
char *psz_text = xml_ReaderValue( p_xml_reader );
/* item specific meta data */
if( b_item == true && !strcmp( psz_elname, "title" ) )
if( b_item == true )
{
if( !strcmp( psz_elname, "title" ) )
{
psz_item_name = strdup( psz_text );
}
else if( b_item == true
&& ( !strcmp( psz_elname, "itunes:author" )
||!strcmp( psz_elname, "author" ) ) )
else if( !strcmp( psz_elname, "itunes:author" ) ||
!strcmp( psz_elname, "author" ) )
{ /* <author> isn't standard iTunes podcast stuff */
psz_item_author = strdup( psz_text );
}
else if( b_item == true
&& ( !strcmp( psz_elname, "itunes:summary" )
||!strcmp( psz_elname, "description" ) ) )
else if( !strcmp( psz_elname, "itunes:summary" ) ||
!strcmp( psz_elname, "description" ) )
{ /* <description> isn't standard iTunes podcast stuff */
psz_item_summary = strdup( psz_text );
}
......@@ -241,15 +247,18 @@ static int Demux( demux_t *p_demux )
SET_DATA( psz_item_duration, "itunes:duration" )
SET_DATA( psz_item_keywords, "itunes:keywords" )
SET_DATA( psz_item_subtitle, "itunes:subtitle" )
}
#undef SET_DATA
/* toplevel meta data */
else if( b_item == false && b_image == false
&& !strcmp( psz_elname, "title" ) )
else if( b_image == false )
{
if( !strcmp( psz_elname, "title" ) )
{
input_item_SetName( p_current_input, psz_text );
}
#define ADD_GINFO( info, name ) \
else if( !b_item && !b_image && !strcmp( psz_elname, name ) ) \
else if( !strcmp( psz_elname, name ) ) \
{ \
input_item_AddInfo( p_current_input, _("Podcast Info"), \
_( info ), "%s", psz_text ); \
......@@ -260,14 +269,14 @@ static int Demux( demux_t *p_demux )
ADD_GINFO( "Podcast Keywords", "itunes:keywords" )
ADD_GINFO( "Podcast Subtitle", "itunes:subtitle" )
#undef ADD_GINFO
else if( b_item == false && b_image == false
&& ( !strcmp( psz_elname, "itunes:summary" )
||!strcmp( psz_elname, "description" ) ) )
else if( !strcmp( psz_elname, "itunes:summary" ) ||
!strcmp( psz_elname, "description" ) )
{ /* <description> isn't standard iTunes podcast stuff */
input_item_AddInfo( p_current_input,
_( "Podcast Info" ), _( "Podcast Summary" ),
"%s", psz_text );
}
}
else
{
msg_Dbg( p_demux, "unhandled text in element '%s'",
......
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