1 | #ifndef IMDB_H |
---|
2 | #define IMDB_H |
---|
3 | |
---|
4 | #define TMPIMDBPIC1 "/tmp/tmpimdb1.jpg" |
---|
5 | #define TMPIMDBPIC2 "/tmp/tmpimdb2.jpg" |
---|
6 | |
---|
7 | void freeimdb(struct imdb** node, int flag) |
---|
8 | { |
---|
9 | if(node == NULL || *node == NULL) return; |
---|
10 | |
---|
11 | free((*node)->title); (*node)->title = NULL; |
---|
12 | free((*node)->year); (*node)->year = NULL; |
---|
13 | free((*node)->rated); (*node)->rated = NULL; |
---|
14 | free((*node)->released); (*node)->released = NULL; |
---|
15 | free((*node)->genre); (*node)->genre = NULL; |
---|
16 | free((*node)->director); (*node)->director = NULL; |
---|
17 | free((*node)->writer); (*node)->writer = NULL; |
---|
18 | free((*node)->actors); (*node)->actors = NULL; |
---|
19 | free((*node)->plot); (*node)->plot = NULL; |
---|
20 | free((*node)->poster); (*node)->poster = NULL; |
---|
21 | free((*node)->runtime); (*node)->runtime = NULL; |
---|
22 | free((*node)->rating); (*node)->rating = NULL; |
---|
23 | free((*node)->votes); (*node)->votes = NULL; |
---|
24 | free((*node)->id); (*node)->id = NULL; |
---|
25 | |
---|
26 | unlink(TMPIMDBPIC1); |
---|
27 | unlink(TMPIMDBPIC2); |
---|
28 | |
---|
29 | free(*node); *node = NULL; |
---|
30 | } |
---|
31 | |
---|
32 | // flag 0 = title search |
---|
33 | // flag 1 = iimdbid search |
---|
34 | // flag 2 = iimdbid search and save |
---|
35 | struct imdb* getimdb(struct imdb** first, char* input, int flag, int flag1, int flag2) |
---|
36 | { |
---|
37 | char* tmpstr = NULL, *tmpstr1 = NULL, *tmpstr2 = NULL, *tmpsearch = NULL, *savefile = NULL, *pageposter = NULL, *title = NULL; |
---|
38 | |
---|
39 | debug(133, "title: %s",input); |
---|
40 | debug(133, "flag: %d",flag); |
---|
41 | debug(133, "flag1: %d",flag1); |
---|
42 | debug(133, "flag2: %d",flag2); |
---|
43 | |
---|
44 | title = ostrcat(title, input, 1, 0); |
---|
45 | |
---|
46 | start: |
---|
47 | debug(133, "title: %s",title); |
---|
48 | // tmpsearch = ostrcat("find?s=tt;q=", NULL, 0, 0); |
---|
49 | tmpsearch = ostrcat("find?q=", NULL, 0, 0); |
---|
50 | |
---|
51 | if(checkinternet() == 1) |
---|
52 | { |
---|
53 | debug(133, "Error, Internet Connection not found"); |
---|
54 | return NULL; |
---|
55 | } |
---|
56 | |
---|
57 | if(flag == 0) |
---|
58 | { |
---|
59 | tmpsearch = ostrcat(tmpsearch, title, 1, 0); |
---|
60 | tmpsearch = ostrcat(tmpsearch, "&s=all", 1, 0); |
---|
61 | } |
---|
62 | else |
---|
63 | tmpsearch = ostrcat("/title/tt", title, 0, 0); |
---|
64 | tmpsearch = stringreplacechar(tmpsearch, ' ', '+'); |
---|
65 | |
---|
66 | debug(133, "search: http://www.imdb.de/%s", tmpsearch); |
---|
67 | |
---|
68 | tmpstr = gethttp("www.imdb.de", tmpsearch, 80, NULL, NULL, 5000, NULL, 0); |
---|
69 | // writesys("/var/usr/local/share/titan/plugins/imdb/tmpstr0", tmpstr, 1); |
---|
70 | |
---|
71 | |
---|
72 | debug(133, "tmpsearch: %s", tmpsearch); |
---|
73 | free(tmpsearch); tmpsearch = NULL; |
---|
74 | |
---|
75 | if(tmpstr != NULL) |
---|
76 | { |
---|
77 | if(ostrstr(tmpstr, "<b>Keine Treffer.</b>") != NULL) |
---|
78 | { |
---|
79 | debug(133, "<b>Keine Treffer.</b>"); |
---|
80 | free(tmpstr); tmpstr = NULL; |
---|
81 | return NULL; |
---|
82 | } |
---|
83 | |
---|
84 | *first = (struct imdb*)calloc(1, sizeof(struct imdb)); |
---|
85 | if(*first == NULL) |
---|
86 | { |
---|
87 | err("no mem"); |
---|
88 | free(tmpstr); tmpstr = NULL; |
---|
89 | return NULL; |
---|
90 | } |
---|
91 | |
---|
92 | if(flag == 0) |
---|
93 | (*first)->id = string_resub("<a href=\"/title/tt", "/", tmpstr, 0); |
---|
94 | else |
---|
95 | (*first)->id = ostrcat(title, NULL, 0, 0); |
---|
96 | |
---|
97 | if(flag1 == 1) |
---|
98 | { |
---|
99 | if((*first)->id != NULL) |
---|
100 | (*first)->id = ostrcat("tt", (*first)->id, 0, 1); |
---|
101 | |
---|
102 | debug(133, "----------------------imdb start----------------------"); |
---|
103 | debug(133, "id: %s", (*first)->id); |
---|
104 | debug(133, "----------------------imdb end----------------------"); |
---|
105 | |
---|
106 | free(tmpstr); tmpstr = NULL; |
---|
107 | return *first; |
---|
108 | } |
---|
109 | |
---|
110 | // todo - use Meistgesuchte Titel (default) |
---|
111 | // Meistgesuchte Titel |
---|
112 | // Titel (näherungsweise Übereinstimmung) |
---|
113 | // Titel (genaue Übereinstimmung) |
---|
114 | |
---|
115 | if(flag1 == 0 && ostrstr(tmpstr, "<title>IMDb Titelsuche</title>") != NULL && ostrstr(tmpstr, "<p><b>Meistgesuchte Titel</b>") == NULL) |
---|
116 | { |
---|
117 | char* tmp = tmpstr; |
---|
118 | tmpstr = string_resub("<p><b>Titel", "</td></tr></table> </p>", tmpstr, 0); |
---|
119 | free(tmp); tmp = NULL; |
---|
120 | // writesys("/var/usr/local/share/titan/plugins/imdb/tmpstr", tmpstr, 0); |
---|
121 | |
---|
122 | while(ostrstr(tmpstr, "</td><td valign=\"top\"><a href=\"/title/") != NULL) |
---|
123 | { |
---|
124 | tmpstr = string_replace("</td><td valign=\"top\"><a href=\"/title/", "\n\n", tmpstr, 1); |
---|
125 | } |
---|
126 | // writesys("/var/usr/local/share/titan/plugins/imdb/tmpstr1", tmpstr, 0); |
---|
127 | |
---|
128 | struct menulist* mlist = NULL, *mbox = NULL; |
---|
129 | |
---|
130 | int count = 0; |
---|
131 | struct splitstr* ret = NULL; |
---|
132 | ret = strsplit(tmpstr, "\n", &count); |
---|
133 | |
---|
134 | int max = count; |
---|
135 | int i = 0; |
---|
136 | for(i = 0; i < max; i++) |
---|
137 | { |
---|
138 | // tmpstr1 = string_resub("link=/title", "</a>", (&ret[i])->part, 0); |
---|
139 | tmpstr1 = string_resub("link=/title", "</td>", (&ret[i])->part, 0); |
---|
140 | debug(133, "tmpstr1(%d): %s\n", i, tmpstr1); |
---|
141 | tmpstr1 = string_replace("</a>", "", tmpstr1, 1); |
---|
142 | debug(133, "tmpstr1(%d): %s\n", i, tmpstr1); |
---|
143 | |
---|
144 | char* x = oregex("/tt([0-9]{7})", tmpstr1); |
---|
145 | char* y = oregex(";\">(.*)", tmpstr1); |
---|
146 | if(ostrstr(y, "<img src") == NULL && x != NULL && y != NULL) |
---|
147 | { |
---|
148 | debug(133, "x(%d): %s\n", i, x); |
---|
149 | debug(133, "y(%d): %s\n", i, y); |
---|
150 | string_striptags(x); |
---|
151 | string_striptags(y); |
---|
152 | string_strip_whitechars(x); |
---|
153 | string_strip_whitechars(y); |
---|
154 | debug(133, "x(%d): %s\n", i, x); |
---|
155 | debug(133, "y(%d): %s\n", i, y); |
---|
156 | y = string_decode(y, 1); |
---|
157 | x = string_decode(x, 1); |
---|
158 | debug(133, "x(%d): %s\n", i, x); |
---|
159 | debug(133, "y(%d): %s\n", i, y); |
---|
160 | |
---|
161 | addmenulist(&mlist, y, x, NULL, 0, 0); |
---|
162 | } |
---|
163 | free(x), x = NULL; |
---|
164 | free(y), y = NULL; |
---|
165 | /* |
---|
166 | current not working |
---|
167 | struct regex* x = regexstruct("/tt([0-9]{7})", tmpstr1); |
---|
168 | struct regex* y = regexstruct(";\">(.*)", tmpstr1); |
---|
169 | if(x != NULL && y != NULL) |
---|
170 | { |
---|
171 | debug(133, "x->match2(%d): %s\n", i, x->match2); |
---|
172 | debug(133, "y->match2(%d): %s\n", i, y->match2); |
---|
173 | x->match2 = string_decode(x->match2, 1); |
---|
174 | y->match2 = string_decode(y->match2, 1); |
---|
175 | addmenulist(&mlist, y->match2, x->match2, NULL, 0, 0); |
---|
176 | debug(133, "x->match2(%d): %s\n", i, x->match2); |
---|
177 | debug(133, "y->match2(%d): %s\n", i, y->match2); |
---|
178 | } |
---|
179 | freeregexstruct(x); x = NULL; |
---|
180 | freeregexstruct(y); y = NULL; |
---|
181 | */ |
---|
182 | free(tmpstr1),tmpstr1 = NULL; |
---|
183 | } |
---|
184 | free(ret); ret = NULL; |
---|
185 | |
---|
186 | mbox = menulistbox(mlist, NULL, NULL, NULL, NULL, 1, 0); |
---|
187 | if(mbox != NULL) |
---|
188 | { |
---|
189 | free(title), title = NULL; |
---|
190 | free(tmpstr), tmpstr = NULL; |
---|
191 | |
---|
192 | debug(133, "mbox->name %s", mbox->name); |
---|
193 | debug(133, "mbox->text %s", mbox->text); |
---|
194 | |
---|
195 | title = ostrcat(mbox->text, NULL, 0, 0); |
---|
196 | flag = 1; |
---|
197 | goto start; |
---|
198 | } |
---|
199 | } |
---|
200 | if(flag != 2) |
---|
201 | free(tmpstr), tmpstr = NULL; |
---|
202 | } |
---|
203 | |
---|
204 | if(*first != NULL && flag != 2) |
---|
205 | { |
---|
206 | if((*first)->id == NULL) |
---|
207 | free(tmpstr), tmpstr = NULL; |
---|
208 | else |
---|
209 | { |
---|
210 | debug(133, "imdb->id: %s", (*first)->id); |
---|
211 | |
---|
212 | tmpsearch = ostrcat("/title/tt", NULL, 0, 0); |
---|
213 | tmpsearch = ostrcat(tmpsearch, (*first)->id, 1, 0); |
---|
214 | |
---|
215 | tmpstr = gethttp("www.imdb.de", tmpsearch, 80, NULL, NULL, 5000, NULL, 0); |
---|
216 | // writesys("/var/usr/local/share/titan/plugins/imdb/tmpstrj", tmpstr, 0); |
---|
217 | |
---|
218 | debug(133, "tmpsearch: %s", tmpsearch); |
---|
219 | free(tmpsearch); tmpsearch = NULL; |
---|
220 | } |
---|
221 | } |
---|
222 | |
---|
223 | if(*first != NULL && tmpstr != NULL) |
---|
224 | { |
---|
225 | if(ostrstr(tmpstr, "<title>") != NULL) |
---|
226 | { |
---|
227 | (*first)->title = string_resub("<title>", "</title>", tmpstr, 0); |
---|
228 | (*first)->title = string_decode((*first)->title, 1); |
---|
229 | string_strip_whitechars((*first)->title); |
---|
230 | strstrip((*first)->title); |
---|
231 | } |
---|
232 | |
---|
233 | if(ostrstr(tmpstr, "\"genre\">") != NULL) |
---|
234 | { |
---|
235 | tmpstr1 = string_resub(" - ", "</div>", tmpstr, 0); |
---|
236 | |
---|
237 | while(ostrstr(tmpstr1, "\"genre\"") != NULL) |
---|
238 | { |
---|
239 | tmpstr2 = string_resub("\"genre\">", "</span>", tmpstr1, 0); |
---|
240 | tmpstr1 = string_replace("\"genre\">", "", tmpstr1, 1); |
---|
241 | if((*first)->genre != NULL && tmpstr2 != NULL) |
---|
242 | (*first)->genre = ostrcat((*first)->genre, ",", 1, 0); |
---|
243 | |
---|
244 | (*first)->genre = ostrcat((*first)->genre, tmpstr2, 1, 0); |
---|
245 | free(tmpstr2), tmpstr2 = NULL; |
---|
246 | } |
---|
247 | free(tmpstr1), tmpstr1 = NULL; |
---|
248 | |
---|
249 | string_striptags((*first)->genre); |
---|
250 | string_strip_whitechars((*first)->genre); |
---|
251 | strstrip((*first)->genre); |
---|
252 | } |
---|
253 | |
---|
254 | if(ostrstr(tmpstr, ">Writers:</h4>") != NULL) |
---|
255 | { |
---|
256 | tmpstr1 = string_resub(">Writers:</h4>", "</div>", tmpstr, 0); |
---|
257 | |
---|
258 | while(ostrstr(tmpstr1, "\"name\"") != NULL) |
---|
259 | { |
---|
260 | tmpstr2 = string_resub("\"name\">", "</span>", tmpstr1, 0); |
---|
261 | tmpstr1 = string_replace("\"name\">", "", tmpstr1, 1); |
---|
262 | if((*first)->writer != NULL && tmpstr2 != NULL) |
---|
263 | (*first)->writer = ostrcat((*first)->writer, ",", 1, 0); |
---|
264 | |
---|
265 | (*first)->writer = ostrcat((*first)->writer, tmpstr2, 1, 0); |
---|
266 | free(tmpstr2), tmpstr2 = NULL; |
---|
267 | } |
---|
268 | free(tmpstr1), tmpstr1 = NULL; |
---|
269 | |
---|
270 | string_striptags((*first)->writer); |
---|
271 | string_strip_whitechars((*first)->writer); |
---|
272 | strstrip((*first)->writer); |
---|
273 | } |
---|
274 | |
---|
275 | if((*first)->writer == NULL && ostrstr(tmpstr, ">Writer:</h4>") != NULL) |
---|
276 | { |
---|
277 | tmpstr1 = string_resub(">Writer:</h4>", "</div>", tmpstr, 0); |
---|
278 | |
---|
279 | while(ostrstr(tmpstr1, "\"name\"") != NULL) |
---|
280 | { |
---|
281 | tmpstr2 = string_resub("\"name\">", "</span>", tmpstr1, 0); |
---|
282 | tmpstr1 = string_replace("\"name\">", "", tmpstr1, 1); |
---|
283 | if((*first)->writer != NULL && tmpstr2 != NULL) |
---|
284 | (*first)->writer = ostrcat((*first)->writer, ",", 1, 0); |
---|
285 | |
---|
286 | (*first)->writer = ostrcat((*first)->writer, tmpstr2, 1, 0); |
---|
287 | free(tmpstr2), tmpstr2 = NULL; |
---|
288 | } |
---|
289 | free(tmpstr1), tmpstr1 = NULL; |
---|
290 | |
---|
291 | string_striptags((*first)->writer); |
---|
292 | string_strip_whitechars((*first)->writer); |
---|
293 | strstrip((*first)->writer); |
---|
294 | } |
---|
295 | |
---|
296 | if(ostrstr(tmpstr, ">Director:</h4>") != NULL) |
---|
297 | { |
---|
298 | tmpstr1 = string_resub(">Director:</h4>", "</div>", tmpstr, 0); |
---|
299 | |
---|
300 | while(ostrstr(tmpstr1, "\"name\"") != NULL) |
---|
301 | { |
---|
302 | tmpstr2 = string_resub("\"name\">", "</span>", tmpstr1, 0); |
---|
303 | tmpstr1 = string_replace("\"name\">", "", tmpstr1, 1); |
---|
304 | if((*first)->director != NULL && tmpstr2 != NULL) |
---|
305 | (*first)->director = ostrcat((*first)->director, ",", 1, 0); |
---|
306 | |
---|
307 | (*first)->director = ostrcat((*first)->director, tmpstr2, 1, 0); |
---|
308 | free(tmpstr2), tmpstr2 = NULL; |
---|
309 | } |
---|
310 | free(tmpstr1), tmpstr1 = NULL; |
---|
311 | |
---|
312 | string_striptags((*first)->director); |
---|
313 | string_strip_whitechars((*first)->director); |
---|
314 | strstrip((*first)->director); |
---|
315 | } |
---|
316 | |
---|
317 | if((*first)->director == NULL && ostrstr(tmpstr, ">Directors:</h4>") != NULL) |
---|
318 | { |
---|
319 | tmpstr1 = string_resub(">Directors:</h4>", "</div>", tmpstr, 0); |
---|
320 | |
---|
321 | while(ostrstr(tmpstr1, "\"name\"") != NULL) |
---|
322 | { |
---|
323 | tmpstr2 = string_resub("\"name\">", "</span>", tmpstr1, 0); |
---|
324 | tmpstr1 = string_replace("\"name\">", "", tmpstr1, 1); |
---|
325 | if((*first)->director != NULL && tmpstr2 != NULL) |
---|
326 | (*first)->director = ostrcat((*first)->director, ",", 1, 0); |
---|
327 | |
---|
328 | (*first)->director = ostrcat((*first)->director, tmpstr2, 1, 0); |
---|
329 | free(tmpstr2), tmpstr2 = NULL; |
---|
330 | } |
---|
331 | free(tmpstr1), tmpstr1 = NULL; |
---|
332 | |
---|
333 | string_striptags((*first)->director); |
---|
334 | string_strip_whitechars((*first)->director); |
---|
335 | strstrip((*first)->director); |
---|
336 | } |
---|
337 | |
---|
338 | if((*first)->director == NULL && ostrstr(tmpstr, "<b>Director:</b>") != NULL) |
---|
339 | { |
---|
340 | (*first)->director = string_resub("<b>Director:</b>", "</div>", tmpstr, 0); |
---|
341 | string_striptags((*first)->director); |
---|
342 | string_strip_whitechars((*first)->director); |
---|
343 | strstrip((*first)->director); |
---|
344 | } |
---|
345 | |
---|
346 | if((*first)->director == NULL && ostrstr(tmpstr, ">Creator:</h4>") != NULL) |
---|
347 | { |
---|
348 | tmpstr1 = string_resub(">Creator:</h4>", "</div>", tmpstr, 0); |
---|
349 | |
---|
350 | while(ostrstr(tmpstr1, "\"name\"") != NULL) |
---|
351 | { |
---|
352 | tmpstr2 = string_resub("\"name\">", "</span>", tmpstr1, 0); |
---|
353 | tmpstr1 = string_replace("\"name\">", "", tmpstr1, 1); |
---|
354 | if((*first)->director != NULL && tmpstr2 != NULL) |
---|
355 | (*first)->director = ostrcat((*first)->director, ",", 1, 0); |
---|
356 | |
---|
357 | (*first)->director = ostrcat((*first)->director, tmpstr2, 1, 0); |
---|
358 | free(tmpstr2), tmpstr2 = NULL; |
---|
359 | } |
---|
360 | free(tmpstr1), tmpstr1 = NULL; |
---|
361 | |
---|
362 | string_striptags((*first)->director); |
---|
363 | string_strip_whitechars((*first)->director); |
---|
364 | strstrip((*first)->director); |
---|
365 | } |
---|
366 | |
---|
367 | if((*first)->director == NULL && ostrstr(tmpstr, ">Creators:</h4>") != NULL) |
---|
368 | { |
---|
369 | tmpstr1 = string_resub(">Creators:</h4>", "</div>", tmpstr, 0); |
---|
370 | |
---|
371 | while(ostrstr(tmpstr1, "\"name\"") != NULL) |
---|
372 | { |
---|
373 | tmpstr2 = string_resub("\"name\">", "</span>", tmpstr1, 0); |
---|
374 | tmpstr1 = string_replace("\"name\">", "", tmpstr1, 1); |
---|
375 | if((*first)->director != NULL && tmpstr2 != NULL) |
---|
376 | (*first)->director = ostrcat((*first)->director, ",", 1, 0); |
---|
377 | |
---|
378 | (*first)->director = ostrcat((*first)->director, tmpstr2, 1, 0); |
---|
379 | free(tmpstr2), tmpstr2 = NULL; |
---|
380 | } |
---|
381 | free(tmpstr1), tmpstr1 = NULL; |
---|
382 | |
---|
383 | string_striptags((*first)->director); |
---|
384 | string_strip_whitechars((*first)->director); |
---|
385 | strstrip((*first)->director); |
---|
386 | } |
---|
387 | |
---|
388 | if(ostrstr(tmpstr, ">Release Date:</h4>") != NULL) |
---|
389 | { |
---|
390 | (*first)->released = string_resub(">Release Date:</h4>", "<span", tmpstr, 0); |
---|
391 | string_striptags((*first)->released); |
---|
392 | string_strip_whitechars((*first)->released); |
---|
393 | strstrip((*first)->released); |
---|
394 | } |
---|
395 | |
---|
396 | if(ostrstr(tmpstr, ">Star:</h4>") != NULL) |
---|
397 | { |
---|
398 | tmpstr1 = string_resub(">Star:</h4>", "</div>", tmpstr, 0); |
---|
399 | |
---|
400 | while(ostrstr(tmpstr1, "\"name\"") != NULL) |
---|
401 | { |
---|
402 | tmpstr2 = string_resub("\"name\">", "</span>", tmpstr1, 0); |
---|
403 | tmpstr1 = string_replace("\"name\">", "", tmpstr1, 1); |
---|
404 | if((*first)->actors != NULL && tmpstr2 != NULL) |
---|
405 | (*first)->actors = ostrcat((*first)->actors, ",", 1, 0); |
---|
406 | |
---|
407 | (*first)->actors = ostrcat((*first)->actors, tmpstr2, 1, 0); |
---|
408 | free(tmpstr2), tmpstr2 = NULL; |
---|
409 | } |
---|
410 | free(tmpstr1), tmpstr1 = NULL; |
---|
411 | |
---|
412 | string_striptags((*first)->actors); |
---|
413 | string_strip_whitechars((*first)->actors); |
---|
414 | strstrip((*first)->actors); |
---|
415 | } |
---|
416 | |
---|
417 | if(ostrstr(tmpstr, ">Stars:</h4>") != NULL) |
---|
418 | { |
---|
419 | tmpstr1 = string_resub(">Stars:</h4>", "</div>", tmpstr, 0); |
---|
420 | |
---|
421 | while(ostrstr(tmpstr1, "\"name\"") != NULL) |
---|
422 | { |
---|
423 | tmpstr2 = string_resub("\"name\">", "</span>", tmpstr1, 0); |
---|
424 | tmpstr1 = string_replace("\"name\">", "", tmpstr1, 1); |
---|
425 | if((*first)->actors != NULL && tmpstr2 != NULL) |
---|
426 | (*first)->actors = ostrcat((*first)->actors, ",", 1, 0); |
---|
427 | |
---|
428 | (*first)->actors = ostrcat((*first)->actors, tmpstr2, 1, 0); |
---|
429 | free(tmpstr2), tmpstr2 = NULL; |
---|
430 | } |
---|
431 | free(tmpstr1), tmpstr1 = NULL; |
---|
432 | |
---|
433 | string_striptags((*first)->actors); |
---|
434 | string_strip_whitechars((*first)->actors); |
---|
435 | strstrip((*first)->actors); |
---|
436 | } |
---|
437 | |
---|
438 | if(ostrstr(tmpstr, "\"description\">") != NULL) |
---|
439 | { |
---|
440 | tmpstr1 = string_resub("\"description\">", "</div>", tmpstr, 0); |
---|
441 | (*first)->plot = string_resub("<p>", "</p>", tmpstr1, 0); |
---|
442 | } |
---|
443 | |
---|
444 | if(ostrstr(tmpstr, "<meta property='og:image' content=\"") != NULL) |
---|
445 | { |
---|
446 | (*first)->thumb = string_resub("<meta property='og:image' content=\"", "\"", tmpstr, 0); |
---|
447 | } |
---|
448 | |
---|
449 | if(ostrstr(tmpstr, "/media/rm") != NULL) |
---|
450 | { |
---|
451 | pageposter = string_resub("/media/rm", "/", tmpstr, 0); |
---|
452 | strstrip(pageposter); |
---|
453 | } |
---|
454 | free(tmpstr), tmpstr = NULL; |
---|
455 | } |
---|
456 | |
---|
457 | if(*first != NULL && pageposter != NULL) |
---|
458 | { |
---|
459 | tmpsearch = ostrcat("/media/rm", pageposter, 0, 0); |
---|
460 | tmpsearch = ostrcat(tmpsearch, "/tt", 1, 0); |
---|
461 | tmpsearch = ostrcat(tmpsearch, (*first)->id, 1, 0); |
---|
462 | tmpsearch = ostrcat(tmpsearch, "/", 1, 0); |
---|
463 | |
---|
464 | tmpstr = gethttp("www.imdb.de", tmpsearch, 80, NULL, NULL, 5000, NULL, 0); |
---|
465 | |
---|
466 | debug(133, "tmpsearch: %s", tmpsearch); |
---|
467 | free(tmpsearch); tmpsearch = NULL; |
---|
468 | |
---|
469 | if(tmpstr != NULL) |
---|
470 | { |
---|
471 | if(ostrstr(tmpstr, "image_src") != NULL) |
---|
472 | { |
---|
473 | (*first)->poster = string_resub("<link rel=\"image_src\" href=\"", "\"", tmpstr, 0); |
---|
474 | strstrip((*first)->poster); |
---|
475 | } |
---|
476 | free(tmpstr), tmpstr = NULL; |
---|
477 | } |
---|
478 | } |
---|
479 | |
---|
480 | // if(*first != NULL && (*first)->id == NULL) |
---|
481 | if(*first != NULL && (*first)->id != NULL) |
---|
482 | { |
---|
483 | tmpsearch = ostrcat("/title/tt", NULL, 0, 0); |
---|
484 | tmpsearch = ostrcat(tmpsearch, (*first)->id, 1, 0); |
---|
485 | tmpsearch = ostrcat(tmpsearch, "/plotsummary", 1, 0); |
---|
486 | |
---|
487 | tmpstr = gethttp("www.imdb.de", tmpsearch, 80, NULL, NULL, 5000, NULL, 0); |
---|
488 | // writesys("/var/usr/local/share/titan/plugins/imdb/tmpstrplot", tmpstr, 0); |
---|
489 | |
---|
490 | debug(133, "tmpsearch: %s", tmpsearch); |
---|
491 | |
---|
492 | free(tmpsearch); tmpsearch = NULL; |
---|
493 | } |
---|
494 | |
---|
495 | if(*first != NULL && tmpstr != NULL) |
---|
496 | { |
---|
497 | if(ostrstr(tmpstr, "<p class=\"plotSummary\">") != NULL) |
---|
498 | { |
---|
499 | tmpstr1 = string_resub("<p class=\"plotSummary\">", "<span", tmpstr, 0); |
---|
500 | if(tmpstr1 != NULL) |
---|
501 | { |
---|
502 | (*first)->plot = ostrcat((*first)->plot, tmpstr1, 1, 0); |
---|
503 | string_striptags((*first)->plot); |
---|
504 | string_strip_whitechars((*first)->plot); |
---|
505 | strstrip((*first)->plot); |
---|
506 | } |
---|
507 | free(tmpstr1), tmpstr1 = NULL; |
---|
508 | } |
---|
509 | free(tmpstr), tmpstr = NULL; |
---|
510 | } |
---|
511 | |
---|
512 | if(flag2 == 0 && *first != NULL && (*first)->id != NULL) |
---|
513 | { |
---|
514 | if((*first)->poster != NULL) |
---|
515 | { |
---|
516 | char* ip = NULL, *pos = NULL, *path = NULL; |
---|
517 | ip = string_replace("http://", "", (*first)->poster, 0); |
---|
518 | |
---|
519 | if(ip != NULL) |
---|
520 | pos = strchr(ip, '/'); |
---|
521 | if(pos != NULL) |
---|
522 | { |
---|
523 | pos[0] = '\0'; |
---|
524 | path = pos + 1; |
---|
525 | } |
---|
526 | |
---|
527 | if(flag1 == 1) |
---|
528 | { |
---|
529 | savefile = ostrcat(getconfig("mediadbpath", NULL), "/tt", 0, 0); |
---|
530 | savefile = ostrcat(savefile, (*first)->id, 1, 0); |
---|
531 | savefile = ostrcat(savefile, "_poster.jpg", 1, 0); |
---|
532 | gethttp(ip, path, 80, savefile, NULL, 5000, NULL, 0); |
---|
533 | free((*first)->poster); |
---|
534 | (*first)->poster = savefile; |
---|
535 | } |
---|
536 | else |
---|
537 | { |
---|
538 | gethttp(ip, path, 80, TMPIMDBPIC1, NULL, 5000, NULL, 0); |
---|
539 | free((*first)->poster); |
---|
540 | (*first)->poster = ostrcat(TMPIMDBPIC1, NULL, 0, 0); |
---|
541 | } |
---|
542 | |
---|
543 | free(ip); ip = NULL; |
---|
544 | } |
---|
545 | |
---|
546 | if((*first)->thumb != NULL) |
---|
547 | { |
---|
548 | char* ip = NULL, *pos = NULL, *path = NULL; |
---|
549 | ip = string_replace("http://", "", (*first)->thumb, 0); |
---|
550 | |
---|
551 | if(ip != NULL) |
---|
552 | pos = strchr(ip, '/'); |
---|
553 | if(pos != NULL) |
---|
554 | { |
---|
555 | pos[0] = '\0'; |
---|
556 | path = pos + 1; |
---|
557 | } |
---|
558 | |
---|
559 | if(flag1 == 1) |
---|
560 | { |
---|
561 | savefile = ostrcat(getconfig("mediadbpath", NULL), "/tt", 0, 0); |
---|
562 | savefile = ostrcat(savefile, (*first)->id, 1, 0); |
---|
563 | savefile = ostrcat(savefile, "_thumb.jpg", 1, 0); |
---|
564 | gethttp(ip, path, 80, savefile, NULL, 5000, NULL, 0); |
---|
565 | free((*first)->thumb); |
---|
566 | (*first)->thumb = savefile; |
---|
567 | } |
---|
568 | else |
---|
569 | { |
---|
570 | gethttp(ip, path, 80, TMPIMDBPIC2, NULL, 5000, NULL, 0); |
---|
571 | free((*first)->thumb); |
---|
572 | (*first)->thumb = ostrcat(TMPIMDBPIC2, NULL, 0, 0); |
---|
573 | } |
---|
574 | |
---|
575 | free(ip); ip = NULL; |
---|
576 | } |
---|
577 | } |
---|
578 | else if(*first != NULL) |
---|
579 | { |
---|
580 | if((*first)->thumb != NULL) |
---|
581 | { |
---|
582 | free((*first)->thumb); |
---|
583 | (*first)->thumb = NULL; |
---|
584 | } |
---|
585 | if((*first)->poster != NULL) |
---|
586 | { |
---|
587 | free((*first)->poster); |
---|
588 | (*first)->poster = NULL; |
---|
589 | } |
---|
590 | } |
---|
591 | |
---|
592 | if(*first != NULL && (*first)->id != NULL) |
---|
593 | (*first)->id = ostrcat("tt", (*first)->id, 0, 1); |
---|
594 | |
---|
595 | free(tmpstr); tmpstr = NULL; |
---|
596 | |
---|
597 | if(*first != NULL) |
---|
598 | { |
---|
599 | debug(133, "----------------------imdb start----------------------"); |
---|
600 | debug(133, "id: %s", (*first)->id); |
---|
601 | debug(133, "title: %s", (*first)->title); |
---|
602 | debug(133, "genre: %s", (*first)->genre); |
---|
603 | debug(133, "writer: %s", (*first)->writer); |
---|
604 | debug(133, "director: %s", (*first)->director); |
---|
605 | debug(133, "released: %s", (*first)->released); |
---|
606 | debug(133, "actors: %s", (*first)->actors); |
---|
607 | debug(133, "plot: %s", (*first)->plot); |
---|
608 | debug(133, "poster: %s", (*first)->poster); |
---|
609 | debug(133, "thumb: %s", (*first)->thumb); |
---|
610 | debug(133, "----------------------imdb end----------------------"); |
---|
611 | } |
---|
612 | |
---|
613 | return *first; |
---|
614 | } |
---|
615 | |
---|
616 | void screenimdb(char* title, char* dummy1, char* dummy2, char* path, char* file) |
---|
617 | { |
---|
618 | debug(133, "title: %s",title); |
---|
619 | debug(133, "path: %s",path); |
---|
620 | debug(133, "file: %s",file); |
---|
621 | char* searchstr = NULL, *tmpstr = NULL; |
---|
622 | int rcret = 0; |
---|
623 | |
---|
624 | if(checkinternet() == 1) |
---|
625 | { |
---|
626 | textbox(_("Message"), _("Error, Internet Connection not found"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1100, 500, 10, 0); |
---|
627 | return; |
---|
628 | } |
---|
629 | |
---|
630 | struct skin* imdbskin = getscreen("imdb"); |
---|
631 | struct skin* skin_plot = getscreennode(imdbskin, "plot"); |
---|
632 | struct skin* skin_title = getscreennode(imdbskin, "title"); |
---|
633 | struct skin* skin_director = getscreennode(imdbskin, "director"); |
---|
634 | struct skin* skin_writers = getscreennode(imdbskin, "writers"); |
---|
635 | struct skin* skin_genre = getscreennode(imdbskin, "genre"); |
---|
636 | struct skin* skin_releasetime = getscreennode(imdbskin, "releasetime"); |
---|
637 | struct skin* skin_cover = getscreennode(imdbskin, "cover"); |
---|
638 | struct skin* skin_actors = getscreennode(imdbskin, "actors"); |
---|
639 | struct skin* skin_b2 = getscreennode(imdbskin, "b2"); |
---|
640 | struct skin* load = getscreen("loading"); |
---|
641 | struct skin* blackscreen = getscreen("blackscreen"); |
---|
642 | |
---|
643 | struct imdb* node = NULL; |
---|
644 | char* search = NULL; |
---|
645 | |
---|
646 | if(path == NULL || file == NULL || !file_exist(getconfig("mediadbpath", NULL))) |
---|
647 | skin_b2->hidden = YES; |
---|
648 | else |
---|
649 | skin_b2->hidden = NO; |
---|
650 | |
---|
651 | // setfbtransparent(255); |
---|
652 | status.hangtime = 99999; |
---|
653 | |
---|
654 | if(title == NULL) |
---|
655 | searchstr = getepgakttitle(NULL); |
---|
656 | else |
---|
657 | { |
---|
658 | int isrec = 0, iscam = 0; |
---|
659 | tmpstr = createshortname(file, &isrec, &iscam, 1); |
---|
660 | if(tmpstr != NULL) |
---|
661 | searchstr = ostrcat(searchstr, tmpstr, 1, 0); |
---|
662 | else |
---|
663 | searchstr = ostrcat(searchstr, title, 1, 0); |
---|
664 | } |
---|
665 | |
---|
666 | debug(133, "searchstr: %s",searchstr); |
---|
667 | |
---|
668 | drawscreen(blackscreen, 0, 0); |
---|
669 | drawscreen(load, 0, 0); |
---|
670 | |
---|
671 | node = getimdb(&node, searchstr, 0, 0, 0); |
---|
672 | |
---|
673 | clearscreen(load); |
---|
674 | clearscreen(blackscreen); |
---|
675 | |
---|
676 | start: |
---|
677 | if(node != NULL) |
---|
678 | { |
---|
679 | changetext(skin_plot, node->plot); |
---|
680 | changetext(skin_title, node->title); |
---|
681 | changetext(skin_director, node->director); |
---|
682 | changetext(skin_writers, node->writer); |
---|
683 | changetext(skin_genre, node->genre); |
---|
684 | changetext(skin_releasetime, node->released); |
---|
685 | changetext(skin_actors, node->actors); |
---|
686 | changepic(skin_cover, node->poster); |
---|
687 | skin_cover->hidden = NO; |
---|
688 | } |
---|
689 | else |
---|
690 | { |
---|
691 | changetext(skin_plot, "--plot--"); |
---|
692 | changetext(skin_title, "--title--"); |
---|
693 | changetext(skin_director, "--director--"); |
---|
694 | changetext(skin_writers, "--writers--"); |
---|
695 | changetext(skin_genre, "--genre--"); |
---|
696 | changetext(skin_releasetime, "--releasetime--"); |
---|
697 | changetext(skin_actors, "--actors--"); |
---|
698 | skin_cover->hidden = YES; |
---|
699 | } |
---|
700 | |
---|
701 | drawscreen(imdbskin, 0, 0); |
---|
702 | |
---|
703 | while(1) |
---|
704 | { |
---|
705 | rcret = waitrc(imdbskin, 0, 0); |
---|
706 | |
---|
707 | if(rcret == getrcconfigint("rcexit", NULL)) break; |
---|
708 | if(rcret == getrcconfigint("rcok", NULL)) break; |
---|
709 | |
---|
710 | if(rcret == getrcconfigint("rcred", NULL)) |
---|
711 | { |
---|
712 | search = textinput("Search", searchstr); |
---|
713 | if(search != NULL) |
---|
714 | { |
---|
715 | freeimdb(&node, 0); node = NULL; |
---|
716 | drawscreen(blackscreen, 0, 0); |
---|
717 | drawscreen(load, 0, 0); |
---|
718 | node = getimdb(&node, search, 0, 0, 0); |
---|
719 | clearscreen(load); |
---|
720 | clearscreen(blackscreen); |
---|
721 | free(search), search = NULL; |
---|
722 | goto start; |
---|
723 | } |
---|
724 | drawscreen(imdbskin, 0, 0); |
---|
725 | continue; |
---|
726 | } |
---|
727 | |
---|
728 | if(path != NULL && file != NULL && node != NULL && node->id != NULL && rcret == getrcconfigint("rcgreen", NULL)) |
---|
729 | { |
---|
730 | drawscreen(blackscreen, 0, 0); |
---|
731 | drawscreen(load, 0, 0); |
---|
732 | debug(133, "path: %s",path); |
---|
733 | debug(133, "file: %s",file); |
---|
734 | debug(133, "type: 2"); |
---|
735 | debug(133, "imdbid: %s",node->id); |
---|
736 | addconfigtmp("mediadbscantimeout", "0"); |
---|
737 | mediadbfindfilecb(path, file, 0, node->id, 1); |
---|
738 | delconfigtmp("mediadbscantimeout"); |
---|
739 | clearscreen(load); |
---|
740 | clearscreen(blackscreen); |
---|
741 | break; |
---|
742 | } |
---|
743 | } |
---|
744 | |
---|
745 | free(searchstr), searchstr = NULL; |
---|
746 | freeimdb(&node, 0); node = NULL; |
---|
747 | // setosdtransparent(getskinconfigint("osdtransparent", NULL)); |
---|
748 | status.hangtime = getconfigint("hangtime", NULL); |
---|
749 | clearscreen(imdbskin); |
---|
750 | } |
---|
751 | |
---|
752 | #endif |
---|