-
Notifications
You must be signed in to change notification settings - Fork 3
/
xmltv.c
72 lines (65 loc) · 1.78 KB
/
xmltv.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <time.h>
#include "xmltv.h"
#include "tv_grab_dvb.h"
void
xmltv_write_event(event_t *event, void *data)
{
char chanbuf[64], startbuf[64], stopbuf[64];
time_t t;
const char *s;
event_aspect_t aspect;
event_audio_t audio;
size_t count, i;
const event_langstr_t **ll;
chanbuf[0] = 0;
t = event_start(event);
strftime(startbuf, sizeof(startbuf), "%Y%m%d%H%M%S %z", localtime(&t));
t += event_duration(event);
strftime(stopbuf, sizeof(stopbuf), "%Y%m%d%H%M%S %z", localtime(&t));
printf("\t<programme channel=\"%s\" start=\"%s\" stop=\"%s\">\n",
chanbuf, startbuf, stopbuf);
/* Tags should be output in this order:
*
* 'title', 'sub-title', 'desc', 'credits', 'date', 'category', 'language',
* 'orig-language', 'length', 'icon', 'url', 'country', 'episode-num',
* 'video', 'audio', 'previously-shown', 'premiere', 'last-chance',
* 'new', 'subtitles', 'rating', 'star-rating'
*/
if((ll = event_titles(event, &count)))
{
for(i = 0; i < count; i++)
{
printf("\t\t<title lang=\"%s\">%s</title>\n", ll[i]->lang, xmlify(ll[i]->str));
}
}
if((ll = event_subtitles(event, &count)))
{
for(i = 0; i < count; i++)
{
printf("\t\t<sub-title lang=\"%s\">%s</sub-title>\n", ll[i]->lang, xmlify(ll[i]->str));
}
}
if((s = event_lang(event)))
{
printf("\t\t<language>%s</language>\n", s);
}
if(EA_INVALID != (aspect = event_aspect(event)))
{
printf("\t\t<video>\n"
"\t\t\t<aspect>%s</aspect>\n"
"\t\t</video>\n",
lookup(aspect_table, aspect));
}
if(EA_INVALID != (audio = event_audio(event)))
{
printf("\t\t<audio>\n"
"\t\t\t<stereo>%s</stereo>\n"
"\t\t</audio>\n",
lookup(audio_table, audio));
}
printf("\t</programme>\n");
}