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;
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 ||
.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",
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
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,
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);
}