From: E.Smith <31170571+azlm8t@users.noreply.github.com> Date: Sat, 29 Sep 2018 11:12:21 +0000 (+0100) Subject: dvr: Add tick box for fetching artwork. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9eb7adaae33e74de902074e7f03a819a9412c6c8;p=thirdparty%2Ftvheadend.git dvr: Add tick box for fetching artwork. 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). --- diff --git a/src/dvr/dvr.h b/src/dvr/dvr.h index c27e042eb..7aa605cc0 100644 --- a/src/dvr/dvr.h +++ b/src/dvr/dvr.h @@ -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; diff --git a/src/dvr/dvr_config.c b/src/dvr/dvr_config.c index 40ea62401..cec3efac7 100644 --- a/src/dvr/dvr_config.c +++ b/src/dvr/dvr_config.c @@ -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", diff --git a/src/dvr/dvr_rec.c b/src/dvr/dvr_rec.c index 99591ceda..71e93a000 100644 --- a/src/dvr/dvr_rec.c +++ b/src/dvr/dvr_rec.c @@ -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; }