]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
ui: Prefer to use accessor for de_image. (#4685).
authorE.Smith <31170571+azlm8t@users.noreply.github.com>
Wed, 1 Nov 2017 15:43:13 +0000 (15:43 +0000)
committerJaroslav Kysela <perex@perex.cz>
Wed, 8 Nov 2017 16:54:53 +0000 (17:54 +0100)
This allows it to also try and get an image from the current EPG
if the entry does not have an associated image.

Issue: #4685

src/dvr/dvr.h
src/dvr/dvr_db.c
src/htsp_server.c

index 6120d5a1544a2da9b97bbcf15bf3a5586c254e68..6f674557a194298810dda1e86ae8eed2d487c14b 100644 (file)
@@ -689,6 +689,7 @@ htsmsg_t * dvr_autorec_entry_class_time_list(void *o, const char *null);
 htsmsg_t * dvr_autorec_entry_class_weekdays_get(uint32_t weekdays);
 htsmsg_t * dvr_autorec_entry_class_weekdays_list (void *o, const char *list);
 char * dvr_autorec_entry_class_weekdays_rend(uint32_t weekdays, const char *lang);
+const char *dvr_entry_class_image_url_get(const dvr_entry_t *o);
 
 void dvr_autorec_check_event(epg_broadcast_t *e);
 void dvr_autorec_check_brand(epg_brand_t *b);
index d4a3f5569b04d74b719202689878bbb8c1a51dcd..f3a4ef56d4945c8eeba92805a896a08e91b41458 100644 (file)
@@ -3297,7 +3297,7 @@ dvr_entry_class_channel_icon_url_get(void *o)
 }
 
 static const void *
-dvr_entry_class_image_url_get(void *o)
+dvr_entry_class_image_url_get_as_property(void *o)
 {
   dvr_entry_t *de = (dvr_entry_t *)o;
   if (de->de_image) {
@@ -3312,6 +3312,19 @@ dvr_entry_class_image_url_get(void *o)
   return &prop_sbuf_ptr;
 }
 
+const char *
+dvr_entry_class_image_url_get(const dvr_entry_t *o)
+{
+    const void *image = dvr_entry_class_image_url_get_as_property((void*)o);
+    if (!image) return NULL;
+    const char *image_str = *(const char**)image;
+    if (!image_str) return NULL;
+    if (!*image_str) return NULL;
+    return image_str;
+}
+
+
+
 static const void *
 dvr_entry_class_duplicate_get(void *o)
 {
@@ -3491,7 +3504,7 @@ const idclass_t dvr_entry_class = {
       .id       = "image", /* Name chosen to be compatible with api_epg */
       .name     = N_("Episode image"),
       .desc     = N_("Episode image."),
-      .get      = dvr_entry_class_image_url_get,
+      .get      = dvr_entry_class_image_url_get_as_property,
       .off      = offsetof(dvr_entry_t, de_image),
       .opts     = PO_HIDDEN,
     },
index 8c9085c1eaa18089b2080a8e212a3c3dae4df8c3..b146b8140c6b3249d37c5a2b0a568381f5e20a54 100644 (file)
@@ -1003,8 +1003,13 @@ htsp_build_dvrentry(htsp_connection_t *htsp, dvr_entry_t *de, const char *method
       htsmsg_add_str(out, "creator", de->de_creator);
     if(de->de_comment)
       htsmsg_add_str(out, "comment", de->de_comment);
-    if(de->de_image && *de->de_image)
-      htsmsg_add_str(out, "image", de->de_image);
+    /* We use the accessor since it will also try to get
+     * an image from current EPG if recording does not have
+     * an associated image.
+     */
+    const char *image = dvr_entry_class_image_url_get(de);
+    if(image && *image)
+      htsmsg_add_str(out, "image", image);
     if (de->de_copyright_year)
       htsmsg_add_u32(out, "copyrightYear", de->de_copyright_year);