summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2015-07-16 11:37:45 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2015-07-17 16:47:21 +0100
commit42a939111800a51df0ef73dab0e2b3e39ad43396 (patch)
treedf64e0d27925efd94595e6cd5291d61de281e786 /src
parent60417240a6464d5f640f5bba35d453f22cb12967 (diff)
downloadgrilo-plugins-42a939111800a51df0ef73dab0e2b3e39ad43396.tar.gz
local-metadata: try per-track XDG thumbnails before per-album media art
Some XDG thumbnailers (including at least Tumbler and Totem's thumbnailer) are able to extract embedded art from media files and cache it in XDG_CACHE_HOME/thumbnails, just like they would for images and videos. In some cases the thumbnailer might support embedded art even when the libmediaart extractor (in my case tracker-extract) does not. If this embedded art exists, it is likely to be a better match for the track than the album art would be: for instance, http://freemusicarchive.org/music/Nine_Inch_Nails/The_Slip/ has a distinct piece of artwork embedded in each track, none of which match the album cover. Accordingly, I'm trying the thumbnail before falling back to libmediaart, not the other way round. Using the thumbnailer's interpretation of the correct per-track thumbnail also has the benefit that the track is guaranteed to look the same in a Grilo application as it does in a general-purpose file manager, whereas with libmediaart it is possible that the thumbnailer and the libmediaart extractor might choose different images in corner cases. In principle, https://wiki.gnome.org/DraftSpecs/MediaArtStorageSpec supports per-track artwork, which libmediaart could process and store; the specification recommends treating embedded art as the highest possible priority. However, in practice libmediaart does not currently do this. Bug: https://bugzilla.gnome.org/show_bug.cgi?id=752437
Diffstat (limited to 'src')
-rw-r--r--src/local-metadata/grl-local-metadata.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/local-metadata/grl-local-metadata.c b/src/local-metadata/grl-local-metadata.c
index bcba507..9707ba8 100644
--- a/src/local-metadata/grl-local-metadata.c
+++ b/src/local-metadata/grl-local-metadata.c
@@ -632,6 +632,9 @@ extract_gibest_hash_async (ResolveData *resolve_data,
g_task_run_in_thread (task, extract_gibest_hash);
}
+static void resolve_album_art (ResolveData *resolve_data,
+ resolution_flags_t flags);
+
static void
got_file_info (GFile *file,
GAsyncResult *result,
@@ -645,6 +648,7 @@ got_file_info (GFile *file,
GrlLocalMetadataSourcePriv *priv;
ResolveData *resolve_data = user_data;
GrlSourceResolveSpec *rs = resolve_data->rs;
+ resolution_flags_t flags;
GRL_DEBUG ("got_file_info");
@@ -683,7 +687,16 @@ got_file_info (GFile *file,
grl_media_get_url (rs->media));
}
- if (get_resolution_flags (rs->keys, priv) & FLAG_GIBEST_HASH) {
+ flags = get_resolution_flags (rs->keys, priv);
+
+ if (GRL_IS_MEDIA_AUDIO (rs->media) &&
+ !(thumbnail_path && thumbnail_is_valid)) {
+ /* We couldn't get a per-track thumbnail; try for a per-album one,
+ * using libmediaart */
+ resolve_album_art (resolve_data, flags);
+ }
+
+ if (flags & FLAG_GIBEST_HASH) {
extract_gibest_hash_async (resolve_data, file, cancellable);
} else {
resolve_data_finish_operation (resolve_data, "image", NULL);
@@ -1186,7 +1199,9 @@ grl_local_metadata_source_resolve (GrlSource *source,
} else if (GRL_IS_MEDIA_IMAGE (rs->media)) {
resolve_image (data, flags);
} else if (GRL_IS_MEDIA_AUDIO (rs->media)) {
- resolve_album_art (data, flags);
+ /* Try for a per-track thumbnail first; we'll fall back to album art
+ * if the track doesn't have one */
+ resolve_image (data, flags);
}
/* Finish the overall operation (this might not call the callback if there