From: E.Smith <31170571+azlm8t@users.noreply.github.com> Date: Wed, 3 Oct 2018 09:13:24 +0000 (+0100) Subject: fanart: Add option to only lookup fanart for identifiable recordings. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1e7a1b5fa9dbeb7a01bd2e9de5071b3290e135bc;p=thirdparty%2Ftvheadend.git fanart: Add option to only lookup fanart for identifiable recordings. OTA broadcasts can have data that will fail a fanart lookup or is too vague so will match incorrect programmes. So add option so by default we ignore fanart for programmes without a year (for movie) or season/episode (for episode). --- diff --git a/src/dvr/dvr.h b/src/dvr/dvr.h index 665171b25..41763ef0f 100644 --- a/src/dvr/dvr.h +++ b/src/dvr/dvr.h @@ -95,6 +95,7 @@ typedef struct dvr_config { uint32_t dvr_cleanup_threshold_free; uint32_t dvr_cleanup_threshold_used; int dvr_fetch_artwork; + int dvr_fetch_artwork_allow_unknown; char *dvr_fetch_artwork_options; muxer_config_t dvr_muxcnf; @@ -519,6 +520,9 @@ static inline int dvr_entry_is_editable(dvr_entry_t *de) static inline int dvr_entry_is_valid(dvr_entry_t *de) { return de->de_refcnt > 0; } +/// Does the user want fanart lookup for this entry? +int dvr_entry_allow_fanart_lookup(const dvr_entry_t *de); + static inline int dvr_entry_is_completed_ok(dvr_entry_t *de) { assert(de->de_sched_state == DVR_COMPLETED); return de->de_last_error == SM_CODE_OK || diff --git a/src/dvr/dvr_config.c b/src/dvr/dvr_config.c index cec3efac7..ac9203c17 100644 --- a/src/dvr/dvr_config.c +++ b/src/dvr/dvr_config.c @@ -1005,6 +1005,22 @@ const idclass_t dvr_config_class = { .opts = PO_ADVANCED, .group = 8, }, + { + .type = PT_BOOL, + .id = "fetch-artwork-known-broadcasts-allow-unknown", + .name = N_("Fetch artwork for unidentifiable broadcasts."), + .desc = N_("Artwork fetching requires broadcasts to have good quality " + "information that uniquely identifies them, such as " + "year, season and episode. " + "Without this information, lookups will frequently fail " + "or return incorrect artwork. " + "The default is to only lookup fanart for broadcasts that " + "have high quality identifiable information. " + ), + .off = offsetof(dvr_config_t, dvr_fetch_artwork_allow_unknown), + .opts = PO_ADVANCED, + .group = 8, + }, { .type = PT_STR, .id = "fetch-artwork-options", diff --git a/src/dvr/dvr_db.c b/src/dvr/dvr_db.c index 3eeb94492..02a9174ed 100644 --- a/src/dvr/dvr_db.c +++ b/src/dvr/dvr_db.c @@ -761,6 +761,39 @@ dvr_usage_count(access_t *aa) return used; } +int +dvr_entry_allow_fanart_lookup(const dvr_entry_t *de) +{ + char ubuf[UUID_HEX_SIZE]; + + /* User doesn't want us to fetch artwork? */ + if (!de || !de->de_config || !de->de_config->dvr_fetch_artwork) + return 0; + + /* Entry already have artwork? So nothing to do */ + if (de->de_image && *de->de_image && + de->de_fanart_image && *de->de_fanart_image) + return 0; + + /* Allow any artwork even if we can't identify episode? */ + if (de->de_config->dvr_fetch_artwork_allow_unknown) + return 1; + + /* Only want 'good' episodes since ones with bad data will get + * bad artwork. Good episodes have a season/episode (assume + * episode) or year (assume movie). + */ + if (!de->de_epnum.s_num && !de->de_epnum.e_num && + !de->de_copyright_year) { + tvhdebug(LS_DVR, "Ignoring fanart for entry without good data for %s \"%s\"", + lang_str_get(de->de_title, NULL), + idnode_uuid_as_str(&de->de_id, ubuf)); + return 0; + } + + return 1; +} + /// Add the entry details to a list of fanart to prefetch. /// We then periodically check the list to update artwork. /// We don't do the check too frequently since most providers @@ -771,13 +804,8 @@ static void dvr_entry_fanart_add_to_prefetch(const dvr_entry_t *de) { char ubuf[UUID_HEX_SIZE]; - if (!de || !de->de_enabled) - return; - /* Nothing to do if we have images already */ - if (de->de_image && de->de_fanart_image) - return; - /* User doesn't want us to fetch artwork */ - if (de->de_config && !de->de_config->dvr_fetch_artwork) + + if (!dvr_entry_allow_fanart_lookup(de)) return; string_list_insert(dvr_fanart_to_prefetch, diff --git a/src/dvr/dvr_rec.c b/src/dvr/dvr_rec.c index 5dac2a628..54c861a43 100644 --- a/src/dvr/dvr_rec.c +++ b/src/dvr/dvr_rec.c @@ -61,26 +61,16 @@ static const int prio2weight[6] = { void dvr_spawn_fetch_artwork(dvr_entry_t *de) { - const dvr_config_t *cfg; /* Don't want to use _SC_ARG_MAX since it will be a large number */ char buf[1024]; char ubuf[UUID_HEX_SIZE]; - /* Entry already have artwork? So nothing to do */ - if (de->de_image && *de->de_image && - de->de_fanart_image && *de->de_fanart_image) - return; - - if (!de->de_config) - return; - - cfg = de->de_config; - if (!cfg->dvr_fetch_artwork) - return; + if (!dvr_entry_allow_fanart_lookup(de)) + return; snprintf(buf, sizeof buf, "tvhmeta --uuid %s %s", idnode_uuid_as_str(&de->de_id, ubuf), - cfg->dvr_fetch_artwork_options); + de->de_config->dvr_fetch_artwork_options); dvr_spawn_cmd(de, buf, NULL, 1); }