Guest User

Untitled

a guest
Nov 23rd, 2018
299
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff --git a/src/api/api_epg.c b/src/api/api_epg.c
  2. index 82d4760ce..e41ef63b1 100644
  3. --- a/src/api/api_epg.c
  4. +++ b/src/api/api_epg.c
  5. @@ -170,6 +170,10 @@ api_epg_entry ( epg_broadcast_t *eb, const char *lang, access_t *perm, const cha
  6. /* Image */
  7. if (eb->image)
  8. htsmsg_add_str(m, "image", eb->image);
  9. +
  10. + /* Original Title */
  11. + if (eb->original_title)
  12. + htsmsg_add_str(m, "originalTitle", eb->original_title);
  13.  
  14. /* Rating */
  15. if (eb->star_rating)
  16. diff --git a/src/dvr/dvr.h b/src/dvr/dvr.h
  17. index 398e7061c..bf0a94756 100644
  18. --- a/src/dvr/dvr.h
  19. +++ b/src/dvr/dvr.h
  20. @@ -232,6 +232,7 @@ typedef struct dvr_entry {
  21. lang_str_t *de_summary; /* Summary in UTF-8 (from EPG) */
  22. lang_str_t *de_desc; /* Description in UTF-8 (from EPG) */
  23. uint32_t de_content_type; /* Content type (from EPG) (only code) */
  24. + uint32_t de_genre; /* Episode genre (from EPG) (only code) */
  25. uint16_t de_copyright_year; /* Copyright year (from EPG) */
  26. uint16_t de_dvb_eid;
  27.  
  28. diff --git a/src/dvr/dvr_db.c b/src/dvr/dvr_db.c
  29. index e1a087128..0c92cd992 100644
  30. --- a/src/dvr/dvr_db.c
  31. +++ b/src/dvr/dvr_db.c
  32. @@ -1069,8 +1069,10 @@ dvr_entry_create_from_htsmsg(htsmsg_t *conf, epg_broadcast_t *e)
  33. if (e->image)
  34. htsmsg_add_str(conf, "image", e->image);
  35. genre = LIST_FIRST(&e->genre);
  36. - if (genre)
  37. + if (genre) {
  38. htsmsg_add_u32(conf, "content_type", genre->code / 16);
  39. + htsmsg_add_u32(conf, "genre", genre->code);
  40. + }
  41. }
  42.  
  43. de = dvr_entry_create(NULL, conf, 0);
  44. @@ -3574,6 +3576,15 @@ dvr_entry_class_content_type_list(void *o, const char *lang)
  45. return m;
  46. }
  47.  
  48. +static htsmsg_t *
  49. +dvr_entry_class_genre_list(void *o, const char *lang)
  50. +{
  51. + htsmsg_t *m = htsmsg_create_map();
  52. + htsmsg_add_str(m, "type", "api");
  53. + htsmsg_add_str(m, "uri", "epg/genre/list");
  54. + return m;
  55. +}
  56. +
  57. CLASS_DOC(dvrentry)
  58. PROP_DOC(dvr_status)
  59. PROP_DOC(dvr_start_extra)
  60. @@ -4002,6 +4013,15 @@ const idclass_t dvr_entry_class = {
  61. .opts = PO_RDONLY | PO_SORTKEY,
  62. },
  63. {
  64. + .type = PT_U32,
  65. + .id = "genre",
  66. + .name = N_("Episode genre"),
  67. + .desc = N_("Episode genre code."),
  68. + .list = dvr_entry_class_genre_list,
  69. + .off = offsetof(dvr_entry_t, de_genre),
  70. + .opts = PO_RDONLY,
  71. + },
  72. + {
  73. .type = PT_U16,
  74. .id = "copyright_year",
  75. .name = N_("The copyright year of the program."),
  76. diff --git a/src/epg.c b/src/epg.c
  77. index f7ad33f1e..a1a4b1d99 100644
  78. --- a/src/epg.c
  79. +++ b/src/epg.c
  80. @@ -858,10 +858,11 @@ static void _epg_broadcast_destroy ( void *eo )
  81. }
  82. free(ebc->image);
  83. free(ebc->epnum.text);
  84. - if (ebc->credits) htsmsg_destroy(ebc->credits);
  85. + free(ebc->original_title);
  86. + if (ebc->credits) htsmsg_destroy(ebc->credits);
  87. if (ebc->credits_cached) lang_str_destroy(ebc->credits_cached);
  88. - if (ebc->category) string_list_destroy(ebc->category);
  89. - if (ebc->keyword) string_list_destroy(ebc->keyword);
  90. + if (ebc->category) string_list_destroy(ebc->category);
  91. + if (ebc->keyword) string_list_destroy(ebc->keyword);
  92. if (ebc->keyword_cached) lang_str_destroy(ebc->keyword_cached);
  93. epg_set_broadcast_remove(&epg_serieslinks, ebc->serieslink, ebc);
  94. epg_set_broadcast_remove(&epg_episodelinks, ebc->episodelink, ebc);
  95. @@ -1014,6 +1015,8 @@ int epg_broadcast_change_finish
  96. save |= _epg_object_set_u16(broadcast, &broadcast->epnum.p_cnt, 0, NULL, 0);
  97. if (!(changes & EPG_CHANGED_EPTEXT))
  98. save |= _epg_object_set_str(broadcast, &broadcast->epnum.text, NULL, NULL, 0);
  99. + if (!(changes & EPG_CHANGED_ORIGINAL_TITLE))
  100. + save |= epg_broadcast_set_original_title(broadcast, NULL, NULL);
  101. if (!(changes & EPG_CHANGED_FIRST_AIRED))
  102. save |= epg_broadcast_set_first_aired(broadcast, 0, NULL);
  103. if (!(changes & EPG_CHANGED_COPYRIGHT_YEAR))
  104. @@ -1058,6 +1061,7 @@ epg_broadcast_t *epg_broadcast_clone
  105. *save |= epg_broadcast_set_summary(ebc, src->summary, &changes);
  106. *save |= epg_broadcast_set_description(ebc, src->description, &changes);
  107. *save |= epg_broadcast_set_epnum(ebc, &src->epnum, &changes);
  108. + *save |= epg_broadcast_set_original_title(ebc, src->original_title, &changes);
  109. *save |= epg_broadcast_set_credits(ebc, src->credits, &changes);
  110. *save |= epg_broadcast_set_category(ebc, src->category, &changes);
  111. *save |= epg_broadcast_set_keyword(ebc, src->keyword, &changes);
  112. @@ -1425,6 +1429,14 @@ int epg_broadcast_set_genre
  113. return save;
  114. }
  115.  
  116. +int epg_broadcast_set_original_title
  117. + ( epg_broadcast_t *b, const char *original_title, epg_changes_t *changed )
  118. +{
  119. + if (!b) return 0;
  120. + return _epg_object_set_str(b, &b->original_title, original_title,
  121. + changed, EPG_CHANGED_ORIGINAL_TITLE);
  122. +}
  123. +
  124. int epg_broadcast_set_copyright_year
  125. ( epg_broadcast_t *b, uint16_t year, epg_changes_t *changed )
  126. {
  127. @@ -1580,6 +1592,8 @@ htsmsg_t *epg_broadcast_serialize ( epg_broadcast_t *broadcast )
  128. htsmsg_add_u32(a, NULL, eg->code);
  129. }
  130. if (a) htsmsg_add_msg(m, "genre", a);
  131. + if (broadcast->original_title)
  132. + htsmsg_add_str(m, "otitle", broadcast->original_title);
  133. if (broadcast->copyright_year)
  134. htsmsg_add_u32(m, "cyear", broadcast->copyright_year);
  135. if (broadcast->first_aired)
  136. @@ -1699,6 +1713,9 @@ epg_broadcast_t *epg_broadcast_deserialize
  137. *save |= epg_broadcast_set_epnum(ebc, &num, &changes);
  138. if (num.text) free(num.text);
  139. }
  140. +
  141. + if ((str = htsmsg_get_str(m, "otitle")))
  142. + *save |= epg_broadcast_set_original_title(ebc, str, &changes);
  143.  
  144. if (!htsmsg_get_u32(m, "cyear", &u32))
  145. *save |= epg_broadcast_set_copyright_year(ebc, u32, &changes);
  146. diff --git a/src/epg.h b/src/epg.h
  147. index 84d872c4b..f212b79cc 100644
  148. --- a/src/epg.h
  149. +++ b/src/epg.h
  150. @@ -149,6 +149,7 @@ typedef uint64_t epg_changes_t;
  151. #define EPG_CHANGED_AGE_RATING (1ULL<<31)
  152. #define EPG_CHANGED_FIRST_AIRED (1ULL<<32)
  153. #define EPG_CHANGED_COPYRIGHT_YEAR (1ULL<<33)
  154. +#define EPG_CHANGED_ORIGINAL_TITLE (1ULL<<34)
  155.  
  156. typedef struct epg_object_ops {
  157. void (*getref) ( void *o ); ///< Get a reference
  158. @@ -287,6 +288,7 @@ struct epg_broadcast
  159. lang_str_t *summary; ///< Summary
  160. lang_str_t *description; ///< Description
  161.  
  162. + char *original_title; ///< Original title
  163. char *image; ///< Episode image
  164. epg_genre_list_t genre; ///< Episode genre(s)
  165. epg_episode_num_t epnum; ///< Episode numbering; NOTE: use the accessor routine!
  166. @@ -400,6 +402,9 @@ int epg_broadcast_set_genre
  167. int epg_broadcast_set_image
  168. ( epg_broadcast_t *b, const char *i, epg_changes_t *changed )
  169. __attribute__((warn_unused_result));
  170. +int epg_broadcast_set_original_title
  171. + ( epg_broadcast_t *b, const char *original_title, epg_changes_t *changed )
  172. + __attribute__((warn_unused_result));
  173. int epg_broadcast_set_is_bw
  174. ( epg_broadcast_t *b, uint8_t bw, epg_changes_t *changed )
  175. __attribute__((warn_unused_result));
  176. diff --git a/src/epggrab/module/xmltv.c b/src/epggrab/module/xmltv.c
  177. index 776907bda..44f3a051d 100644
  178. --- a/src/epggrab/module/xmltv.c
  179. +++ b/src/epggrab/module/xmltv.c
  180. @@ -483,6 +483,21 @@ static int _xmltv_parse_age_rating
  181. }
  182.  
  183. /*
  184. + * Parse original title
  185. + * <original-title>Title</original-title>
  186. + */
  187. +static int _xmltv_parse_original_title
  188. + ( epg_broadcast_t *ebc, htsmsg_t *tags, epg_changes_t *changes )
  189. +{
  190. + const char *original_title;
  191. +
  192. + if (!ebc || !tags) return 0;
  193. + if (!(original_title = htsmsg_xml_get_cdata_str(tags, "original-title"))) return 0;
  194. +
  195. + return epg_broadcast_set_original_title(ebc, original_title, changes);
  196. +}
  197. +
  198. +/*
  199. * Parse category list
  200. */
  201. static epg_genre_list_t
  202. @@ -776,6 +791,8 @@ static int _xmltv_parse_programme_tags
  203.  
  204. save |= _xmltv_parse_age_rating(ebc, tags, &changes);
  205.  
  206. + save |= _xmltv_parse_original_title(ebc, tags, &changes);
  207. +
  208. if (icon)
  209. save |= epg_broadcast_set_image(ebc, icon, &changes);
  210.  
  211. diff --git a/src/htsp_server.c b/src/htsp_server.c
  212. index a873c4aa8..5e8fa0bbf 100644
  213. --- a/src/htsp_server.c
  214. +++ b/src/htsp_server.c
  215. @@ -1004,6 +1004,7 @@ htsp_build_dvrentry(htsp_connection_t *htsp, dvr_entry_t *de, const char *method
  216. u32 = DVR_PRIO_NORMAL;
  217. htsmsg_add_u32(out, "priority", u32);
  218. htsmsg_add_u32(out, "contentType", de->de_content_type);
  219. + htsmsg_add_u32(out, "genre", de->de_genre);
  220.  
  221. if (de->de_sched_state == DVR_RECORDING || de->de_sched_state == DVR_COMPLETED) {
  222. htsmsg_add_u32(out, "playcount", de->de_playcount);
  223. @@ -1312,6 +1313,8 @@ htsp_build_event
  224. htsp_serialize_epnum(out, &epnum, NULL);
  225. if (e->image)
  226. htsmsg_add_str(out, "image", e->image);
  227. + if (e->original_title)
  228. + htsmsg_add_str(out, "originalTitle", e->original_title);
  229.  
  230. if (e->channel) {
  231. LIST_FOREACH(de, &e->channel->ch_dvrs, de_channel_link) {
RAW Paste Data