[grilo-plugins] local-metadata: Rework may_resolve
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo-plugins] local-metadata: Rework may_resolve
- Date: Fri, 13 Apr 2012 14:41:56 +0000 (UTC)
commit 4ab76a9eaad0ca1f4b4f6143f70b066d4d134042
Author: Bastien Nocera <hadess hadess net>
Date: Wed Apr 11 17:49:17 2012 +0100
local-metadata: Rework may_resolve
To be understandable by normal humans, and require the URL only if the
title isn't usable, or require the title if the URL isn't usable.
https://bugzilla.gnome.org/show_bug.cgi?id=673916
src/metadata/local-metadata/grl-local-metadata.c | 56 ++++++++++++++-------
1 files changed, 37 insertions(+), 19 deletions(-)
---
diff --git a/src/metadata/local-metadata/grl-local-metadata.c b/src/metadata/local-metadata/grl-local-metadata.c
index 6a7e1a6..096e286 100644
--- a/src/metadata/local-metadata/grl-local-metadata.c
+++ b/src/metadata/local-metadata/grl-local-metadata.c
@@ -902,30 +902,48 @@ grl_local_metadata_source_may_resolve (GrlMetadataSource *source,
return FALSE;
}
- /* IMAGE || VIDEO case */
- if (media && grl_data_has_key (GRL_DATA (media),
- GRL_METADATA_KEY_URL)) {
- if (GRL_IS_MEDIA_IMAGE (media)) {
- if (has_compatible_media_url (media) &&
- (key_id == GRL_METADATA_KEY_THUMBNAIL))
+ if (GRL_IS_MEDIA_IMAGE (media)) {
+ if (key_id != GRL_METADATA_KEY_THUMBNAIL)
+ return FALSE;
+ if (!grl_data_has_key (GRL_DATA (media), GRL_METADATA_KEY_URL))
+ goto missing_url;
+ if (!has_compatible_media_url (media))
+ return FALSE;
+ return TRUE;
+ }
+
+ if (GRL_IS_MEDIA_VIDEO (media)) {
+ switch (key_id) {
+ case GRL_METADATA_KEY_TITLE:
+ case GRL_METADATA_KEY_SHOW:
+ case GRL_METADATA_KEY_PUBLICATION_DATE:
+ case GRL_METADATA_KEY_SEASON:
+ case GRL_METADATA_KEY_EPISODE:
+ if (!priv->guess_video)
+ return FALSE;
+ if (grl_data_has_key (GRL_DATA (media), GRL_METADATA_KEY_URL) &&
+ has_compatible_media_url (media))
return TRUE;
+ if (!grl_data_has_key (GRL_DATA (media), GRL_METADATA_KEY_TITLE))
+ goto missing_title;
+ return TRUE;
+ case GRL_METADATA_KEY_THUMBNAIL:
+ if (grl_data_has_key (GRL_DATA (media), GRL_METADATA_KEY_URL) == FALSE)
+ goto missing_url;
+ return has_compatible_media_url (media);
}
+ }
- if (GRL_IS_MEDIA_VIDEO (media)) {
- if (priv->guess_video &&
- (key_id == GRL_METADATA_KEY_TITLE ||
- key_id == GRL_METADATA_KEY_SHOW ||
- key_id == GRL_METADATA_KEY_PUBLICATION_DATE ||
- key_id == GRL_METADATA_KEY_SEASON ||
- key_id == GRL_METADATA_KEY_EPISODE))
- return TRUE;
- if (has_compatible_media_url (media)) {
- if (key_id == GRL_METADATA_KEY_THUMBNAIL)
- return TRUE;
- }
- }
+missing_title:
+ if (missing_keys) {
+ if (grl_data_has_key (GRL_DATA (media), GRL_METADATA_KEY_URL) == FALSE)
+ *missing_keys = grl_metadata_key_list_new (GRL_METADATA_KEY_TITLE, GRL_METADATA_KEY_URL, NULL);
+ else
+ *missing_keys = grl_metadata_key_list_new (GRL_METADATA_KEY_TITLE, NULL);
}
+ return FALSE;
+missing_url:
if (missing_keys)
*missing_keys = grl_metadata_key_list_new (GRL_METADATA_KEY_URL, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]