Commit ecdf0f1a authored by zorglub's avatar zorglub

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 * ); ...@@ -50,8 +50,6 @@ static int FindMeta( vlc_object_t * );
*****************************************************************************/ *****************************************************************************/
vlc_module_begin(); vlc_module_begin();
/* set_category( CAT_INTERFACE );
set_subcategory( SUBCAT_INTERFACE_CONTROL );*/
set_shortname( N_( "Folder" ) ); set_shortname( N_( "Folder" ) );
set_description( _("Folder meta data") ); set_description( _("Folder meta data") );
...@@ -63,71 +61,59 @@ vlc_module_end(); ...@@ -63,71 +61,59 @@ vlc_module_end();
*****************************************************************************/ *****************************************************************************/
static int FindMeta( vlc_object_t *p_this ) static int FindMeta( vlc_object_t *p_this )
{ {
meta_engine_t *p_me = (meta_engine_t *)p_this; playlist_t *p_playlist = (playlist_t *)p_this;
input_item_t *p_item = p_me->p_item; input_item_t *p_item = (input_item_t *)(p_playlist->p_private);
vlc_bool_t b_have_art = VLC_FALSE; vlc_bool_t b_have_art = VLC_FALSE;
uint32_t i_meta; uint32_t i_meta;
if( !p_item->p_meta ) return VLC_EGENERIC; 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_me->i_mandatory & VLC_META_ENGINE_ART_URL if( !p_item->p_meta ) return VLC_EGENERIC;
|| p_me->i_optional & VLC_META_ENGINE_ART_URL ) if( psz_buf )
{ {
int i = 0; psz_buf++;
struct stat a; *psz_buf = '\0';
char psz_filename[MAX_PATH]; }
char *psz_dir = strdup( p_item->psz_uri ); else
char *psz_buf = strrchr( psz_dir, '/' ); {
*psz_dir = '\0';
}
if( psz_buf ) for( i = 0; b_have_art == VLC_FALSE && i < 3; i++ )
{ {
psz_buf++; switch( i )
*psz_buf = '\0';
}
else
{ {
*psz_dir = '\0'; case 0:
/* Windows Folder.jpg */
snprintf( psz_filename, MAX_PATH,
"file://%sFolder.jpg", psz_dir );
break;
case 1:
/* Windows AlbumArtSmall.jpg == small version of Folder.jpg */
snprintf( psz_filename, MAX_PATH,
"file://%sAlbumArtSmall.jpg", psz_dir );
break;
case 2:
/* KDE (?) .folder.png */
snprintf( psz_filename, MAX_PATH,
"file://%s.folder.png", psz_dir );
break;
} }
for( i = 0; b_have_art == VLC_FALSE && i < 3; i++ ) if( utf8_stat( psz_filename+7, &a ) != -1 )
{ {
switch( i ) vlc_meta_SetArtURL( p_item->p_meta, psz_filename );
{ b_have_art = VLC_TRUE;
case 0:
/* Windows Folder.jpg */
snprintf( psz_filename, MAX_PATH,
"file://%sFolder.jpg", psz_dir );
break;
case 1:
/* Windows AlbumArtSmall.jpg == small version of Folder.jpg */
snprintf( psz_filename, MAX_PATH,
"file://%sAlbumArtSmall.jpg", psz_dir );
break;
case 2:
/* KDE (?) .folder.png */
snprintf( psz_filename, MAX_PATH,
"file://%s.folder.png", psz_dir );
break;
}
if( utf8_stat( psz_filename+7, &a ) != -1 )
{
vlc_meta_SetArtURL( p_item->p_meta, psz_filename );
b_have_art = VLC_TRUE;
}
} }
free( psz_dir );
} }
i_meta = input_CurrentMetaFlags( p_item->p_meta ); free( psz_dir );
p_me->i_mandatory &= ~i_meta;
p_me->i_optional &= ~i_meta; return b_have_art ? VLC_SUCCESS : VLC_EGENERIC;
if( p_me->i_mandatory )
return VLC_EGENERIC;
else
return VLC_SUCCESS;
} }
...@@ -162,7 +162,8 @@ static int FindMetaMBId( vlc_object_t *p_this ) ...@@ -162,7 +162,8 @@ static int FindMetaMBId( vlc_object_t *p_this )
{ {
meta_engine_t *p_me = (meta_engine_t *)p_this; meta_engine_t *p_me = (meta_engine_t *)p_this;
input_item_t *p_item = p_me->p_item; 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 ) if( !i_ret )
{ {
...@@ -176,9 +177,9 @@ static int FindMetaMBId( vlc_object_t *p_this ) ...@@ -176,9 +177,9 @@ static int FindMetaMBId( vlc_object_t *p_this )
static int FindArt( vlc_object_t *p_this ) static int FindArt( vlc_object_t *p_this )
{ {
playlist_t *p_playlist; playlist_t *p_playlist = (playlist_t *)p_this;
input_item_t *p_item = (input_item_t *)p_playlist->p_private; input_item_t *p_item = (input_item_t *)(p_playlist->p_private);
assert( p_item ); 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 ) ...@@ -1047,7 +1047,6 @@ static bo_t *GetUdtaTag( sout_mux_t *p_mux )
} } } }
ADD_META_BOX( title, "nam" ); ADD_META_BOX( title, "nam" );
ADD_META_BOX( author, "aut" );
ADD_META_BOX( artist, "ART" ); ADD_META_BOX( artist, "ART" );
ADD_META_BOX( genre, "gen" ); ADD_META_BOX( genre, "gen" );
ADD_META_BOX( copyright, "cpy" ); ADD_META_BOX( copyright, "cpy" );
......
...@@ -2249,7 +2249,6 @@ static void InputMetaUser( input_thread_t *p_input ) ...@@ -2249,7 +2249,6 @@ static void InputMetaUser( input_thread_t *p_input )
free( val.psz_string ) free( val.psz_string )
GET_META( title, "meta-title" ); GET_META( title, "meta-title" );
GET_META( author, "meta-author" );
GET_META( artist, "meta-artist" ); GET_META( artist, "meta-artist" );
GET_META( genre, "meta-genre" ); GET_META( genre, "meta-genre" );
GET_META( copyright, "meta-copyright" ); GET_META( copyright, "meta-copyright" );
......
...@@ -102,10 +102,12 @@ int input_ArtFetch( playlist_t *p_playlist, input_item_t *p_item ) ...@@ -102,10 +102,12 @@ int input_ArtFetch( playlist_t *p_playlist, input_item_t *p_item )
if( !p_module ) if( !p_module )
{ {
msg_Dbg( p_playlist, "unable to find art" ); msg_Dbg( p_playlist, "unable to find art" );
PL_UNLOCK;
return VLC_EGENERIC; return VLC_EGENERIC;
} }
module_Unneed( p_playlist, p_module ); module_Unneed( p_playlist, p_module );
p_playlist->p_private = NULL; p_playlist->p_private = NULL;
PL_UNLOCK;
if( !p_item->p_meta->psz_arturl || !*p_item->p_meta->psz_arturl ) if( !p_item->p_meta->psz_arturl || !*p_item->p_meta->psz_arturl )
return VLC_EGENERIC; return VLC_EGENERIC;
...@@ -141,8 +143,6 @@ int input_FindArtInCache( playlist_t *p_playlist, input_item_t *p_item ) ...@@ -141,8 +143,6 @@ int input_FindArtInCache( playlist_t *p_playlist, input_item_t *p_item )
/* Check if file exists */ /* Check if file exists */
if( utf8_stat( psz_filename+7, &a ) == 0 ) 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 ); vlc_meta_SetArtURL( p_item->p_meta, psz_filename );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -211,7 +211,7 @@ int input_DownloadAndCacheArt( playlist_t *p_playlist, input_item_t *p_item ) ...@@ -211,7 +211,7 @@ int input_DownloadAndCacheArt( playlist_t *p_playlist, input_item_t *p_item )
free( p_buffer ); free( p_buffer );
fclose( p_file ); fclose( p_file );
stream_Delete( p_stream ); 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 ); free( p_item->p_meta->psz_arturl );
p_item->p_meta->psz_arturl = strdup( psz_filename ); p_item->p_meta->psz_arturl = strdup( psz_filename );
i_status = VLC_SUCCESS; i_status = VLC_SUCCESS;
...@@ -228,7 +228,6 @@ uint32_t input_CurrentMetaFlags( vlc_meta_t *p_meta ) ...@@ -228,7 +228,6 @@ uint32_t input_CurrentMetaFlags( vlc_meta_t *p_meta )
i_meta |= VLC_META_ENGINE_ ## b; i_meta |= VLC_META_ENGINE_ ## b;
CHECK( title, TITLE ) CHECK( title, TITLE )
CHECK( author, AUTHOR )
CHECK( artist, ARTIST ) CHECK( artist, ARTIST )
CHECK( genre, GENRE ) CHECK( genre, GENRE )
CHECK( copyright, COPYRIGHT ) CHECK( copyright, COPYRIGHT )
......
...@@ -565,14 +565,28 @@ void playlist_SecondaryPreparseLoop( playlist_secondary_preparse_t *p_obj ) ...@@ -565,14 +565,28 @@ void playlist_SecondaryPreparseLoop( playlist_secondary_preparse_t *p_obj )
{ {
input_MetaFetch( p_playlist, p_item ); input_MetaFetch( p_playlist, p_item );
p_item->p_meta->i_status |= ITEM_META_FETCHED; 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 else
{ {
input_ArtFetch( p_playlist, p_item ); input_ArtFetch( p_playlist, p_item );
p_item->p_meta->i_status |= ITEM_ART_FETCHED; p_item->p_meta->i_status |= ITEM_ART_FETCHED;
} vlc_gc_decref( p_item );
var_SetInteger( p_playlist, "item-change", p_item->i_id ); }
vlc_gc_decref( p_item );
} }
vlc_mutex_lock( &p_obj->object_lock ); vlc_mutex_lock( &p_obj->object_lock );
i_activity = var_GetInteger( p_playlist, "activity" ); i_activity = var_GetInteger( p_playlist, "activity" );
......
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