]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
dvr: Add tick box for fetching artwork.
authorE.Smith <31170571+azlm8t@users.noreply.github.com>
Sat, 29 Sep 2018 11:12:21 +0000 (12:12 +0100)
committerperexg <perex@perex.cz>
Tue, 2 Oct 2018 14:05:03 +0000 (16:05 +0200)
In Configuration->Recording->Digital Video Recorder Profiles there
is now a "fetch artwork for new recordings" button, and a place
to enter additional arguments (such as --tmdb-key).

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

index c27e042eb98e93f80ac03932e331a04abc8d46cf..7aa605cc0451a88fb81a395f63a528378dfa3a42 100644 (file)
@@ -94,6 +94,8 @@ typedef struct dvr_config {
   int dvr_running;
   uint32_t dvr_cleanup_threshold_free;
   uint32_t dvr_cleanup_threshold_used;
+  int dvr_fetch_artwork;
+  char *dvr_fetch_artwork_options;
 
   muxer_config_t dvr_muxcnf;
 
index 40ea624018c3ddfdd1cfce7ace53eb18191a3e69..cec3efac7d0408b88878b9277740b5564be71da9 100644 (file)
@@ -852,6 +852,11 @@ const idclass_t dvr_config_class = {
          .name   = N_("Miscellaneous Settings"),
          .number = 7,
       },
+      {
+         .name   = N_("Artwork Settings"),
+         .number = 8,
+         .column = 1,
+      },
       {}
   },
   .ic_properties = (const property_t[]){
@@ -989,6 +994,27 @@ const idclass_t dvr_config_class = {
       .opts     = PO_ADVANCED,
       .group    = 1,
     },
+    {
+      .type     = PT_BOOL,
+      .id       = "fetch-artwork",
+      .name     = N_("Fetch artwork for new recordings."),
+      .desc     = N_("Fetch additional artwork from installed providers. "
+                     "Tvheadend has a 'tmdb' provider for movies, which requires "
+                     "you to specify your authorized 'tmdb key' in the options below."),
+      .off      = offsetof(dvr_config_t, dvr_fetch_artwork),
+      .opts     = PO_ADVANCED,
+      .group    = 8,
+    },
+    {
+      .type     = PT_STR,
+      .id       = "fetch-artwork-options",
+      .name     = N_("Additional command line options when fetching artwork for new recordings."),
+      .desc     = N_("Some artwork providers require additional arguments such as "
+                     "'--tmdb-key my_key_from_website'. These can be specified here."),
+      .off      = offsetof(dvr_config_t, dvr_fetch_artwork_options),
+      .opts     = PO_ADVANCED,
+      .group    = 8,
+    },
     {
       .type     = PT_STR,
       .id       = "comment",
index 99591ceda6815912bc2d615481157b56fe898892..71e93a0004931df3ea86236161894c935be6f322 100644 (file)
@@ -57,6 +57,33 @@ static const int prio2weight[6] = {
   [DVR_PRIO_NOTSET]      = 300, /* DVR_PRIO_NORMAL */
 };
 
+/// Spawn a fetch of artwork for the entry.
+static 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;
+
+  snprintf(buf, sizeof buf, "tvhmeta --uuid %s %s",
+           idnode_uuid_as_str(&de->de_id, ubuf),
+           cfg->dvr_fetch_artwork_options);
+  dvr_spawn_cmd(de, buf, NULL, 1);
+}
+
 /**
  *
  */
@@ -154,6 +181,8 @@ dvr_rec_subscribe(dvr_entry_t *de)
 
   if (de->de_config->dvr_preproc)
     dvr_spawn_cmd(de, de->de_config->dvr_preproc, NULL, 1);
+  if (de->de_config->dvr_fetch_artwork)
+    dvr_spawn_fetch_artwork(de);
   return 0;
 }