]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
dvr: Add minyear/maxyear to autorec.
authorE.Smith <31170571+azlm8t@users.noreply.github.com>
Tue, 18 Sep 2018 22:34:04 +0000 (23:34 +0100)
committerJaroslav Kysela <perex@perex.cz>
Thu, 20 Sep 2018 12:33:46 +0000 (14:33 +0200)
My listings provider thinks every old film is worth 5/5, so we add
minyear to allow an autorec of "good films" to filter out old
films. Also add corresponding maxyear for people who think the
opposite and only want old programmes recorded.

src/dvr/dvr.h
src/dvr/dvr_autorec.c
src/webui/static/app/dvr.js

index 596c9845bffa3c438fcfee4425e839179520c332..5e0967933c15aa482deaa622e243ecb8c9b865ca 100644 (file)
@@ -402,6 +402,8 @@ typedef struct dvr_autorec_entry {
 
   int dae_minduration;
   int dae_maxduration;
+  int dae_minyear;
+  int dae_maxyear;
   uint32_t dae_retention;
   uint32_t dae_removal;
   uint32_t dae_btype;
index 17413b422737bd8a2f957eca9435a7b88a1ccc9d..c8fe54f4e3824466830118dc0852a888f1d880ce 100644 (file)
@@ -164,6 +164,8 @@ autorec_cmp(dvr_autorec_entry_t *dae, epg_broadcast_t *e)
      (dae->dae_cat3 == NULL || *dae->dae_cat3 == 0) &&
      dae->dae_minduration <= 0 &&
      (dae->dae_maxduration <= 0 || dae->dae_maxduration > 24 * 3600) &&
+     dae->dae_minyear <= 0 &&
+     dae->dae_maxyear <= 0 &&
      dae->dae_serieslink_uri == NULL)
     return 0; // Avoid super wildcard match
 
@@ -260,6 +262,14 @@ autorec_cmp(dvr_autorec_entry_t *dae, epg_broadcast_t *e)
     if(duration > dae->dae_maxduration) return 0;
   }
 
+  if(dae->dae_minyear > 0) {
+    if(e->copyright_year < dae->dae_minyear) return 0;
+  }
+
+  if(dae->dae_maxyear > 0) {
+    if(e->copyright_year > dae->dae_maxyear) return 0;
+  }
+
   if(dae->dae_weekdays != 0x7f) {
     struct tm tm;
     localtime_r(&e->start, &tm);
@@ -892,6 +902,29 @@ dvr_autorec_entry_class_star_rating_list ( void *o, const char *lang )
   return m;
 }
 
+/** Generate a year list to make it easier to select min/max year */
+static htsmsg_t *
+dvr_autorec_entry_class_year_list ( void *o, const char *lang )
+{
+  htsmsg_t *m = htsmsg_create_list();
+  htsmsg_t *e = htsmsg_create_map();
+  htsmsg_add_u32(e, "key", 0);
+  htsmsg_add_str(e, "val", tvh_gettext_lang(lang, N_("Any")));
+  htsmsg_add_msg(m, NULL, e);
+
+  uint32_t i;
+  /* We create the list from highest to lowest since you're more
+   * likely to want to record something recent.
+   */
+  for (i = 2020; i > 1900 ; i-=5) {
+    e = htsmsg_create_map();
+    htsmsg_add_u32(e, "key", i);
+    htsmsg_add_u32(e, "val", i);
+    htsmsg_add_msg(m, NULL, e);
+  }
+  return m;
+}
+
 static htsmsg_t *
 dvr_autorec_entry_class_content_type_list(void *o, const char *lang)
 {
@@ -1208,6 +1241,24 @@ const idclass_t dvr_autorec_entry_class = {
       .off      = offsetof(dvr_autorec_entry_t, dae_maxduration),
       .opts     = PO_EXPERT | PO_DOC_NLIST,
     },
+    {
+      .type     = PT_U32,
+      .id       = "minyear",
+      .name     = N_("Minimum year"),
+      .desc     = N_("The earliest year for the programme. Programmes must be equal to or later than this year."),
+      .list     = dvr_autorec_entry_class_year_list,
+      .off      = offsetof(dvr_autorec_entry_t, dae_minyear),
+      .opts     = PO_EXPERT | PO_DOC_NLIST,
+    },
+    {
+      .type     = PT_U32,
+      .id       = "maxyear",
+      .name     = N_("Maximum year"),
+      .desc     = N_("The latest year for the programme. Programmes must be equal to or earlier than this year."),
+      .list     = dvr_autorec_entry_class_year_list,
+      .off      = offsetof(dvr_autorec_entry_t, dae_maxyear),
+      .opts     = PO_EXPERT | PO_DOC_NLIST,
+    },
     {
       .type     = PT_U32,
       .id       = "pri",
index 7a623658b62e8f8dffa4558933e9a12701d43dc2..aca6dc51c6fa5a9ace6f650f0f1e4251181d8ea0 100644 (file)
@@ -900,7 +900,7 @@ tvheadend.dvr_settings = function(panel, index) {
 tvheadend.autorec_editor = function(panel, index) {
 
     var list = 'name,title,fulltext,channel,start,start_window,weekdays,' +
-               'record,tag,btype,content_type,cat1,cat2,cat3,minduration,maxduration,' +
+               'record,tag,btype,content_type,cat1,cat2,cat3,minduration,maxduration,minyear,maxyear,' +
                'star_rating,dedup,directory,config_name,comment,pri';
     var elist = 'enabled,start_extra,stop_extra,' +
                 (tvheadend.accessUpdate.admin ?