Project

General

Profile

Feature #4052

More information for Autorec in DVR recordings.

Added by Joe User about 8 years ago. Updated about 5 years ago.

Status:
Fixed
Priority:
Normal
Assignee:
-
Category:
User Interface
Target version:
Start date:
2016-10-28
Due date:
% Done:

0%

Estimated time:

Description

I recently was looking at my upcoming recordings and I found 4 recordings that should not be there. They all show:

Status:Scheduled for recording
Comment:Auto recording: Created from EPG query
Autorec: (Created from EPG query)

Almost all of my scheduled recordings are created from about 30 autorec entries. All of the autorec entries were created through the EPG (hence the auto generated comment.) But aside form going back and manually changing the comment for each autorec, how do I know which autorec rule each scheduled recording is from? Normally it is obvious because the scheduled recording is what I want (correct title) but in the case of ones that are incorrect, there is no way of knowing which autorec created the scheduled recording.

Maybe you can add the title from the autorec entry to the information of the scheduled recording to make it easier to track down? Or maybe when creating an autorec from the EPG, include the title in the comment (ie - "Created from EPG query - Title") - then it would propagate to the scheduled recordings. (and finished/failed/etc recordings)

BTW - I can see if I search the dvr log directory for the scheduled recording, the file shows the id of the autorec from which it was generated, but it would be much easier to be able to do it from the web interface.

For now I just made a quick script to append the title to the comment in each autorec...

#!/bin/bash

cp -rp autorec autorec.sv

