]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
xmltv: Only log "new episode" if episode has been created. (#4803).
authorE.Smith <31170571+azlm8t@users.noreply.github.com>
Wed, 13 Dec 2017 14:53:26 +0000 (14:53 +0000)
committerJaroslav Kysela <perex@perex.cz>
Tue, 19 Dec 2017 20:45:59 +0000 (21:45 +0100)
The "save" flag is always set so we now also check the changes flag to
see if the entry was actually created.

Issue: #4803.

src/epggrab/module/xmltv.c

index f2b17aaa62a2f89b2a27139e07403f72ae9ffcba..79ee93ce67495715c971e38913a052d4adb9f5c6 100644 (file)
@@ -630,7 +630,7 @@ static int _xmltv_parse_programme_tags
   if (!(ebc = epg_broadcast_find_by_time(ch, mod, start, stop, 1, &save, &changes)))
     return 0;
   stats->broadcasts.total++;
-  if (save) stats->broadcasts.created++;
+  if (save && changes & EPG_CHANGED_CREATE) stats->broadcasts.created++;
 
   /* Description (wait for episode first) */
   _xmltv_parse_lang_str(&desc, tags, "desc");
@@ -727,7 +727,7 @@ static int _xmltv_parse_programme_tags
     }
     free(suri);
     if (es) stats->seasons.total++;
-    if (save2) stats->seasons.created++;
+    if (save2 && changes2 & EPG_CHANGED_CREATE) stats->seasons.created++;
   }
 
   /*
@@ -742,7 +742,11 @@ static int _xmltv_parse_programme_tags
   }
   save |= epg_broadcast_set_episode(ebc, ee, &changes);
   if (ee)    stats->episodes.total++;
-  if (save3) stats->episodes.created++;
+  /* save3 is always set by epg_episode_find_by_uri call to
+   * _epg_object_set_grabber so need to also check for
+   * EPG_CHANGED_CREATE.
+   */
+  if (save3 && changes3 & EPG_CHANGED_CREATE) stats->episodes.created++;
 
   if (ee) {
     _xmltv_parse_lang_str(&title, tags, "title");
@@ -780,9 +784,16 @@ static int _xmltv_parse_programme_tags
   save |= epg_broadcast_change_finish(ebc, changes, 0);
 
   /* Stats */
-  if (save)  stats->broadcasts.modified++;
-  if (save2) stats->seasons.modified++;
-  if (save3) stats->episodes.modified++;
+  /* The "changes" variable actually track all fields that
+   * exist in the message rather than ones explicitly modified.
+   * So a file that contained "title a" and replayed a day later
+   * and still says "title a" will be reported as modified since
+   * the field exists in the message. This then means that the
+   * "save" variable then indicate the record was modified.
+   */
+  if (save &&  !(changes  & EPG_CHANGED_CREATE))  stats->broadcasts.modified++;
+  if (save2 && !(changes2 & EPG_CHANGED_CREATE))  stats->seasons.modified++;
+  if (save3 && !(changes3 && EPG_CHANGED_CREATE)) stats->episodes.modified++;
 
   /* Cleanup */
   if (title)    lang_str_destroy(title);