]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
fanart: Add option to only lookup fanart for identifiable recordings.
authorE.Smith <31170571+azlm8t@users.noreply.github.com>
Wed, 3 Oct 2018 09:13:24 +0000 (10:13 +0100)
committerJaroslav Kysela <perex@perex.cz>
Mon, 8 Oct 2018 12:01:16 +0000 (14:01 +0200)
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).

src/dvr/dvr.h
src/dvr/dvr_config.c
src/dvr/dvr_db.c
src/dvr/dvr_rec.c

index 665171b2583cb16a6ab065a97f5c0b816b8e8dbd..41763ef0fcfcdf9fa8d08c96c1071f6a10003873 100644 (file)
@@ -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 ||
index cec3efac7d0408b88878b9277740b5564be71da9..ac9203c17bebf580fc17d02eacbe510882a0b061 100644 (file)
@@ -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",
index 3eeb94492ff0feec9817253b1f26a323f09efe0c..02a9174edf1b80ee84b2d590175f6a6975bb678a 100644 (file)
@@ -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,
index 5dac2a628486b57a2521254702972c0b09ab0921..54c861a43cea60d701577d8edf6b65a50a333a53 100644 (file)
@@ -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);
 }