Commit ecdf0f1a authored by Clément Stenac's avatar Clément Stenac

Re-enable art fetching when in "ALL" mode

Todo: we should recheck cache just before downloading in case it has been downloaded while we were in the queue
parent b3b71030
......@@ -50,8 +50,6 @@ static int FindMeta( vlc_object_t * );
*****************************************************************************/
vlc_module_begin();
/* set_category( CAT_INTERFACE );
set_subcategory( SUBCAT_INTERFACE_CONTROL );*/
set_shortname( N_( "Folder" ) );
set_description( _("Folder meta data") );
......@@ -63,23 +61,18 @@ vlc_module_end();
*****************************************************************************/
static int FindMeta( vlc_object_t *p_this )
{
meta_engine_t *p_me = (meta_engine_t *)p_this;
input_item_t *p_item = p_me->p_item;
playlist_t *p_playlist = (playlist_t *)p_this;
input_item_t *p_item = (input_item_t *)(p_playlist->p_private);
vlc_bool_t b_have_art = VLC_FALSE;
uint32_t i_meta;
if( !p_item->p_meta ) return VLC_EGENERIC;
if( p_me->i_mandatory & VLC_META_ENGINE_ART_URL
|| p_me->i_optional & VLC_META_ENGINE_ART_URL )
{
int i = 0;
struct stat a;
char psz_filename[MAX_PATH];
char *psz_dir = strdup( p_item->psz_uri );
char *psz_buf = strrchr( psz_dir, '/' );
if( !p_item->p_meta ) return VLC_EGENERIC;
if( psz_buf )
{
psz_buf++;
......@@ -121,13 +114,6 @@ static int FindMeta( vlc_object_t *p_this )
}
free( psz_dir );
}
i_meta = input_CurrentMetaFlags( p_item->p_meta );
p_me->i_mandatory &= ~i_meta;
p_me->i_optional &= ~i_meta;
if( p_me->i_mandatory )
return VLC_EGENERIC;
else
return VLC_SUCCESS;
return b_have_art ? VLC_SUCCESS : VLC_EGENERIC;
}
......@@ -162,7 +162,8 @@ static int FindMetaMBId( vlc_object_t *p_this )
{
meta_engine_t *p_me = (meta_engine_t *)p_this;
input_item_t *p_item = p_me->p_item;
int i_ret = GetData( VLC_OBJECT(p_me), p_item, VLC_FALSE );
int i_ret = GetData( VLC_OBJECT(p_me), p_item,
p_me->i_mandatory & VLC_META_ENGINE_ART_URL );
if( !i_ret )
{
......@@ -176,9 +177,9 @@ static int FindMetaMBId( vlc_object_t *p_this )
static int FindArt( vlc_object_t *p_this )
{
playlist_t *p_playlist;
input_item_t *p_item = (input_item_t *)p_playlist->p_private;
playlist_t *p_playlist = (playlist_t *)p_this;
input_item_t *p_item = (input_item_t *)(p_playlist->p_private);
assert( p_item );
return GetData( p_playlist, p_item, VLC_TRUE );
return GetData( VLC_OBJECT(p_playlist), p_item, VLC_TRUE );
}
......@@ -1047,7 +1047,6 @@ static bo_t *GetUdtaTag( sout_mux_t *p_mux )
} }
ADD_META_BOX( title, "nam" );
ADD_META_BOX( author, "aut" );
ADD_META_BOX( artist, "ART" );
ADD_META_BOX( genre, "gen" );
ADD_META_BOX( copyright, "cpy" );
......
......@@ -2249,7 +2249,6 @@ static void InputMetaUser( input_thread_t *p_input )
free( val.psz_string )
GET_META( title, "meta-title" );
GET_META( author, "meta-author" );
GET_META( artist, "meta-artist" );
GET_META( genre, "meta-genre" );
GET_META( copyright, "meta-copyright" );
......
......@@ -102,10 +102,12 @@ int input_ArtFetch( playlist_t *p_playlist, input_item_t *p_item )
if( !p_module )
{
msg_Dbg( p_playlist, "unable to find art" );
PL_UNLOCK;
return VLC_EGENERIC;
}
module_Unneed( p_playlist, p_module );
p_playlist->p_private = NULL;
PL_UNLOCK;
if( !p_item->p_meta->psz_arturl || !*p_item->p_meta->psz_arturl )
return VLC_EGENERIC;
......@@ -141,8 +143,6 @@ int input_FindArtInCache( playlist_t *p_playlist, input_item_t *p_item )
/* Check if file exists */
if( utf8_stat( psz_filename+7, &a ) == 0 )
{
msg_Dbg( p_playlist, "album art %s already exists in cache"
, psz_filename );
vlc_meta_SetArtURL( p_item->p_meta, psz_filename );
return VLC_SUCCESS;
}
......@@ -211,7 +211,7 @@ int input_DownloadAndCacheArt( playlist_t *p_playlist, input_item_t *p_item )
free( p_buffer );
fclose( p_file );
stream_Delete( p_stream );
msg_Dbg( p_playlist, "Album art saved to %s\n", psz_filename );
msg_Dbg( p_playlist, "album art saved to %s\n", psz_filename );
free( p_item->p_meta->psz_arturl );
p_item->p_meta->psz_arturl = strdup( psz_filename );
i_status = VLC_SUCCESS;
......@@ -228,7 +228,6 @@ uint32_t input_CurrentMetaFlags( vlc_meta_t *p_meta )
i_meta |= VLC_META_ENGINE_ ## b;
CHECK( title, TITLE )
CHECK( author, AUTHOR )
CHECK( artist, ARTIST )
CHECK( genre, GENRE )
CHECK( copyright, COPYRIGHT )
......
......@@ -565,15 +565,29 @@ void playlist_SecondaryPreparseLoop( playlist_secondary_preparse_t *p_obj )
{
input_MetaFetch( p_playlist, p_item );
p_item->p_meta->i_status |= ITEM_META_FETCHED;
var_SetInteger( p_playlist, "item-change", p_item->i_id );
/* Fetch right now */
if( var_GetInteger( p_playlist, "album-art" ) == ALBUM_ART_ALL )
{
vlc_mutex_lock( &p_obj->object_lock );
preparse_item_t p;
p.p_item = p_item;
p.b_fetch_art = VLC_TRUE;
INSERT_ELEM( p_playlist->p_secondary_preparse->p_waiting,
p_playlist->p_secondary_preparse->i_waiting,
0, p );
vlc_mutex_unlock( &p_obj->object_lock );
}
else
vlc_gc_decref( p_item );
}
else
{
input_ArtFetch( p_playlist, p_item );
p_item->p_meta->i_status |= ITEM_ART_FETCHED;
}
var_SetInteger( p_playlist, "item-change", p_item->i_id );
vlc_gc_decref( p_item );
}
}
vlc_mutex_lock( &p_obj->object_lock );
i_activity = var_GetInteger( p_playlist, "activity" );
if( i_activity < 0 ) i_activity = 0;
......
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