[vlc-devel] [PATCH 3/3] Add file dialogue to manually set album art.

Angelo Haller vlc-devel at szanni.org
Sun Jul 29 18:12:45 CEST 2012


On 07/28/2012 11:10 PM, Jean-Baptiste Kempf wrote:
> On Sat, Jul 28, 2012 at 04:39:36PM +0200, vlc-devel at szanni.org wrote :
>> -    QAction *action = new QAction( qtr( "Download cover art" ), this );
>> -    CONNECT( action, triggered(), this, askForUpdate() );
>> -    addAction( action );
>> +    QAction *action_download = new QAction( qtr( "Download cover art" ), this );
>> +    CONNECT( action_download, triggered(), this, askForUpdate() );
>> +    addAction( action_download );
>> +
>> +    QAction *action_from_file = new QAction( qtr( "Cover art from file" ), this );
>> +    CONNECT( action_from_file, triggered(), this, setArtFromFile() );
>> +    addAction( action_from_file );
> You do not relly need 2 different QAction here,, but well...
Yeah, you're right. Thought it might make things more clear, but I guess
it just eats up memory.

>> +    input_item_t *_p_item = p_item;
> Why?
I got confused with all the input_item_ts flying around. Doesn't need
caching, my bad.

>> +        char *psz_cachedir = config_GetUserDir( VLC_CACHE_DIR );
>> +        QString old_url = THEMIM->getIM()->decodeArtURL( p_item );
>> +
>> +        if( old_url.startsWith( QString( psz_cachedir ) ) )
>> +            QFile( old_url ).remove(); /* Purge cached artwork */
>> +
>> +        free( psz_cachedir );
>> +
>> +        input_item_SetArtURL( p_item , fileUrl.toLocal8Bit().data() );
>> +        UpdateArt();
> I do not really understand what you are trying to do here, to be
> honest...
> Best regards,
This one is actually a bit weird. I didn't find a way on how to 
invalidate the
existing album art cache when overwriting an existing album art.

Refetching the metadata for the file won't work, because the fetcher assumes
all urls starting with file:// are cached (maybe a bug?).
Apart from that the picture would be written to a different location, 
because
the ArtUrl is used to determine the cache path. The ArtUrl is a URL when 
saving
but something like attachment:// on startup resulting in a different 
cache location.

So what I'm doing is: check if the current url is in cache, if so delete 
the file;
set the new url.

Happy to receive suggestions.

Oh and looking at vlc_fs it should probably be .toUtf8

Greetings,
Angelo



More information about the vlc-devel mailing list