Merge branch 'feature/epggrab_prio' into epg-rewrite
This commit is contained in:
commit
9431526742
11 changed files with 405 additions and 267 deletions
270
src/epg.c
270
src/epg.c
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Electronic Program Guide - Common functions
|
||||
* Copyright (C) 2007 Andreas Öman
|
||||
* Copyright (C) 2012 Adam Sutton
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -213,23 +213,40 @@ static htsmsg_t * _epg_object_serialize ( void *o )
|
|||
htsmsg_add_u32(m, "type", eo->type);
|
||||
if (eo->uri)
|
||||
htsmsg_add_str(m, "uri", eo->uri);
|
||||
if (eo->grabber)
|
||||
htsmsg_add_str(m, "grabber", eo->grabber->id);
|
||||
return m;
|
||||
}
|
||||
|
||||
static epg_object_t *_epg_object_deserialize ( htsmsg_t *m, epg_object_t *eo )
|
||||
{
|
||||
const char *s;
|
||||
if (htsmsg_get_u64(m, "id", &eo->id)) return NULL;
|
||||
if (htsmsg_get_u32(m, "type", &eo->type)) return NULL;
|
||||
eo->uri = (char*)htsmsg_get_str(m, "uri");
|
||||
if ((s = htsmsg_get_str(m, "grabber")))
|
||||
eo->grabber = epggrab_module_find_by_id(s);
|
||||
return eo;
|
||||
}
|
||||
|
||||
static int _epg_object_set_str
|
||||
( void *o, char **old, const char *new )
|
||||
static int _epg_object_set_grabber ( void *o, epggrab_module_t *grab )
|
||||
{
|
||||
epg_object_t *eo = o;
|
||||
if ( !grab ) return 1; // grab=NULL is override
|
||||
if ( !eo->grabber ||
|
||||
((eo->grabber != grab) && (grab->priority > eo->grabber->priority)) ) {
|
||||
eo->grabber = grab;
|
||||
}
|
||||
return grab == eo->grabber;
|
||||
}
|
||||
|
||||
static int _epg_object_set_str
|
||||
( void *o, char **old, const char *new, epggrab_module_t *src )
|
||||
{
|
||||
epg_object_t *eo = (epg_object_t*)o;
|
||||
int save = 0;
|
||||
epg_object_t *eo = (epg_object_t*)o;
|
||||
if ( !eo || !new ) return 0;
|
||||
if ( !_epg_object_set_grabber(eo, src) && *old ) return 0;
|
||||
if ( !*old || strcmp(*old, new) ) {
|
||||
if ( *old ) free(*old);
|
||||
*old = strdup(new);
|
||||
|
@ -240,9 +257,10 @@ static int _epg_object_set_str
|
|||
}
|
||||
|
||||
static int _epg_object_set_u8
|
||||
( void *o, uint8_t *old, const uint8_t new )
|
||||
( void *o, uint8_t *old, const uint8_t new, epggrab_module_t *src )
|
||||
{
|
||||
int save = 0;
|
||||
if ( !_epg_object_set_grabber(o, src) && *old ) return 0;
|
||||
if ( *old != new ) {
|
||||
*old = new;
|
||||
_epg_object_set_updated(o);
|
||||
|
@ -252,9 +270,10 @@ static int _epg_object_set_u8
|
|||
}
|
||||
|
||||
static int _epg_object_set_u16
|
||||
( void *o, uint16_t *old, const uint16_t new )
|
||||
( void *o, uint16_t *old, const uint16_t new, epggrab_module_t *src )
|
||||
{
|
||||
int save = 0;
|
||||
if ( !_epg_object_set_grabber(o, src) && *old ) return 0;
|
||||
if ( *old != new ) {
|
||||
*old = new;
|
||||
_epg_object_set_updated(o);
|
||||
|
@ -316,28 +335,32 @@ epg_brand_t *epg_brand_find_by_id ( uint64_t id )
|
|||
return (epg_brand_t*)_epg_object_find_by_id(id, EPG_BRAND);
|
||||
}
|
||||
|
||||
int epg_brand_set_title ( epg_brand_t *brand, const char *title )
|
||||
int epg_brand_set_title
|
||||
( epg_brand_t *brand, const char *title, epggrab_module_t *src )
|
||||
{
|
||||
if (!brand || !title) return 0;
|
||||
return _epg_object_set_str(brand, &brand->title, title);
|
||||
return _epg_object_set_str(brand, &brand->title, title, src);
|
||||
}
|
||||
|
||||
int epg_brand_set_summary ( epg_brand_t *brand, const char *summary )
|
||||
int epg_brand_set_summary
|
||||
( epg_brand_t *brand, const char *summary, epggrab_module_t *src )
|
||||
{
|
||||
if (!brand || !summary) return 0;
|
||||
return _epg_object_set_str(brand, &brand->summary, summary);
|
||||
return _epg_object_set_str(brand, &brand->summary, summary, src);
|
||||
}
|
||||
|
||||
int epg_brand_set_image ( epg_brand_t *brand, const char *image )
|
||||
int epg_brand_set_image
|
||||
( epg_brand_t *brand, const char *image, epggrab_module_t *src )
|
||||
{
|
||||
if (!brand || !image) return 0;
|
||||
return _epg_object_set_str(brand, &brand->image, image);
|
||||
return _epg_object_set_str(brand, &brand->image, image, src);
|
||||
}
|
||||
|
||||
int epg_brand_set_season_count ( epg_brand_t *brand, uint16_t count )
|
||||
int epg_brand_set_season_count
|
||||
( epg_brand_t *brand, uint16_t count, epggrab_module_t *src )
|
||||
{
|
||||
if (!brand || !count) return 0;
|
||||
return _epg_object_set_u16(brand, &brand->season_count, count);
|
||||
return _epg_object_set_u16(brand, &brand->season_count, count, src);
|
||||
}
|
||||
|
||||
static void _epg_brand_add_season
|
||||
|
@ -397,11 +420,11 @@ epg_brand_t *epg_brand_deserialize ( htsmsg_t *m, int create, int *save )
|
|||
if ( !(eb = epg_brand_find_by_uri((*skel)->uri, create, save)) ) return NULL;
|
||||
|
||||
if ( (str = htsmsg_get_str(m, "title")) )
|
||||
*save |= epg_brand_set_title(eb, str);
|
||||
*save |= epg_brand_set_title(eb, str, NULL);
|
||||
if ( (str = htsmsg_get_str(m, "summary")) )
|
||||
*save |= epg_brand_set_summary(eb, str);
|
||||
*save |= epg_brand_set_summary(eb, str, NULL);
|
||||
if ( !htsmsg_get_u32(m, "season-count", &u32) )
|
||||
*save |= epg_brand_set_season_count(eb, u32);
|
||||
*save |= epg_brand_set_season_count(eb, u32, NULL);
|
||||
|
||||
return eb;
|
||||
}
|
||||
|
@ -468,34 +491,40 @@ epg_season_t *epg_season_find_by_id ( uint64_t id )
|
|||
return (epg_season_t*)_epg_object_find_by_id(id, EPG_SEASON);
|
||||
}
|
||||
|
||||
int epg_season_set_summary ( epg_season_t *season, const char *summary )
|
||||
int epg_season_set_summary
|
||||
( epg_season_t *season, const char *summary, epggrab_module_t *src )
|
||||
{
|
||||
if (!season || !summary) return 0;
|
||||
return _epg_object_set_str(season, &season->summary, summary);
|
||||
return _epg_object_set_str(season, &season->summary, summary, src);
|
||||
}
|
||||
|
||||
int epg_season_set_image ( epg_season_t *season, const char *image )
|
||||
int epg_season_set_image
|
||||
( epg_season_t *season, const char *image, epggrab_module_t *src )
|
||||
{
|
||||
if (!season || !image) return 0;
|
||||
return _epg_object_set_str(season, &season->image, image);
|
||||
return _epg_object_set_str(season, &season->image, image, src);
|
||||
}
|
||||
|
||||
int epg_season_set_episode_count ( epg_season_t *season, uint16_t count )
|
||||
int epg_season_set_episode_count
|
||||
( epg_season_t *season, uint16_t count, epggrab_module_t *src )
|
||||
{
|
||||
if (!season || !count) return 0;
|
||||
return _epg_object_set_u16(season, &season->episode_count, count);
|
||||
return _epg_object_set_u16(season, &season->episode_count, count, src);
|
||||
}
|
||||
|
||||
int epg_season_set_number ( epg_season_t *season, uint16_t number )
|
||||
int epg_season_set_number
|
||||
( epg_season_t *season, uint16_t number, epggrab_module_t *src )
|
||||
{
|
||||
if (!season || !number) return 0;
|
||||
return _epg_object_set_u16(season, &season->number, number);
|
||||
return _epg_object_set_u16(season, &season->number, number, src);
|
||||
}
|
||||
|
||||
int epg_season_set_brand ( epg_season_t *season, epg_brand_t *brand, int u )
|
||||
int epg_season_set_brand
|
||||
( epg_season_t *season, epg_brand_t *brand, epggrab_module_t *src )
|
||||
{
|
||||
int save = 0;
|
||||
if ( !season || !brand ) return 0;
|
||||
if ( !_epg_object_set_grabber(season, src) && season->brand ) return 0;
|
||||
if ( season->brand != brand ) {
|
||||
if ( season->brand ) _epg_brand_rem_season(season->brand, season);
|
||||
season->brand = brand;
|
||||
|
@ -550,15 +579,15 @@ epg_season_t *epg_season_deserialize ( htsmsg_t *m, int create, int *save )
|
|||
if ( !(es = epg_season_find_by_uri((*skel)->uri, create, save)) ) return NULL;
|
||||
|
||||
if ( (str = htsmsg_get_str(m, "summary")) )
|
||||
*save |= epg_season_set_summary(es, str);
|
||||
*save |= epg_season_set_summary(es, str, NULL);
|
||||
if ( !htsmsg_get_u32(m, "number", &u32) )
|
||||
*save |= epg_season_set_number(es, u32);
|
||||
*save |= epg_season_set_number(es, u32, NULL);
|
||||
if ( !htsmsg_get_u32(m, "episode-count", &u32) )
|
||||
*save |= epg_season_set_episode_count(es, u32);
|
||||
*save |= epg_season_set_episode_count(es, u32, NULL);
|
||||
|
||||
if ( (str = htsmsg_get_str(m, "brand")) )
|
||||
if ( (eb = epg_brand_find_by_uri(str, 0, NULL)) )
|
||||
*save |= epg_season_set_brand(es, eb, 1);
|
||||
*save |= epg_season_set_brand(es, eb, NULL);
|
||||
|
||||
return es;
|
||||
}
|
||||
|
@ -670,76 +699,94 @@ epg_episode_t *epg_episode_find_by_id ( uint64_t id )
|
|||
return (epg_episode_t*)_epg_object_find_by_id(id, EPG_EPISODE);
|
||||
}
|
||||
|
||||
int epg_episode_set_title ( epg_episode_t *episode, const char *title )
|
||||
int epg_episode_set_title
|
||||
( epg_episode_t *episode, const char *title, epggrab_module_t *src )
|
||||
{
|
||||
if (!episode || !title) return 0;
|
||||
return _epg_object_set_str(episode, &episode->title, title);
|
||||
return _epg_object_set_str(episode, &episode->title, title, src);
|
||||
}
|
||||
|
||||
int epg_episode_set_subtitle ( epg_episode_t *episode, const char *subtitle )
|
||||
int epg_episode_set_subtitle
|
||||
( epg_episode_t *episode, const char *subtitle, epggrab_module_t *src )
|
||||
{
|
||||
if (!episode || !subtitle) return 0;
|
||||
return _epg_object_set_str(episode, &episode->subtitle, subtitle);
|
||||
return _epg_object_set_str(episode, &episode->subtitle, subtitle, src);
|
||||
}
|
||||
|
||||
int epg_episode_set_summary ( epg_episode_t *episode, const char *summary )
|
||||
int epg_episode_set_summary
|
||||
( epg_episode_t *episode, const char *summary, epggrab_module_t *src )
|
||||
{
|
||||
if (!episode || !summary) return 0;
|
||||
return _epg_object_set_str(episode, &episode->summary, summary);
|
||||
return _epg_object_set_str(episode, &episode->summary, summary, src);
|
||||
}
|
||||
|
||||
int epg_episode_set_description ( epg_episode_t *episode, const char *desc )
|
||||
int epg_episode_set_description
|
||||
( epg_episode_t *episode, const char *desc, epggrab_module_t *src )
|
||||
{
|
||||
if (!episode || !desc) return 0;
|
||||
return _epg_object_set_str(episode, &episode->description, desc);
|
||||
return _epg_object_set_str(episode, &episode->description, desc, src);
|
||||
}
|
||||
|
||||
int epg_episode_set_image ( epg_episode_t *episode, const char *image )
|
||||
int epg_episode_set_image
|
||||
( epg_episode_t *episode, const char *image, epggrab_module_t *src )
|
||||
{
|
||||
if (!episode || !image) return 0;
|
||||
return _epg_object_set_str(episode, &episode->image, image);
|
||||
return _epg_object_set_str(episode, &episode->image, image, src);
|
||||
}
|
||||
|
||||
int epg_episode_set_number ( epg_episode_t *episode, uint16_t number )
|
||||
int epg_episode_set_number
|
||||
( epg_episode_t *episode, uint16_t number, epggrab_module_t *src )
|
||||
{
|
||||
if (!episode || !number) return 0;
|
||||
return _epg_object_set_u16(episode, &episode->epnum.e_num, number);
|
||||
return _epg_object_set_u16(episode, &episode->epnum.e_num, number, src);
|
||||
}
|
||||
|
||||
int epg_episode_set_part ( epg_episode_t *episode, uint16_t part, uint16_t count )
|
||||
int epg_episode_set_part
|
||||
( epg_episode_t *episode, uint16_t part, uint16_t count,
|
||||
epggrab_module_t *src )
|
||||
{
|
||||
int save = 0;
|
||||
if (!episode || !part) return 0;
|
||||
save |= _epg_object_set_u16(episode, &episode->epnum.p_num, part);
|
||||
save |= _epg_object_set_u16(episode, &episode->epnum.p_cnt, count);
|
||||
save |= _epg_object_set_u16(episode, &episode->epnum.p_num, part, src);
|
||||
save |= _epg_object_set_u16(episode, &episode->epnum.p_cnt, count, src);
|
||||
return save;
|
||||
}
|
||||
|
||||
int epg_episode_set_epnum ( epg_episode_t *episode, epg_episode_num_t *num )
|
||||
int epg_episode_set_epnum
|
||||
( epg_episode_t *episode, epg_episode_num_t *num, epggrab_module_t *src )
|
||||
{
|
||||
int save = 0;
|
||||
if (!episode || !num || (!num->e_num && !num->text)) return 0;
|
||||
if (num->s_num)
|
||||
save |= _epg_object_set_u16(episode, &episode->epnum.s_num, num->s_num);
|
||||
save |= _epg_object_set_u16(episode, &episode->epnum.s_num,
|
||||
num->s_num, src);
|
||||
if (num->s_cnt)
|
||||
save |= _epg_object_set_u16(episode, &episode->epnum.s_cnt, num->s_cnt);
|
||||
save |= _epg_object_set_u16(episode, &episode->epnum.s_cnt,
|
||||
num->s_cnt, src);
|
||||
if (num->e_num)
|
||||
save |= _epg_object_set_u16(episode, &episode->epnum.e_num, num->e_num);
|
||||
save |= _epg_object_set_u16(episode, &episode->epnum.e_num,
|
||||
num->e_num, src);
|
||||
if (num->e_cnt)
|
||||
save |= _epg_object_set_u16(episode, &episode->epnum.e_cnt, num->e_cnt);
|
||||
save |= _epg_object_set_u16(episode, &episode->epnum.e_cnt,
|
||||
num->e_cnt, src);
|
||||
if (num->p_num)
|
||||
save |= _epg_object_set_u16(episode, &episode->epnum.p_num, num->p_num);
|
||||
save |= _epg_object_set_u16(episode, &episode->epnum.p_num,
|
||||
num->p_num, src);
|
||||
if (num->p_cnt)
|
||||
save |= _epg_object_set_u16(episode, &episode->epnum.p_cnt, num->p_cnt);
|
||||
save |= _epg_object_set_u16(episode, &episode->epnum.p_cnt,
|
||||
num->p_cnt, src);
|
||||
if (num->text)
|
||||
save |= _epg_object_set_str(episode, &episode->epnum.text, num->text);
|
||||
save |= _epg_object_set_str(episode, &episode->epnum.text,
|
||||
num->text, src);
|
||||
return save;
|
||||
}
|
||||
|
||||
int epg_episode_set_brand ( epg_episode_t *episode, epg_brand_t *brand )
|
||||
int epg_episode_set_brand
|
||||
( epg_episode_t *episode, epg_brand_t *brand, epggrab_module_t *src )
|
||||
{
|
||||
int save = 0;
|
||||
if ( !episode || !brand ) return 0;
|
||||
if ( !_epg_object_set_grabber(episode, src) && episode->brand ) return 0;
|
||||
if ( episode->brand != brand ) {
|
||||
if ( episode->brand ) _epg_brand_rem_episode(episode->brand, episode);
|
||||
episode->brand = brand;
|
||||
|
@ -750,28 +797,34 @@ int epg_episode_set_brand ( epg_episode_t *episode, epg_brand_t *brand )
|
|||
return save;
|
||||
}
|
||||
|
||||
int epg_episode_set_season ( epg_episode_t *episode, epg_season_t *season )
|
||||
int epg_episode_set_season
|
||||
( epg_episode_t *episode, epg_season_t *season, epggrab_module_t *src )
|
||||
{
|
||||
int save = 0;
|
||||
if ( !episode || !season ) return 0;
|
||||
if ( !_epg_object_set_grabber(episode, src) && episode->season ) return 0;
|
||||
if ( episode->season != season ) {
|
||||
if ( episode->season ) _epg_season_rem_episode(episode->season, episode);
|
||||
episode->season = season;
|
||||
_epg_season_add_episode(season, episode);
|
||||
if ( season->brand ) save |= epg_episode_set_brand(episode, season->brand);
|
||||
if ( season->brand )
|
||||
save |= epg_episode_set_brand(episode, season->brand, src);
|
||||
_epg_object_set_updated(episode);
|
||||
save = 1;
|
||||
}
|
||||
return save;
|
||||
}
|
||||
|
||||
int epg_episode_set_genre ( epg_episode_t *ee, epg_genre_list_t *genre )
|
||||
int epg_episode_set_genre
|
||||
( epg_episode_t *ee, epg_genre_list_t *genre, epggrab_module_t *src )
|
||||
{
|
||||
int save = 0;
|
||||
epg_genre_t *g1, *g2;
|
||||
|
||||
/* Remove old */
|
||||
g1 = LIST_FIRST(&ee->genre);
|
||||
if (!_epg_object_set_grabber(ee, src) && g1) return 0;
|
||||
|
||||
/* Remove old */
|
||||
while (g1) {
|
||||
g2 = LIST_NEXT(g1, link);
|
||||
if (!epg_genre_list_contains(genre, g1, 0)) {
|
||||
|
@ -789,12 +842,11 @@ int epg_episode_set_genre ( epg_episode_t *ee, epg_genre_list_t *genre )
|
|||
return save;
|
||||
}
|
||||
|
||||
int epg_episode_set_is_bw ( epg_episode_t *e, uint8_t bw )
|
||||
int epg_episode_set_is_bw
|
||||
( epg_episode_t *episode, uint8_t bw, epggrab_module_t *src )
|
||||
{
|
||||
int save = 0;
|
||||
if (!e) return 0;
|
||||
return _epg_object_set_u8(e, &e->is_bw, bw);
|
||||
return save;
|
||||
if (!episode) return 0;
|
||||
return _epg_object_set_u8(episode, &episode->is_bw, bw, src);
|
||||
}
|
||||
|
||||
static void _epg_episode_add_broadcast
|
||||
|
@ -918,21 +970,22 @@ epg_episode_t *epg_episode_deserialize ( htsmsg_t *m, int create, int *save )
|
|||
epg_episode_num_t num;
|
||||
htsmsg_t *sub;
|
||||
htsmsg_field_t *f;
|
||||
uint32_t u32;
|
||||
|
||||
if ( !_epg_object_deserialize(m, *skel) ) return NULL;
|
||||
if ( !(ee = epg_episode_find_by_uri((*skel)->uri, create, save)) ) return NULL;
|
||||
|
||||
if ( (str = htsmsg_get_str(m, "title")) )
|
||||
*save |= epg_episode_set_title(ee, str);
|
||||
*save |= epg_episode_set_title(ee, str, NULL);
|
||||
if ( (str = htsmsg_get_str(m, "subtitle")) )
|
||||
*save |= epg_episode_set_subtitle(ee, str);
|
||||
*save |= epg_episode_set_subtitle(ee, str, NULL);
|
||||
if ( (str = htsmsg_get_str(m, "summary")) )
|
||||
*save |= epg_episode_set_summary(ee, str);
|
||||
*save |= epg_episode_set_summary(ee, str, NULL);
|
||||
if ( (str = htsmsg_get_str(m, "description")) )
|
||||
*save |= epg_episode_set_description(ee, str);
|
||||
*save |= epg_episode_set_description(ee, str, NULL);
|
||||
if ( (sub = htsmsg_get_map(m, "epnum")) ) {
|
||||
epg_episode_num_deserialize(sub, &num);
|
||||
*save |= epg_episode_set_epnum(ee, &num);
|
||||
*save |= epg_episode_set_epnum(ee, &num, NULL);
|
||||
if (num.text) free(num.text);
|
||||
}
|
||||
if ( (sub = htsmsg_get_list(m, "genre")) ) {
|
||||
|
@ -942,18 +995,19 @@ epg_episode_t *epg_episode_deserialize ( htsmsg_t *m, int create, int *save )
|
|||
genre.code = (uint8_t)f->hmf_s64;
|
||||
epg_genre_list_add(egl, &genre);
|
||||
}
|
||||
*save |= epg_episode_set_genre(ee, egl);
|
||||
*save |= epg_episode_set_genre(ee, egl, NULL);
|
||||
epg_genre_list_destroy(egl);
|
||||
}
|
||||
|
||||
if ( (str = htsmsg_get_str(m, "season")) )
|
||||
if ( (es = epg_season_find_by_uri(str, 0, NULL)) )
|
||||
*save |= epg_episode_set_season(ee, es);
|
||||
*save |= epg_episode_set_season(ee, es, NULL);
|
||||
if ( (str = htsmsg_get_str(m, "brand")) )
|
||||
if ( (eb = epg_brand_find_by_uri(str, 0, NULL)) )
|
||||
*save |= epg_episode_set_brand(ee, eb);
|
||||
*save |= epg_episode_set_brand(ee, eb, NULL);
|
||||
|
||||
*save |= epg_episode_set_is_bw(ee, htsmsg_get_u32_or_default(m , "is_bw", 0));
|
||||
if (!htsmsg_get_u32(m, "is_bw", &u32))
|
||||
*save |= epg_episode_set_is_bw(ee, u32, NULL);
|
||||
|
||||
return ee;
|
||||
}
|
||||
|
@ -1165,12 +1219,15 @@ epg_broadcast_t *epg_broadcast_find_by_eid ( channel_t *ch, int eid )
|
|||
}
|
||||
|
||||
int epg_broadcast_set_episode
|
||||
( epg_broadcast_t *broadcast, epg_episode_t *episode )
|
||||
( epg_broadcast_t *broadcast, epg_episode_t *episode, epggrab_module_t *src )
|
||||
{
|
||||
int save = 0;
|
||||
if ( !broadcast || !episode ) return 0;
|
||||
if ( !_epg_object_set_grabber(broadcast, src) && broadcast->episode )
|
||||
return 0;
|
||||
if ( broadcast->episode != episode ) {
|
||||
if ( broadcast->episode ) _epg_episode_rem_broadcast(broadcast->episode, broadcast);
|
||||
if ( broadcast->episode )
|
||||
_epg_episode_rem_broadcast(broadcast->episode, broadcast);
|
||||
broadcast->episode = episode;
|
||||
_epg_episode_add_broadcast(episode, broadcast);
|
||||
_epg_object_set_updated(broadcast);
|
||||
|
@ -1179,58 +1236,67 @@ int epg_broadcast_set_episode
|
|||
return save;
|
||||
}
|
||||
|
||||
int epg_broadcast_set_is_widescreen ( epg_broadcast_t *b, uint8_t ws )
|
||||
int epg_broadcast_set_is_widescreen
|
||||
( epg_broadcast_t *b, uint8_t ws, epggrab_module_t *src )
|
||||
{
|
||||
if (!b) return 0;
|
||||
return _epg_object_set_u8(b, &b->is_widescreen, ws);
|
||||
return _epg_object_set_u8(b, &b->is_widescreen, ws, src);
|
||||
}
|
||||
|
||||
int epg_broadcast_set_is_hd ( epg_broadcast_t *b, uint8_t hd )
|
||||
int epg_broadcast_set_is_hd
|
||||
( epg_broadcast_t *b, uint8_t hd, epggrab_module_t *src )
|
||||
{
|
||||
if (!b) return 0;
|
||||
return _epg_object_set_u8(b, &b->is_hd, hd);
|
||||
return _epg_object_set_u8(b, &b->is_hd, hd, src);
|
||||
}
|
||||
|
||||
int epg_broadcast_set_lines ( epg_broadcast_t *b, uint16_t lines )
|
||||
int epg_broadcast_set_lines
|
||||
( epg_broadcast_t *b, uint16_t lines, epggrab_module_t *src )
|
||||
{
|
||||
if (!b) return 0;
|
||||
return _epg_object_set_u16(b, &b->lines, lines);
|
||||
return _epg_object_set_u16(b, &b->lines, lines, src);
|
||||
}
|
||||
|
||||
int epg_broadcast_set_aspect ( epg_broadcast_t *b, uint16_t aspect )
|
||||
int epg_broadcast_set_aspect
|
||||
( epg_broadcast_t *b, uint16_t aspect, epggrab_module_t *src )
|
||||
{
|
||||
if (!b) return 0;
|
||||
return _epg_object_set_u16(b, &b->aspect, aspect);
|
||||
return _epg_object_set_u16(b, &b->aspect, aspect, src);
|
||||
}
|
||||
|
||||
int epg_broadcast_set_is_deafsigned ( epg_broadcast_t *b, uint8_t ds )
|
||||
int epg_broadcast_set_is_deafsigned
|
||||
( epg_broadcast_t *b, uint8_t ds, epggrab_module_t *src )
|
||||
{
|
||||
if (!b) return 0;
|
||||
return _epg_object_set_u8(b, &b->is_deafsigned, ds);
|
||||
return _epg_object_set_u8(b, &b->is_deafsigned, ds, src);
|
||||
}
|
||||
|
||||
int epg_broadcast_set_is_subtitled ( epg_broadcast_t *b, uint8_t st )
|
||||
int epg_broadcast_set_is_subtitled
|
||||
( epg_broadcast_t *b, uint8_t st, epggrab_module_t *src )
|
||||
{
|
||||
if (!b) return 0;
|
||||
return _epg_object_set_u8(b, &b->is_subtitled, st);
|
||||
return _epg_object_set_u8(b, &b->is_subtitled, st, src);
|
||||
}
|
||||
|
||||
int epg_broadcast_set_is_audio_desc ( epg_broadcast_t *b, uint8_t ad )
|
||||
int epg_broadcast_set_is_audio_desc
|
||||
( epg_broadcast_t *b, uint8_t ad, epggrab_module_t *src )
|
||||
{
|
||||
if (!b) return 0;
|
||||
return _epg_object_set_u8(b, &b->is_audio_desc, ad);
|
||||
return _epg_object_set_u8(b, &b->is_audio_desc, ad, src);
|
||||
}
|
||||
|
||||
int epg_broadcast_set_is_new ( epg_broadcast_t *b, uint8_t n )
|
||||
int epg_broadcast_set_is_new
|
||||
( epg_broadcast_t *b, uint8_t n, epggrab_module_t *src )
|
||||
{
|
||||
if (!b) return 0;
|
||||
return _epg_object_set_u8(b, &b->is_new, n);
|
||||
return _epg_object_set_u8(b, &b->is_new, n, src);
|
||||
}
|
||||
|
||||
int epg_broadcast_set_is_repeat ( epg_broadcast_t *b, uint8_t r )
|
||||
int epg_broadcast_set_is_repeat
|
||||
( epg_broadcast_t *b, uint8_t r, epggrab_module_t *src )
|
||||
{
|
||||
if (!b) return 0;
|
||||
return _epg_object_set_u8(b, &b->is_repeat, r);
|
||||
return _epg_object_set_u8(b, &b->is_repeat, r, src);
|
||||
}
|
||||
|
||||
epg_broadcast_t *epg_broadcast_get_next ( epg_broadcast_t *broadcast )
|
||||
|
@ -1313,26 +1379,26 @@ epg_broadcast_t *epg_broadcast_deserialize
|
|||
|
||||
/* Get metadata */
|
||||
if (!htsmsg_get_u32(m, "is_widescreen", &u32))
|
||||
*save |= epg_broadcast_set_is_widescreen(ebc, u32);
|
||||
*save |= epg_broadcast_set_is_widescreen(ebc, u32, NULL);
|
||||
if (!htsmsg_get_u32(m, "is_hd", &u32))
|
||||
*save |= epg_broadcast_set_is_hd(ebc, u32);
|
||||
*save |= epg_broadcast_set_is_hd(ebc, u32, NULL);
|
||||
if (!htsmsg_get_u32(m, "lines", &u32))
|
||||
*save |= epg_broadcast_set_lines(ebc, u32);
|
||||
*save |= epg_broadcast_set_lines(ebc, u32, NULL);
|
||||
if (!htsmsg_get_u32(m, "aspect", &u32))
|
||||
*save |= epg_broadcast_set_aspect(ebc, u32);
|
||||
*save |= epg_broadcast_set_aspect(ebc, u32, NULL);
|
||||
if (!htsmsg_get_u32(m, "is_deafsigned", &u32))
|
||||
*save |= epg_broadcast_set_is_deafsigned(ebc, u32);
|
||||
*save |= epg_broadcast_set_is_deafsigned(ebc, u32, NULL);
|
||||
if (!htsmsg_get_u32(m, "is_subtitled", &u32))
|
||||
*save |= epg_broadcast_set_is_subtitled(ebc, u32);
|
||||
*save |= epg_broadcast_set_is_subtitled(ebc, u32, NULL);
|
||||
if (!htsmsg_get_u32(m, "is_audio_desc", &u32))
|
||||
*save |= epg_broadcast_set_is_audio_desc(ebc, u32);
|
||||
*save |= epg_broadcast_set_is_audio_desc(ebc, u32, NULL);
|
||||
if (!htsmsg_get_u32(m, "is_new", &u32))
|
||||
*save |= epg_broadcast_set_is_new(ebc, u32);
|
||||
*save |= epg_broadcast_set_is_new(ebc, u32, NULL);
|
||||
if (!htsmsg_get_u32(m, "is_repeat", &u32))
|
||||
*save |= epg_broadcast_set_is_repeat(ebc, u32);
|
||||
*save |= epg_broadcast_set_is_repeat(ebc, u32, NULL);
|
||||
|
||||
/* Set the episode */
|
||||
*save |= epg_broadcast_set_episode(ebc, ee);
|
||||
*save |= epg_broadcast_set_episode(ebc, ee, NULL);
|
||||
|
||||
return ebc;
|
||||
}
|
||||
|
|
104
src/epg.h
104
src/epg.h
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Electronic Program Guide - Common functions
|
||||
* Copyright (C) 2007 Andreas Öman
|
||||
* Copyright (C) 2012 Adam Sutton
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -22,10 +22,11 @@
|
|||
#include "settings.h"
|
||||
|
||||
/*
|
||||
* Forward decls
|
||||
* External forward decls
|
||||
*/
|
||||
struct channel;
|
||||
struct channel_tag;
|
||||
struct epggrab_module;
|
||||
|
||||
/*
|
||||
* Map/List types
|
||||
|
@ -117,6 +118,8 @@ struct epg_object
|
|||
int refcount; ///< Reference counting
|
||||
// Note: could use LIST_ENTRY field to determine this!
|
||||
|
||||
struct epggrab_module *grabber; ///< Originating grabber
|
||||
|
||||
void (*getref) ( void *o ); ///< Get a reference
|
||||
void (*putref) ( void *o ); ///< Release a reference
|
||||
void (*destroy) ( void *o ); ///< Delete the object
|
||||
|
@ -148,13 +151,17 @@ epg_brand_t *epg_brand_find_by_uri
|
|||
epg_brand_t *epg_brand_find_by_id ( uint64_t id );
|
||||
|
||||
/* Mutators */
|
||||
int epg_brand_set_title ( epg_brand_t *b, const char *title )
|
||||
int epg_brand_set_title
|
||||
( epg_brand_t *b, const char *title, struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
int epg_brand_set_summary ( epg_brand_t *b, const char *summary )
|
||||
int epg_brand_set_summary
|
||||
( epg_brand_t *b, const char *summary, struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
int epg_brand_set_season_count ( epg_brand_t *b, uint16_t season_count )
|
||||
int epg_brand_set_season_count
|
||||
( epg_brand_t *b, uint16_t season_count, struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
int epg_brand_set_image ( epg_brand_t *b, const char *i )
|
||||
int epg_brand_set_image
|
||||
( epg_brand_t *b, const char *i, struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
|
||||
/* Serialization */
|
||||
|
@ -190,15 +197,20 @@ epg_season_t *epg_season_find_by_uri
|
|||
epg_season_t *epg_season_find_by_id ( uint64_t id );
|
||||
|
||||
/* Mutators */
|
||||
int epg_season_set_summary ( epg_season_t *s, const char *summary )
|
||||
int epg_season_set_summary
|
||||
( epg_season_t *s, const char *summary, struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
int epg_season_set_number ( epg_season_t *s, uint16_t number )
|
||||
int epg_season_set_number
|
||||
( epg_season_t *s, uint16_t number, struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
int epg_season_set_episode_count ( epg_season_t *s, uint16_t episode_count )
|
||||
int epg_season_set_episode_count
|
||||
( epg_season_t *s, uint16_t episode_count, struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
int epg_season_set_brand ( epg_season_t *s, epg_brand_t *b, int u )
|
||||
int epg_season_set_brand
|
||||
( epg_season_t *s, epg_brand_t *b, struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
int epg_season_set_image ( epg_season_t *s, const char *image )
|
||||
int epg_season_set_image
|
||||
( epg_season_t *s, const char *image, struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
|
||||
/* Serialization */
|
||||
|
@ -254,32 +266,42 @@ epg_episode_t *epg_episode_find_by_uri
|
|||
epg_episode_t *epg_episode_find_by_id ( uint64_t id );
|
||||
|
||||
/* Mutators */
|
||||
int epg_episode_set_title ( epg_episode_t *e, const char *title )
|
||||
int epg_episode_set_title
|
||||
( epg_episode_t *e, const char *title, struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
int epg_episode_set_subtitle ( epg_episode_t *e, const char *subtitle )
|
||||
int epg_episode_set_subtitle
|
||||
( epg_episode_t *e, const char *subtitle, struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
int epg_episode_set_summary ( epg_episode_t *e, const char *summary )
|
||||
int epg_episode_set_summary
|
||||
( epg_episode_t *e, const char *summary, struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
int epg_episode_set_description ( epg_episode_t *e, const char *description )
|
||||
int epg_episode_set_description
|
||||
( epg_episode_t *e, const char *description, struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
int epg_episode_set_number ( epg_episode_t *e, uint16_t number )
|
||||
int epg_episode_set_number
|
||||
( epg_episode_t *e, uint16_t number, struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
int epg_episode_set_part ( epg_episode_t *e,
|
||||
uint16_t number, uint16_t count )
|
||||
int epg_episode_set_part
|
||||
( epg_episode_t *e, uint16_t number, uint16_t count,
|
||||
struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
int epg_episode_set_epnum ( epg_episode_t *e, epg_episode_num_t *num )
|
||||
int epg_episode_set_epnum
|
||||
( epg_episode_t *e, epg_episode_num_t *num, struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
int epg_episode_set_brand ( epg_episode_t *e, epg_brand_t *b )
|
||||
int epg_episode_set_brand
|
||||
( epg_episode_t *e, epg_brand_t *b, struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
int epg_episode_set_season ( epg_episode_t *e, epg_season_t *s )
|
||||
int epg_episode_set_season
|
||||
( epg_episode_t *e, epg_season_t *s, struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
int epg_episode_set_genre ( epg_episode_t *e, epg_genre_list_t *g )
|
||||
int epg_episode_set_genre
|
||||
( epg_episode_t *e, epg_genre_list_t *g, struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
int epg_episode_set_genre_str ( epg_episode_t *e, const char **s )
|
||||
int epg_episode_set_image
|
||||
( epg_episode_t *e, const char *i, struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
int epg_episode_set_image ( epg_episode_t *e, const char *i )
|
||||
__attribute__((warn_unused_result));
|
||||
int epg_episode_set_is_bw ( epg_episode_t *b, uint8_t bw )
|
||||
int epg_episode_set_is_bw
|
||||
( epg_episode_t *b, uint8_t bw, struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
|
||||
// Note: this does NOT strdup the text field
|
||||
|
@ -355,25 +377,35 @@ epg_broadcast_t *epg_broadcast_find_by_eid ( struct channel *ch, int eid );
|
|||
epg_broadcast_t *epg_broadcast_find_by_id ( uint64_t id, struct channel *ch );
|
||||
|
||||
/* Mutators */
|
||||
int epg_broadcast_set_episode ( epg_broadcast_t *b, epg_episode_t *e )
|
||||
int epg_broadcast_set_episode
|
||||
( epg_broadcast_t *b, epg_episode_t *e, struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
int epg_broadcast_set_is_widescreen ( epg_broadcast_t *b, uint8_t ws )
|
||||
int epg_broadcast_set_is_widescreen
|
||||
( epg_broadcast_t *b, uint8_t ws, struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
int epg_broadcast_set_is_hd ( epg_broadcast_t *b, uint8_t hd )
|
||||
int epg_broadcast_set_is_hd
|
||||
( epg_broadcast_t *b, uint8_t hd, struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
int epg_broadcast_set_lines ( epg_broadcast_t *b, uint16_t lines )
|
||||
int epg_broadcast_set_lines
|
||||
( epg_broadcast_t *b, uint16_t lines, struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
int epg_broadcast_set_aspect ( epg_broadcast_t *b, uint16_t aspect )
|
||||
int epg_broadcast_set_aspect
|
||||
( epg_broadcast_t *b, uint16_t aspect, struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
int epg_broadcast_set_is_deafsigned ( epg_broadcast_t *b, uint8_t ds )
|
||||
int epg_broadcast_set_is_deafsigned
|
||||
( epg_broadcast_t *b, uint8_t ds, struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
int epg_broadcast_set_is_subtitled ( epg_broadcast_t *b, uint8_t st )
|
||||
int epg_broadcast_set_is_subtitled
|
||||
( epg_broadcast_t *b, uint8_t st, struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
int epg_broadcast_set_is_audio_desc ( epg_broadcast_t *b, uint8_t ad )
|
||||
int epg_broadcast_set_is_audio_desc
|
||||
( epg_broadcast_t *b, uint8_t ad, struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
int epg_broadcast_set_is_new ( epg_broadcast_t *b, uint8_t n )
|
||||
int epg_broadcast_set_is_new
|
||||
( epg_broadcast_t *b, uint8_t n, struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
int epg_broadcast_set_is_repeat ( epg_broadcast_t *b, uint8_t r )
|
||||
int epg_broadcast_set_is_repeat
|
||||
( epg_broadcast_t *b, uint8_t r, struct epggrab_module *src )
|
||||
__attribute__((warn_unused_result));
|
||||
|
||||
/* Accessors */
|
||||
|
|
10
src/epgdb.c
10
src/epgdb.c
|
@ -77,20 +77,20 @@ static void _epgdb_v1_process ( htsmsg_t *c, epggrab_stats_t *stats )
|
|||
if (!ee) return;
|
||||
if (save) stats->episodes.total++;
|
||||
if (title)
|
||||
save |= epg_episode_set_title(ee, title);
|
||||
save |= epg_episode_set_title(ee, title, NULL);
|
||||
if (desc)
|
||||
save |= epg_episode_set_summary(ee, desc);
|
||||
save |= epg_episode_set_summary(ee, desc, NULL);
|
||||
if (!htsmsg_get_u32(c, "episode", &u32))
|
||||
save |= epg_episode_set_number(ee, u32);
|
||||
save |= epg_episode_set_number(ee, u32, NULL);
|
||||
if (!htsmsg_get_u32(c, "part", &u32))
|
||||
save |= epg_episode_set_part(ee, u32, 0);
|
||||
save |= epg_episode_set_part(ee, u32, 0, NULL);
|
||||
if (!htsmsg_get_u32(c, "season", &u32))
|
||||
ee->epnum.s_num = u32;
|
||||
if ((str = htsmsg_get_str(c, "epname")))
|
||||
ee->epnum.text = strdup(str);
|
||||
|
||||
/* Set episode */
|
||||
save |= epg_broadcast_set_episode(ebc, ee);
|
||||
save |= epg_broadcast_set_episode(ebc, ee, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -103,6 +103,7 @@ static void* _epggrab_internal_thread ( void* p )
|
|||
static void _epggrab_load ( void )
|
||||
{
|
||||
epggrab_module_t *mod;
|
||||
htsmsg_field_t *f;
|
||||
htsmsg_t *m, *a;
|
||||
uint32_t enabled = 1;
|
||||
const char *str;
|
||||
|
@ -120,8 +121,10 @@ static void _epggrab_load ( void )
|
|||
htsmsg_get_u32(m, "channel_rename", &epggrab_channel_rename);
|
||||
htsmsg_get_u32(m, "channel_renumber", &epggrab_channel_renumber);
|
||||
htsmsg_get_u32(m, "channel_reicon", &epggrab_channel_reicon);
|
||||
if (!htsmsg_get_u32(m, old ? "grab-interval" : "interval", &epggrab_interval))
|
||||
if (!htsmsg_get_u32(m, old ? "grab-interval" : "interval",
|
||||
&epggrab_interval)) {
|
||||
if (old) epggrab_interval *= 3600;
|
||||
}
|
||||
htsmsg_get_u32(m, "grab-enabled", &enabled);
|
||||
if (enabled) {
|
||||
if ( (str = htsmsg_get_str(m, old ? "current-grabber" : "module")) ) {
|
||||
|
@ -133,16 +136,24 @@ static void _epggrab_load ( void )
|
|||
if ( (a = htsmsg_get_map(m, "mod_enabled")) ) {
|
||||
LIST_FOREACH(mod, &epggrab_modules, link) {
|
||||
if (htsmsg_get_u32_or_default(a, mod->id, 0)) {
|
||||
epggrab_enable_module(mod, 1);
|
||||
epggrab_enable_module(mod, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( (a = htsmsg_get_list(m, "mod_priority")) ) {
|
||||
int prio = 1;
|
||||
LIST_FOREACH(mod, &epggrab_modules, link)
|
||||
mod->priority = 0;
|
||||
HTSMSG_FOREACH(f, a) {
|
||||
mod = epggrab_module_find_by_id(f->hmf_str);
|
||||
if (mod) mod->priority = prio++;
|
||||
}
|
||||
}
|
||||
}
|
||||
htsmsg_destroy(m);
|
||||
|
||||
/* Finish up migration */
|
||||
if (old) {
|
||||
htsmsg_field_t *f;
|
||||
htsmsg_t *xc, *ch;
|
||||
htsmsg_t *xchs = hts_settings_load("xmltv/channels");
|
||||
htsmsg_t *chs = hts_settings_load("channels");
|
||||
|
|
|
@ -120,6 +120,7 @@ struct epggrab_module
|
|||
const char *id; ///< Module identifier
|
||||
const char *name; ///< Module name (for display)
|
||||
uint8_t enabled; ///< Whether the module is enabled
|
||||
int priority; ///< Priority of the module
|
||||
epggrab_channel_tree_t *channels; ///< Channel list
|
||||
|
||||
/* Enable/Disable */
|
||||
|
|
|
@ -73,7 +73,7 @@ htsmsg_t *epggrab_module_list ( void )
|
|||
* *************************************************************************/
|
||||
|
||||
epggrab_module_t *epggrab_module_create
|
||||
( epggrab_module_t *skel, const char *id, const char *name,
|
||||
( epggrab_module_t *skel, const char *id, const char *name, int priority,
|
||||
epggrab_channel_tree_t *channels )
|
||||
{
|
||||
assert(skel);
|
||||
|
@ -81,6 +81,7 @@ epggrab_module_t *epggrab_module_create
|
|||
/* Setup */
|
||||
skel->id = strdup(id);
|
||||
skel->name = strdup(name);
|
||||
skel->priority = priority;
|
||||
skel->channels = channels;
|
||||
if (channels) {
|
||||
skel->ch_save = epggrab_module_ch_save;
|
||||
|
@ -227,7 +228,8 @@ void epggrab_module_channels_load ( epggrab_module_t *mod )
|
|||
|
||||
epggrab_module_int_t *epggrab_module_int_create
|
||||
( epggrab_module_int_t *skel,
|
||||
const char *id, const char *name, const char *path,
|
||||
const char *id, const char *name, int priority,
|
||||
const char *path,
|
||||
char* (*grab) (void*m),
|
||||
int (*parse) (void *m, htsmsg_t *data, epggrab_stats_t *sta),
|
||||
htsmsg_t* (*trans) (void *mod, char *data),
|
||||
|
@ -237,7 +239,7 @@ epggrab_module_int_t *epggrab_module_int_create
|
|||
if (!skel) skel = calloc(1, sizeof(epggrab_module_int_t));
|
||||
|
||||
/* Pass through */
|
||||
epggrab_module_create((epggrab_module_t*)skel, id, name, channels);
|
||||
epggrab_module_create((epggrab_module_t*)skel, id, name, priority, channels);
|
||||
|
||||
/* Int data */
|
||||
skel->type = EPGGRAB_INT;
|
||||
|
@ -397,7 +399,7 @@ int epggrab_module_enable_socket ( void *m, uint8_t e )
|
|||
*/
|
||||
epggrab_module_ext_t *epggrab_module_ext_create
|
||||
( epggrab_module_ext_t *skel,
|
||||
const char *id, const char *name, const char *sockid,
|
||||
const char *id, const char *name, int priority, const char *sockid,
|
||||
int (*parse) (void *m, htsmsg_t *data, epggrab_stats_t *sta),
|
||||
htsmsg_t* (*trans) (void *mod, char *data),
|
||||
epggrab_channel_tree_t *channels )
|
||||
|
@ -411,7 +413,7 @@ epggrab_module_ext_t *epggrab_module_ext_create
|
|||
snprintf(path, 512, "%s/epggrab/%s.sock",
|
||||
hts_settings_get_root(), sockid);
|
||||
epggrab_module_int_create((epggrab_module_int_t*)skel,
|
||||
id, name, path,
|
||||
id, name, priority, path,
|
||||
NULL, parse, trans,
|
||||
channels);
|
||||
|
||||
|
@ -428,7 +430,7 @@ epggrab_module_ext_t *epggrab_module_ext_create
|
|||
|
||||
epggrab_module_ota_t *epggrab_module_ota_create
|
||||
( epggrab_module_ota_t *skel,
|
||||
const char *id, const char *name,
|
||||
const char *id, const char *name, int priority,
|
||||
void (*start) (epggrab_module_ota_t*m,
|
||||
struct th_dvb_mux_instance *tdmi),
|
||||
int (*enable) (void *m, uint8_t e ),
|
||||
|
@ -437,7 +439,7 @@ epggrab_module_ota_t *epggrab_module_ota_create
|
|||
if (!skel) skel = calloc(1, sizeof(epggrab_module_ota_t));
|
||||
|
||||
/* Pass through */
|
||||
epggrab_module_create((epggrab_module_t*)skel, id, name, channels);
|
||||
epggrab_module_create((epggrab_module_t*)skel, id, name, priority, channels);
|
||||
|
||||
/* Setup */
|
||||
skel->type = EPGGRAB_OTA;
|
||||
|
|
|
@ -145,7 +145,7 @@ static int _eit_callback
|
|||
( th_dvb_mux_instance_t *tdmi, uint8_t *ptr, int len,
|
||||
uint8_t tableid, void *opaque )
|
||||
{
|
||||
epggrab_module_ota_t *mod = opaque;
|
||||
epggrab_module_t *mod = opaque;
|
||||
epggrab_ota_mux_t *ota;
|
||||
th_dvb_adapter_t *tda;
|
||||
service_t *svc;
|
||||
|
@ -168,7 +168,7 @@ static int _eit_callback
|
|||
return -1;
|
||||
|
||||
/* Get OTA */
|
||||
ota = epggrab_ota_find(mod, tdmi);
|
||||
ota = epggrab_ota_find((epggrab_module_ota_t*)mod, tdmi);
|
||||
if (!ota || !ota->status) return 0;
|
||||
sta = ota->status;
|
||||
|
||||
|
@ -364,11 +364,11 @@ static int _eit_callback
|
|||
|
||||
/* Metadata */
|
||||
if ( save2 ) {
|
||||
save |= epg_broadcast_set_is_hd(ebc, hd);
|
||||
save |= epg_broadcast_set_is_widescreen(ebc, ws);
|
||||
save |= epg_broadcast_set_is_audio_desc(ebc, ad);
|
||||
save |= epg_broadcast_set_is_subtitled(ebc, st);
|
||||
save |= epg_broadcast_set_is_deafsigned(ebc, ds);
|
||||
save |= epg_broadcast_set_is_hd(ebc, hd, mod);
|
||||
save |= epg_broadcast_set_is_widescreen(ebc, ws, mod);
|
||||
save |= epg_broadcast_set_is_audio_desc(ebc, ad, mod);
|
||||
save |= epg_broadcast_set_is_subtitled(ebc, st, mod);
|
||||
save |= epg_broadcast_set_is_deafsigned(ebc, ds, mod);
|
||||
}
|
||||
|
||||
/* Create episode */
|
||||
|
@ -378,7 +378,7 @@ static int _eit_callback
|
|||
uri = epg_hash(title, summary, desc);
|
||||
if (uri) {
|
||||
if ((ee = epg_episode_find_by_uri(uri, 1, &save2)))
|
||||
save |= epg_broadcast_set_episode(ebc, ee);
|
||||
save |= epg_broadcast_set_episode(ebc, ee, mod);
|
||||
free(uri);
|
||||
}
|
||||
}
|
||||
|
@ -386,18 +386,18 @@ static int _eit_callback
|
|||
|
||||
/* Episode data */
|
||||
if (ee) {
|
||||
save |= epg_episode_set_is_bw(ee, bw);
|
||||
if ( !ee->title && *title )
|
||||
save |= epg_episode_set_title(ee, title);
|
||||
if ( !ee->summary && *summary )
|
||||
save |= epg_episode_set_summary(ee, summary);
|
||||
if ( !ee->description && *desc )
|
||||
save |= epg_episode_set_description(ee, desc);
|
||||
if ( !LIST_FIRST(&ee->genre) && egl )
|
||||
save |= epg_episode_set_genre(ee, egl);
|
||||
save |= epg_episode_set_is_bw(ee, bw, mod);
|
||||
if ( *title )
|
||||
save |= epg_episode_set_title(ee, title, mod);
|
||||
if ( *summary )
|
||||
save |= epg_episode_set_summary(ee, summary, mod);
|
||||
if ( *desc )
|
||||
save |= epg_episode_set_description(ee, desc, mod);
|
||||
if ( egl )
|
||||
save |= epg_episode_set_genre(ee, egl, mod);
|
||||
#if TODO_ADD_EXTRA
|
||||
if ( extra )
|
||||
save |= epg_episode_set_extra(ee, extra);
|
||||
save |= epg_episode_set_extra(ee, extra, mod);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -431,7 +431,7 @@ static void _eit_start
|
|||
|
||||
void eit_init ( void )
|
||||
{
|
||||
epggrab_module_ota_create(NULL, "eit", "EIT: DVB Grabber",
|
||||
epggrab_module_ota_create(NULL, "eit", "EIT: DVB Grabber", 1,
|
||||
_eit_start, NULL, NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -349,6 +349,7 @@ static int _opentv_parse_event_section
|
|||
epg_episode_t *ee;
|
||||
epg_season_t *es;
|
||||
opentv_event_t ev;
|
||||
epggrab_module_t *src = (epggrab_module_t*)mod;
|
||||
|
||||
/* Channel */
|
||||
cid = ((int)buf[0] << 8) | buf[1];
|
||||
|
@ -398,27 +399,27 @@ static int _opentv_parse_event_section
|
|||
/* Update */
|
||||
if (ee) {
|
||||
if (!ev.title && ebc->episode)
|
||||
save |= epg_episode_set_title(ee, ebc->episode->title);
|
||||
save |= epg_episode_set_title(ee, ebc->episode->title, src);
|
||||
else if (ev.title)
|
||||
save |= epg_episode_set_title(ee, ev.title);
|
||||
save |= epg_episode_set_title(ee, ev.title, src);
|
||||
if (ev.summary)
|
||||
save |= epg_episode_set_summary(ee, ev.summary);
|
||||
save |= epg_episode_set_summary(ee, ev.summary, src);
|
||||
if (ev.desc)
|
||||
save |= epg_episode_set_description(ee, ev.desc);
|
||||
save |= epg_episode_set_description(ee, ev.desc, src);
|
||||
if (ev.cat) {
|
||||
epg_genre_list_t *egl = calloc(1, sizeof(epg_genre_list_t));
|
||||
epg_genre_list_add_by_eit(egl, ev.cat);
|
||||
save |= epg_episode_set_genre(ee, egl);
|
||||
save |= epg_episode_set_genre(ee, egl, src);
|
||||
epg_genre_list_destroy(egl);
|
||||
}
|
||||
// Note: don't override the season (since the ID is channel specific
|
||||
// it'll keep changing!
|
||||
if (ev.series && !ee->season) {
|
||||
es = _opentv_find_season(mod, cid, ev.series);
|
||||
if (es) save |= epg_episode_set_season(ee, es);
|
||||
if (es) save |= epg_episode_set_season(ee, es, src);
|
||||
}
|
||||
|
||||
save |= epg_broadcast_set_episode(ebc, ee);
|
||||
save |= epg_broadcast_set_episode(ebc, ee, src);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -874,7 +875,7 @@ static int _opentv_prov_load_one ( const char *id, htsmsg_t *m )
|
|||
sprintf(nbuf, "OpenTV: %s", name);
|
||||
mod = (opentv_module_t*)
|
||||
epggrab_module_ota_create(calloc(1, sizeof(opentv_module_t)),
|
||||
ibuf, nbuf,
|
||||
ibuf, nbuf, 2,
|
||||
_opentv_start, _opentv_enable,
|
||||
NULL);
|
||||
|
||||
|
|
|
@ -71,7 +71,8 @@ static epg_genre_list_t
|
|||
return egl;
|
||||
}
|
||||
|
||||
static int _pyepg_parse_channel ( htsmsg_t *data, epggrab_stats_t *stats )
|
||||
static int _pyepg_parse_channel
|
||||
( epggrab_module_t *mod, htsmsg_t *data, epggrab_stats_t *stats )
|
||||
{
|
||||
int save = 0;
|
||||
epggrab_channel_t *ch;
|
||||
|
@ -105,7 +106,8 @@ static int _pyepg_parse_channel ( htsmsg_t *data, epggrab_stats_t *stats )
|
|||
return save;
|
||||
}
|
||||
|
||||
static int _pyepg_parse_brand ( htsmsg_t *data, epggrab_stats_t *stats )
|
||||
static int _pyepg_parse_brand
|
||||
( epggrab_module_t *mod, htsmsg_t *data, epggrab_stats_t *stats )
|
||||
{
|
||||
int save = 0;
|
||||
htsmsg_t *attr, *tags;
|
||||
|
@ -126,24 +128,24 @@ static int _pyepg_parse_brand ( htsmsg_t *data, epggrab_stats_t *stats )
|
|||
|
||||
/* Set title */
|
||||
if ((str = htsmsg_xml_get_cdata_str(tags, "title"))) {
|
||||
save |= epg_brand_set_title(brand, str);
|
||||
save |= epg_brand_set_title(brand, str, mod);
|
||||
}
|
||||
|
||||
/* Set summary */
|
||||
if ((str = htsmsg_xml_get_cdata_str(tags, "summary"))) {
|
||||
save |= epg_brand_set_summary(brand, str);
|
||||
save |= epg_brand_set_summary(brand, str, mod);
|
||||
}
|
||||
|
||||
/* Set image */
|
||||
if ((str = htsmsg_xml_get_cdata_str(tags, "image"))) {
|
||||
save |= epg_brand_set_image(brand, str);
|
||||
save |= epg_brand_set_image(brand, str, mod);
|
||||
} else if ((str = htsmsg_xml_get_cdata_str(tags, "thumb"))) {
|
||||
save |= epg_brand_set_image(brand, str);
|
||||
save |= epg_brand_set_image(brand, str, mod);
|
||||
}
|
||||
|
||||
/* Set season count */
|
||||
if (htsmsg_xml_get_cdata_u32(tags, "series-count", &u32) == 0) {
|
||||
save |= epg_brand_set_season_count(brand, u32);
|
||||
save |= epg_brand_set_season_count(brand, u32, mod);
|
||||
}
|
||||
|
||||
if (save) stats->brands.modified++;
|
||||
|
@ -151,7 +153,8 @@ static int _pyepg_parse_brand ( htsmsg_t *data, epggrab_stats_t *stats )
|
|||
return save;
|
||||
}
|
||||
|
||||
static int _pyepg_parse_season ( htsmsg_t *data, epggrab_stats_t *stats )
|
||||
static int _pyepg_parse_season
|
||||
( epggrab_module_t *mod, htsmsg_t *data, epggrab_stats_t *stats )
|
||||
{
|
||||
int save = 0;
|
||||
htsmsg_t *attr, *tags;
|
||||
|
@ -174,30 +177,30 @@ static int _pyepg_parse_season ( htsmsg_t *data, epggrab_stats_t *stats )
|
|||
/* Set brand */
|
||||
if ((str = htsmsg_get_str(attr, "brand"))) {
|
||||
if ((brand = epg_brand_find_by_uri(str, 0, NULL))) {
|
||||
save |= epg_season_set_brand(season, brand, 1);
|
||||
save |= epg_season_set_brand(season, brand, mod);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set summary */
|
||||
if ((str = htsmsg_xml_get_cdata_str(tags, "summary"))) {
|
||||
save |= epg_season_set_summary(season, str);
|
||||
save |= epg_season_set_summary(season, str, mod);
|
||||
}
|
||||
|
||||
/* Set image */
|
||||
if ((str = htsmsg_xml_get_cdata_str(tags, "image"))) {
|
||||
save |= epg_season_set_image(season, str);
|
||||
save |= epg_season_set_image(season, str, mod);
|
||||
} else if ((str = htsmsg_xml_get_cdata_str(tags, "thumb"))) {
|
||||
save |= epg_season_set_image(season, str);
|
||||
save |= epg_season_set_image(season, str, mod);
|
||||
}
|
||||
|
||||
/* Set season number */
|
||||
if (htsmsg_xml_get_cdata_u32(tags, "number", &u32) == 0) {
|
||||
save |= epg_season_set_number(season, u32);
|
||||
save |= epg_season_set_number(season, u32, mod);
|
||||
}
|
||||
|
||||
/* Set episode count */
|
||||
if (htsmsg_xml_get_cdata_u32(tags, "episode-count", &u32) == 0) {
|
||||
save |= epg_season_set_episode_count(season, u32);
|
||||
save |= epg_season_set_episode_count(season, u32, mod);
|
||||
}
|
||||
|
||||
if(save) stats->seasons.modified++;
|
||||
|
@ -205,7 +208,8 @@ static int _pyepg_parse_season ( htsmsg_t *data, epggrab_stats_t *stats )
|
|||
return save;
|
||||
}
|
||||
|
||||
static int _pyepg_parse_episode ( htsmsg_t *data, epggrab_stats_t *stats )
|
||||
static int _pyepg_parse_episode
|
||||
( epggrab_module_t *mod, htsmsg_t *data, epggrab_stats_t *stats )
|
||||
{
|
||||
int save = 0;
|
||||
htsmsg_t *attr, *tags;
|
||||
|
@ -230,56 +234,56 @@ static int _pyepg_parse_episode ( htsmsg_t *data, epggrab_stats_t *stats )
|
|||
/* Set season */
|
||||
if ((str = htsmsg_get_str(attr, "series"))) {
|
||||
if ((season = epg_season_find_by_uri(str, 0, NULL))) {
|
||||
save |= epg_episode_set_season(episode, season);
|
||||
save |= epg_episode_set_season(episode, season, mod);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set brand */
|
||||
if ((str = htsmsg_get_str(attr, "brand"))) {
|
||||
if ((brand = epg_brand_find_by_uri(str, 0, NULL))) {
|
||||
save |= epg_episode_set_brand(episode, brand);
|
||||
save |= epg_episode_set_brand(episode, brand, mod);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set title/subtitle */
|
||||
if ((str = htsmsg_xml_get_cdata_str(tags, "title"))) {
|
||||
save |= epg_episode_set_title(episode, str);
|
||||
save |= epg_episode_set_title(episode, str, mod);
|
||||
}
|
||||
if ((str = htsmsg_xml_get_cdata_str(tags, "subtitle"))) {
|
||||
save |= epg_episode_set_subtitle(episode, str);
|
||||
save |= epg_episode_set_subtitle(episode, str, mod);
|
||||
}
|
||||
|
||||
/* Set summary */
|
||||
if ((str = htsmsg_xml_get_cdata_str(tags, "summary"))) {
|
||||
save |= epg_episode_set_summary(episode, str);
|
||||
save |= epg_episode_set_summary(episode, str, mod);
|
||||
}
|
||||
|
||||
/* Number */
|
||||
if (htsmsg_xml_get_cdata_u32(tags, "number", &u32) == 0) {
|
||||
save |= epg_episode_set_number(episode, u32);
|
||||
save |= epg_episode_set_number(episode, u32, mod);
|
||||
}
|
||||
if (!htsmsg_xml_get_cdata_u32(tags, "part-number", &pn)) {
|
||||
pc = 0;
|
||||
htsmsg_xml_get_cdata_u32(tags, "part-count", &pc);
|
||||
save |= epg_episode_set_part(episode, pn, pc);
|
||||
save |= epg_episode_set_part(episode, pn, pc, mod);
|
||||
}
|
||||
|
||||
/* Set image */
|
||||
if ((str = htsmsg_xml_get_cdata_str(tags, "image"))) {
|
||||
save |= epg_episode_set_image(episode, str);
|
||||
save |= epg_episode_set_image(episode, str, mod);
|
||||
} else if ((str = htsmsg_xml_get_cdata_str(tags, "thumb"))) {
|
||||
save |= epg_episode_set_image(episode, str);
|
||||
save |= epg_episode_set_image(episode, str, mod);
|
||||
}
|
||||
|
||||
/* Genre */
|
||||
if ((egl = _pyepg_parse_genre(tags))) {
|
||||
save |= epg_episode_set_genre(episode, egl);
|
||||
save |= epg_episode_set_genre(episode, egl, mod);
|
||||
epg_genre_list_destroy(egl);
|
||||
}
|
||||
|
||||
/* Content */
|
||||
if ((htsmsg_get_map(tags, "blackandwhite")))
|
||||
save |= epg_episode_set_is_bw(episode, 1);
|
||||
save |= epg_episode_set_is_bw(episode, 1, mod);
|
||||
|
||||
if (save) stats->episodes.modified++;
|
||||
|
||||
|
@ -287,7 +291,8 @@ static int _pyepg_parse_episode ( htsmsg_t *data, epggrab_stats_t *stats )
|
|||
}
|
||||
|
||||
static int _pyepg_parse_broadcast
|
||||
( htsmsg_t *data, channel_t *channel, epggrab_stats_t *stats )
|
||||
( epggrab_module_t *mod, htsmsg_t *data, channel_t *channel,
|
||||
epggrab_stats_t *stats )
|
||||
{
|
||||
int save = 0;
|
||||
htsmsg_t *attr, *tags;
|
||||
|
@ -320,31 +325,32 @@ static int _pyepg_parse_broadcast
|
|||
if ( save ) stats->broadcasts.created++;
|
||||
|
||||
/* Set episode */
|
||||
save |= epg_broadcast_set_episode(broadcast, episode);
|
||||
save |= epg_broadcast_set_episode(broadcast, episode, mod);
|
||||
|
||||
/* Quality */
|
||||
u32 = htsmsg_get_map(tags, "hd") ? 1 : 0;
|
||||
save |= epg_broadcast_set_is_hd(broadcast, u32);
|
||||
save |= epg_broadcast_set_is_hd(broadcast, u32, mod);
|
||||
u32 = htsmsg_get_map(tags, "widescreen") ? 1 : 0;
|
||||
save |= epg_broadcast_set_is_widescreen(broadcast, u32);
|
||||
save |= epg_broadcast_set_is_widescreen(broadcast, u32, mod);
|
||||
// TODO: lines, aspect
|
||||
|
||||
/* Accessibility */
|
||||
// Note: reuse XMLTV parse code as this is the same
|
||||
xmltv_parse_accessibility(broadcast, tags);
|
||||
xmltv_parse_accessibility(mod, broadcast, tags);
|
||||
|
||||
/* New/Repeat */
|
||||
u32 = htsmsg_get_map(tags, "new") || htsmsg_get_map(tags, "premiere");
|
||||
save |= epg_broadcast_set_is_new(broadcast, u32);
|
||||
save |= epg_broadcast_set_is_new(broadcast, u32, mod);
|
||||
u32 = htsmsg_get_map(tags, "repeat") ? 1 : 0;
|
||||
save |= epg_broadcast_set_is_repeat(broadcast, u32);
|
||||
save |= epg_broadcast_set_is_repeat(broadcast, u32, mod);
|
||||
|
||||
if (save) stats->broadcasts.modified++;
|
||||
|
||||
return save;
|
||||
}
|
||||
|
||||
static int _pyepg_parse_schedule ( htsmsg_t *data, epggrab_stats_t *stats )
|
||||
static int _pyepg_parse_schedule
|
||||
( epggrab_module_t *mod, htsmsg_t *data, epggrab_stats_t *stats )
|
||||
{
|
||||
int save = 0;
|
||||
htsmsg_t *attr, *tags;
|
||||
|
@ -362,7 +368,7 @@ static int _pyepg_parse_schedule ( htsmsg_t *data, epggrab_stats_t *stats )
|
|||
|
||||
HTSMSG_FOREACH(f, tags) {
|
||||
if (strcmp(f->hmf_name, "broadcast") == 0) {
|
||||
save |= _pyepg_parse_broadcast(htsmsg_get_map_by_field(f),
|
||||
save |= _pyepg_parse_broadcast(mod, htsmsg_get_map_by_field(f),
|
||||
ec->channel, stats);
|
||||
}
|
||||
}
|
||||
|
@ -370,7 +376,8 @@ static int _pyepg_parse_schedule ( htsmsg_t *data, epggrab_stats_t *stats )
|
|||
return save;
|
||||
}
|
||||
|
||||
static int _pyepg_parse_epg ( htsmsg_t *data, epggrab_stats_t *stats )
|
||||
static int _pyepg_parse_epg
|
||||
( epggrab_module_t *mod, htsmsg_t *data, epggrab_stats_t *stats )
|
||||
{
|
||||
int save = 0;
|
||||
htsmsg_t *tags;
|
||||
|
@ -380,15 +387,15 @@ static int _pyepg_parse_epg ( htsmsg_t *data, epggrab_stats_t *stats )
|
|||
|
||||
HTSMSG_FOREACH(f, tags) {
|
||||
if (strcmp(f->hmf_name, "channel") == 0 ) {
|
||||
save |= _pyepg_parse_channel(htsmsg_get_map_by_field(f), stats);
|
||||
save |= _pyepg_parse_channel(mod, htsmsg_get_map_by_field(f), stats);
|
||||
} else if (strcmp(f->hmf_name, "brand") == 0 ) {
|
||||
save |= _pyepg_parse_brand(htsmsg_get_map_by_field(f), stats);
|
||||
save |= _pyepg_parse_brand(mod, htsmsg_get_map_by_field(f), stats);
|
||||
} else if (strcmp(f->hmf_name, "series") == 0 ) {
|
||||
save |= _pyepg_parse_season(htsmsg_get_map_by_field(f), stats);
|
||||
save |= _pyepg_parse_season(mod, htsmsg_get_map_by_field(f), stats);
|
||||
} else if (strcmp(f->hmf_name, "episode") == 0 ) {
|
||||
save |= _pyepg_parse_episode(htsmsg_get_map_by_field(f), stats);
|
||||
save |= _pyepg_parse_episode(mod, htsmsg_get_map_by_field(f), stats);
|
||||
} else if (strcmp(f->hmf_name, "schedule") == 0 ) {
|
||||
save |= _pyepg_parse_schedule(htsmsg_get_map_by_field(f), stats);
|
||||
save |= _pyepg_parse_schedule(mod, htsmsg_get_map_by_field(f), stats);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -404,7 +411,7 @@ static int _pyepg_parse
|
|||
|
||||
/* PyEPG format */
|
||||
if ((epg = htsmsg_get_map(tags, "epg")) != NULL)
|
||||
return _pyepg_parse_epg(epg, stats);
|
||||
return _pyepg_parse_epg(mod, epg, stats);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -416,12 +423,13 @@ static int _pyepg_parse
|
|||
void pyepg_init ( void )
|
||||
{
|
||||
/* Internal module */
|
||||
epggrab_module_int_create(NULL, "/usr/bin/pyepg", "PyEPG", "/usr/bin/pyepg",
|
||||
epggrab_module_int_create(NULL, "/usr/bin/pyepg", "PyEPG", 4,
|
||||
"/usr/bin/pyepg",
|
||||
NULL, _pyepg_parse, NULL, NULL);
|
||||
|
||||
/* External module */
|
||||
_pyepg_module = (epggrab_module_t*)
|
||||
epggrab_module_ext_create(NULL, "pyepg", "PyEPG", "pyepg",
|
||||
epggrab_module_ext_create(NULL, "pyepg", "PyEPG", 4, "pyepg",
|
||||
_pyepg_parse, NULL,
|
||||
&_pyepg_channels);
|
||||
}
|
||||
|
|
|
@ -214,7 +214,9 @@ get_episode_info
|
|||
* job
|
||||
*/
|
||||
static int
|
||||
parse_vid_quality ( epg_broadcast_t *ebc, epg_episode_t *ee, htsmsg_t *m )
|
||||
parse_vid_quality
|
||||
( epggrab_module_t *mod, epg_broadcast_t *ebc, epg_episode_t *ee,
|
||||
htsmsg_t *m )
|
||||
{
|
||||
int save = 0;
|
||||
int hd = 0, lines = 0, aspect = 0;
|
||||
|
@ -222,7 +224,7 @@ parse_vid_quality ( epg_broadcast_t *ebc, epg_episode_t *ee, htsmsg_t *m )
|
|||
if (!ebc || !m) return 0;
|
||||
|
||||
if ((str = htsmsg_xml_get_cdata_str(m, "colour")))
|
||||
save |= epg_episode_set_is_bw(ee, strcmp(str, "no") ? 0 : 1);
|
||||
save |= epg_episode_set_is_bw(ee, strcmp(str, "no") ? 0 : 1, mod);
|
||||
if ((str = htsmsg_xml_get_cdata_str(m, "quality"))) {
|
||||
if (strstr(str, "HD")) {
|
||||
hd = 1;
|
||||
|
@ -248,13 +250,13 @@ parse_vid_quality ( epg_broadcast_t *ebc, epg_episode_t *ee, htsmsg_t *m )
|
|||
aspect = (100 * w) / h;
|
||||
}
|
||||
}
|
||||
save |= epg_broadcast_set_is_hd(ebc, hd);
|
||||
save |= epg_broadcast_set_is_hd(ebc, hd, mod);
|
||||
if (aspect) {
|
||||
save |= epg_broadcast_set_is_widescreen(ebc, hd || aspect > 137);
|
||||
save |= epg_broadcast_set_aspect(ebc, aspect);
|
||||
save |= epg_broadcast_set_is_widescreen(ebc, hd || aspect > 137, mod);
|
||||
save |= epg_broadcast_set_aspect(ebc, aspect, mod);
|
||||
}
|
||||
if (lines)
|
||||
save |= epg_broadcast_set_lines(ebc, lines);
|
||||
save |= epg_broadcast_set_lines(ebc, lines, mod);
|
||||
|
||||
return save;
|
||||
}
|
||||
|
@ -263,7 +265,8 @@ parse_vid_quality ( epg_broadcast_t *ebc, epg_episode_t *ee, htsmsg_t *m )
|
|||
* Parse accessibility data
|
||||
*/
|
||||
int
|
||||
xmltv_parse_accessibility ( epg_broadcast_t *ebc, htsmsg_t *m )
|
||||
xmltv_parse_accessibility
|
||||
( epggrab_module_t *mod, epg_broadcast_t *ebc, htsmsg_t *m )
|
||||
{
|
||||
int save = 0;
|
||||
htsmsg_t *tag;
|
||||
|
@ -275,12 +278,12 @@ xmltv_parse_accessibility ( epg_broadcast_t *ebc, htsmsg_t *m )
|
|||
if ((tag = htsmsg_get_map_by_field(f))) {
|
||||
str = htsmsg_xml_get_attr_str(tag, "type");
|
||||
if (str && !strcmp(str, "teletext"))
|
||||
save |= epg_broadcast_set_is_subtitled(ebc, 1);
|
||||
save |= epg_broadcast_set_is_subtitled(ebc, 1, mod);
|
||||
else if (str && !strcmp(str, "deaf-signed"))
|
||||
save |= epg_broadcast_set_is_deafsigned(ebc, 1);
|
||||
save |= epg_broadcast_set_is_deafsigned(ebc, 1, mod);
|
||||
}
|
||||
} else if (!strcmp(f->hmf_name, "audio-described")) {
|
||||
save |= epg_broadcast_set_is_audio_desc(ebc, 1);
|
||||
save |= epg_broadcast_set_is_audio_desc(ebc, 1, mod);
|
||||
}
|
||||
}
|
||||
return save;
|
||||
|
@ -307,9 +310,9 @@ static epg_genre_list_t
|
|||
/**
|
||||
* Parse tags inside of a programme
|
||||
*/
|
||||
static int
|
||||
_xmltv_parse_programme_tags(channel_t *ch, htsmsg_t *tags,
|
||||
time_t start, time_t stop, epggrab_stats_t *stats)
|
||||
static int _xmltv_parse_programme_tags
|
||||
(epggrab_module_t *mod, channel_t *ch, htsmsg_t *tags,
|
||||
time_t start, time_t stop, epggrab_stats_t *stats)
|
||||
{
|
||||
int save = 0, save2 = 0;
|
||||
epg_episode_t *ee;
|
||||
|
@ -325,24 +328,33 @@ _xmltv_parse_programme_tags(channel_t *ch, htsmsg_t *tags,
|
|||
/* Ignore */
|
||||
if (!title) return 0;
|
||||
|
||||
/* Build episode */
|
||||
uri = md5sum(desc ?: title);
|
||||
/*
|
||||
* Episode
|
||||
*/
|
||||
|
||||
uri = epg_hash(title, NULL, desc);
|
||||
ee = epg_episode_find_by_uri(uri, 1, &save);
|
||||
free(uri);
|
||||
if (!ee) return 0;
|
||||
stats->episodes.total++;
|
||||
if (save) stats->episodes.created++;
|
||||
|
||||
if (title) save |= epg_episode_set_title(ee, title);
|
||||
if (desc) save |= epg_episode_set_description(ee, desc);
|
||||
if (title)
|
||||
save |= epg_episode_set_title(ee, title, mod);
|
||||
if (desc)
|
||||
save |= epg_episode_set_description(ee, desc, mod);
|
||||
if ((egl = _xmltv_parse_categories(tags))) {
|
||||
save |= epg_episode_set_genre(ee, egl);
|
||||
save |= epg_episode_set_genre(ee, egl, mod);
|
||||
epg_genre_list_destroy(egl);
|
||||
}
|
||||
if (pn) save |= epg_episode_set_part(ee, pn, pc);
|
||||
if (en) save |= epg_episode_set_number(ee, en);
|
||||
if (pn) save |= epg_episode_set_part(ee, pn, pc, mod);
|
||||
if (en) save |= epg_episode_set_number(ee, en, mod);
|
||||
if (save) stats->episodes.modified++;
|
||||
|
||||
/*
|
||||
* Broadcast
|
||||
*/
|
||||
|
||||
// TODO: need to handle certification and ratings
|
||||
// TODO: need to handle season numbering!
|
||||
// TODO: need to handle onscreen numbering
|
||||
|
@ -353,20 +365,20 @@ _xmltv_parse_programme_tags(channel_t *ch, htsmsg_t *tags,
|
|||
if ( ebc ) {
|
||||
stats->broadcasts.total++;
|
||||
if (save2) stats->broadcasts.created++;
|
||||
save2 |= epg_broadcast_set_episode(ebc, ee);
|
||||
save2 |= epg_broadcast_set_episode(ebc, ee, mod);
|
||||
|
||||
/* Quality metadata */
|
||||
save2 |= parse_vid_quality(ebc, ee, htsmsg_get_map(tags, "video"));
|
||||
save2 |= parse_vid_quality(mod, ebc, ee, htsmsg_get_map(tags, "video"));
|
||||
|
||||
/* Accessibility */
|
||||
save2 |= xmltv_parse_accessibility(ebc, tags);
|
||||
save2 |= xmltv_parse_accessibility(mod, ebc, tags);
|
||||
|
||||
/* Misc */
|
||||
if (htsmsg_get_map(tags, "previously-shown"))
|
||||
save |= epg_broadcast_set_is_repeat(ebc, 1);
|
||||
save |= epg_broadcast_set_is_repeat(ebc, 1, mod);
|
||||
else if (htsmsg_get_map(tags, "premiere") ||
|
||||
htsmsg_get_map(tags, "new"))
|
||||
save |= epg_broadcast_set_is_new(ebc, 1);
|
||||
save |= epg_broadcast_set_is_new(ebc, 1, mod);
|
||||
|
||||
/* Stats */
|
||||
if (save2) stats->broadcasts.modified++;
|
||||
|
@ -378,8 +390,8 @@ _xmltv_parse_programme_tags(channel_t *ch, htsmsg_t *tags,
|
|||
/**
|
||||
* Parse a <programme> tag from xmltv
|
||||
*/
|
||||
static int
|
||||
_xmltv_parse_programme(htsmsg_t *body, epggrab_stats_t *stats)
|
||||
static int _xmltv_parse_programme
|
||||
(epggrab_module_t *mod, htsmsg_t *body, epggrab_stats_t *stats)
|
||||
{
|
||||
int save = 0;
|
||||
htsmsg_t *attribs, *tags;
|
||||
|
@ -397,19 +409,20 @@ _xmltv_parse_programme(htsmsg_t *body, epggrab_stats_t *stats)
|
|||
if((s = htsmsg_get_str(attribs, "start")) == NULL) return 0;
|
||||
start = _xmltv_str2time(s);
|
||||
if((s = htsmsg_get_str(attribs, "stop")) == NULL) return 0;
|
||||
stop = _xmltv_str2time(s);
|
||||
stop = _xmltv_str2time(s);
|
||||
|
||||
if(stop <= start || stop < dispatch_clock) return 0;
|
||||
|
||||
save |= _xmltv_parse_programme_tags(ch->channel, tags, start, stop, stats);
|
||||
save |= _xmltv_parse_programme_tags(mod, ch->channel, tags,
|
||||
start, stop, stats);
|
||||
return save;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a <channel> tag from xmltv
|
||||
*/
|
||||
static int
|
||||
_xmltv_parse_channel(htsmsg_t *body, epggrab_stats_t *stats)
|
||||
static int _xmltv_parse_channel
|
||||
(epggrab_module_t *mod, htsmsg_t *body, epggrab_stats_t *stats)
|
||||
{
|
||||
int save =0;
|
||||
htsmsg_t *attribs, *tags, *subtag;
|
||||
|
@ -444,8 +457,8 @@ _xmltv_parse_channel(htsmsg_t *body, epggrab_stats_t *stats)
|
|||
/**
|
||||
*
|
||||
*/
|
||||
static int
|
||||
_xmltv_parse_tv(htsmsg_t *body, epggrab_stats_t *stats)
|
||||
static int _xmltv_parse_tv
|
||||
(epggrab_module_t *mod, htsmsg_t *body, epggrab_stats_t *stats)
|
||||
{
|
||||
int save = 0;
|
||||
htsmsg_t *tags;
|
||||
|
@ -456,9 +469,9 @@ _xmltv_parse_tv(htsmsg_t *body, epggrab_stats_t *stats)
|
|||
|
||||
HTSMSG_FOREACH(f, tags) {
|
||||
if(!strcmp(f->hmf_name, "channel")) {
|
||||
save |= _xmltv_parse_channel(htsmsg_get_map_by_field(f), stats);
|
||||
save |= _xmltv_parse_channel(mod, htsmsg_get_map_by_field(f), stats);
|
||||
} else if(!strcmp(f->hmf_name, "programme")) {
|
||||
save |= _xmltv_parse_programme(htsmsg_get_map_by_field(f), stats);
|
||||
save |= _xmltv_parse_programme(mod, htsmsg_get_map_by_field(f), stats);
|
||||
}
|
||||
}
|
||||
return save;
|
||||
|
@ -475,7 +488,7 @@ static int _xmltv_parse
|
|||
if((tv = htsmsg_get_map(tags, "tv")) == NULL)
|
||||
return 0;
|
||||
|
||||
return _xmltv_parse_tv(tv, stats);
|
||||
return _xmltv_parse_tv(mod, tv, stats);
|
||||
}
|
||||
|
||||
/* ************************************************************************
|
||||
|
@ -501,7 +514,7 @@ static void _xmltv_load_grabbers ( void )
|
|||
if ( outbuf[i] == '\n' || outbuf[i] == '\0' ) {
|
||||
outbuf[i] = '\0';
|
||||
sprintf(name, "XMLTV: %s", &outbuf[n]);
|
||||
epggrab_module_int_create(NULL, &outbuf[p], name, &outbuf[p],
|
||||
epggrab_module_int_create(NULL, &outbuf[p], name, 3, &outbuf[p],
|
||||
NULL, _xmltv_parse, NULL, NULL);
|
||||
p = n = i + 1;
|
||||
} else if ( outbuf[i] == '|' ) {
|
||||
|
@ -517,7 +530,7 @@ void xmltv_init ( void )
|
|||
{
|
||||
/* External module */
|
||||
_xmltv_module = (epggrab_module_t*)
|
||||
epggrab_module_ext_create(NULL, "xmltv", "XMLTV", "xmltv",
|
||||
epggrab_module_ext_create(NULL, "xmltv", "XMLTV", 3, "xmltv",
|
||||
_xmltv_parse, NULL,
|
||||
&_xmltv_channels);
|
||||
|
||||
|
|
|
@ -25,7 +25,8 @@
|
|||
|
||||
epggrab_module_t *epggrab_module_create
|
||||
( epggrab_module_t *skel,
|
||||
const char *id, const char *name, epggrab_channel_tree_t *channels );
|
||||
const char *id, const char *name, int priority,
|
||||
epggrab_channel_tree_t *channels );
|
||||
|
||||
char *epggrab_module_grab_spawn ( void *m );
|
||||
htsmsg_t *epggrab_module_trans_xml ( void *m, char *data );
|
||||
|
@ -57,7 +58,8 @@ epggrab_channel_t *epggrab_channel_find
|
|||
|
||||
epggrab_module_int_t *epggrab_module_int_create
|
||||
( epggrab_module_int_t *skel,
|
||||
const char *id, const char *name, const char *path,
|
||||
const char *id, const char *name, int priority,
|
||||
const char *path,
|
||||
char* (*grab) (void*m),
|
||||
int (*parse) (void *m, htsmsg_t *data, epggrab_stats_t *sta),
|
||||
htsmsg_t* (*trans) (void *mod, char *data),
|
||||
|
@ -69,7 +71,8 @@ epggrab_module_int_t *epggrab_module_int_create
|
|||
|
||||
epggrab_module_ext_t *epggrab_module_ext_create
|
||||
( epggrab_module_ext_t *skel,
|
||||
const char *id, const char *name, const char *sockid,
|
||||
const char *id, const char *name, int priority,
|
||||
const char *sockid,
|
||||
int (*parse) (void *m, htsmsg_t *data, epggrab_stats_t *sta),
|
||||
htsmsg_t* (*trans) (void *mod, char *data),
|
||||
epggrab_channel_tree_t *channels );
|
||||
|
@ -80,7 +83,7 @@ epggrab_module_ext_t *epggrab_module_ext_create
|
|||
|
||||
epggrab_module_ota_t *epggrab_module_ota_create
|
||||
( epggrab_module_ota_t *skel,
|
||||
const char *id, const char *name,
|
||||
const char *id, const char *name, int priority,
|
||||
void (*start) (epggrab_module_ota_t*m,
|
||||
struct th_dvb_mux_instance *tdmi),
|
||||
int (*enable) (void *m, uint8_t e ),
|
||||
|
@ -152,6 +155,7 @@ void xmltv_init ( void );
|
|||
void xmltv_load ( void );
|
||||
|
||||
/* Note: this is reused by pyepg since they share a common format */
|
||||
int xmltv_parse_accessibility ( epg_broadcast_t *ebc, htsmsg_t *m );
|
||||
int xmltv_parse_accessibility
|
||||
( epggrab_module_t *mod, epg_broadcast_t *ebc, htsmsg_t *m );
|
||||
|
||||
#endif /* __EPGGRAB_PRIVATE_H__ */
|
||||
|
|
Loading…
Add table
Reference in a new issue