source: titan/plugins/tithek/movie4k.h @ 24396

Last change on this file since 24396 was 24396, checked in by obi, 10 years ago

[tithek] optimize hoster stuff

File size: 29.4 KB
Line 
1#ifndef MOVIE4K_H
2#define MOVIE4K_H
3
4// flag 1 = putlocker/sockshare
5// flag 2 = filenuke
6
7char* movie4k(char* link)
8{
9        debug(99, "link: %s", link);
10        char* tmpstr = NULL, *url = NULL, *streamurl = NULL, *tmppath = NULL, *tmphost = NULL, *pos = NULL, *id = NULL;
11
12        if(link == NULL || ostrncmp("http://", link, 7)) return NULL;
13
14        tmphost = string_replace("http://", "", (char*)link, 0);
15
16        if(tmphost != NULL)
17                pos = strchr(tmphost, '/');
18        if(pos != NULL)
19        {
20                pos[0] = '\0';
21                tmppath = pos + 1;
22        }
23
24        tmpstr = gethttp(tmphost, tmppath, 80, NULL, NULL, 5000, NULL, 0);
25
26        url = string_resub("<a target=\"_blank\" href=\"", "\"><", tmpstr, 0);
27
28        if(ostrstr(url, "http://") == NULL)
29        {
30                free(url), url = NULL;
31                url = string_resub("<iframe src=", "\" width", tmpstr, 0);
32        }
33       
34        if(ostrstr(url, "http://www.facebook.com") != NULL)
35        {
36                free(url), url = NULL;
37                url = oregex(".*<iframe width=.*(http://.*)&width.*", tmpstr);
38        }
39       
40        url = string_replace_all("/embed/", "/file/", url, 1);
41        url = string_replace_all("\"", "", url, 1);
42
43        streamurl = hoster(url);
44        free(url), url = NULL;
45        free(tmpstr), tmpstr = NULL;
46        free(tmphost), tmphost = NULL;
47// *** glibc detected *** /var/usr/local/share/titan/plugins/tithek/titan: munmap_chunk(): invalid pointer: 0x008c5307 ***
48//      free(tmppath), tmppath = NULL;
49        free(id), id = NULL;
50
51        return streamurl;
52}
53
54int movie4k_search(struct skin* grid, struct skin* listbox, struct skin* countlabel, struct skin* load, char* link, char* title, char* searchstr, int flag)
55{
56        int ret = 1;
57        int incount = 0;
58        char* tmpstr = NULL;
59        char* from = NULL;
60        char* folgen = NULL;
61        char* folgentmp = NULL;
62        char* name = NULL;
63        char* lang = NULL;
64        char* season = NULL;
65        char* episode = NULL;
66        char* line = NULL;
67        char* menu = NULL;
68        char* str = NULL;
69        char* pic = NULL;
70        char* type = NULL;
71
72        int debuglevel = getconfigint("debuglevel", NULL);
73
74        if(listbox == NULL || listbox->select == NULL || listbox->select->handle == NULL)
75                return ret;
76
77        char* search = NULL;
78        if(flag == 0)
79        {
80                if(searchstr == NULL)
81                        search = textinputhist("Search", " ", "searchhist");
82                else
83                        search = textinputhist("Search", searchstr, "searchhist");
84        }
85        else
86                search = ostrcat(link, NULL, 0, 0);
87
88        if(search != NULL)
89        {
90                drawscreen(load, 0, 0);
91                search = strstrip(search);
92                search = stringreplacechar(search, ' ', '+');
93                debug(99, "search: %s", search);
94
95                char* send = NULL;
96                send = ostrcat(send, "GET /searchAutoCompleteNew.php?search=the HTTP/1.1\r\n", 1, 0);
97                send = ostrcat(send, "Accept-Encoding: identity\r\nAccept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n", 1, 0);
98                send = ostrcat(send, "Host: www.movie4k.to\r\nAccept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4\r\n", 1, 0);
99                send = ostrcat(send, "Connection: close\r\nUser-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3\r\n\r\n", 1, 0);
100                debug(99, "send: %s", send);
101
102                tmpstr = gethttpreal("www.movie4k.to", "/searchAutoCompleteNew.php?search=the", 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
103                free(send); send = NULL;
104                debug(99, "tmpstr: %s", tmpstr);
105                titheklog(debuglevel, "/tmp/movie4k_search", NULL, tmpstr);
106
107                char* key = string_resub("securekey=", "&search", tmpstr, 0);
108                debug(99, "key: %s", key);
109
110                send = ostrcat(send, "GET /movies.php?list=search&securekey=", 1, 0);
111                send = ostrcat(send, key, 1, 0);
112                send = ostrcat(send, "&search=", 1, 0);
113                send = ostrcat(send, search, 1, 0);
114                send = ostrcat(send, " HTTP/1.1\r\nAccept-Encoding: identity\r\n", 1, 0);
115                send = ostrcat(send, "Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4\r\n", 1, 0);
116                send = ostrcat(send, "Host: www.movie4k.to\r\n", 1, 0);
117                send = ostrcat(send, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3\r\n", 1, 0);
118                send = ostrcat(send, "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n", 1, 0);
119                send = ostrcat(send, "Connection: close\r\nCookie: xxx2=ok;\r\n\r\n", 1, 0);
120                debug(99, "send: %s", send);
121
122                free(tmpstr), tmpstr = NULL;
123                tmpstr = gethttpreal("movie4k.to", "/", 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
124
125                folgen = string_resub("<TABLE id=\"tablemoviesindex\">", "</TABLE>", tmpstr, 0);
126                folgen = string_replace_all("1000\r\n", "", folgen, 1);
127                folgen = string_replace_all("2000\r\n", "", folgen, 1);
128                stringreplacechar(folgen, '\n', ' ');
129                stringreplacechar(folgen, '\t', ' ');
130                string_strip_whitechars(folgen);
131                folgen = string_replace_all("</TD> </TR> <TR id=\"coverPreview", "</TD> </TR>\n<TR id=\"cover1Preview", folgen, 1);
132                if(folgen != NULL)
133                {
134                        int count = 0;
135                        int j;
136                        struct splitstr* ret1 = NULL;
137                        ret1 = strsplit(folgen, "\n", &count);
138
139                        if(ret1 != NULL && count > 0)
140                        {
141                                int max = count;
142                                for(j = 0; j < max; j++)
143                                {
144                                        int rcret = waitrc(NULL, 10, 0);
145                                        if(rcret == getrcconfigint("rcexit", NULL)) break;
146
147                                        incount += 1;
148                                        link = string_resub("<a href=\"", "\">", ret1[j].part, 0);
149                                        name = string_resub(".html\">", "</a>", ret1[j].part, 0);
150                                        char* id = string_resub("online-film-", ".html", link, 0);
151                                        if(id == NULL)
152                                                id = string_resub("watch-movie-", ".html", link, 0);
153                                        if(id == NULL)
154                                                id = oregex(".*tvshows-(.*[0-9]{1,10})-.*", link);
155
156
157                                        from = ostrcat("#coverPreview", id, 0, 0);
158                                        pic = string_resub(from, from, tmpstr, 0);     
159                                        pic = string_resub("<img src='", "' alt=", pic, 1);     
160                                        if(pic == NULL)
161                                                pic = ostrcat("http://atemio.dyndns.tv/mediathek/menu/default.jpg", NULL, 0, 0);
162
163                                        if(ostrstr(link, "online-serie-") != NULL)
164                                                type = ostrcat("40", NULL, 0, 0);
165                                        else
166                                                type = ostrcat("34", NULL, 0, 0);
167
168
169                                        if(ostrstr(ret1[j].part, "us_ger_small.png") != NULL)
170                                                lang = ostrcat(" (de)", NULL, 0, 0);
171                                        else if(ostrstr(ret1[j].part, "us_flag_small.png") != NULL)
172                                                lang = ostrcat(" (en)", NULL, 0, 0);
173                                        else
174                                                lang = ostrcat(" (\?\?)", NULL, 0, 0);
175                                        line = ostrcat(line, name, 1, 0);
176
177                                        line = ostrcat(line, lang, 1, 0);
178                                        line = ostrcat(line, "#http://www.movie4k.to/", 1, 0);
179                                        line = ostrcat(line, link, 1, 0);
180                                        line = ostrcat(line, "#", 1, 0);
181                                        line = ostrcat(line, pic, 1, 0);
182                                        line = ostrcat(line, "#movie4k_search_", 1, 0);
183                                        line = ostrcat(line, oitoa(incount + time(NULL)), 1, 1);
184                                        line = ostrcat(line, ".jpg#Movie4k - Search#", 1, 0);
185                                        line = ostrcat(line, type, 1, 0);
186                                        line = ostrcat(line, "\n", 1, 0);
187                                        free(str), str = NULL;
188                                                                                       
189                                        free(name), name = NULL;
190                                        free(lang), lang = NULL;
191                                        free(season), season = NULL;
192                                        free(episode), episode = NULL;
193                                        free(from), from = NULL;
194                                        free(pic), pic = NULL;
195                                        free(type), type = NULL;
196                                        if(j == 60)
197                                                break;
198                                }
199                        }
200                        free(ret1), ret1 = NULL;
201                }                               
202                free(from), from = NULL;
203                free(folgen), folgen = NULL;
204                free(folgentmp), folgentmp = NULL;             
205
206                if(line != NULL)
207                {
208                        menu = ostrcat("/tmp/tithek/movie4k.search.list", NULL, 0, 0);
209                        writesys(menu, line, 0);
210                        struct tithek* tnode = (struct tithek*)listbox->select->handle;
211                        createtithek(tnode, tnode->title,  menu, tnode->pic, tnode->localname, tnode->menutitle, tnode->flag);
212                        ret = 0;
213                        free(menu); menu = NULL;
214                }
215
216                free(tmpstr), tmpstr = NULL;
217        }
218        free(search), search = NULL;
219        return ret;
220}
221
222int movie4k_hoster(struct skin* grid, struct skin* listbox, struct skin* countlabel, struct skin* load, char* link, char* title)
223{
224        debug(99, "link: %s", link);
225        int debuglevel = getconfigint("debuglevel", NULL);
226        int ret = 1;
227        char* extra = NULL, *pos3 = NULL, *ip = NULL, *pos = NULL, *path = NULL, *tmpstr = NULL, *tmpstr1 = NULL, *line = NULL, *url = NULL, *url2 = NULL, *url3 = NULL, *url4 = NULL, *pathnew = NULL, *id = NULL, *logfile = NULL, *tmphname = NULL, *hnamein = NULL, *nolinks = NULL;
228        char* pichname = NULL;
229        if(listbox == NULL || listbox->select == NULL || listbox->select->handle == NULL)
230                return ret;
231
232        ip = string_replace("http://", "", (char*)link, 0);
233
234        if(ip != NULL)
235                pos = strchr(ip, '/');
236        if(pos != NULL)
237        {
238                pos[0] = '\0';
239                path = pos + 1;
240        }
241
242        tmpstr = gethttp(ip, path, 80, NULL, NULL, 10000, NULL, 0);
243        titheklog(debuglevel, "/tmp/movie4k2_tmpstr", NULL, tmpstr);
244        int a = 0;
245
246        if(tmpstr != NULL)
247        {
248                drawscreen(load, 0, 0);
249
250                if(ostrstr(tmpstr, "links\[") == NULL)
251                {
252                        hnamein = string_resub("width=\"16\"> &nbsp;", "</a></td><td align=", tmpstr, 0);
253                        nolinks = ostrcat(tmpstr, NULL, 0, 0);
254                }
255                else
256                {
257                        unlink("/tmp/movie4k.list");
258                        writesys("/tmp/movie4k.list", tmpstr, 1);
259                        tmpstr = command("cat /tmp/movie4k.list | grep ^links");
260                }
261
262                tmpstr1 = ostrcat(tmpstr, NULL, 0, 0);
263
264                int count = 0;
265                int incount = 0;
266                int i;
267                struct splitstr* ret1 = NULL;
268                ret1 = strsplit(tmpstr, "\n", &count);         
269
270
271                if(ret1 != NULL && count > 0)
272                {
273                        int max = count;
274                        for(i = 0; i < max; i++)
275                        {
276                                if((!ostrncmp("links", ret1[i].part, 5) && nolinks == NULL) || nolinks != NULL)
277                                {
278                                        if(nolinks == NULL)
279                                        {
280                                                a++;
281//                                              ret1[i].part = string_replace_all("</a>&nbsp;</td>", "</a></td>", ret1[i].part, 0);
282
283                                                pathnew = string_resub("<a href=\\\"", "\\", ret1[i].part, 0);
284                                                tmphname = string_resub("title=\\\"", " ", ret1[i].part, 0);
285                                                if(tmphname == NULL)
286                                                        tmphname = string_resub("&nbsp;", "</a", ret1[i].part, 0);
287
288                                                pos3 = ostrstr(ret1[i].part, "Movie quality");
289                                                extra = getxmlentry(pos3, "quality ");
290
291                                                id = oregex(".*-online-film-(.*[0-9]{1,10}).html.*", pathnew);                                                 
292                                                if(id == NULL)
293                                                        id = string_resub("watch-movie-", ".html", pathnew, 0);
294                                                if(id == NULL)
295                                                        id = oregex(".*tvshows-(.*[0-9]{1,10})-.*", pathnew);
296                                                if(id == NULL)
297                                                        id = oregex(".*movie.php?id=(.*[0-9]{1,10})&part=.*", tmpstr1);
298
299//                                              debug(99, "(%d/%d/%d) pathnew: %s hname: %s id: %s",a ,i ,max ,pathnew , tmphname, id);
300
301                                                if(ostrstr(pathnew, "tvshows-") != NULL)
302                                                {
303                                                        pathnew = string_replace("tvshows-", "", pathnew, 1);
304                                                        pathnew = string_replace(id, "", pathnew, 1);
305                                                        pathnew = string_replace("-", "", pathnew, 1);
306                                                        pathnew = string_replace(".html", "", pathnew, 1);
307                                                        pathnew = ostrcat(pathnew, "-online-serie-", 1, 0);
308                                                        pathnew = ostrcat(pathnew, id, 1, 0);
309                                                        pathnew = ostrcat(pathnew, ".html", 1, 0);
310                                                        debug(99, "(%d/%d/%d) pathnew: %s hname: %s id: %s",a ,i ,max ,pathnew, tmphname, id);
311                                                }       
312
313
314//                                              logfile = ostrcat("/tmp/movie4k4_pathnew1", id, 0, 0);
315//                                              logfile = ostrcat(logfile, "_", 1, 0);
316//                                              titheklog(debuglevel, logfile, tmphname, pathnew);
317//                                              free(logfile), logfile= NULL;
318                                               
319                                                url = ostrcat(pathnew, NULL, 0, 0);
320                                        }
321                                        else
322                                        {
323                                                id = oregex(".*-online-film-(.*[0-9]{1,10}).html.*", path);                                                     
324                                                if(id == NULL)
325                                                        id = string_resub("watch-movie-", ".html", path, 0);
326                                                if(id == NULL)
327                                                        id = oregex(".*tvshows-(.*[0-9]{1,10})-.*", path);
328                                                if(id == NULL)
329                                                        id = oregex(".*movie.php?id=(.*[0-9]{1,10})&part=.*", tmpstr1);
330
331                                                tmphname = ostrcat(hnamein, NULL, 0, 0);
332
333                                                pos3 = ostrstr(ret1[i].part, "Movie quality");
334                                                extra = getxmlentry(pos3, "quality ");
335                                        }       
336
337                                        pichname = ostrcat(tmphname, NULL, 0, 0);
338                                        string_tolower(pichname);
339                                        pichname = stringreplacecharonce(pichname, '.', '\0');
340                                               
341                                        int countj = 0;
342                                        if(ostrstr(tmpstr1, "&part=1") != NULL)
343                                                countj = 1;
344                                        if(ostrstr(tmpstr1, "&part=2") != NULL)
345                                                countj = 2;
346                                        if(ostrstr(tmpstr1, "&part=3") != NULL)
347                                                countj = 3;
348                                        if(ostrstr(tmpstr1, "&part=4") != NULL)
349                                                countj = 4;
350
351                                        if(id != NULL)
352                                        {
353                                                if(countj >= 1)
354                                                {       
355                                                        free(url), url = NULL;
356                                                        free(pathnew), pathnew = NULL;
357                                                        pathnew = ostrcat("movie.php?id=", id, 0, 0);
358                                                        pathnew = ostrcat(pathnew, "&part=1", 1, 0);
359                                                        url = ostrcat(pathnew, NULL, 0, 0);
360                                                }
361                                                if(countj >= 2)
362                                                {
363                                                        free(pathnew), pathnew = NULL;
364                                                        pathnew = ostrcat("movie.php?id=", id, 0, 0);
365                                                        pathnew = ostrcat(pathnew, "&part=2", 1, 0);
366                                                        url2 = ostrcat(pathnew, NULL, 0, 0);
367                                                }
368                                                if(countj >= 3)
369                                                {
370                                                        free(pathnew), pathnew = NULL;
371                                                        pathnew = ostrcat("movie.php?id=", id, 0, 0);
372                                                        pathnew = ostrcat(pathnew, "&part=3", 1, 0);
373                                                        url3 = ostrcat(pathnew, NULL, 0, 0);
374
375                                                }                                               
376                                                if(countj >= 4)
377                                                {
378                                                        free(pathnew), pathnew = NULL;
379                                                        pathnew = ostrcat("movie.php?id=", id, 0, 0);
380                                                        pathnew = ostrcat(pathnew, "&part=4", 1, 0);
381                                                        url4 = ostrcat(pathnew, NULL, 0, 0);
382                                                }
383                                        }
384
385                                        int type = 41;
386                                       
387                                        if(ostrcmp(url, url2) != 0)
388                                        {
389                                                debug(99, "(%d/%d/%d) %s (Part1) extra: %s url: %s",a ,i ,max ,tmphname, extra, url);
390                                        }
391                                        else
392                                        {
393                                                debug(99, "(%d/%d/%d) %s extra: %s url: %s",a ,i ,max ,tmphname, extra, url);
394                                        }
395                                        incount += 1;
396                                        line = ostrcat(line, tmphname, 1, 0);
397                                        if(url2 != NULL && ostrcmp(url, url2) != 0)
398                                                line = ostrcat(line, " (Part1)", 1, 0);
399                                        if(extra != NULL)
400                                        {
401                                                line = ostrcat(line, " (", 1, 0);                                       
402                                                line = ostrcat(line, extra, 1, 0);                                     
403                                                line = ostrcat(line, ")", 1, 0);                                       
404                                        }
405                                        line = ostrcat(line, "#", 1, 0);
406                                        line = ostrcat(line, "http://www.movie4k.to/", 1, 0);
407                                        line = ostrcat(line, url, 1, 0);
408                                        line = ostrcat(line, "#", 1, 0);
409                                        line = ostrcat(line, "http://atemio.dyndns.tv/mediathek/menu/", 1, 0);
410                                        line = ostrcat(line, pichname, 1, 0);
411                                        line = ostrcat(line, ".jpg#movie4k_", 1, 0);
412                                        line = ostrcat(line, pichname, 1, 0);
413                                        line = ostrcat(line, ".jpg#Movie4k - ", 1, 0);
414                                        line = ostrcat(line, title, 1, 0);
415                                        line = ostrcat(line, "#", 1, 0);
416                                        line = ostrcat(line, oitoa(type), 1, 0);
417                                        line = ostrcat(line, "\n", 1, 0);
418
419                                        if(url2 != NULL && ostrcmp(url, url2) != 0)
420                                        {                                               
421                                                int type = 41;
422       
423                                                debug(99, "-------------------------------");
424                                                debug(99, "(%d/%d/%d) %s (Part2) extra: %s url: %s",a ,i ,max ,tmphname, extra, url2);
425                               
426                                                incount += 1;
427                                                line = ostrcat(line, tmphname, 1, 0);
428                                                line = ostrcat(line, " (Part2)", 1, 0);
429                                                if(extra != NULL)
430                                                {
431                                                        line = ostrcat(line, " (", 1, 0);                                       
432                                                        line = ostrcat(line, extra, 1, 0);                                     
433                                                        line = ostrcat(line, ")", 1, 0);                                       
434                                                }
435                                                line = ostrcat(line, "#", 1, 0);
436                                                line = ostrcat(line, "http://www.movie4k.to/", 1, 0);
437                                                line = ostrcat(line, url2, 1, 0);
438                                                line = ostrcat(line, "#", 1, 0);
439                                                line = ostrcat(line, "http://atemio.dyndns.tv/mediathek/menu/", 1, 0);
440                                                line = ostrcat(line, pichname, 1, 0);
441                                                line = ostrcat(line, ".jpg#kinox_", 1, 0);
442                                                line = ostrcat(line, pichname, 1, 0);
443                                                line = ostrcat(line, ".jpg#Movie4k - ", 1, 0);
444                                                line = ostrcat(line, title, 1, 0);
445                                                line = ostrcat(line, "#", 1, 0);
446                                                line = ostrcat(line, oitoa(type), 1, 0);
447                                                line = ostrcat(line, "\n", 1, 0);
448                                        }
449                                        if(url3 != NULL && ostrcmp(url, url3) != 0)
450                                        {
451                                                int type = 41;
452                                                                                                                               
453                                                debug(99, "-------------------------------");
454                                                debug(99, "(%d/%d/%d) %s (Part3) extra: %s url: %s",a ,i ,max ,tmphname, extra, url3);
455                       
456                                                incount += 1;
457                                                line = ostrcat(line, tmphname, 1, 0);
458                                                line = ostrcat(line, " (Part3)", 1, 0);
459                                                if(extra != NULL)
460                                                {
461                                                        line = ostrcat(line, " (", 1, 0);                                       
462                                                        line = ostrcat(line, extra, 1, 0);                                     
463                                                        line = ostrcat(line, ")", 1, 0);                                       
464                                                }
465                                                line = ostrcat(line, "#", 1, 0);
466                                                line = ostrcat(line, "http://www.movie4k.to/", 1, 0);
467                                                line = ostrcat(line, url3, 1, 0);
468                                                line = ostrcat(line, "#", 1, 0);
469                                                line = ostrcat(line, "http://atemio.dyndns.tv/mediathek/menu/", 1, 0);
470                                                line = ostrcat(line, pichname, 1, 0);
471                                                line = ostrcat(line, ".jpg#movie4k_", 1, 0);
472                                                line = ostrcat(line, pichname, 1, 0);
473                                                line = ostrcat(line, ".jpg#Movie4k - ", 1, 0);
474                                                line = ostrcat(line, title, 1, 0);
475                                                line = ostrcat(line, "#", 1, 0);
476                                                line = ostrcat(line, oitoa(type), 1, 0);
477                                                line = ostrcat(line, "\n", 1, 0);
478                                        }
479                                        if(url4 != NULL && ostrcmp(url, url4) != 0)
480                                        {
481                                                int type = 41;
482       
483                                                debug(99, "-------------------------------");
484                                                debug(99, "(%d/%d/%d) %s (Part4) extra: %s url: %s",a ,i ,max ,tmphname, extra, url4);
485                                                                                       
486                                                incount += 1;
487                                                line = ostrcat(line, tmphname, 1, 0);
488                                                line = ostrcat(line, " (Part4)", 1, 0);
489                                                if(extra != NULL)
490                                                {
491                                                        line = ostrcat(line, " (", 1, 0);                                       
492                                                        line = ostrcat(line, extra, 1, 0);                                     
493                                                        line = ostrcat(line, ")", 1, 0);                                       
494                                                }                               
495                                                line = ostrcat(line, "#", 1, 0);
496                                                line = ostrcat(line, "http://www.movie4k.to/", 1, 0);
497                                                line = ostrcat(line, url4, 1, 0);
498                                                line = ostrcat(line, "#", 1, 0);
499                                                line = ostrcat(line, "http://atemio.dyndns.tv/mediathek/menu/", 1, 0);
500                                                line = ostrcat(line, pichname, 1, 0);
501                                                line = ostrcat(line, ".jpg#movie4k_", 1, 0);
502                                                line = ostrcat(line, pichname, 1, 0);
503                                                line = ostrcat(line, ".jpg#Movie4k - ", 1, 0);
504                                                line = ostrcat(line, title, 1, 0);
505                                                line = ostrcat(line, "#", 1, 0);
506                                                line = ostrcat(line, oitoa(type), 1, 0);
507                                                line = ostrcat(line, "\n", 1, 0);
508                                        }
509                                        free(tmphname), tmphname = NULL;
510                                        free(extra), extra = NULL;
511                                        free(pichname), pichname = NULL;
512
513                                        if(nolinks != NULL)
514                                        {
515                                                printf("break\n");
516                                                break;
517                                        }
518
519                                }
520
521                                free(url), url = NULL;
522                                free(url2), url2 = NULL;
523                                free(url3), url3 = NULL;
524                                free(url4), url4 = NULL;
525                                free(pathnew), pathnew = NULL;
526                                free(logfile), logfile = NULL;                                 
527                        }
528                }
529                free(ret1), ret1 = NULL;
530        }
531
532        free(tmpstr1), tmpstr1 = NULL;
533        free(tmpstr), tmpstr = NULL;   
534
535        if(line != NULL)
536        {
537                tmpstr = ostrcat("/tmp/tithek/movie4k.hoster.list", NULL, 0, 0);
538                writesys(tmpstr, line, 0);
539                                       
540                struct tithek* tnode = (struct tithek*)listbox->select->handle;
541                createtithek(tnode, tnode->title,  tmpstr, tnode->pic, tnode->localname, tnode->menutitle, tnode->flag);
542                ret = 0;
543        }
544
545        return ret;
546}
547
548int movie4k_hoster_series(struct skin* grid, struct skin* listbox, struct skin* countlabel, struct skin* load, char* link, char* title)
549{
550        debug(99, "link: %s", link);
551        int debuglevel = getconfigint("debuglevel", NULL);
552        int ret = 1, series = 0;
553        char* ip = NULL, *pos = NULL, *id = NULL, *tpath = NULL, *path = NULL, *tmpstr = NULL, *line = NULL, *episode = NULL;
554        char* from = NULL;
555        char* folgen = NULL;
556        char* folgentmp = NULL;
557
558        if(listbox == NULL || listbox->select == NULL || listbox->select->handle == NULL)
559                return ret;
560
561        ip = string_replace("http://", "", (char*)link, 0);
562
563        if(ip != NULL)
564                pos = strchr(ip, '/');
565        if(pos != NULL)
566        {
567                pos[0] = '\0';
568                path = pos + 1;
569        }
570/*
571        if(!ostrncmp("tvshows-", path, 8))
572        {
573                debug(99, "path: %s",path);
574                tpath = ostrcat(path, NULL, 0, 0);
575                id = oregex(".*tvshows-(.*[0-9]{1,10})-.*", path);
576                tpath = string_replace("tvshows-season-", "", tpath, 1);
577                tpath = string_replace(".html", "", tpath, 1);
578                tpath = ostrcat(tpath, "-online-serie-", 1, 0);
579                tpath = ostrcat(tpath, id, 1, 0);
580                tpath = ostrcat(tpath, ".html", 1, 0);
581                debug(99, "convertpath: %s",tpath);
582        }
583        else
584*/
585                tpath = ostrcat(path, NULL, 0, 0);
586
587        tmpstr = gethttp(ip, tpath, 80, NULL, NULL, 10000, NULL, 0);
588        free(tpath), tpath = NULL;
589        titheklog(debuglevel, "/tmp/movie4k2_tmpstr", NULL, tmpstr);
590
591        if(tmpstr != NULL)
592        {
593                drawscreen(load, 0, 0);
594
595                if(ostrstr(tmpstr, "episodeform") != NULL)
596                {
597                        int i;
598                        for(i = 1; i < 30; i++)
599                        {
600                                from = ostrcat(from, "<FORM name=\"episodeform", 1, 0);
601                                from = ostrcat(from, oitoa(i), 1, 0);
602                                from = ostrcat(from, "\">", 1, 0);
603                                folgen = string_resub(from, "</FORM>", tmpstr, 0);
604                                folgen = string_resub("<OPTION></OPTION>", "</SELECT>", folgen, 1);
605                                folgen = string_replace_all("><", ">\n<", folgen, 1);
606                                folgentmp = ostrcat(folgen, NULL, 0, 0);
607
608                                if(folgen != NULL)
609                                {
610                                        int count = 0;
611                                        int incount = 0;
612                                        int j;
613                                        struct splitstr* ret1 = NULL;
614                                        ret1 = strsplit(folgen, "\n", &count);
615                                               
616                                        if(ret1 != NULL && count > 0)
617                                        {
618                                                int max = count + 1;
619                                                for(j = 1; j < max; j++)
620                                                {
621                                                        link = string_resub("<OPTION value=\"", "\"", ret1[j-1].part, 0);
622                                                        id = oregex(".*tvshows-(.*[0-9]{1,10})-.*", link);
623                                                        episode = oregex(".*>Episode (.*[0-9]{1,10})</OPTION>.*", ret1[j-1].part);
624
625                                                        debug(99, "(S%d/E%s)(%d) link: %s id: %s", i, episode, j, link, id);
626                                                        link = string_replace("tvshows-", "", link, 1);
627                                                        link = string_replace(id, "", link, 1);
628                                                        link = string_replace("-", "", link, 1);
629                                                        link = string_replace(".html", "", link, 1);
630                                                        link = ostrcat(link, "-online-serie-", 1, 0);
631                                                        link = ostrcat(link, id, 1, 0);
632                                                        link = ostrcat(link, ".html", 1, 0);
633                                                        debug(99, "(S%d/E%d) convertlink: %s id: %s", i, j, link, id);
634
635                                                        incount += 1;
636                                                        line = ostrcat(line, _("Season"), 1, 0);
637                                                        line = ostrcat(line, " ", 1, 0);
638                                                        line = ostrcat(line, oitoa(i), 1, 0);
639                                                        line = ostrcat(line, " ", 1, 0);
640                                                        line = ostrcat(line, _("Episode"), 1, 0);
641                                                        line = ostrcat(line, " ", 1, 0);
642//                                                      line = ostrcat(line, oitoa(j), 1, 0);
643                                                        line = ostrcat(line, episode, 1, 0);                                   
644                                                        line = ostrcat(line, "#", 1, 0);
645                                                        line = ostrcat(line, "http://www.movie4k.to/", 1, 0);
646                                                        line = ostrcat(line, link, 1, 0);
647                                                        line = ostrcat(line, "#", 1, 0);
648                                                        line = ostrcat(line, "http://atemio.dyndns.tv/mediathek/menu/s", 1, 0);
649                                                        line = ostrcat(line, oitoa(i), 1, 0);
650                                                        line = ostrcat(line, "e", 1, 0);
651//                                                      line = ostrcat(line, oitoa(j), 1, 0);
652                                                        line = ostrcat(line, episode, 1, 0);
653                                                        line = ostrcat(line, ".jpg", 1, 0);                                                                                                                             
654                                                        line = ostrcat(line, "#movie4k_search_", 1, 0);
655                                                        line = ostrcat(line, oitoa(i), 1, 0);
656                                                        line = ostrcat(line, "e", 1, 0);
657//                                                      line = ostrcat(line, oitoa(j), 1, 0);
658                                                        line = ostrcat(line, episode, 1, 0);
659                                                        line = ostrcat(line, ".jpg#Movie4k - ", 1, 0);
660                                                        line = ostrcat(line, title, 1, 0);
661                                                        line = ostrcat(line, "#34\n", 1, 0);
662                                                        free(id), id = NULL;
663                                                        free(episode), episode = NULL;
664                                                }
665                                        }
666                                        free(ret1), ret1 = NULL;
667                                }                               
668                                free(from), from = NULL;
669                                free(folgen), folgen = NULL;
670                                free(folgentmp), folgentmp = NULL;
671                        }
672                }
673        }
674        free(tmpstr), tmpstr = NULL;   
675
676        if(line != NULL)
677        {
678                if(series == 0)
679                        tmpstr = ostrcat("/tmp/tithek/movie4k.hoster.list", NULL, 0, 0);
680                else
681                        tmpstr = ostrcat("/tmp/tithek/movie4k.hoster.ser.list", NULL, 0, 0);
682                writesys(tmpstr, line, 0);
683
684                titheklog(debuglevel, "/tmp/movie4k8_line", NULL, line);
685                                       
686                struct tithek* tnode = (struct tithek*)listbox->select->handle;
687                createtithek(tnode, tnode->title,  tmpstr, tnode->pic, tnode->localname, tnode->menutitle, tnode->flag);
688                ret = 0;
689        }
690        return ret;
691}
692
693int movie4k_series(struct skin* grid, struct skin* listbox, struct skin* countlabel, struct skin* load, char* link, char* title)
694{
695        debug(99, "link: %s", link);
696        int debuglevel = getconfigint("debuglevel", NULL);
697        int ret = 1;
698        char* ip = NULL, *pos = NULL, *tpath = NULL, *path = NULL, *tmpstr = NULL, *line = NULL;
699        char* from = NULL;
700        char* folgen = NULL;
701        char* folgentmp = NULL;
702        char* name = NULL;
703        char* lang = NULL;
704        char* season = NULL;
705
706        if(listbox == NULL || listbox->select == NULL || listbox->select->handle == NULL)
707                return ret;
708
709        ip = string_replace("http://", "", (char*)link, 0);
710
711        if(ip != NULL)
712                pos = strchr(ip, '/');
713        if(pos != NULL)
714        {
715                pos[0] = '\0';
716                path = pos + 1;
717        }
718
719        tmpstr = gethttp(ip, path, 80, NULL, NULL, 10000, NULL, 0);
720        free(tpath), tpath = NULL;
721        titheklog(debuglevel, "/tmp/movie4k2_tmpstr", NULL, tmpstr);
722
723        if(tmpstr != NULL)
724        {
725                drawscreen(load, 0, 0);
726
727                folgen = string_resub("<TABLE id=\"tablemoviesindex\">", "</TABLE>", tmpstr, 0);
728                folgen = string_replace_all("\n", "", folgen, 1);
729                folgen = string_replace_all("\t", "", folgen, 1);
730                string_strip_whitechars(folgen);
731                folgen = string_replace_all("</TD> </TR> <TR>", "</TD> </TR>\n<TR>", folgen, 1);
732
733                if(folgen != NULL)
734                {
735                        int count = 0;
736                        int j;
737                        struct splitstr* ret1 = NULL;
738                        ret1 = strsplit(folgen, "\n", &count);
739
740                        if(ret1 != NULL && count > 0)
741                        {
742                                int max = count;
743                                for(j = 0; j < max; j++)
744                                {
745                                        link = string_resub("<a href=\"", "\">", ret1[j].part, 0);
746
747                                        name = oregex(".*><a href=.*\">(.*)</a></TD>.*", ret1[j].part);
748
749                                        if(ostrstr(ret1[j].part, "us_ger_small.png") != NULL)
750                                                lang = ostrcat(" (de)", NULL, 0, 0);
751                                        else if(ostrstr(ret1[j].part, "us_flag_small.png") != NULL)
752                                                lang = ostrcat(" (en)", NULL, 0, 0);
753                                        else
754                                                lang = ostrcat(" (\?\?)", NULL, 0, 0);
755
756                                        season = oregex(".*Season:(.*[0-9]{1,3}).*", name);
757                                        season = strstrip(season);
758                                        debug(99, "(S%s) input: %s%s",season, name, lang);
759
760                                        line = ostrcat(line, _("Season"), 1, 0);
761                                        line = ostrcat(line, " ", 1, 0);
762                                        line = ostrcat(line, season, 1, 0);
763                                        line = ostrcat(line, " ", 1, 0);
764                                                                               
765                                        line = ostrcat(line, lang, 1, 0);       
766                                        line = ostrcat(line, "#", 1, 0);
767                                        line = ostrcat(line, "http://www.movie4k.to/", 1, 0);
768                                        line = ostrcat(line, link, 1, 0);
769                                        line = ostrcat(line, "#", 1, 0);
770                                        line = ostrcat(line, "http://atemio.dyndns.tv/mediathek/menu/s", 1, 0);
771                                        line = ostrcat(line, season, 1, 0);
772                                        line = ostrcat(line, ".jpg", 1, 0);
773                                        line = ostrcat(line, "#s", 1, 0);
774                                        line = ostrcat(line, season, 1, 0);
775                                        line = ostrcat(line, ".jpg", 1, 0);
776                                        line = ostrcat(line, "#Movie4k - ", 1, 0);
777                                        line = ostrcat(line, title, 1, 0);
778                                        line = ostrcat(line, "#39\n", 1, 0);
779                                        free(name), name = NULL;
780                                        free(lang), lang = NULL;
781                                        free(season), season = NULL;
782                                }
783                        }
784                        free(ret1), ret1 = NULL;
785                }                               
786                free(from), from = NULL;
787                free(folgen), folgen = NULL;
788                free(folgentmp), folgentmp = NULL;             
789        }
790        free(tmpstr), tmpstr = NULL;   
791
792        if(line != NULL)
793        {
794                tmpstr = ostrcat("/tmp/tithek/movie4k.series.list", NULL, 0, 0);
795                writesys(tmpstr, line, 0);
796
797                titheklog(debuglevel, "/tmp/movie4k8_line", NULL, line);
798                                       
799                struct tithek* tnode = (struct tithek*)listbox->select->handle;
800                createtithek(tnode, tnode->title,  tmpstr, tnode->pic, tnode->localname, tnode->menutitle, tnode->flag);
801                ret = 0;
802        }
803        return ret;
804}
805
806int movie4k_series_listed(struct skin* grid, struct skin* listbox, struct skin* countlabel, struct skin* load, char* link, char* title)
807{
808        debug(99, "link: %s", link);
809        int debuglevel = getconfigint("debuglevel", NULL);
810        int ret = 1;
811        char* ip = NULL, *pos = NULL, *tpath = NULL, *path = NULL, *tmpstr = NULL, *line = NULL;
812        char* from = NULL;
813        char* folgen = NULL;
814        char* folgentmp = NULL;
815        char* name = NULL;
816        char* lang = NULL;
817        char* season = NULL;
818        char* episode = NULL;
819
820        if(listbox == NULL || listbox->select == NULL || listbox->select->handle == NULL)
821                return ret;
822
823        ip = string_replace("http://", "", (char*)link, 0);
824
825        if(ip != NULL)
826                pos = strchr(ip, '/');
827        if(pos != NULL)
828        {
829                pos[0] = '\0';
830                path = pos + 1;
831        }
832
833        tmpstr = gethttp(ip, path, 80, NULL, NULL, 10000, NULL, 0);
834        free(tpath), tpath = NULL;
835        titheklog(debuglevel, "/tmp/movie4k2_tmpstr", NULL, tmpstr);
836
837        if(tmpstr != NULL)
838        {
839                drawscreen(load, 0, 0);
840
841                folgen = string_resub("<TABLE id=\"tablemoviesindex\">", "</TABLE>", tmpstr, 0);
842                folgen = string_replace_all("\n", "", folgen, 1);
843                folgen = string_replace_all("\t", "", folgen, 1);
844                string_strip_whitechars(folgen);
845                folgen = string_replace_all("</TD> </TR> <TR>", "</TD> </TR>\n<TR>", folgen, 1);
846
847                if(folgen != NULL)
848                {
849                        int count = 0;
850                        int j;
851                        struct splitstr* ret1 = NULL;
852                        ret1 = strsplit(folgen, "\n", &count);
853
854                        if(ret1 != NULL && count > 0)
855                        {
856                                int max = count;
857                                for(j = 0; j < max; j++)
858                                {
859                                        link = string_resub("<a href=\"", "\">", ret1[j].part, 0);
860                                        name = oregex(".*><a href=.*\">(.*)</a></TD>.*", ret1[j].part);
861
862                                        if(ostrstr(ret1[j].part, "us_ger_small.png") != NULL)
863                                                lang = ostrcat(" (de)", NULL, 0, 0);
864                                        else if(ostrstr(ret1[j].part, "us_flag_small.png") != NULL)
865                                                lang = ostrcat(" (en)", NULL, 0, 0);
866                                        else
867                                                lang = ostrcat(" (\?\?)", NULL, 0, 0);
868
869                                        season = oregex(".*Season:(.*),.*", name);
870                                        season = strstrip(season);
871                                        episode = oregex(".*Episode:(.*[0-9]{1,3}).*", name);
872                                        episode = strstrip(episode);
873                                        debug(99, "(S%s/E%s) input: %s%s",season, episode, name, lang);
874
875                                        line = ostrcat(line, _("Season"), 1, 0);
876                                        line = ostrcat(line, " ", 1, 0);
877                                        line = ostrcat(line, season, 1, 0);
878                                        line = ostrcat(line, " ", 1, 0);
879                                        line = ostrcat(line, _("Episode"), 1, 0);
880                                        line = ostrcat(line, " ", 1, 0);                               
881                                        line = ostrcat(line, episode, 1, 0);
882                                        line = ostrcat(line, " ", 1, 0);
883                                        line = ostrcat(line, lang, 1, 0);       
884                                        line = ostrcat(line, "#", 1, 0);
885                                        line = ostrcat(line, "http://www.movie4k.to/", 1, 0);
886                                        line = ostrcat(line, link, 1, 0);
887                                        line = ostrcat(line, "#", 1, 0);
888                                        line = ostrcat(line, "http://atemio.dyndns.tv/mediathek/menu/s", 1, 0);
889                                        line = ostrcat(line, season, 1, 0);
890                                        line = ostrcat(line, "e", 1, 0);
891                                        line = ostrcat(line, episode, 1, 0);
892                                        line = ostrcat(line, ".jpg", 1, 0);
893                                        line = ostrcat(line, "#s", 1, 0);
894                                        line = ostrcat(line, season, 1, 0);
895                                        line = ostrcat(line, "e", 1, 0);
896                                        line = ostrcat(line, episode, 1, 0);
897                                        line = ostrcat(line, ".jpg", 1, 0);
898                                        line = ostrcat(line, "#Movie4k - ", 1, 0);
899                                        line = ostrcat(line, title, 1, 0);
900                                        line = ostrcat(line, "#34\n", 1, 0);
901                                        free(name), name = NULL;
902                                        free(lang), lang = NULL;
903                                        free(season), season = NULL;
904                                        free(episode), episode = NULL;
905                                }
906                        }
907                        free(ret1), ret1 = NULL;
908                }                               
909                free(from), from = NULL;
910                free(folgen), folgen = NULL;
911                free(folgentmp), folgentmp = NULL;             
912        }
913        free(tmpstr), tmpstr = NULL;   
914
915        if(line != NULL)
916        {
917                tmpstr = ostrcat("/tmp/tithek/movie4k.series.listed.list", NULL, 0, 0);
918                writesys(tmpstr, line, 0);
919
920                titheklog(debuglevel, "/tmp/movie4k8_line", NULL, line);
921                                       
922                struct tithek* tnode = (struct tithek*)listbox->select->handle;
923                createtithek(tnode, tnode->title,  tmpstr, tnode->pic, tnode->localname, tnode->menutitle, tnode->flag);
924                ret = 0;
925        }
926        return ret;
927}
928
929
930#endif
Note: See TracBrowser for help on using the repository browser.