source: titan/plugins/imdb/imdb_old.h @ 15276

Last change on this file since 15276 was 15276, checked in by nit, 10 years ago

[titan] update imdb

File size: 11.0 KB
Line 
1#ifndef IMDB_H
2#define IMDB_H
3
4extern struct skin* skin;
5
6char* screensearch(char* input)
7{
8        char* lastline = NULL;
9        char* tmpstr = NULL;
10        if(input != NULL)
11                lastline = textinput(_("Imdb Suche"), input);
12        else
13                lastline = textinput(_("Imdb Suche"), "");
14
15        return lastline;
16}
17
18void imdb()
19{
20        int rcret = 0;
21        drawscreen(skin, 0);
22        setfbtransparent(255);
23//NIT: muß wieder richtig gesetzt werden
24        status.hangtime = 99999;
25        struct skin* blackscreen = getscreen("blackscreen");
26        drawscreen(blackscreen, 0);
27
28        // main screen
29        struct skin* imdbskin = getscreen("imdb");
30        struct skin* skin_plot = getscreennode(imdbskin, "plot");
31        struct skin* skin_title = getscreennode(imdbskin, "title");
32        struct skin* skin_director = getscreennode(imdbskin, "director");
33        struct skin* skin_writers = getscreennode(imdbskin, "writers");
34        struct skin* skin_genre = getscreennode(imdbskin, "genre");
35        struct skin* skin_tagline = getscreennode(imdbskin, "tagline");
36        struct skin* skin_releasetime = getscreennode(imdbskin, "releasetime");
37        struct skin* skin_bigcover = getscreennode(imdbskin, "bigcover");
38        struct skin* skin_cover = getscreennode(imdbskin, "cover");
39        struct skin* skin_cast = getscreennode(imdbskin, "cast");
40
41//if(ostrcmp("vfdisplay", name) == 0) return 0;
42//tmpstr = ostrcat(tmpstr, "", 1, 0);
43
44        char* input = NULL;
45
46        char* url = NULL;
47        char* apiSearchTV = NULL;
48        char* apiImdbLookup = NULL;
49        char* apiSearch = NULL;
50        char* localfile = NULL;
51        char* fetchurl = NULL;
52        char* search = NULL;
53        char* tmpstr = NULL;
54        char* imdbid = NULL;
55        char* title = NULL;
56        char* plot = NULL;
57        char* director = NULL;
58        char* writers = NULL;
59        char* genre = NULL;
60        char* tagline = NULL;
61        char* releasetime = NULL;
62        char* pagebigcover = NULL;
63        char* bigcover = NULL;
64        char* cover = NULL;
65        char* cast = NULL;
66
67
68        input = getepgakttitle(NULL);
69//      input = screensearch("Rambo");
70        printf("input: %s\n", input);
71//      stringreplacechar(input, ' ', '%20');
72        input = string_replace(" ", "%20", input, 1);
73//      htmlencode(input);
74        printf("input: %s\n", input);
75
76//drawscreen(imdbskin, 0);
77//imdbskin->hidden = YES;
78//      input = ostrcat("", "Days+of+Summer", 0, 0);
79        url = ostrcat(url, "www.imdb.de", 1, 0);
80
81        apiSearchTV = ostrcat("", "/search/title?title=<title>&title_type=tv_series", 0, 0);
82        apiImdbLookup = ostrcat("", "/title/tt", 0, 0);
83        apiSearch = ostrcat("", "/find?s=tt;q=", 0, 0);
84        localfile = ostrcat("", "/tmp/cache.getMovieByTitle.html", 0, 0);
85        search = ostrcat(apiSearch, input, 0, 0);
86        printf("search: %s\n", search);
87        tmpstr = get_ip(url);
88        printf("get_ip(url): %s\n", tmpstr);
89        gethttp(tmpstr, search, 80, localfile, NULL, NULL, 0);
90        free(tmpstr); tmpstr = NULL;
91//      gethttp(url, search, 80, localfile, NULL, NULL, 0);
92
93
94        tmpstr = readfiletomem(localfile, 1);
95
96        if(string_find("<title>IMDb Title Search</title>",tmpstr))
97        {
98                imdbid = ostrcat(tmpstr, "", 0, 0);
99                string_resub("<a href=\"/title/tt","/",imdbid);
100                strstrip(imdbid);
101                printf("imdbid: %s\n", imdbid);
102        }
103
104        free(tmpstr), tmpstr = NULL;
105////////////////////
106        search = ostrcat(apiImdbLookup, imdbid, 0, 0);
107        search = ostrcat(search, "/", 0, 0);
108
109        localfile = ostrcat("", "/tmp/cache.getMoviesByImdbId.html", 0, 0);
110        printf("search: %s\n", search);
111        printf("url: %s\n", get_ip(url));
112        printf("localfile: %s\n", localfile);
113
114//      gethttp(get_ip(url), search, 80, localfile, NULL, NULL, 0);
115//      gethttp(url, search, 80, localfile, NULL, NULL, 0);
116        unlink(localfile);
117//cache.getMoviesByImdbId.html
118        char* cmd = NULL;
119        cmd = ostrcat(cmd, "wget http://", 1, 0);
120        cmd = ostrcat(cmd, url, 1, 0);
121        cmd = ostrcat(cmd, search, 1, 0);
122        cmd = ostrcat(cmd, " -O ", 1, 0);
123        cmd = ostrcat(cmd, localfile, 1, 0);
124        printf("cmd: %s\n",cmd);
125        system(cmd);
126        free(cmd), cmd = NULL;
127//      tmpstr = string_strip_whitechars(readfiletomem(localfile, 1));
128        tmpstr = readfiletomem(localfile, 1);
129
130        title = ostrcat(tmpstr, "", 0, 0);
131        string_resub("<title>","</title>",title);
132        printf("title: %s\n", title);
133        title = string_decode(title,1);
134        printf("title: %s\n", title);
135        changetext(skin_title, title);
136
137////////////////////
138        director = ostrcat(tmpstr, "", 0, 0);
139//      string_resub("Director:","</div>",director);   
140        string_resub("Regisseur:","</div>",director);
141        string_striptags(director);
142        printf("director: %s\n", director);
143        director = string_decode(director,1);
144        printf("director: %s\n", director);
145        changetext(skin_director, director);
146
147
148////////////////////
149
150        writers = ostrcat(tmpstr, "", 0, 0);
151//      string_resub("<h5>Writers","</div>",writers);
152        string_resub("<h5>Drehbuchautor","</div>",writers);
153        printf("writers1: %s\n", writers);
154        string_resub("<div class=\"info-content\">","</div>",writers);
155        printf("writers2: %s\n", writers);
156
157        string_striptags(writers);
158        printf("writers3: %s\n", writers);
159        writers = string_decode(writers,1);
160        printf("writers: %s\n", writers);       
161        changetext(skin_writers, writers);
162////////////////////
163
164        genre = ostrcat(tmpstr, "", 0, 0);
165        string_resub("<h5>Genre:</h5>","</div>",genre);
166        printf("genre1: %s\n", genre);
167        string_striptags(genre);
168        printf("genre2: %s\n", genre);
169        genre = string_decode(genre,1);
170        printf("genre: %s\n", genre);
171        changetext(skin_genre, genre);
172
173/*
174        genre = string_replace("&#x", "%", genre, 1);
175        printf("genre2222: %s\n", genre);
176        char* genre_tmp = NULL;
177        genre = string_replace(";", " ", genre, 1);
178        genre_tmp = ostrcat(genre_tmp, genre, 1, 0);
179        printf("genre333: %s\n", genre_tmp);           
180//      free(genre),genre = NULL;
181
182        htmldecode(genre,genre_tmp);
183        printf("genre444: %s\n", genre);
184//      free(genre_tmp),genre_tmp = NULL;               
185        changetext(skin_genre, genre);
186*/     
187////////////////////
188
189/*
190
191        tagline = ostrcat(tmpstr, "", 0, 0);
192        string_resub("<h4 class=\"inline\">Taglines:</h4>","<span class",tagline);
193
194        strstrip(tagline);
195        printf("tagline: %s\n", tagline);
196        changetext(skin_tagline, tagline);
197
198        releasetime = ostrcat(tmpstr, "", 0, 0);
199        string_resub("<h4 class=\"inline\">Release Date:</h4>","</time>",releasetime);
200        count2 = 0;     
201        tmpstr2 = ostrcat(tmpstr2, releasetime, 1, 0);
202        ret2 = strsplit(tmpstr2, "<>", &count2);
203        printf("releasetime1: %s\n", (&ret2[2])->part);
204        strstrip(releasetime);
205        printf("releasetime: %s\n", releasetime);
206        changetext(skin_releasetime, (&ret2[2])->part);
207*/
208
209        releasetime = ostrcat(tmpstr, "", 0, 0);
210        string_resub("<h5>Premierendatum:</h5>","<a class=",releasetime);
211        printf("releasetime1: %s\n", releasetime);
212
213        string_striptags(releasetime);
214        printf("releasetime2: %s\n", releasetime);
215        releasetime = string_decode(releasetime,1);
216        printf("releasetime: %s\n", releasetime);
217        changetext(skin_releasetime, releasetime);
218
219////////////////////
220
221        cast = ostrcat(tmpstr, "", 0, 0);
222        string_resub("<h3>Besetzung</h3>&nbsp;","</td></tr></table>",cast);
223        string_resub("<div class=\"info-content block\"><table class=\"cast\">","</a></td></tr>",cast);
224
225        cast = string_replace("...", "als", cast, 1);
226
227        printf("cast1: %s\n", cast);
228
229        string_striptags(cast);
230        string_strip_whitechars(cast);
231        printf("cast2: %s\n", cast);
232        cast = string_decode(cast,1);
233        printf("cast: %s\n", cast);
234        changetext(skin_cast, cast);
235       
236////////////////////
237
238
239        pagebigcover = ostrcat(tmpstr, "", 0, 0);
240//      string_resub("href=\"/media/rm","/",pagebigcover);
241        string_resub("/media/rm","/",pagebigcover);
242
243        strstrip(pagebigcover);
244        printf("pagebigcover: %s\n", pagebigcover);
245
246/*
247http://ia.media-imdb.com/images/M/MV5BMjE2MzU3Nzk4M15BMl5BanBnXkFtZTcwODcxNTI5Mw@@._V1_.jpg
248<link rel="image_src" href="
249
250//      char* tmpstr3 = NULL;
251//      tmpstr3 = ostrcat("href=\"/media/rm", pagebigcover, 0, 0);
252//      tmpstr3 = ostrcat(tmpstr3, "/tt", 1, 0);
253//      tmpstr3 = ostrcat(tmpstr3, imdbid, 1, 0);
254//      tmpstr3 = ostrcat(tmpstr3, "\"    ><img src=\"", 1, 0);
255
256        cover = ostrcat(tmpstr, "", 0, 0);
257        string_resub(tmpstr3,"\"",cover);
258
259        printf("tmpstr3: %s\n", tmpstr3);
260        strstrip(cover);
261        printf("cover: %s\n", cover);
262
263char* filename = NULL;
264filename = ostrcat("wget ", cover, 0, 0);
265filename = ostrcat(filename, " -O /tmp/cover.jpg", 1, 0);
266system(filename);       
267changepic(skin_cover, "/tmp/cover.jpg");
268////////////////////
269
270*/
271        char* filename = NULL;
272        search = ostrcat("/media/rm", pagebigcover, 0, 0);
273        search = ostrcat(search, "/tt", 1, 0);
274        search = ostrcat(search, imdbid, 1, 0);
275        search = ostrcat(search, "/", 1, 0);
276
277        localfile = ostrcat("", "/tmp/cache.getpageBigCoverHtml.html", 0, 0);
278        printf("search: %s\n", search);
279        printf("url: %s\n", get_ip(url));
280        printf("localfile: %s\n", localfile);
281
282
283//NIT: get_ip braucht ein free
284        gethttp(get_ip(url), search, 80, localfile, NULL, NULL, 0);
285//      gethttp(url, search, 80, localfile, NULL, NULL, 0);
286        bigcover = readfiletomem(localfile, 1);
287        string_resub("<link rel=\"image_src\" href=\"","\"",bigcover);
288        strstrip(bigcover);
289        printf("bigcover: %s\n", bigcover);
290
291        unlink("/tmp/bigcover.jpg");
292        filename = ostrcat("wget ", bigcover, 0, 0);
293        filename = ostrcat(filename, " -O /tmp/bigcover.jpg", 1, 0);
294        system(filename);
295
296        rcret = servicestop(status.aktservice, 1, 0);
297        if(rcret == 1) return;
298
299changepic(skin_cover, "/tmp/bigcover.jpg");
300////////////////////
301
302//      free(tmpstr), tmpstr = NULL;
303        search = ostrcat(apiImdbLookup, imdbid, 0, 0);
304        search = ostrcat(search, "/plotsummary", 1, 0);
305
306        localfile = ostrcat("", "/tmp/cache.getPlot.html", 0, 0);
307        printf("search: %s\n", search);
308        printf("url: %s\n", get_ip(url));
309        printf("localfile: %s\n", localfile);
310//      gethttp(get_ip(url), search, 80, localfile, NULL, NULL, 0);
311//      gethttp(url, search, 80, localfile, NULL, NULL, 0);
312
313        unlink(localfile);
314        cmd = ostrcat(cmd, "wget http://", 1, 0);
315        cmd = ostrcat(cmd, url, 1, 0);
316        cmd = ostrcat(cmd, search, 1, 0);
317        cmd = ostrcat(cmd, " -O ", 1, 0);
318        cmd = ostrcat(cmd, localfile, 1, 0);
319        printf("cmd: %s\n",cmd);
320        system(cmd);
321        free(cmd), cmd = NULL;
322       
323       
324        plot = readfiletomem(localfile, 1);
325        string_resub("<div id=\"swiki.2.1\">","</div>",plot);
326        printf("plot1: %s\n", plot);
327        string_striptags(plot);
328        printf("plot: %s\n", plot);
329        plot = string_decode(plot,1);
330        printf("plot: %s\n", plot);
331        changetext(skin_plot, plot);   
332       
333//      if(string_find("<p class=\"plotpar\">",plot))
334//      {
335//              string_resub("<p class=\"plotpar\">","<i>",plot);
336//              strstrip(plot);
337//              printf("plot: %s\n", plot);
338//changetext(skin_plot, plot);
339//      }
340
341drawscreen(imdbskin, 0);
342//imdbskin->hidden = NO;
343        struct skin* tmp = NULL;
344        while(1)
345        {
346//              addscreenrc(mc_videoplayer_settings, tmp);
347                rcret = waitrc(imdbskin, 0, 0);
348//              tmp = listbox->select;
349       
350                if(rcret == getrcconfigint("rcexit", NULL)) break;
351                if(rcret == getrcconfigint("rcok", NULL))
352                {
353                        break;
354                }
355  }
356
357
358        printf("done:\n");
359
360        free(tmpstr), tmpstr = NULL;
361        free(url), url = NULL;
362        free(apiSearchTV), apiSearchTV = NULL;
363        free(apiImdbLookup), apiImdbLookup = NULL;
364        free(apiSearch), apiSearch = NULL;
365        free(localfile), localfile = NULL;
366        free(fetchurl), fetchurl = NULL;
367        free(search), search = NULL;
368        free(imdbid), imdbid = NULL;
369        free(plot), plot = NULL;
370        free(director), director = NULL;
371        free(writers), writers = NULL;
372        free(genre), genre = NULL;
373        free(tagline), tagline = NULL;
374        free(releasetime), releasetime = NULL;
375        free(pagebigcover), pagebigcover = NULL;
376        free(bigcover), bigcover = NULL;
377        free(cover), cover = NULL;
378        free(cast), cast = NULL;
379
380        delownerrc(imdbskin);
381        clearscreen(imdbskin);
382        drawscreen(skin, 0);
383
384        setosdtransparent(getskinconfigint("osdtransparent", NULL));
385        servicestart(status.lastservice->channel, NULL, NULL, 0);
386       
387//      return apiSearch;
388        return;
389}
390
391#endif
Note: See TracBrowser for help on using the repository browser.