[vlc-devel] Customizing the way lua scripts are run

Gergely Kiss mail.gery at gmail.com
Tue Dec 29 14:02:43 CET 2009

Dear Developers,

I'd like to modify the source a bit to change the way lua scripts are
run. The goal is to replace a playlist item with another one processed
by a lua script, so that youtube "watch" links are replaced by the URL
of the actual FLV file.

I'm trying to modify /modules/misc/lua/vlc.c like this (function

                    /* Append item to playlist */
                    /* HACK: replace the parent node to keep item position */
                    /* without this, the item would be placed at an
undesired position */
                    if( p_parent ) /* Replace node */
						/* get the playlist_item of the parent input_item */
						playlist_item_t *parent_pls_item;
						parent_pls_item = playlist_ItemGetByInput(p_playlist, p_parent);
						int plspos = parent_pls_item->i_id;
                                                /* delete the parent node */
					    playlist_DeleteFromInput(p_playlist, p_parent, true);
					    /* create a leaf */
						playlist_AddInput( p_playlist, p_input,
                               PLAYLIST_APPEND |
                               ( b_play ? PLAYLIST_GO : PLAYLIST_PREPARSE ),
                               plspos, true, false );
                    else /* Play or Enqueue (preparse) */
                        /* FIXME: playlist_AddInput() can fail */
                        playlist_AddInput( p_playlist, p_input,
                               PLAYLIST_APPEND |
                               ( b_play ? PLAYLIST_GO : PLAYLIST_PREPARSE ),
                               PLAYLIST_END, true, false );
                    i_count ++; /* increment counter */
                    vlc_gc_decref( p_input );
                    while( i_options > 0 )
                        free( ppsz_options[--i_options] );
                    free( ppsz_options );

When the code tries to append the new item, VLC exits silently.
Deleting the parent item is also not working for some reason. If I try
to append the new item to PLAYLIST_END, it works, but the parent item
still cannot be deleted.

What's wrong with the code? I'm very new to the internals of VLC, so
probably my code doesn't do what I expect. Could you please help?

Thanks in advance!


More information about the vlc-devel mailing list