for file in autorec.sv/*
do
    fname=$(basename "$file")
    jq '.comment = .comment + " - " + .title' $file > autorec/$fname
done

History

#1

Updated by Em Smith over 7 years ago

This patch will alter the GUI so that the title will be appended to the autorec comment for new autorecs. We could also include other information (channel, duration) but we might then end up with really long strings that provide too much information.

diff --git a/src/webui/static/app/epg.js b/src/webui/static/app/epg.js
index a9389eba4..57aadda53 100644
--- a/src/webui/static/app/epg.js
+++ b/src/webui/static/app/epg.js
@@ -1084,7 +1084,12 @@ tvheadend.epg = function() {
           enabled: 1,
           comment: _('Created from EPG query')
         };
-        if (params.title) conf.title = params.title;
+        if (params.title) {
+          conf.title = params.title;
+          // Amend comment to include the title to make it easier for
+          // user to match autorecs against finished recorded.
+          conf.comment += _(' - ') + conf.title;
+        }
         if (params.fulltext) conf.fulltext = params.fulltext;
         if (params.channel) conf.channel = params.channel;
         if (params.channelTag) conf.tag = params.channelTag;

It could be argued that the GUI presentation should generate this info when displaying rather than pushing it to the server, but saving it in the comment field ensures it propagates nicely.

#2

Updated by Joe User over 7 years ago

Thanks I will give it a try.

#3

Updated by Joe User almost 6 years ago

I forgot to update this. Your change worked, but only when highlighting an entry and using the "Create AutoRec" button at the top. If you open (Details) an EPG entry and use the "Autorec" button at the bottom of the pop-up, it is created in a different way. What I am now using is this:

diff --git a/src/api/api_dvr.c b/src/api/api_dvr.c
index 767371f00..b96503dad 100644
--- a/src/api/api_dvr.c
+++ b/src/api/api_dvr.c
@@ -465,6 +465,9 @@ api_dvr_autorec_create_by_series
   const char *config_uuid, *s;
   int count = 0;
   char ubuf[UUID_HEX_SIZE];
+  char *title;
+  const char * msg = " - Created from EPG query";
+  char comment[256];

   if (!(entries = htsmsg_get_list(args, "entries"))) {
     entries = entries2 = api_dvr_entry_create_from_single(args);
@@ -484,11 +487,14 @@ api_dvr_autorec_create_by_series
     if ((e = epg_broadcast_find_by_id(strtoll(s, NULL, 10)))) {
       dvr_config_t *cfg = dvr_config_find_by_list(perm->aa_dvrcfgs, config_uuid);
       if (cfg) {
+    title = regexp_escape(epg_broadcast_get_title(e, NULL));
+    strcpy(comment,title);
+    strcat(comment,msg);
         dae = dvr_autorec_add_series_link(idnode_uuid_as_str(&cfg->dvr_id, ubuf),
                                           e,
                                           perm->aa_username,
                                           perm->aa_representative,
-                                          "Created from EPG query");
+                                          comment);
         if (dae) {
           if (l == NULL)
             l = htsmsg_create_list();

diff --git a/src/webui/static/app/epg.js b/src/webui/static/app/epg.js
index 57a14aa88..8fdde3a7e 100644
--- a/src/webui/static/app/epg.js
+++ b/src/webui/static/app/epg.js
@@ -1473,7 +1473,12 @@ tvheadend.epg = function() {
           enabled: 1,
           comment: _('Created from EPG query')
         };
-        if (params.title) conf.title = params.title;
+        if (params.title) {
+      conf.title = params.title;
+          // Amend comment to include the title to make it easier for
+      // user to match autorecs against finished recorded.
+          conf.comment = conf.title + _(' - ') + conf.comment;
+        }
         if (params.fulltext) conf.fulltext = params.fulltext;
         if (params.new) conf.btype = 3; // DVR_AUTOREC_BTYPE_NEW in dvr.h has value 3.
         if (params.channel) conf.channel = params.channel;


Might need some error check (null string?) and I wasn't sure how big to make "comment256".

Note, I changed it so the "title" is first, which makes it more readable and allows for better sorting.

#4

Updated by Em Smith almost 6 years ago

I'm not sure how big either. Checking imdb database, the maximum title length is 408 characters (seems like direct to video), but it's difficult to find "good" maximum lengths for proper programmes. There are "tv shorts" and movies in imdb such as tt1840920 (221 chars) and tt8682654 (242 chars), but that just seems like things that would never be on tv. Longest tv series title is 134 characters, so we should be fine.

If you use "tvh_strlcatf" (there are a couple of examples in the code), then the buffer won't overflow.

From "10 Commandments of C":

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.

:)

Can you submit a GitHub patch?

#5

Updated by Em Smith almost 6 years ago

Just noticed, you need to free(title) at the end since it gets allocated by the escape. Though, I don't know if you need the escape at all. That's mainly for titles that have "." or "?" in their title, so I think you can remove that, then you don't need a free.

If you don't want to tvh_strlcatf, you could use alloca for the buffer since you know the size (char *comment=alloca(strlen(title) + strlen(msg) + 1), no need to free at end) and then just do the strcpy/strcat.

Hope that seems ok?

#6

Updated by Joe User almost 6 years ago

I only used the regexp_escape because I found the line when searching where to grab the title from, then without it there was a type mismatch...

How about this?

diff --git a/src/api/api_dvr.c b/src/api/api_dvr.c
index 767371f00..1671edbb8 100644
--- a/src/api/api_dvr.c
+++ b/src/api/api_dvr.c
@@ -465,6 +465,8 @@ api_dvr_autorec_create_by_series
   const char *config_uuid, *s;
   int count = 0;
   char ubuf[UUID_HEX_SIZE];
+  const char * msg = " - Created from EPG query";
+  char comment[160] = "\0";

   if (!(entries = htsmsg_get_list(args, "entries"))) {
     entries = entries2 = api_dvr_entry_create_from_single(args);
@@ -484,11 +486,13 @@ api_dvr_autorec_create_by_series
     if ((e = epg_broadcast_find_by_id(strtoll(s, NULL, 10)))) {
       dvr_config_t *cfg = dvr_config_find_by_list(perm->aa_dvrcfgs, config_uuid);
       if (cfg) {
+    strlcat(comment, epg_broadcast_get_title(e, NULL), sizeof(comment));
+    strlcat(comment, msg, sizeof(comment));
         dae = dvr_autorec_add_series_link(idnode_uuid_as_str(&cfg->dvr_id, ubuf),
                                           e,
                                           perm->aa_username,
                                           perm->aa_representative,
-                                          "Created from EPG query");
+                                          comment);
         if (dae) {
           if (l == NULL)
             l = htsmsg_create_list();

#7

Updated by Joe User almost 6 years ago

Or maybe this is better - it would truncate a long title to leave space for the "Created..." msg.

diff --git a/src/api/api_dvr.c b/src/api/api_dvr.c
index 767371f00..d6c8bd064 100644
--- a/src/api/api_dvr.c
+++ b/src/api/api_dvr.c
@@ -465,6 +465,8 @@ api_dvr_autorec_create_by_series
   const char *config_uuid, *s;
   int count = 0;
   char ubuf[UUID_HEX_SIZE];
+  const char * msg = " - Created from EPG query";
+  char comment[160] = "\0";

   if (!(entries = htsmsg_get_list(args, "entries"))) {
     entries = entries2 = api_dvr_entry_create_from_single(args);
@@ -484,11 +486,13 @@ api_dvr_autorec_create_by_series
     if ((e = epg_broadcast_find_by_id(strtoll(s, NULL, 10)))) {
       dvr_config_t *cfg = dvr_config_find_by_list(perm->aa_dvrcfgs, config_uuid);
       if (cfg) {
+    strlcat(comment, epg_broadcast_get_title(e, NULL), (sizeof(comment) - sizeof(msg)));
+    strlcat(comment, msg, sizeof(comment));
         dae = dvr_autorec_add_series_link(idnode_uuid_as_str(&cfg->dvr_id, ubuf),
                                           e,
                                           perm->aa_username,
                                           perm->aa_representative,
-                                          "Created from EPG query");
+                                          comment);
         if (dae) {
           if (l == NULL)
             l = htsmsg_create_list();

#8

Updated by Em Smith almost 6 years ago

I was thinking something like this:
(I only did very basic testing)

So, using alloca means the user could put any length string and we'd work (it allocates on the stack, so no need to free).

diff --git a/src/api/api_dvr.c b/src/api/api_dvr.c
index 767371f00..c04b29c22 100644
--- a/src/api/api_dvr.c
+++ b/src/api/api_dvr.c
@@ -462,9 +462,11 @@ api_dvr_autorec_create_by_series
   epg_broadcast_t *e;
   htsmsg_t *entries, *entries2 = NULL, *m, *l = NULL;
   htsmsg_field_t *f;
-  const char *config_uuid, *s;
+  const char *config_uuid, *s, *title;
   int count = 0;
   char ubuf[UUID_HEX_SIZE];
+  const char msg[] = " - Created from  EPG query";
+  char *comment;

   if (!(entries = htsmsg_get_list(args, "entries"))) {
     entries = entries2 = api_dvr_entry_create_from_single(args);
@@ -484,11 +486,14 @@ api_dvr_autorec_create_by_series
     if ((e = epg_broadcast_find_by_id(strtoll(s, NULL, 10)))) {
       dvr_config_t *cfg = dvr_config_find_by_list(perm->aa_dvrcfgs, config_uuid);
       if (cfg) {
+        title = epg_broadcast_get_title(e, NULL);
+        comment = alloca(strlen(title) + strlen(msg) + 1);
+        sprintf(comment, "%s%s", title, msg);
         dae = dvr_autorec_add_series_link(idnode_uuid_as_str(&cfg->dvr_id, ubuf),
                                           e,
                                           perm->aa_username,
                                           perm->aa_representative,
-                                          "Created from EPG query");
+                                          comment);
         if (dae) {
           if (l == NULL)
             l = htsmsg_create_list();

#9

Updated by Joe User almost 6 years ago

Ok, thanks. I will create a pull request, but it seems the latest code has triggered a lot of bugs (I use dvb-c also...) so I will wait a little bit before updating to the latest git to test.

#11

Updated by Jaroslav Kysela about 5 years ago

  • Status changed from New to Fixed
  • Target version set to 4.4

Also available in: Atom PDF