]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
DVR: autorec - implement record per month, fixes #4216
authorJaroslav Kysela <perex@perex.cz>
Wed, 8 Feb 2017 12:47:55 +0000 (13:47 +0100)
committerJaroslav Kysela <perex@perex.cz>
Wed, 8 Feb 2017 12:47:55 +0000 (13:47 +0100)
src/dvr/dvr.h
src/dvr/dvr_db.c

index 987f95893d5f575c9023a3ab1617b95308667e2d..c802512612f0cc5e0c447a095a4beb327c915d8b 100644 (file)
@@ -299,14 +299,17 @@ typedef enum {
   DVR_AUTOREC_RECORD_DIFFERENT_EPISODE_NUMBER = 1,
   DVR_AUTOREC_RECORD_DIFFERENT_SUBTITLE = 2,
   DVR_AUTOREC_RECORD_DIFFERENT_DESCRIPTION = 3,
+  DVR_AUTOREC_RECORD_ONCE_PER_MONTH = 12,
   DVR_AUTOREC_RECORD_ONCE_PER_WEEK = 4,
   DVR_AUTOREC_RECORD_ONCE_PER_DAY = 5,
   DVR_AUTOREC_LRECORD_DIFFERENT_EPISODE_NUMBER = 6,
   DVR_AUTOREC_LRECORD_DIFFERENT_TITLE = 7,
   DVR_AUTOREC_LRECORD_DIFFERENT_SUBTITLE = 8,
   DVR_AUTOREC_LRECORD_DIFFERENT_DESCRIPTION = 9,
+  DVR_AUTOREC_LRECORD_ONCE_PER_MONTH = 13,
   DVR_AUTOREC_LRECORD_ONCE_PER_WEEK = 10,
   DVR_AUTOREC_LRECORD_ONCE_PER_DAY = 11,
+  /* last free value == 14 */
 } dvr_autorec_dedup_t;
 
 typedef enum {
index a1a7be0fc036f9e8aafbc101c8d2c8af131eac7b..ffa16062d5edc25023b44dbafdaee9d21bd36ea2 100644 (file)
@@ -1240,6 +1240,19 @@ static int _dvr_duplicate_desc(dvr_entry_t *de, dvr_entry_t *de2, void **aux)
   return !lang_str_compare(de->de_desc, de2->de_desc);
 }
 
+static int _dvr_duplicate_per_month(dvr_entry_t *de, dvr_entry_t *de2, void **aux)
+{
+  struct tm *de1_start = *aux, de2_start;
+  if (de1_start == NULL) {
+    de1_start = calloc(1, sizeof(*de1_start));
+    localtime_r(&de->de_start, de1_start);
+    *aux = de1_start;
+  }
+  localtime_r(&de2->de_start, &de2_start);
+  return de1_start->tm_year == de2_start.tm_year &&
+         de1_start->tm_mon == de2_start.tm_mon;
+}
+
 static int _dvr_duplicate_per_week(dvr_entry_t *de, dvr_entry_t *de2, void **aux)
 {
   struct tm *de1_start = *aux, de2_start;
@@ -1283,6 +1296,8 @@ static dvr_entry_t *_dvr_duplicate_event(dvr_entry_t *de)
     [DVR_AUTOREC_LRECORD_DIFFERENT_SUBTITLE]       = _dvr_duplicate_subtitle,
     [DVR_AUTOREC_RECORD_DIFFERENT_DESCRIPTION]     = _dvr_duplicate_desc,
     [DVR_AUTOREC_LRECORD_DIFFERENT_DESCRIPTION]    = _dvr_duplicate_desc,
+    [DVR_AUTOREC_RECORD_ONCE_PER_MONTH]            = _dvr_duplicate_per_month,
+    [DVR_AUTOREC_LRECORD_ONCE_PER_MONTH]           = _dvr_duplicate_per_month,
     [DVR_AUTOREC_RECORD_ONCE_PER_WEEK]             = _dvr_duplicate_per_week,
     [DVR_AUTOREC_LRECORD_ONCE_PER_WEEK]            = _dvr_duplicate_per_week,
     [DVR_AUTOREC_RECORD_ONCE_PER_DAY]              = _dvr_duplicate_per_day,