1 |
#include <stdio.h> |
---|
2 |
#include <stdlib.h> |
---|
3 |
#include <unistd.h> |
---|
4 |
#include <string.h> |
---|
5 |
#include <getopt.h> |
---|
6 |
#include <iconv.h> |
---|
7 |
#include <time.h> |
---|
8 |
|
---|
9 |
#include "ts.h" |
---|
10 |
#include "sdt.h" |
---|
11 |
#include "eit.h" |
---|
12 |
#include "ts_ctl.h" |
---|
13 |
|
---|
14 |
typedef struct _ContentTYPE{ |
---|
15 |
char *japanese ; |
---|
16 |
char *english ; |
---|
17 |
}CONTENT_TYPE; |
---|
18 |
|
---|
19 |
#define CAT_COUNT 16 |
---|
20 |
static CONTENT_TYPE ContentCatList[CAT_COUNT] = { |
---|
21 |
{ "����若��糸���, "news" }, |
---|
22 |
{ "�鴻��若�", "sports" }, |
---|
23 |
{ "���", "information" }, |
---|
24 |
{ "�����, "drama" }, |
---|
25 |
{ "�恰ソ", "music" }, |
---|
26 |
{ "��������, "variety" }, |
---|
27 |
{ "���", "cinema" }, |
---|
28 |
{ "�≪��<��号�", "anime" }, |
---|
29 |
{ "����ャ��潟�����紙�蕕�, "documentary" }, |
---|
30 |
{ "羲��", "stage" }, |
---|
31 |
{ "莇e��糸���, "hobby" }, |
---|
32 |
{ "胼霛�, "etc" }, |
---|
33 |
{ "篋��", "etc" }, |
---|
34 |
{ "篋��", "etc" }, |
---|
35 |
{ "���篁�, "etc" } //���篁�}; |
---|
36 |
typedef struct _TAG_STATION |
---|
37 |
{ |
---|
38 |
char *name; |
---|
39 |
char *ontv; |
---|
40 |
int tsId; // OriginalNetworkID |
---|
41 |
int onId; // TransportStreamID |
---|
42 |
int svId; // ServiceID |
---|
43 |
} STATION; |
---|
44 |
|
---|
45 |
static STATION bsSta[] = { |
---|
46 |
{ "NHK BS1", "3001.ontvjapan.com", 16625, 4, 101}, |
---|
47 |
{ "NHK BS2", "3002.ontvjapan.com", 16625, 4, 102},//綮�� 2011/3/31 |
---|
48 |
{ "NHK BS��������, "3003.ontvjapan.com", 16626, 4, 103}, |
---|
49 |
{ "BS�ャ���, "3004.ontvjapan.com", 16592, 4, 141}, |
---|
50 |
{ "BS���", "3005.ontvjapan.com", 16400, 4, 151}, |
---|
51 |
{ "BS-TBS", "3006.ontvjapan.com", 16401, 4, 161}, |
---|
52 |
{ "BS�吾����", "3007.ontvjapan.com", 16433, 4, 171}, |
---|
53 |
{ "BS���", "3008.ontvjapan.com", 16593, 4, 181}, |
---|
54 |
// { "WOWOW", "3009.ontvjapan.com", 16432, 4, 191}, |
---|
55 |
// { "WOWOW2", "3010.ontvjapan.com", 16432, 4, 192}, |
---|
56 |
// { "WOWOW3", "3011.ontvjapan.com", 16432, 4, 193}, |
---|
57 |
{ "WOWOW����ゃ�", "3009.ontvjapan.com", 16432, 4, 191}, |
---|
58 |
{ "WOWOW�����, "4192.epgdata.ontvjapan", 17488, 4, 192}, |
---|
59 |
{ "WOWOW�激���, "4193.epgdata.ontvjapan", 17489, 4, 193}, |
---|
60 |
// { "�鴻��若�����潟���, "3012.ontvjapan.com", 16529, 4, 200}, |
---|
61 |
{ "�鴻��若�����潟���", "3012.ontvjapan.com", 16529, 4, 200}, |
---|
62 |
{ "�鴻��若�����潟���", "4201.epgdata.ontvjapan", 17520, 4, 201}, |
---|
63 |
{ "�鴻��若�����潟���", "4202.epgdata.ontvjapan", 17520, 4, 202}, |
---|
64 |
{ "BS11", "3013.ontvjapan.com", 16528, 4, 211}, |
---|
65 |
{ "TwellV", "3014.ontvjapan.com", 16530, 4, 222}, |
---|
66 |
{ "�冗�紊у�1", "4231.epgdata.ontvjapan", 18098, 4, 231}, |
---|
67 |
{ "�冗�紊у�2", "4232.epgdata.ontvjapan", 18098, 4, 232}, |
---|
68 |
{ "�冗�紊у�3", "4233.epgdata.ontvjapan", 18098, 4, 233}, |
---|
69 |
{ "�違��若�����潟���, "4234.epgdata.ontvjapan", 18224, 4, 234}, |
---|
70 |
{ "BS�≪�������", "1047.ontvjapan.com", 18033, 4, 236}, |
---|
71 |
{ "FOX bs238", "4238.epgdata.ontvjapan", 18096, 4, 238}, |
---|
72 |
{ "BS�鴻����鐚�, "4241.epgdata.ontvjapan", 18097, 4, 241}, |
---|
73 |
{ "J SPORTS 1", "4242.epgdata.ontvjapan", 18225, 4, 242}, |
---|
74 |
{ "J SPORTS 2", "4243.epgdata.ontvjapan", 18226, 4, 243}, |
---|
75 |
{ "J SPORTS 3", "4244.epgdata.ontvjapan", 18257, 4, 244}, |
---|
76 |
{ "J SPORTS 4", "4245.epgdata.ontvjapan", 18258, 4, 245}, |
---|
77 |
{ "BS�c�����с�", "4251.epgdata.ontvjapan", 18288, 4, 251}, |
---|
78 |
{ "IMAGICA BS", "4252.epgdata.ontvjapan", 18256, 4, 252}, |
---|
79 |
{ "�ユ����絨������潟���, "4255.epgdata.ontvjapan", 18289, 4, 255}, |
---|
80 |
{ "����冴��若�����潟���, "1090.ontvjapan.com", 18034, 4, 256}, |
---|
81 |
{ "D-Life", "4258.epgdata.ontvjapan", 18290, 4, 258}, |
---|
82 |
{ "NHK膩�������吾��鰹��延根鐚�, "4291.epgdata.ontvjapan", 17168, 4, 291}, |
---|
83 |
{ "NHK����������с�鐚��篋��", "4292.epgdata.ontvjapan", 17168, 4, 292}, |
---|
84 |
{ "�ユ������, "4294.epgdata.ontvjapan", 17169, 4, 294}, |
---|
85 |
{ "��������, "4295.epgdata.ontvjapan", 17169, 4, 295}, |
---|
86 |
{ "TBS�����, "4296.epgdata.ontvjapan", 17169, 4, 296}, |
---|
87 |
{ "������篋�, "4297.epgdata.ontvjapan", 17169, 4, 297}, |
---|
88 |
{ "��������, "4298.epgdata.ontvjapan", 17168, 4, 298}, |
---|
89 |
{ "�冗�紊у������, "4531.epgdata.ontvjapan", 18098, 4, 531}, |
---|
90 |
{ "WNI", "4910.ontvjapan.com", 16626, 4, 910}, |
---|
91 |
}; |
---|
92 |
|
---|
93 |
static int bsStaCount = sizeof(bsSta) / sizeof (STATION); |
---|
94 |
|
---|
95 |
|
---|
96 |
|
---|
97 |
static STATION csSta[] = { |
---|
98 |
// { "�鴻��種�鐔�����", "1002.ontvjapan.com", 24608, 6, 237},//綮�� |
---|
99 |
// { "�ユ����絨��鐔��鐚�爾", "1086.ontvjapan.com", 24608, 6, 239},//BS紊�� |
---|
100 |
{ "��������汐鐚ワ叱鐚�, "309ch.epgdata.ontvjapan", 24608, 6, 309}, |
---|
101 |
{ "�激��������潟���, "1059.ontvjapan.com", 24704, 6, 55}, |
---|
102 |
{ "�吟��激���, "1217.ontvjapan.com", 24736, 6, 227}, |
---|
103 |
{ "�鴻������ HD", "800ch.epgdata.ontvjapan", 24736, 6, 800}, |
---|
104 |
{ "�鴻������ HD", "801ch.epgdata.ontvjapan", 24736, 6, 801}, |
---|
105 |
{ "�鴻������", "802ch.epgdata.ontvjapan", 24736, 6, 802}, |
---|
106 |
{ "鐔�������, "100ch.epgdata.ontvjapan", 28736, 7, 100}, |
---|
107 |
// { "�ゃ��帥�������鐚器雫", "194ch.epgdata.ontvjapan", 28736, 7, 194},//綮�� 2010/9/16/ |
---|
108 |
// { "鐚��������鐚ワ竺鐚逸汐", "1025.ontvjapan.com", 28736, 7, 256},//BS����� { "鐚�鹿鐚�, "1016.ontvjapan.com", 28736, 7, 312}, |
---|
109 |
{ "FOX�����, "315ch.epgdata.ontvjapan", 28736, 7, 315}, |
---|
110 |
{ "�鴻��若��激����鐚器雫", "1018.ontvjapan.com", 28736, 7, 322}, |
---|
111 |
{ "�������若�������", "1046.ontvjapan.com", 28736, 7, 331}, |
---|
112 |
{ "����冴��種叱鐚�, "1213.ontvjapan.com", 28736, 7, 334}, |
---|
113 |
{ "茵�����", "1005.ontvjapan.com", 28768, 7, 222}, |
---|
114 |
{ "����潟���汐鐚ワ治鐚�, "1008.ontvjapan.com", 28768, 7, 223}, |
---|
115 |
// { "羇���������c�", "1009.ontvjapan.com", 28768, 7, 224},//BS紊�� |
---|
116 |
// { "�鴻��若�����激���, "1003.ontvjapan.com", 28768, 7, 238}, |
---|
117 |
{ "��撮�������c����", "1133.ontvjapan.com", 28768, 7, 292}, |
---|
118 |
{ "�鴻���������, "1006.ontvjapan.com", 28768, 7, 310}, |
---|
119 |
{ "鐚¥叱鐚�, "1014.ontvjapan.com", 28768, 7, 311}, |
---|
120 |
{ "�������c����", "1204.ontvjapan.com", 28768, 7, 343}, |
---|
121 |
|
---|
122 |
{ "����若�����祉���, "1024.ontvjapan.com", 28864, 7, 324}, |
---|
123 |
�������若��帥�HD", "1067.ontvjapan.com", 28864, 6, 299},//2012綛�����CS1/Ch.299����� { "鐚�滋鐚c��若���, "1070.ontvjapan.com", 28864, 7, 353}, |
---|
124 |
{ "鐚o汐鐚��", "1069.ontvjapan.com", 28864, 7, 354}, |
---|
125 |
|
---|
126 |
{ "�������������潟���, "294ch.epgdata.ontvjapan", 28736, 7, 294}, |
---|
127 |
鐚��������鐚�, "1041.ontvjapan.com", 28896, 7, 251}, |
---|
128 |
{ "鐚э次鐚�鴫鐚�, "1026.ontvjapan.com", 28896, 7, 254}, |
---|
129 |
�鴻��ゃ�A sports鐚�, "1040.ontvjapan.com", 28896, 7, 250}, |
---|
130 |
{ "TAKARAZUKA SKY STAGE", "1207.ontvjapan.com", 28928, 7, 290}, |
---|
131 |
{ "����潟����羃�, "305ch.epgdata.ontvjapan", 28928, 7, 305}, |
---|
132 |
{ "鐚¥軸-鐚�, "1201.ontvjapan.com", 28928, 7, 333}, |
---|
133 |
{ "�������若��c����", "1050.ontvjapan.com", 28928, 7, 342}, |
---|
134 |
|
---|
135 |
{ "�鴻������", "805ch.epgdata.ontvjapan", 28928, 7, 805}, |
---|
136 |
{ "����������刻示鐚�, "1007.ontvjapan.com", 28960, 7, 240}, |
---|
137 |
{ "�眼������������, "1027.ontvjapan.com", 28960, 7, 262}, |
---|
138 |
{ "鐚��鐚����示鐚�, "1074.ontvjapan.com", 28960, 7, 314}, |
---|
139 |
{ "��������鹿鐚�璽", "1073.ontvjapan.com", 28992, 7, 307},//��������39�� { "��������軸鐚件鹿", "1072.ontvjapan.com", 28992, 7, 308},//��������21��// { "�≪�������", "1047.ontvjapan.com", 28992, 7, 332},//BS�≪���������Щ�� { "����鴻������, "1062.ontvjapan.com", 28992, 7, 340}, |
---|
140 |
{ "�≪������������, "1193.ontvjapan.com", 28992, 7, 341}, |
---|
141 |
// { "鐚�鐚器滋鐚潟�������", "160ch.epgdata.ontvjapan", 29024, 7, 160},//2012綛���1�ュ�罩� { "鐚縁雫鐚�, "1120.ontvjapan.com", 29024, 7, 161}, |
---|
142 |
|
---|
143 |
{ "�������弱���, "1015.ontvjapan.com", 29024, 7, 293}, |
---|
144 |
TBS����潟���D", "3201.ontvjapan.com", 29024, 6, 296},//2012綛�����CS1/Ch.296����� |
---|
145 |
����冴��若��c����", "1090.ontvjapan.com", 29024, 7, 304},//BS�後��� { "MUSIC ON! TV", "1022.ontvjapan.com", 29024, 7, 325}, |
---|
146 |
����冴�����激���D", "1045.ontvjapan.com", 29024, 7, 330},//HD�� { "鐚器滋鐚潟��ャ��鴻��若�", "1076.ontvjapan.com", 29024, 7, 351}, |
---|
147 |
鐚o竺�ユ���������, "147ch.epgdata.ontvjapan", 29056, 7, 147}, |
---|
148 |
{ "�ャ���磁鐚�示鐚�, "1068.ontvjapan.com", 29056, 7, 257},//HD��// { "fashion TV", "5004.ontvjapan.com", 29056, 7, 291},//綮�� 2009/3/31 |
---|
149 |
�ャ�������", "300ch.epgdata.ontvjapan", 29056, 7, 300}, |
---|
150 |
�������若����鐚器雫", "1023.ontvjapan.com", 29056, 7, 320},//綮�� 2009/3/31 |
---|
151 |
Music Japan TV", "1208.ontvjapan.com", 29056, 7, 321},//綮�� 2012/3/31 |
---|
152 |
�鴻��若��激����鐚器雫 �����, "321ch.epgdata.ontvjapan", 29056, 7, 321}, |
---|
153 |
{ "�ャ���汐鐚ワ七鐚鰹�鐚�, "2002.ontvjapan.com", 29056, 7, 350}, |
---|
154 |
{ "����c����", "1052.ontvjapan.com", 29056, 7, 362}, |
---|
155 |
}; |
---|
156 |
|
---|
157 |
static int csStaCount = sizeof(csSta) / sizeof (STATION); |
---|
158 |
SVT_CONTROL *svttop = NULL; |
---|
159 |
#define SECCOUNT 4 |
---|
160 |
char title[1024]; |
---|
161 |
char subtitle[1024]; |
---|
162 |
char Category[1024]; |
---|
163 |
char ServiceName[1024]; |
---|
164 |
|
---|
165 |
/* prototype */ |
---|
166 |
extern int strrep(char *buf, char *mae, char *ato); |
---|
167 |
|
---|
168 |
void xmlspecialchars(char *str) |
---|
169 |
{ |
---|
170 |
strrep(str, "&", "&"); |
---|
171 |
strrep(str, "'", "'"); |
---|
172 |
strrep(str, "\"", """); |
---|
173 |
strrep(str, "<", "<"); |
---|
174 |
strrep(str, ">", ">"); |
---|
175 |
} |
---|
176 |
|
---|
177 |
|
---|
178 |
|
---|
179 |
void GetSDT(FILE *infile, SVT_CONTROL *svttop, SECcache *secs, int count) |
---|
180 |
{ |
---|
181 |
SECcache *bsecs; |
---|
182 |
|
---|
183 |
while((bsecs = readTS(infile, secs, count)) != NULL) { |
---|
184 |
|
---|
185 |
if((bsecs->pid & 0xFF) == 0x11) { |
---|
186 |
dumpSDT(bsecs->buf, svttop); |
---|
187 |
} |
---|
188 |
} |
---|
189 |
} |
---|
190 |
void GetEIT(FILE *infile, FILE *outfile, STATION *psta, SECcache *secs, int count) |
---|
191 |
{ |
---|
192 |
SECcache *bsecs; |
---|
193 |
EIT_CONTROL *eitcur ; |
---|
194 |
EIT_CONTROL *eitnext ; |
---|
195 |
EIT_CONTROL *eittop = NULL; |
---|
196 |
time_t l_time ; |
---|
197 |
time_t end_time ; |
---|
198 |
struct tm tl ; |
---|
199 |
struct tm *endtl ; |
---|
200 |
char cendtime[32]; |
---|
201 |
char cstarttime[32]; |
---|
202 |
|
---|
203 |
eittop = calloc(1, sizeof(EIT_CONTROL)); |
---|
204 |
eitcur = eittop ; |
---|
205 |
fseek(infile, 0, SEEK_SET); |
---|
206 |
while((bsecs = readTS(infile, secs, SECCOUNT)) != NULL) { |
---|
207 |
|
---|
208 |
if((bsecs->pid & 0xFF) == 0x12) { |
---|
209 |
dumpEIT(bsecs->buf, psta->svId, psta->onId, psta->tsId, eittop); |
---|
210 |
}else if((bsecs->pid & 0xFF) == 0x26) { |
---|
211 |
dumpEIT(bsecs->buf, psta->svId, psta->onId, psta->tsId, eittop); |
---|
212 |
}else if((bsecs->pid & 0xFF) == 0x27) { |
---|
213 |
dumpEIT(bsecs->buf, psta->svId, psta->onId, psta->tsId, eittop); |
---|
214 |
} |
---|
215 |
} |
---|
216 |
eitcur = eittop ; |
---|
217 |
while(eitcur != NULL){ |
---|
218 |
if(!eitcur->servid){ |
---|
219 |
eitcur = eitcur->next ; |
---|
220 |
continue ; |
---|
221 |
} |
---|
222 |
if(eitcur->content_type > CAT_COUNT){ |
---|
223 |
eitcur->content_type = CAT_COUNT -1 ; |
---|
224 |
} |
---|
225 |
memset(title, '\0', sizeof(title)); |
---|
226 |
strcpy(title, eitcur->title); |
---|
227 |
xmlspecialchars(title); |
---|
228 |
|
---|
229 |
memset(subtitle, '\0', sizeof(subtitle)); |
---|
230 |
strcpy(subtitle, eitcur->subtitle); |
---|
231 |
xmlspecialchars(subtitle); |
---|
232 |
|
---|
233 |
memset(Category, '\0', sizeof(Category)); |
---|
234 |
strcpy(Category, ContentCatList[eitcur->content_type].japanese); |
---|
235 |
xmlspecialchars(Category); |
---|
236 |
|
---|
237 |
tl.tm_sec = eitcur->ss ; |
---|
238 |
tl.tm_min = eitcur->hm ; |
---|
239 |
tl.tm_hour = eitcur->hh ; |
---|
240 |
tl.tm_mday = eitcur->dd ; |
---|
241 |
tl.tm_mon = (eitcur->mm - 1); |
---|
242 |
tl.tm_year = (eitcur->yy - 1900); |
---|
243 |
tl.tm_wday = 0; |
---|
244 |
tl.tm_isdst = 0; |
---|
245 |
tl.tm_yday = 0; |
---|
246 |
l_time = mktime(&tl); |
---|
247 |
if((eitcur->ehh == 0) && (eitcur->emm == 0) && (eitcur->ess == 0)){ |
---|
248 |
(void)time(&l_time); |
---|
249 |
end_time = l_time + (60 * 5); |
---|
250 |
endtl = localtime(&end_time); |
---|
251 |
}else{ |
---|
252 |
end_time = l_time + eitcur->ehh * 3600 + eitcur->emm * 60 + eitcur->ess; |
---|
253 |
endtl = localtime(&end_time); |
---|
254 |
} |
---|
255 |
memset(cendtime, '\0', sizeof(cendtime)); |
---|
256 |
memset(cstarttime, '\0', sizeof(cstarttime)); |
---|
257 |
strftime(cendtime, (sizeof(cendtime) - 1), "%Y%m%d%H%M%S", endtl); |
---|
258 |
strftime(cstarttime, (sizeof(cstarttime) - 1), "%Y%m%d%H%M%S", &tl); |
---|
259 |
#if 1 |
---|
260 |
fprintf(outfile, " <programme start=\"%s +0900\" stop=\"%s +0900\" channel=\"%s\">\n", |
---|
261 |
cstarttime, cendtime, psta->ontv); |
---|
262 |
fprintf(outfile, " <title lang=\"ja_JP\">%s</title>\n", title); |
---|
263 |
fprintf(outfile, " <desc lang=\"ja_JP\">%s</desc>\n", subtitle); |
---|
264 |
fprintf(outfile, " <category lang=\"ja_JP\">%s</category>\n", Category); |
---|
265 |
fprintf(outfile, " <category lang=\"en\">%s</category>\n", ContentCatList[eitcur->content_type].english); |
---|
266 |
fprintf(outfile, " </programme>\n"); |
---|
267 |
#else |
---|
268 |
fprintf(outfile, "(%x:%x:%x)%s,%s,%s,%s,%s,%s\n", |
---|
269 |
eitcur->servid, eitcur->table_id, eitcur->event_id, |
---|
270 |
cstarttime, cendtime, |
---|
271 |
title, subtitle, |
---|
272 |
Category, |
---|
273 |
ContentCatList[eitcur->content_type].english); |
---|
274 |
#endif |
---|
275 |
#if 0 |
---|
276 |
fprintf(outfile, "(%x:%x)%04d/%02d/%02d,%02d:%02d:%02d,%02d:%02d:%02d,%s,%s,%s,%s\n", |
---|
277 |
eitcur->table_id, eitcur->event_id, |
---|
278 |
eitcur->yy, eitcur->mm, eitcur->dd, |
---|
279 |
eitcur->hh, eitcur->hm, eitcur->ss, |
---|
280 |
eitcur->ehh, eitcur->emm, eitcur->ess, |
---|
281 |
eitcur->title, eitcur->subtitle, |
---|
282 |
ContentCatList[eitcur->content_type].japanese, |
---|
283 |
ContentCatList[eitcur->content_type].english); |
---|
284 |
#endif |
---|
285 |
eitnext = eitcur->next ; |
---|
286 |
free(eitcur->title); |
---|
287 |
free(eitcur->subtitle); |
---|
288 |
free(eitcur); |
---|
289 |
eitcur = eitnext ; |
---|
290 |
} |
---|
291 |
free(eittop); |
---|
292 |
eittop = NULL; |
---|
293 |
} |
---|
294 |
int main(int argc, char *argv[]) |
---|
295 |
{ |
---|
296 |
|
---|
297 |
FILE *infile = stdin; |
---|
298 |
FILE *outfile = stdout; |
---|
299 |
char *arg_onTV ; |
---|
300 |
int staCount ; |
---|
301 |
char *file; |
---|
302 |
int inclose = 0; |
---|
303 |
int outclose = 0; |
---|
304 |
SVT_CONTROL *svtcur ; |
---|
305 |
SVT_CONTROL *svtsave ; |
---|
306 |
SECcache secs[SECCOUNT]; |
---|
307 |
int lp ; |
---|
308 |
STATION *pStas ; |
---|
309 |
int act ; |
---|
310 |
|
---|
311 |
|
---|
312 |
memset(secs, 0, sizeof(SECcache) * SECCOUNT); |
---|
313 |
secs[0].pid = 0x11; |
---|
314 |
secs[1].pid = 0x12; |
---|
315 |
secs[2].pid = 0x26; |
---|
316 |
secs[3].pid = 0x27; |
---|
317 |
|
---|
318 |
if(argc == 4){ |
---|
319 |
arg_onTV = argv[1]; |
---|
320 |
file = argv[2]; |
---|
321 |
if(strcmp(file, "-")) { |
---|
322 |
infile = fopen(file, "r"); |
---|
323 |
inclose = 1; |
---|
324 |
} |
---|
325 |
if(strcmp(argv[3], "-")) { |
---|
326 |
outfile = fopen(argv[3], "w+"); |
---|
327 |
outclose = 1; |
---|
328 |
} |
---|
329 |
}else{ |
---|
330 |
fprintf(stdout, "Usage : %s {/BS|/CS} <tsFile> <outfile>\n", argv[0]); |
---|
331 |
fprintf(stdout, "Usage : %s <ontvcode> <tsFile> <outfile>\n", argv[0]); |
---|
332 |
fprintf(stdout, "\n"); |
---|
333 |
fprintf(stdout, " ontvcode Channel identifier (ex. ****.ontvjapan.com)\n"); |
---|
334 |
fprintf(stdout, " /BS BS mode\n"); |
---|
335 |
fprintf(stdout, " This mode reads the data of all BS TV stations\n"); |
---|
336 |
fprintf(stdout, " from one TS data.\n"); |
---|
337 |
fprintf(stdout, " /CS CS mode\n"); |
---|
338 |
fprintf(stdout, " This mode reads the data of two or more CS TV stations\n"); |
---|
339 |
fprintf(stdout, " from one TS data.\n"); |
---|
340 |
return 0; |
---|
341 |
} |
---|
342 |
|
---|
343 |
if(strcmp(arg_onTV, "/BS") == 0){ |
---|
344 |
pStas = bsSta; |
---|
345 |
staCount = bsStaCount; |
---|
346 |
act = 0 ; |
---|
347 |
}else if(strcmp(arg_onTV, "/CS") == 0){ |
---|
348 |
pStas = csSta; |
---|
349 |
staCount = csStaCount; |
---|
350 |
act = 0 ; |
---|
351 |
}else{ |
---|
352 |
act = 1 ; |
---|
353 |
svttop = calloc(1, sizeof(SVT_CONTROL)); |
---|
354 |
GetSDT(infile, svttop, secs, SECCOUNT); |
---|
355 |
svtcur = svttop->next ; |
---|
356 |
if(svtcur == NULL){ |
---|
357 |
free(svttop); |
---|
358 |
return 1; |
---|
359 |
} |
---|
360 |
|
---|
361 |
pStas = calloc(1, sizeof(STATION)); |
---|
362 |
pStas->tsId = svtcur->transport_stream_id ; |
---|
363 |
pStas->onId = svtcur->original_network_id ; |
---|
364 |
pStas->svId = svtcur->event_id ; |
---|
365 |
pStas->ontv = arg_onTV ; |
---|
366 |
pStas->name = svtcur->servicename ; |
---|
367 |
staCount = 1; |
---|
368 |
} |
---|
369 |
|
---|
370 |
fprintf(outfile, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); |
---|
371 |
fprintf(outfile, "<!DOCTYPE tv SYSTEM \"xmltv.dtd\">\n\n"); |
---|
372 |
fprintf(outfile, "<tv generator-info-name=\"tsEPG2xml\" generator-info-url=\"http://localhost/\">\n"); |
---|
373 |
|
---|
374 |
for(lp = 0 ; lp < staCount ; lp++){ |
---|
375 |
memset(ServiceName, '\0', sizeof(ServiceName)); |
---|
376 |
strcpy(ServiceName, pStas[lp].name); |
---|
377 |
xmlspecialchars(ServiceName); |
---|
378 |
|
---|
379 |
fprintf(outfile, " <channel id=\"%s\">\n", pStas[lp].ontv); |
---|
380 |
fprintf(outfile, " <display-name lang=\"ja_JP\">%s</display-name>\n", ServiceName); |
---|
381 |
fprintf(outfile, " </channel>\n"); |
---|
382 |
} |
---|
383 |
for(lp = 0 ; lp < staCount ; lp++){ |
---|
384 |
GetEIT(infile, outfile, &pStas[lp], secs, SECCOUNT); |
---|
385 |
} |
---|
386 |
fprintf(outfile, "</tv>\n"); |
---|
387 |
if(inclose) { |
---|
388 |
fclose(infile); |
---|
389 |
} |
---|
390 |
|
---|
391 |
if(outclose) { |
---|
392 |
fclose(outfile); |
---|
393 |
} |
---|
394 |
if(act){ |
---|
395 |
free(pStas); |
---|
396 |
svtcur = svttop ; |
---|
397 |
while(svtcur != NULL){ |
---|
398 |
svtsave = svtcur->next ; |
---|
399 |
free(svtcur); |
---|
400 |
svtcur = svtsave ; |
---|
401 |
} |
---|
402 |
} |
---|
403 |
|
---|
404 |
return 0; |
---|
405 |
} |
---|