[vlc-commits] preparser: fix cover mismatch with albums having the same name
Thomas Guillem
git at videolan.org
Mon Aug 26 09:29:43 CEST 2019
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Aug 22 11:35:50 2019 +0200| [f6b2e629a79374a1185cae18e77be3624d7b8d79] | committer: Thomas Guillem
preparser: fix cover mismatch with albums having the same name
Yes, some artists can have multiple albums with the same name, cf.
https://www.discogs.com/fr/artist/700759-The-Spits?filter_anv=0&subtype=Albums&type=Releases
This doesn't solve the problem if such artists produce more than one album per
year.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f6b2e629a79374a1185cae18e77be3624d7b8d79
---
src/preparser/art.c | 20 +++++++++++++++-----
src/preparser/fetcher.c | 6 ++++--
2 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/src/preparser/art.c b/src/preparser/art.c
index ad4b677d52..f7dabbd725 100644
--- a/src/preparser/art.c
+++ b/src/preparser/art.c
@@ -58,7 +58,8 @@ static void ArtCacheCreateDir( const char *psz_dir )
}
static char* ArtCacheGetDirPath( const char *psz_arturl, const char *psz_artist,
- const char *psz_album, const char *psz_title )
+ const char *psz_album, const char *psz_date,
+ const char *psz_title )
{
char *psz_dir;
char *psz_cachedir = config_GetUserDir(VLC_CACHE_DIR);
@@ -81,12 +82,20 @@ static char* ArtCacheGetDirPath( const char *psz_arturl, const char *psz_artist,
return NULL;
}
filename_sanitize( psz_artist_sanitized );
+
+ char *psz_date_sanitized = !EMPTY_STR(psz_date) ? strdup( psz_date ) : NULL;
+ if (psz_date_sanitized)
+ filename_sanitize(psz_date_sanitized);
+
if( asprintf( &psz_dir, "%s" DIR_SEP "art" DIR_SEP "artistalbum"
- DIR_SEP "%s" DIR_SEP "%s", psz_cachedir,
- psz_artist_sanitized, psz_album_sanitized ) == -1 )
+ DIR_SEP "%s" DIR_SEP "%s" DIR_SEP "%s", psz_cachedir,
+ psz_artist_sanitized,
+ psz_date_sanitized ? psz_date_sanitized : "0000",
+ psz_album_sanitized ) == -1 )
psz_dir = NULL;
free( psz_album_sanitized );
free( psz_artist_sanitized );
+ free( psz_date_sanitized );
}
else
{
@@ -121,6 +130,7 @@ static char *ArtCachePath( input_item_t *p_item )
const char *psz_album;
const char *psz_arturl;
const char *psz_title;
+ const char *psz_date;
vlc_mutex_lock( &p_item->lock );
@@ -133,14 +143,14 @@ static char *ArtCachePath( input_item_t *p_item )
psz_album = vlc_meta_Get( p_item->p_meta, vlc_meta_Album );
psz_arturl = vlc_meta_Get( p_item->p_meta, vlc_meta_ArtworkURL );
psz_title = vlc_meta_Get( p_item->p_meta, vlc_meta_Title );
+ psz_date = vlc_meta_Get( p_item->p_meta, vlc_meta_Date );
if( !psz_title )
psz_title = p_item->psz_name;
-
if( (EMPTY_STR(psz_artist) || EMPTY_STR(psz_album) ) && !psz_arturl )
goto end;
- psz_path = ArtCacheGetDirPath( psz_arturl, psz_artist, psz_album, psz_title );
+ psz_path = ArtCacheGetDirPath( psz_arturl, psz_artist, psz_album, psz_date, psz_title );
end:
vlc_mutex_unlock( &p_item->lock );
diff --git a/src/preparser/fetcher.c b/src/preparser/fetcher.c
index 14dcaab8ba..a49090c2fe 100644
--- a/src/preparser/fetcher.c
+++ b/src/preparser/fetcher.c
@@ -81,14 +81,16 @@ static char* CreateCacheKey( input_item_t* item )
char const* artist = vlc_meta_Get( item->p_meta, vlc_meta_Artist );
char const* album = vlc_meta_Get( item->p_meta, vlc_meta_Album );
+ char const *date = vlc_meta_Get( item->p_meta, vlc_meta_Date );
char* key;
/**
* Simple concatenation of artist and album can lead to the same key
* for entities that should not have such. Imagine { dogs, tick } and
* { dog, stick } */
- if( !artist || !album || asprintf( &key, "%s:%zu:%s:%zu",
- artist, strlen( artist ), album, strlen( album ) ) < 0 )
+ if( !artist || !album || asprintf( &key, "%s:%zu:%s:%zu:%s",
+ artist, strlen( artist ), album, strlen( album ),
+ date ? date : "0000" ) < 0 )
{
key = NULL;
}
More information about the vlc-commits
mailing list