+ p_input = input_item_New( psz_urls, psz_urls );
+ input_item_AddOption( p_input, "demux=podcast", VLC_INPUT_OPTION_TRUSTED );
+
+ INSERT_ELEM( pp_new_items, i_new_items, i_new_items, p_input );
+ services_discovery_AddItem( p_sd, p_input, NULL /* no cat */ );
+
+ INSERT_ELEM( p_sys->pp_input, p_sys->i_input, p_sys->i_input,
+ input_CreateAndStart( p_sd, p_input, NULL ) );
+ }
+ else
+ {
+ INSERT_ELEM( ppsz_new_urls, i_new_urls, i_new_urls,
+ strdup( p_sys->ppsz_urls[i]) );
+ INSERT_ELEM( pp_new_items, i_new_items, i_new_items, p_sys->pp_items[i] );
+ }
+ if( psz_tok )
+ psz_urls = psz_tok+1;
+ else
+ break;
+ }
+
+ /* delete removed items and signal the removal */
+ for( i = 0; i<p_sys->i_items; ++i )
+ {
+ for( j = 0; j < i_new_items; ++j )
+ if( pp_new_items[j] == p_sys->pp_items[i] ) break;
+ if( j == i_new_items )
+ {
+ services_discovery_RemoveItem( p_sd, p_sys->pp_items[i] );
+ vlc_gc_decref( p_sys->pp_items[i] );
+ }
+ }
+ free( p_sys->pp_items );
+ for( int i = 0; i < p_sys->i_urls; i++ )
+ free( p_sys->ppsz_urls[i] );
+ free( p_sys->ppsz_urls );
+
+ p_sys->ppsz_urls = ppsz_new_urls;
+ p_sys->i_urls = i_new_urls;
+ p_sys->pp_items = pp_new_items;
+ p_sys->i_items = i_new_items;
+}
+
+static void ParseRequest( services_discovery_t *p_sd )
+{
+ services_discovery_sys_t *p_sys = p_sd->p_sys;
+
+ char *psz_request = p_sys->psz_request;
+
+ int i;
+
+ char *psz_tok = strchr( psz_request, ':' );
+ if( !psz_tok ) return;
+ *psz_tok = '\0';
+
+ if ( ! p_sys->b_savedurls_loaded )
+ {
+ char *psz_urls = var_GetNonEmptyString( p_sd->p_parent,
+ "podcast-urls" );
+ ParseUrls( p_sd, psz_urls );
+ free( psz_urls );
+ }
+
+ if( !strcmp( psz_request, "ADD" ) )
+ {
+ psz_request = psz_tok + 1;
+ for( i = 0; i<p_sys->i_urls; i++ )
+ if( !strcmp(p_sys->ppsz_urls[i],psz_request) )
+ break;
+ if( i == p_sys->i_urls )
+ {