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

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

[titan] optimize movie4k hoster

File size: 30.3 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, maxlen = 0, bigpos = 0;
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, 1);
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                                        ostrcatbig(&line, tmphname, &maxlen, &bigpos);
397                                        if(url2 != NULL && ostrcmp(url, url2) != 0)
398                                                ostrcatbig(&line, " (Part1)", &maxlen, &bigpos);
399                                        if(extra != NULL)
400                                        {
401                                                ostrcatbig(&line, " (", &maxlen, &bigpos);
402                                                ostrcatbig(&line, extra, &maxlen, &bigpos);
403                                                ostrcatbig(&line, ")", &maxlen, &bigpos);                                       
404                                        }
405                                        ostrcatbig(&line, "#", &maxlen, &bigpos);
406                                        ostrcatbig(&line, "http://www.movie4k.to/", &maxlen, &bigpos);
407                                        ostrcatbig(&line, url, &maxlen, &bigpos);
408                                        ostrcatbig(&line, "#", &maxlen, &bigpos);
409                                        ostrcatbig(&line, "http://atemio.dyndns.tv/mediathek/menu/", &maxlen, &bigpos);
410                                        ostrcatbig(&line, pichname, &maxlen, &bigpos);
411                                        ostrcatbig(&line, ".jpg#movie4k_", &maxlen, &bigpos);
412                                        ostrcatbig(&line, pichname, &maxlen, &bigpos);
413                                        ostrcatbig(&line, ".jpg#Movie4k - ", &maxlen, &bigpos);
414                                        ostrcatbig(&line, title, &maxlen, &bigpos);
415                                        ostrcatbig(&line, "#", &maxlen, &bigpos);
416                                        char* ctype = oitoa(type);
417                                        ostrcatbig(&line, ctype, &maxlen, &bigpos);
418                                        free(ctype); ctype = NULL;
419                                        ostrcatbig(&line, "\n", &maxlen, &bigpos);
420
421                                        if(url2 != NULL && ostrcmp(url, url2) != 0)
422                                        {                                               
423                                                int type = 41;
424       
425                                                debug(99, "-------------------------------");
426                                                debug(99, "(%d/%d/%d) %s (Part2) extra: %s url: %s",a ,i ,max ,tmphname, extra, url2);
427                               
428                                                incount += 1;
429                                                ostrcatbig(&line, tmphname, &maxlen, &bigpos);
430                                                ostrcatbig(&line, " (Part2)", &maxlen, &bigpos);
431                                                if(extra != NULL)
432                                                {
433                                                        ostrcatbig(&line, " (", &maxlen, &bigpos);
434                                                        ostrcatbig(&line, extra, &maxlen, &bigpos);
435                                                        ostrcatbig(&line, ")", &maxlen, &bigpos);                                       
436                                                }
437                                                ostrcatbig(&line, "#", &maxlen, &bigpos);
438                                                ostrcatbig(&line, "http://www.movie4k.to/", &maxlen, &bigpos);
439                                                ostrcatbig(&line, url2, &maxlen, &bigpos);
440                                                ostrcatbig(&line, "#", &maxlen, &bigpos);
441                                                ostrcatbig(&line, "http://atemio.dyndns.tv/mediathek/menu/", &maxlen, &bigpos);
442                                                ostrcatbig(&line, pichname, &maxlen, &bigpos);
443                                                ostrcatbig(&line, ".jpg#kinox_", &maxlen, &bigpos);
444                                                ostrcatbig(&line, pichname, &maxlen, &bigpos);
445                                                ostrcatbig(&line, ".jpg#Movie4k - ", &maxlen, &bigpos);
446                                                ostrcatbig(&line, title, &maxlen, &bigpos);
447                                                ostrcatbig(&line, "#", &maxlen, &bigpos);
448                                                char* ctype = oitoa(type);
449                                                ostrcatbig(&line, ctype, &maxlen, &bigpos);
450                                                free(ctype); ctype = NULL;
451                                                ostrcatbig(&line, "\n", &maxlen, &bigpos);
452                                        }
453                                        if(url3 != NULL && ostrcmp(url, url3) != 0)
454                                        {
455                                                int type = 41;
456                                                                                                                               
457                                                debug(99, "-------------------------------");
458                                                debug(99, "(%d/%d/%d) %s (Part3) extra: %s url: %s",a ,i ,max ,tmphname, extra, url3);
459                       
460                                                incount += 1;
461                                                ostrcatbig(&line, tmphname, &maxlen, &bigpos);
462                                                ostrcatbig(&line, " (Part3)", &maxlen, &bigpos);
463                                                if(extra != NULL)
464                                                {
465                                                        ostrcatbig(&line, " (", &maxlen, &bigpos);
466                                                        ostrcatbig(&line, extra, &maxlen, &bigpos);
467                                                        ostrcatbig(&line, ")", &maxlen, &bigpos);                                       
468                                                }
469                                                ostrcatbig(&line, "#", &maxlen, &bigpos);
470                                                ostrcatbig(&line, "http://www.movie4k.to/", &maxlen, &bigpos);
471                                                ostrcatbig(&line, url3, &maxlen, &bigpos);
472                                                ostrcatbig(&line, "#", &maxlen, &bigpos);
473                                                ostrcatbig(&line, "http://atemio.dyndns.tv/mediathek/menu/", &maxlen, &bigpos);
474                                                ostrcatbig(&line, pichname, &maxlen, &bigpos);
475                                                ostrcatbig(&line, ".jpg#movie4k_", &maxlen, &bigpos);
476                                                ostrcatbig(&line, pichname, &maxlen, &bigpos);
477                                                ostrcatbig(&line, ".jpg#Movie4k - ", &maxlen, &bigpos);
478                                                ostrcatbig(&line, title, &maxlen, &bigpos);
479                                                ostrcatbig(&line, "#", &maxlen, &bigpos);
480                                                char* ctype = oitoa(type);
481                                                ostrcatbig(&line, ctype, &maxlen, &bigpos);
482                                                free(ctype); ctype = NULL;
483                                                ostrcatbig(&line, "\n", &maxlen, &bigpos);
484                                        }
485                                        if(url4 != NULL && ostrcmp(url, url4) != 0)
486                                        {
487                                                int type = 41;
488       
489                                                debug(99, "-------------------------------");
490                                                debug(99, "(%d/%d/%d) %s (Part4) extra: %s url: %s",a ,i ,max ,tmphname, extra, url4);
491                                                                                       
492                                                incount += 1;
493                                                ostrcatbig(&line, tmphname, &maxlen, &bigpos);
494                                                ostrcatbig(&line, " (Part4)", &maxlen, &bigpos);
495                                                if(extra != NULL)
496                                                {
497                                                        ostrcatbig(&line, " (", &maxlen, &bigpos);
498                                                        ostrcatbig(&line, extra, &maxlen, &bigpos);
499                                                        ostrcatbig(&line, ")", &maxlen, &bigpos);                                       
500                                                }
501                                                ostrcatbig(&line, "#", &maxlen, &bigpos);
502                                                ostrcatbig(&line, "http://www.movie4k.to/", &maxlen, &bigpos);
503                                                ostrcatbig(&line, url4, &maxlen, &bigpos);
504                                                ostrcatbig(&line, "#", &maxlen, &bigpos);
505                                                ostrcatbig(&line, "http://atemio.dyndns.tv/mediathek/menu/", &maxlen, &bigpos);
506                                                ostrcatbig(&line, pichname, &maxlen, &bigpos);
507                                                ostrcatbig(&line, ".jpg#movie4k_", &maxlen, &bigpos);
508                                                ostrcatbig(&line, pichname, &maxlen, &bigpos);
509                                                ostrcatbig(&line, ".jpg#Movie4k - ", &maxlen, &bigpos);
510                                                ostrcatbig(&line, title, &maxlen, &bigpos);
511                                                ostrcatbig(&line, "#", &maxlen, &bigpos);
512                                                char* ctype = oitoa(type);
513                                                ostrcatbig(&line, ctype, &maxlen, &bigpos);
514                                                free(ctype); ctype = NULL;
515                                                ostrcatbig(&line, "\n", &maxlen, &bigpos);
516                                        }
517                                        free(tmphname), tmphname = NULL;
518                                        free(extra), extra = NULL;
519                                        free(pichname), pichname = NULL;
520
521                                        if(nolinks != NULL)
522                                        {
523                                                printf("break\n");
524                                                break;
525                                        }
526
527                                }
528
529                                free(url), url = NULL;
530                                free(url2), url2 = NULL;
531                                free(url3), url3 = NULL;
532                                free(url4), url4 = NULL;
533                                free(pathnew), pathnew = NULL;
534                                free(logfile), logfile = NULL;                                 
535                        }
536                }
537                free(ret1), ret1 = NULL;
538        }
539
540        free(tmpstr1), tmpstr1 = NULL;
541        free(tmpstr), tmpstr = NULL;   
542
543        if(line != NULL)
544        {
545                tmpstr = ostrcat("/tmp/tithek/movie4k.hoster.list", NULL, 0, 0);
546                writesys(tmpstr, line, 0);
547                free(line); line = NULL;
548                                       
549                struct tithek* tnode = (struct tithek*)listbox->select->handle;
550                createtithek(tnode, tnode->title,  tmpstr, tnode->pic, tnode->localname, tnode->menutitle, tnode->flag);
551                ret = 0;
552        }
553
554        return ret;
555}
556
557int movie4k_hoster_series(struct skin* grid, struct skin* listbox, struct skin* countlabel, struct skin* load, char* link, char* title)
558{
559        debug(99, "link: %s", link);
560        int debuglevel = getconfigint("debuglevel", NULL);
561        int ret = 1, series = 0;
562        char* ip = NULL, *pos = NULL, *id = NULL, *tpath = NULL, *path = NULL, *tmpstr = NULL, *line = NULL, *episode = NULL;
563        char* from = NULL;
564        char* folgen = NULL;
565        char* folgentmp = NULL;
566
567        if(listbox == NULL || listbox->select == NULL || listbox->select->handle == NULL)
568                return ret;
569
570        ip = string_replace("http://", "", (char*)link, 0);
571
572        if(ip != NULL)
573                pos = strchr(ip, '/');
574        if(pos != NULL)
575        {
576                pos[0] = '\0';
577                path = pos + 1;
578        }
579/*
580        if(!ostrncmp("tvshows-", path, 8))
581        {
582                debug(99, "path: %s",path);
583                tpath = ostrcat(path, NULL, 0, 0);
584                id = oregex(".*tvshows-(.*[0-9]{1,10})-.*", path);
585                tpath = string_replace("tvshows-season-", "", tpath, 1);
586                tpath = string_replace(".html", "", tpath, 1);
587                tpath = ostrcat(tpath, "-online-serie-", 1, 0);
588                tpath = ostrcat(tpath, id, 1, 0);
589                tpath = ostrcat(tpath, ".html", 1, 0);
590                debug(99, "convertpath: %s",tpath);
591        }
592        else
593*/
594                tpath = ostrcat(path, NULL, 0, 0);
595
596        tmpstr = gethttp(ip, tpath, 80, NULL, NULL, 10000, NULL, 0);
597        free(tpath), tpath = NULL;
598        titheklog(debuglevel, "/tmp/movie4k2_tmpstr", NULL, tmpstr);
599
600        if(tmpstr != NULL)
601        {
602                drawscreen(load, 0, 0);
603
604                if(ostrstr(tmpstr, "episodeform") != NULL)
605                {
606                        int i;
607                        for(i = 1; i < 30; i++)
608                        {
609                                from = ostrcat(from, "<FORM name=\"episodeform", 1, 0);
610                                from = ostrcat(from, oitoa(i), 1, 0);
611                                from = ostrcat(from, "\">", 1, 0);
612                                folgen = string_resub(from, "</FORM>", tmpstr, 0);
613                                folgen = string_resub("<OPTION></OPTION>", "</SELECT>", folgen, 1);
614                                folgen = string_replace_all("><", ">\n<", folgen, 1);
615                                folgentmp = ostrcat(folgen, NULL, 0, 0);
616
617                                if(folgen != NULL)
618                                {
619                                        int count = 0;
620                                        int incount = 0;
621                                        int j;
622                                        struct splitstr* ret1 = NULL;
623                                        ret1 = strsplit(folgen, "\n", &count);
624                                               
625                                        if(ret1 != NULL && count > 0)
626                                        {
627                                                int max = count + 1;
628                                                for(j = 1; j < max; j++)
629                                                {
630                                                        link = string_resub("<OPTION value=\"", "\"", ret1[j-1].part, 0);
631                                                        id = oregex(".*tvshows-(.*[0-9]{1,10})-.*", link);
632                                                        episode = oregex(".*>Episode (.*[0-9]{1,10})</OPTION>.*", ret1[j-1].part);
633
634                                                        debug(99, "(S%d/E%s)(%d) link: %s id: %s", i, episode, j, link, id);
635                                                        link = string_replace("tvshows-", "", link, 1);
636                                                        link = string_replace(id, "", link, 1);
637                                                        link = string_replace("-", "", link, 1);
638                                                        link = string_replace(".html", "", link, 1);
639                                                        link = ostrcat(link, "-online-serie-", 1, 0);
640                                                        link = ostrcat(link, id, 1, 0);
641                                                        link = ostrcat(link, ".html", 1, 0);
642                                                        debug(99, "(S%d/E%d) convertlink: %s id: %s", i, j, link, id);
643
644                                                        incount += 1;
645                                                        line = ostrcat(line, _("Season"), 1, 0);
646                                                        line = ostrcat(line, " ", 1, 0);
647                                                        line = ostrcat(line, oitoa(i), 1, 0);
648                                                        line = ostrcat(line, " ", 1, 0);
649                                                        line = ostrcat(line, _("Episode"), 1, 0);
650                                                        line = ostrcat(line, " ", 1, 0);
651//                                                      line = ostrcat(line, oitoa(j), 1, 0);
652                                                        line = ostrcat(line, episode, 1, 0);                                   
653                                                        line = ostrcat(line, "#", 1, 0);
654                                                        line = ostrcat(line, "http://www.movie4k.to/", 1, 0);
655                                                        line = ostrcat(line, link, 1, 0);
656                                                        line = ostrcat(line, "#", 1, 0);
657                                                        line = ostrcat(line, "http://atemio.dyndns.tv/mediathek/menu/s", 1, 0);
658                                                        line = ostrcat(line, oitoa(i), 1, 0);
659                                                        line = ostrcat(line, "e", 1, 0);
660//                                                      line = ostrcat(line, oitoa(j), 1, 0);
661                                                        line = ostrcat(line, episode, 1, 0);
662                                                        line = ostrcat(line, ".jpg", 1, 0);                                                                                                                             
663                                                        line = ostrcat(line, "#movie4k_search_", 1, 0);
664                                                        line = ostrcat(line, oitoa(i), 1, 0);
665                                                        line = ostrcat(line, "e", 1, 0);
666//                                                      line = ostrcat(line, oitoa(j), 1, 0);
667                                                        line = ostrcat(line, episode, 1, 0);
668                                                        line = ostrcat(line, ".jpg#Movie4k - ", 1, 0);
669                                                        line = ostrcat(line, title, 1, 0);
670                                                        line = ostrcat(line, "#34\n", 1, 0);
671                                                        free(id), id = NULL;
672                                                        free(episode), episode = NULL;
673                                                }
674                                        }
675                                        free(ret1), ret1 = NULL;
676                                }                               
677                                free(from), from = NULL;
678                                free(folgen), folgen = NULL;
679                                free(folgentmp), folgentmp = NULL;
680                        }
681                }
682        }
683        free(tmpstr), tmpstr = NULL;   
684
685        if(line != NULL)
686        {
687                if(series == 0)
688                        tmpstr = ostrcat("/tmp/tithek/movie4k.hoster.list", NULL, 0, 0);
689                else
690                        tmpstr = ostrcat("/tmp/tithek/movie4k.hoster.ser.list", NULL, 0, 0);
691                writesys(tmpstr, line, 0);
692
693                titheklog(debuglevel, "/tmp/movie4k8_line", NULL, line);
694                                       
695                struct tithek* tnode = (struct tithek*)listbox->select->handle;
696                createtithek(tnode, tnode->title,  tmpstr, tnode->pic, tnode->localname, tnode->menutitle, tnode->flag);
697                ret = 0;
698        }
699        return ret;
700}
701
702int movie4k_series(struct skin* grid, struct skin* listbox, struct skin* countlabel, struct skin* load, char* link, char* title)
703{
704        debug(99, "link: %s", link);
705        int debuglevel = getconfigint("debuglevel", NULL);
706        int ret = 1;
707        char* ip = NULL, *pos = NULL, *tpath = NULL, *path = NULL, *tmpstr = NULL, *line = NULL;
708        char* from = NULL;
709        char* folgen = NULL;
710        char* folgentmp = NULL;
711        char* name = NULL;
712        char* lang = NULL;
713        char* season = NULL;
714
715        if(listbox == NULL || listbox->select == NULL || listbox->select->handle == NULL)
716                return ret;
717
718        ip = string_replace("http://", "", (char*)link, 0);
719
720        if(ip != NULL)
721                pos = strchr(ip, '/');
722        if(pos != NULL)
723        {
724                pos[0] = '\0';
725                path = pos + 1;
726        }
727
728        tmpstr = gethttp(ip, path, 80, NULL, NULL, 10000, NULL, 0);
729        free(tpath), tpath = NULL;
730        titheklog(debuglevel, "/tmp/movie4k2_tmpstr", NULL, tmpstr);
731
732        if(tmpstr != NULL)
733        {
734                drawscreen(load, 0, 0);
735
736                folgen = string_resub("<TABLE id=\"tablemoviesindex\">", "</TABLE>", tmpstr, 0);
737                folgen = string_replace_all("\n", "", folgen, 1);
738                folgen = string_replace_all("\t", "", folgen, 1);
739                string_strip_whitechars(folgen);
740                folgen = string_replace_all("</TD> </TR> <TR>", "</TD> </TR>\n<TR>", folgen, 1);
741
742                if(folgen != NULL)
743                {
744                        int count = 0;
745                        int j;
746                        struct splitstr* ret1 = NULL;
747                        ret1 = strsplit(folgen, "\n", &count);
748
749                        if(ret1 != NULL && count > 0)
750                        {
751                                int max = count;
752                                for(j = 0; j < max; j++)
753                                {
754                                        link = string_resub("<a href=\"", "\">", ret1[j].part, 0);
755
756                                        name = oregex(".*><a href=.*\">(.*)</a></TD>.*", ret1[j].part);
757
758                                        if(ostrstr(ret1[j].part, "us_ger_small.png") != NULL)
759                                                lang = ostrcat(" (de)", NULL, 0, 0);
760                                        else if(ostrstr(ret1[j].part, "us_flag_small.png") != NULL)
761                                                lang = ostrcat(" (en)", NULL, 0, 0);
762                                        else
763                                                lang = ostrcat(" (\?\?)", NULL, 0, 0);
764
765                                        season = oregex(".*Season:(.*[0-9]{1,3}).*", name);
766                                        season = strstrip(season);
767                                        debug(99, "(S%s) input: %s%s",season, name, lang);
768
769                                        line = ostrcat(line, _("Season"), 1, 0);
770                                        line = ostrcat(line, " ", 1, 0);
771                                        line = ostrcat(line, season, 1, 0);
772                                        line = ostrcat(line, " ", 1, 0);
773                                                                               
774                                        line = ostrcat(line, lang, 1, 0);       
775                                        line = ostrcat(line, "#", 1, 0);
776                                        line = ostrcat(line, "http://www.movie4k.to/", 1, 0);
777                                        line = ostrcat(line, link, 1, 0);
778                                        line = ostrcat(line, "#", 1, 0);
779                                        line = ostrcat(line, "http://atemio.dyndns.tv/mediathek/menu/s", 1, 0);
780                                        line = ostrcat(line, season, 1, 0);
781                                        line = ostrcat(line, ".jpg", 1, 0);
782                                        line = ostrcat(line, "#s", 1, 0);
783                                        line = ostrcat(line, season, 1, 0);
784                                        line = ostrcat(line, ".jpg", 1, 0);
785                                        line = ostrcat(line, "#Movie4k - ", 1, 0);
786                                        line = ostrcat(line, title, 1, 0);
787                                        line = ostrcat(line, "#39\n", 1, 0);
788                                        free(name), name = NULL;
789                                        free(lang), lang = NULL;
790                                        free(season), season = NULL;
791                                }
792                        }
793                        free(ret1), ret1 = NULL;
794                }                               
795                free(from), from = NULL;
796                free(folgen), folgen = NULL;
797                free(folgentmp), folgentmp = NULL;             
798        }
799        free(tmpstr), tmpstr = NULL;   
800
801        if(line != NULL)
802        {
803                tmpstr = ostrcat("/tmp/tithek/movie4k.series.list", NULL, 0, 0);
804                writesys(tmpstr, line, 0);
805
806                titheklog(debuglevel, "/tmp/movie4k8_line", NULL, line);
807                                       
808                struct tithek* tnode = (struct tithek*)listbox->select->handle;
809                createtithek(tnode, tnode->title,  tmpstr, tnode->pic, tnode->localname, tnode->menutitle, tnode->flag);
810                ret = 0;
811        }
812        return ret;
813}
814
815int movie4k_series_listed(struct skin* grid, struct skin* listbox, struct skin* countlabel, struct skin* load, char* link, char* title)
816{
817        debug(99, "link: %s", link);
818        int debuglevel = getconfigint("debuglevel", NULL);
819        int ret = 1;
820        char* ip = NULL, *pos = NULL, *tpath = NULL, *path = NULL, *tmpstr = NULL, *line = NULL;
821        char* from = NULL;
822        char* folgen = NULL;
823        char* folgentmp = NULL;
824        char* name = NULL;
825        char* lang = NULL;
826        char* season = NULL;
827        char* episode = NULL;
828
829        if(listbox == NULL || listbox->select == NULL || listbox->select->handle == NULL)
830                return ret;
831
832        ip = string_replace("http://", "", (char*)link, 0);
833
834        if(ip != NULL)
835                pos = strchr(ip, '/');
836        if(pos != NULL)
837        {
838                pos[0] = '\0';
839                path = pos + 1;
840        }
841
842        tmpstr = gethttp(ip, path, 80, NULL, NULL, 10000, NULL, 0);
843        free(tpath), tpath = NULL;
844        titheklog(debuglevel, "/tmp/movie4k2_tmpstr", NULL, tmpstr);
845
846        if(tmpstr != NULL)
847        {
848                drawscreen(load, 0, 0);
849
850                folgen = string_resub("<TABLE id=\"tablemoviesindex\">", "</TABLE>", tmpstr, 0);
851                folgen = string_replace_all("\n", "", folgen, 1);
852                folgen = string_replace_all("\t", "", folgen, 1);
853                string_strip_whitechars(folgen);
854                folgen = string_replace_all("</TD> </TR> <TR>", "</TD> </TR>\n<TR>", folgen, 1);
855
856                if(folgen != NULL)
857                {
858                        int count = 0;
859                        int j;
860                        struct splitstr* ret1 = NULL;
861                        ret1 = strsplit(folgen, "\n", &count);
862
863                        if(ret1 != NULL && count > 0)
864                        {
865                                int max = count;
866                                for(j = 0; j < max; j++)
867                                {
868                                        link = string_resub("<a href=\"", "\">", ret1[j].part, 0);
869                                        name = oregex(".*><a href=.*\">(.*)</a></TD>.*", ret1[j].part);
870
871                                        if(ostrstr(ret1[j].part, "us_ger_small.png") != NULL)
872                                                lang = ostrcat(" (de)", NULL, 0, 0);
873                                        else if(ostrstr(ret1[j].part, "us_flag_small.png") != NULL)
874                                                lang = ostrcat(" (en)", NULL, 0, 0);
875                                        else
876                                                lang = ostrcat(" (\?\?)", NULL, 0, 0);
877
878                                        season = oregex(".*Season:(.*),.*", name);
879                                        season = strstrip(season);
880                                        episode = oregex(".*Episode:(.*[0-9]{1,3}).*", name);
881                                        episode = strstrip(episode);
882                                        debug(99, "(S%s/E%s) input: %s%s",season, episode, name, lang);
883
884                                        line = ostrcat(line, _("Season"), 1, 0);
885                                        line = ostrcat(line, " ", 1, 0);
886                                        line = ostrcat(line, season, 1, 0);
887                                        line = ostrcat(line, " ", 1, 0);
888                                        line = ostrcat(line, _("Episode"), 1, 0);
889                                        line = ostrcat(line, " ", 1, 0);                               
890                                        line = ostrcat(line, episode, 1, 0);
891                                        line = ostrcat(line, " ", 1, 0);
892                                        line = ostrcat(line, lang, 1, 0);       
893                                        line = ostrcat(line, "#", 1, 0);
894                                        line = ostrcat(line, "http://www.movie4k.to/", 1, 0);
895                                        line = ostrcat(line, link, 1, 0);
896                                        line = ostrcat(line, "#", 1, 0);
897                                        line = ostrcat(line, "http://atemio.dyndns.tv/mediathek/menu/s", 1, 0);
898                                        line = ostrcat(line, season, 1, 0);
899                                        line = ostrcat(line, "e", 1, 0);
900                                        line = ostrcat(line, episode, 1, 0);
901                                        line = ostrcat(line, ".jpg", 1, 0);
902                                        line = ostrcat(line, "#s", 1, 0);
903                                        line = ostrcat(line, season, 1, 0);
904                                        line = ostrcat(line, "e", 1, 0);
905                                        line = ostrcat(line, episode, 1, 0);
906                                        line = ostrcat(line, ".jpg", 1, 0);
907                                        line = ostrcat(line, "#Movie4k - ", 1, 0);
908                                        line = ostrcat(line, title, 1, 0);
909                                        line = ostrcat(line, "#34\n", 1, 0);
910                                        free(name), name = NULL;
911                                        free(lang), lang = NULL;
912                                        free(season), season = NULL;
913                                        free(episode), episode = NULL;
914                                }
915                        }
916                        free(ret1), ret1 = NULL;
917                }                               
918                free(from), from = NULL;
919                free(folgen), folgen = NULL;
920                free(folgentmp), folgentmp = NULL;             
921        }
922        free(tmpstr), tmpstr = NULL;   
923
924        if(line != NULL)
925        {
926                tmpstr = ostrcat("/tmp/tithek/movie4k.series.listed.list", NULL, 0, 0);
927                writesys(tmpstr, line, 0);
928
929                titheklog(debuglevel, "/tmp/movie4k8_line", NULL, line);
930                                       
931                struct tithek* tnode = (struct tithek*)listbox->select->handle;
932                createtithek(tnode, tnode->title,  tmpstr, tnode->pic, tnode->localname, tnode->menutitle, tnode->flag);
933                ret = 0;
934        }
935        return ret;
936}
937
938
939#endif
Note: See TracBrowser for help on using the repository browser.