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}, |
---|
100 |
{ "��������汐鐚ワ叱鐚�, "306ch.epgdata.ontvjapan", 24608, 6, 306}, |
---|
101 |
{ "�吟��激���, "1217.ontvjapan.com", 24736, 6, 228}, |
---|
102 |
{ "�鴻�����鰹示鐚わ�鐚��", "800ch.epgdata.ontvjapan", 24736, 6, 800}, |
---|
103 |
{ "�鴻�����鰹�鐚��", "801ch.epgdata.ontvjapan", 24736, 6, 801}, |
---|
104 |
{ "�鴻�����鰹�鐚��", "802ch.epgdata.ontvjapan", 24736, 6, 802}, |
---|
105 |
{ "鐔�������, "100ch.epgdata.ontvjapan", 28736, 7, 100}, |
---|
106 |
|
---|
107 |
{ "鐚��������鐚ワ竺鐚逸汐", "1025.ontvjapan.com", 28736, 7, 256}, |
---|
108 |
{ "鐚�鹿鐚�, "1016.ontvjapan.com", 28736, 7, 312}, |
---|
109 |
{ "�鴻��若��激����鐚器雫", "1018.ontvjapan.com", 28736, 7, 322}, |
---|
110 |
{ "�������若�������", "1046.ontvjapan.com", 28736, 7, 331}, |
---|
111 |
{ "����冴��種叱鐚�, "1213.ontvjapan.com", 28736, 7, 334}, |
---|
112 |
{ "茵�����", "1005.ontvjapan.com", 28768, 7, 222}, |
---|
113 |
{ "����潟���汐鐚ワ治鐚�, "1008.ontvjapan.com", 28768, 7, 223}, |
---|
114 |
{ "羇���������c�", "1009.ontvjapan.com", 28768, 7, 224}, |
---|
115 |
{ "�鴻��若�����激���, "1003.ontvjapan.com", 28768, 7, 238}, |
---|
116 |
{ "��撮�������c����", "1133.ontvjapan.com", 28768, 7, 292}, |
---|
117 |
{ "�鴻���������, "1006.ontvjapan.com", 28768, 7, 310}, |
---|
118 |
{ "鐚¥叱鐚�, "1014.ontvjapan.com", 28768, 7, 311}, |
---|
119 |
{ "�������c����", "1204.ontvjapan.com", 28768, 7, 343}, |
---|
120 |
{ "����������帥�", "110ch.epgdata.ontvjapan", 28864, 7, 110}, |
---|
121 |
{ "�眼�����c����", "1028.ontvjapan.com", 28864, 7, 260}, |
---|
122 |
{ "�������c����", "1092.ontvjapan.com", 28864, 7, 303}, |
---|
123 |
{ "鐚�軸鐚�, "1019.ontvjapan.com", 28864, 7, 323}, |
---|
124 |
{ "����若�����祉���, "1024.ontvjapan.com", 28864, 7, 324}, |
---|
125 |
{ "�������若��帥�", "1067.ontvjapan.com", 28864, 7, 352}, |
---|
126 |
{ "鐚�滋鐚c��若���, "1070.ontvjapan.com", 28864, 7, 353}, |
---|
127 |
{ "鐚o汐鐚��", "1069.ontvjapan.com", 28864, 7, 354}, |
---|
128 |
// { "�吾��鴻��祉���, "361ch.epgdata.ontvjapan", 28864, 7, 361}, |
---|
129 |
{ "�������������潟���, "294ch.epgdata.ontvjapan", 28736, 7, 294}, |
---|
130 |
// { "鐚��������鐚�, "1041.ontvjapan.com", 28896, 7, 251}, |
---|
131 |
{ "鐚э次鐚�鴫鐚�, "1026.ontvjapan.com", 28896, 7, 254}, |
---|
132 |
{ "鐔��鐔��鐚<�������", "1040.ontvjapan.com", 28896, 7, 255}, |
---|
133 |
{ "絎������≪��c����", "101ch.epgdata.ontvjapan", 28928, 7, 101}, |
---|
134 |
{ "鐚鰹自鐚鴻�鐚鰹軸鐚¥磁鐚�, "1207.ontvjapan.com", 28928, 7, 290}, |
---|
135 |
{ "����潟����羃�, "305ch.epgdata.ontvjapan", 28928, 7, 305}, |
---|
136 |
{ "鐚¥軸-鐚�, "1201.ontvjapan.com", 28928, 7, 333}, |
---|
137 |
{ "�������若��c����", "1050.ontvjapan.com", 28928, 7, 342}, |
---|
138 |
{ "�鴻�����鰹�鐚��", "803ch.epgdata.ontvjapan", 28928, 7, 803}, |
---|
139 |
{ "�鴻�����鰹�鐚��", "804ch.epgdata.ontvjapan", 28928, 7, 804}, |
---|
140 |
{ "����������刻示鐚�, "1007.ontvjapan.com", 28960, 7, 240}, |
---|
141 |
{ "�眼������������, "1027.ontvjapan.com", 28960, 7, 262}, |
---|
142 |
{ "鐚��鐚����示鐚�, "1074.ontvjapan.com", 28960, 7, 314}, |
---|
143 |
{ "��������鹿鐚�璽", "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}, |
---|
144 |
{ "�≪������������, "1193.ontvjapan.com", 28992, 7, 341}, |
---|
145 |
{ "鐚�鐚器滋鐚潟�������", "160ch.epgdata.ontvjapan", 29024, 7, 160}, |
---|
146 |
{ "鐚縁雫鐚�, "1120.ontvjapan.com", 29024, 7, 161}, |
---|
147 |
{ "����ゃ�鐚��鐚��鐚器雫", "185ch.epgdata.ontvjapan", 29024, 7, 185}, |
---|
148 |
{ "�������弱���, "1015.ontvjapan.com", 29024, 7, 293}, |
---|
149 |
{ "鐚器滋鐚潟��c����", "3201.ontvjapan.com", 29024, 7, 301}, |
---|
150 |
{ "����冴��若��c����", "1090.ontvjapan.com", 29024, 7, 304}, |
---|
151 |
{ "MUSIC ON! TV", "1022.ontvjapan.com", 29024, 7, 325}, |
---|
152 |
{ "����冴�����激���D", "1045.ontvjapan.com", 29024, 7, 335},//HD�� { "鐚器滋鐚潟��ャ��鴻��若�", "1076.ontvjapan.com", 29024, 7, 351}, |
---|
153 |
// { "鐚o竺�ユ���������, "147ch.epgdata.ontvjapan", 29056, 7, 147}, |
---|
154 |
{ "�ャ���磁鐚�示鐚�, "1068.ontvjapan.com", 29056, 7, 257},//HD��// { "fashion TV", "5004.ontvjapan.com", 29056, 7, 291},//綮�� 2009/3/31 |
---|
155 |
{ "�ャ�������", "300ch.epgdata.ontvjapan", 29056, 7, 300}, |
---|
156 |
// { "�������若����鐚器雫", "1023.ontvjapan.com", 29056, 7, 320},//綮�� 2009/3/31 |
---|
157 |
{ "Music Japan TV", "1208.ontvjapan.com", 29056, 7, 321}, |
---|
158 |
{ "�ャ���汐鐚ワ七鐚鰹�鐚�, "2002.ontvjapan.com", 29056, 7, 350}, |
---|
159 |
{ "����c����", "1052.ontvjapan.com", 29056, 7, 362}, |
---|
160 |
}; |
---|
161 |
|
---|
162 |
static int csStaCount = sizeof(csSta) / sizeof (STATION); |
---|
163 |
SVT_CONTROL *svttop = NULL; |
---|
164 |
#define SECCOUNT 4 |
---|
165 |
char title[1024]; |
---|
166 |
char subtitle[1024]; |
---|
167 |
char Category[1024]; |
---|
168 |
char ServiceName[1024]; |
---|
169 |
|
---|
170 |
|
---|
171 |
extern int strrep(char *buf, char *mae, char *ato); |
---|
172 |
|
---|
173 |
void xmlspecialchars(char *str) |
---|
174 |
{ |
---|
175 |
strrep(str, "&", "&"); |
---|
176 |
strrep(str, "'", "'"); |
---|
177 |
strrep(str, "\"", """); |
---|
178 |
strrep(str, "<", "<"); |
---|
179 |
strrep(str, ">", ">"); |
---|
180 |
} |
---|
181 |
|
---|
182 |
|
---|
183 |
|
---|
184 |
void GetSDT(FILE *infile, SVT_CONTROL *svttop, SECcache *secs, int count) |
---|
185 |
{ |
---|
186 |
SECcache *bsecs; |
---|
187 |
|
---|
188 |
while((bsecs = readTS(infile, secs, count)) != NULL) { |
---|
189 |
|
---|
190 |
if((bsecs->pid & 0xFF) == 0x11) { |
---|
191 |
dumpSDT(bsecs->buf, svttop); |
---|
192 |
} |
---|
193 |
} |
---|
194 |
} |
---|
195 |
void GetEIT(FILE *infile, FILE *outfile, STATION *psta, SECcache *secs, int count) |
---|
196 |
{ |
---|
197 |
SECcache *bsecs; |
---|
198 |
EIT_CONTROL *eitcur ; |
---|
199 |
EIT_CONTROL *eitnext ; |
---|
200 |
EIT_CONTROL *eittop = NULL; |
---|
201 |
time_t l_time ; |
---|
202 |
time_t end_time ; |
---|
203 |
struct tm tl ; |
---|
204 |
struct tm *endtl ; |
---|
205 |
char cendtime[32]; |
---|
206 |
char cstarttime[32]; |
---|
207 |
|
---|
208 |
eittop = calloc(1, sizeof(EIT_CONTROL)); |
---|
209 |
eitcur = eittop ; |
---|
210 |
fseek(infile, 0, SEEK_SET); |
---|
211 |
while((bsecs = readTS(infile, secs, SECCOUNT)) != NULL) { |
---|
212 |
|
---|
213 |
if((bsecs->pid & 0xFF) == 0x12) { |
---|
214 |
dumpEIT(bsecs->buf, psta->svId, psta->onId, psta->tsId, eittop); |
---|
215 |
}else if((bsecs->pid & 0xFF) == 0x26) { |
---|
216 |
dumpEIT(bsecs->buf, psta->svId, psta->onId, psta->tsId, eittop); |
---|
217 |
}else if((bsecs->pid & 0xFF) == 0x27) { |
---|
218 |
dumpEIT(bsecs->buf, psta->svId, psta->onId, psta->tsId, eittop); |
---|
219 |
} |
---|
220 |
} |
---|
221 |
eitcur = eittop ; |
---|
222 |
while(eitcur != NULL){ |
---|
223 |
if(!eitcur->servid){ |
---|
224 |
eitcur = eitcur->next ; |
---|
225 |
continue ; |
---|
226 |
} |
---|
227 |
if(eitcur->content_type > CAT_COUNT){ |
---|
228 |
eitcur->content_type = CAT_COUNT -1 ; |
---|
229 |
} |
---|
230 |
memset(title, '\0', sizeof(title)); |
---|
231 |
strcpy(title, eitcur->title); |
---|
232 |
xmlspecialchars(title); |
---|
233 |
|
---|
234 |
memset(subtitle, '\0', sizeof(subtitle)); |
---|
235 |
strcpy(subtitle, eitcur->subtitle); |
---|
236 |
xmlspecialchars(subtitle); |
---|
237 |
|
---|
238 |
memset(Category, '\0', sizeof(Category)); |
---|
239 |
strcpy(Category, ContentCatList[eitcur->content_type].japanese); |
---|
240 |
xmlspecialchars(Category); |
---|
241 |
|
---|
242 |
tl.tm_sec = eitcur->ss ; |
---|
243 |
tl.tm_min = eitcur->hm ; |
---|
244 |
tl.tm_hour = eitcur->hh ; |
---|
245 |
tl.tm_mday = eitcur->dd ; |
---|
246 |
tl.tm_mon = (eitcur->mm - 1); |
---|
247 |
tl.tm_year = (eitcur->yy - 1900); |
---|
248 |
tl.tm_wday = 0; |
---|
249 |
tl.tm_isdst = 0; |
---|
250 |
tl.tm_yday = 0; |
---|
251 |
l_time = mktime(&tl); |
---|
252 |
if((eitcur->ehh == 0) && (eitcur->emm == 0) && (eitcur->ess == 0)){ |
---|
253 |
(void)time(&l_time); |
---|
254 |
end_time = l_time + (60 * 5); |
---|
255 |
endtl = localtime(&end_time); |
---|
256 |
}else{ |
---|
257 |
end_time = l_time + eitcur->ehh * 3600 + eitcur->emm * 60 + eitcur->ess; |
---|
258 |
endtl = localtime(&end_time); |
---|
259 |
} |
---|
260 |
memset(cendtime, '\0', sizeof(cendtime)); |
---|
261 |
memset(cstarttime, '\0', sizeof(cstarttime)); |
---|
262 |
strftime(cendtime, (sizeof(cendtime) - 1), "%Y%m%d%H%M%S", endtl); |
---|
263 |
strftime(cstarttime, (sizeof(cstarttime) - 1), "%Y%m%d%H%M%S", &tl); |
---|
264 |
#if 1 |
---|
265 |
fprintf(outfile, " <programme start=\"%s +0900\" stop=\"%s +0900\" channel=\"%s\">\n", |
---|
266 |
cstarttime, cendtime, psta->ontv); |
---|
267 |
fprintf(outfile, " <title lang=\"ja_JP\">%s</title>\n", title); |
---|
268 |
fprintf(outfile, " <desc lang=\"ja_JP\">%s</desc>\n", subtitle); |
---|
269 |
fprintf(outfile, " <category lang=\"ja_JP\">%s</category>\n", Category); |
---|
270 |
fprintf(outfile, " <category lang=\"en\">%s</category>\n", ContentCatList[eitcur->content_type].english); |
---|
271 |
fprintf(outfile, " </programme>\n"); |
---|
272 |
#else |
---|
273 |
fprintf(outfile, "(%x:%x:%x)%s,%s,%s,%s,%s,%s\n", |
---|
274 |
eitcur->servid, eitcur->table_id, eitcur->event_id, |
---|
275 |
cstarttime, cendtime, |
---|
276 |
title, subtitle, |
---|
277 |
Category, |
---|
278 |
ContentCatList[eitcur->content_type].english); |
---|
279 |
#endif |
---|
280 |
#if 0 |
---|
281 |
fprintf(outfile, "(%x:%x)%04d/%02d/%02d,%02d:%02d:%02d,%02d:%02d:%02d,%s,%s,%s,%s\n", |
---|
282 |
eitcur->table_id, eitcur->event_id, |
---|
283 |
eitcur->yy, eitcur->mm, eitcur->dd, |
---|
284 |
eitcur->hh, eitcur->hm, eitcur->ss, |
---|
285 |
eitcur->ehh, eitcur->emm, eitcur->ess, |
---|
286 |
eitcur->title, eitcur->subtitle, |
---|
287 |
ContentCatList[eitcur->content_type].japanese, |
---|
288 |
ContentCatList[eitcur->content_type].english); |
---|
289 |
#endif |
---|
290 |
eitnext = eitcur->next ; |
---|
291 |
free(eitcur->title); |
---|
292 |
free(eitcur->subtitle); |
---|
293 |
free(eitcur); |
---|
294 |
eitcur = eitnext ; |
---|
295 |
} |
---|
296 |
free(eittop); |
---|
297 |
eittop = NULL; |
---|
298 |
} |
---|
299 |
int main(int argc, char *argv[]) |
---|
300 |
{ |
---|
301 |
|
---|
302 |
FILE *infile = stdin; |
---|
303 |
FILE *outfile = stdout; |
---|
304 |
char *arg_onTV ; |
---|
305 |
int staCount ; |
---|
306 |
char *file; |
---|
307 |
int inclose = 0; |
---|
308 |
int outclose = 0; |
---|
309 |
SVT_CONTROL *svtcur ; |
---|
310 |
SVT_CONTROL *svtsave ; |
---|
311 |
SECcache secs[SECCOUNT]; |
---|
312 |
int lp ; |
---|
313 |
STATION *pStas ; |
---|
314 |
int act ; |
---|
315 |
|
---|
316 |
|
---|
317 |
memset(secs, 0, sizeof(SECcache) * SECCOUNT); |
---|
318 |
secs[0].pid = 0x11; |
---|
319 |
secs[1].pid = 0x12; |
---|
320 |
secs[2].pid = 0x26; |
---|
321 |
secs[3].pid = 0x27; |
---|
322 |
|
---|
323 |
if(argc == 4){ |
---|
324 |
arg_onTV = argv[1]; |
---|
325 |
file = argv[2]; |
---|
326 |
if(strcmp(file, "-")) { |
---|
327 |
infile = fopen(file, "r"); |
---|
328 |
inclose = 1; |
---|
329 |
} |
---|
330 |
if(strcmp(argv[3], "-")) { |
---|
331 |
outfile = fopen(argv[3], "w+"); |
---|
332 |
outclose = 1; |
---|
333 |
} |
---|
334 |
}else{ |
---|
335 |
fprintf(stdout, "Usage : %s {/BS|/CS} <tsFile> <outfile>\n", argv[0]); |
---|
336 |
fprintf(stdout, "Usage : %s <ontvcode> <tsFile> <outfile>\n", argv[0]); |
---|
337 |
fprintf(stdout, "\n"); |
---|
338 |
fprintf(stdout, " ontvcode Channel identifier (ex. ****.ontvjapan.com)\n"); |
---|
339 |
fprintf(stdout, " /BS BS mode\n"); |
---|
340 |
fprintf(stdout, " This mode reads the data of all BS TV stations\n"); |
---|
341 |
fprintf(stdout, " from one TS data.\n"); |
---|
342 |
fprintf(stdout, " /CS CS mode\n"); |
---|
343 |
fprintf(stdout, " This mode reads the data of two or more CS TV stations\n"); |
---|
344 |
fprintf(stdout, " from one TS data.\n"); |
---|
345 |
return 0; |
---|
346 |
} |
---|
347 |
|
---|
348 |
if(strcmp(arg_onTV, "/BS") == 0){ |
---|
349 |
pStas = bsSta; |
---|
350 |
staCount = bsStaCount; |
---|
351 |
act = 0 ; |
---|
352 |
}else if(strcmp(arg_onTV, "/CS") == 0){ |
---|
353 |
pStas = csSta; |
---|
354 |
staCount = csStaCount; |
---|
355 |
act = 0 ; |
---|
356 |
}else{ |
---|
357 |
act = 1 ; |
---|
358 |
svttop = calloc(1, sizeof(SVT_CONTROL)); |
---|
359 |
GetSDT(infile, svttop, secs, SECCOUNT); |
---|
360 |
svtcur = svttop->next ; |
---|
361 |
if(svtcur == NULL){ |
---|
362 |
free(svttop); |
---|
363 |
return 1; |
---|
364 |
} |
---|
365 |
|
---|
366 |
pStas = calloc(1, sizeof(STATION)); |
---|
367 |
pStas->tsId = svtcur->transport_stream_id ; |
---|
368 |
pStas->onId = svtcur->original_network_id ; |
---|
369 |
pStas->svId = svtcur->event_id ; |
---|
370 |
pStas->ontv = arg_onTV ; |
---|
371 |
pStas->name = svtcur->servicename ; |
---|
372 |
staCount = 1; |
---|
373 |
} |
---|
374 |
|
---|
375 |
fprintf(outfile, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); |
---|
376 |
fprintf(outfile, "<!DOCTYPE tv SYSTEM \"xmltv.dtd\">\n\n"); |
---|
377 |
fprintf(outfile, "<tv generator-info-name=\"tsEPG2xml\" generator-info-url=\"http://localhost/\">\n"); |
---|
378 |
|
---|
379 |
for(lp = 0 ; lp < staCount ; lp++){ |
---|
380 |
memset(ServiceName, '\0', sizeof(ServiceName)); |
---|
381 |
strcpy(ServiceName, pStas[lp].name); |
---|
382 |
xmlspecialchars(ServiceName); |
---|
383 |
|
---|
384 |
fprintf(outfile, " <channel id=\"%s\">\n", pStas[lp].ontv); |
---|
385 |
fprintf(outfile, " <display-name lang=\"ja_JP\">%s</display-name>\n", ServiceName); |
---|
386 |
fprintf(outfile, " </channel>\n"); |
---|
387 |
} |
---|
388 |
for(lp = 0 ; lp < staCount ; lp++){ |
---|
389 |
GetEIT(infile, outfile, &pStas[lp], secs, SECCOUNT); |
---|
390 |
} |
---|
391 |
fprintf(outfile, "</tv>\n"); |
---|
392 |
if(inclose) { |
---|
393 |
fclose(infile); |
---|
394 |
} |
---|
395 |
|
---|
396 |
if(outclose) { |
---|
397 |
fclose(outfile); |
---|
398 |
} |
---|
399 |
if(act){ |
---|
400 |
free(pStas); |
---|
401 |
svtcur = svttop ; |
---|
402 |
while(svtcur != NULL){ |
---|
403 |
svtsave = svtcur->next ; |
---|
404 |
free(svtcur); |
---|
405 |
svtcur = svtsave ; |
---|
406 |
} |
---|
407 |
} |
---|
408 |
|
---|
409 |
return 0; |
---|
410 |
} |
---|