source: titan/plugins/tithek/tithek.h @ 22215

Last change on this file since 22215 was 22215, checked in by obi, 11 years ago

[titan] add movie4k search

File size: 64.9 KB
Line 
1#ifndef TITHEK_H
2#define TITHEK_H
3
4#define HTTPAUTH "aXBrLUdaRmg6RkhaVkJHaG56ZnZFaEZERlRHenVpZjU2NzZ6aGpHVFVHQk5Iam0="
5
6#define TITHEKPATH "/tmp/tithek"
7int tithekdownloadrun = 0;
8int tithekdownloadcount = 0;
9int tithekrun = 0;
10int tithekexit = 0;
11int tithekmovie4k = 0;
12int tithekkinox = 0;
13int titheksolarmovie = 0;
14int tithekmlehd = 0;
15
16//flag 0        - menu
17//flag 1        - menu pay hidden tithek_pay=0/1 0=hidden
18//flag 2        - http (default streamurl)
19//flag 3        - menu cover
20//flag 4        - youtube
21//flag 5        - rtl2now
22//flag 6        - superrtlnow
23//flag 7        - rtlnow
24//flag 8        - voxnow
25//flag 9        - youtube suche 10
26//flag 10       - youtube suche 25
27//flag 11       - youtube suche 50
28//flag 12       - myvideo
29//flag 13       - myvideo search 50
30//flag 14       - hoster putlocker/sockshare
31//flag 15       - hoster filenuke
32//flag 16       - superrtlnow pay
33//flag 17       - rtlnow pay
34//flag 18       - voxnow pay
35//flag 19       - rtl2now pay
36//flag 20       - hoster StreamCloud
37//flag 21       - kinox search
38//flag 22       - kinox hoster
39//flag 23       - kinox hoster serie
40//flag 24       - hoster flashx
41//flag 25       - hoster vidstream
42//flag 26       - hoster xvidstage
43//flag 27       - hoster nowvideo
44//flag 28       - solarmovie hoster
45//flag 29       - solarmovie search movie
46//flag 30       - solarmovie search serie
47//flag 31       - kinox search cast
48//flag 32       - kinox search cast results
49//flag 33       - movie4k search : serie > open seasons and list episode flag=40 > hoster listed flag=34
50//flag 34       - movie4k hoster de
51//flag 35       - movie4k hoster other
52//flag 36       - movie4k series de > open seasons and list episode flag=39 > hoster listed flag=34
53//flag 37       - movie4k series other > open seasons and list episode flag=39 > hoster listed flag=34
54//flag 38       - mlehd
55//flag 39   - movie4k_hoster_listed
56//flag 40   - movie4k_hoster_series
57
58//flag 50       - beeg
59//flag 66   - coming soon dummy
60//flag 1000 - menu pincode
61//flag 9999 - menu hidden codecpack
62
63struct tithek
64{
65        char* title;
66        char* link;
67        char* pic;
68        char* localname;
69        char* menutitle;       
70        int flag;
71        struct tithek* prev;
72        struct tithek* next;
73};
74struct tithek *tithek = NULL;
75
76
77void freetithekcontent(struct tithek* node)
78{
79        if(node == NULL) return;
80
81        free(node->title); node->title = NULL;
82        node->link = NULL;
83        node->pic = NULL;
84        node->localname = NULL;
85        node->menutitle = NULL;
86        node->flag = 0;
87}
88
89int addtithekcontent(struct tithek* node, char *line, int len, int count, int pay)
90{
91        int ret = 0, i = 0, skip = 0;
92        char* tmpstr = NULL, *flag = NULL, *cmd = NULL, *tmp = NULL;
93        if(node == NULL) return 1;
94
95        if(len > 0) tmpstr = malloc(len + 1);
96        if(tmpstr != NULL)
97        {
98                memcpy(tmpstr, line, len);
99                tmpstr[len] = '\0';
100
101                node->title = tmpstr;
102
103                while(tmpstr[0] != '\0')
104                {
105                        if(tmpstr[0] == '#')
106                        {
107                                tmpstr[0] = '\0';
108                                tmpstr++;
109                                switch(ret)
110                                {
111                                        case 0: node->link = tmpstr; break;
112                                        case 1: node->pic = tmpstr; break;
113                                        case 2: node->localname = tmpstr; break;
114                                        case 3: node->menutitle = tmpstr; break;
115                                        case 4: flag = tmpstr; break;
116                                }
117
118                                ret++;
119                        }
120                        else
121                                tmpstr++;
122                }
123        }
124
125        if(ret != 5)
126        {
127                if(count > 0)
128                {
129                        err("tithek line %d not ok (ret=%d)", count, ret);
130                }
131                else
132                {
133                        err("add tithek (ret=%d)", ret);
134                }
135                freetithekcontent(node);
136                return 1;
137        }
138
139        if(flag != NULL) node->flag = atoi(flag);
140
141        if((node->flag == 9996 || node->flag == 9997 || node->flag == 9998 || node->flag == 9999) && !file_exist("/var/swap/etc/.codecpack"))
142                skip = 1;
143        else if(node->flag == 16 && pay == 0)
144                skip = 1;
145        else if(node->flag == 17 && pay == 0)
146                skip = 1;
147        else if(node->flag == 18 && pay == 0)
148                skip = 1;
149        else if(node->flag == 19 && pay == 0)
150                skip = 1;
151        else if(node->flag == 1 && pay == 0)
152                skip = 1;
153        else if(node->flag == 35 && pay == 0)
154                skip = 1;
155        else if(titheksolarmovie == 1 && node->flag == 9996)
156        {
157                cmd = ostrcat(cmd, "ww", 1, 0);
158                cmd = ostrcat(cmd, "w.sola", 1, 0);
159                cmd = ostrcat(cmd, "rmovi", 1, 0);
160                cmd = ostrcat(cmd, "e.", 1, 0);
161                cmd = ostrcat(cmd, "so", 1, 0);
162               
163                //if(system(cmd) != 0)
164                for(i = 0; i < 3; i++)
165                {
166                        free(tmp); tmp = NULL;
167                        tmp = gethttp(cmd, "/", 80, NULL, NULL, 5000, NULL, 0);
168                        if(tmp != NULL) break;
169                }
170                if(tmp == NULL)
171                        skip = 1;
172
173                titheksolarmovie = 0;
174        }
175        else if(tithekmovie4k == 1 && node->flag == 9997)
176        {
177                cmd = ostrcat(cmd, "ww", 1, 0);
178                cmd = ostrcat(cmd, "w.mov", 1, 0);
179                cmd = ostrcat(cmd, "ie4k", 1, 0);
180                cmd = ostrcat(cmd, ".", 1, 0);
181                cmd = ostrcat(cmd, "to", 1, 0);
182               
183                //if(system(cmd) != 0)
184                for(i = 0; i < 3; i++)
185                {
186                        free(tmp); tmp = NULL;
187                        tmp = gethttp(cmd, "/", 80, NULL, NULL, 5000, NULL, 0);
188                        if(tmp != NULL) break;
189                }
190                if(tmp == NULL)
191                        skip = 1;
192
193                tithekmovie4k = 0;
194        }               
195        else if(tithekmlehd == 1 && node->flag == 9998)
196        {
197                cmd = ostrcat(cmd, "ww", 1, 0);
198                cmd = ostrcat(cmd, "w.mle", 1, 0);
199                cmd = ostrcat(cmd, "-hd", 1, 0);
200                cmd = ostrcat(cmd, ".", 1, 0);
201                cmd = ostrcat(cmd, "se", 1, 0);
202               
203                //if(system(cmd) != 0)
204                for(i = 0; i < 3; i++)
205                {
206                        free(tmp); tmp = NULL;
207                        tmp = gethttp(cmd, "/", 80, NULL, NULL, 5000, NULL, 0);
208                        if(tmp != NULL) break;
209                }
210                if(tmp == NULL)
211                        skip = 1;
212
213                tithekmlehd = 0;
214        }
215        else if(tithekkinox == 1 && node->flag == 9999)
216        {
217                cmd = ostrcat(cmd, "kin", 1, 0);
218                cmd = ostrcat(cmd, "ox", 1, 0);
219                cmd = ostrcat(cmd, ".", 1, 0);
220                cmd = ostrcat(cmd, "to", 1, 0);
221               
222                //if(system(cmd) != 0)
223                for(i = 0; i < 3; i++)
224                {
225                        free(tmp); tmp = NULL;
226                        tmp = gethttp(cmd, "/", 80, NULL, NULL, 5000, NULL, 0);
227                        if(tmp != NULL) break;
228                }
229                if(tmp == NULL)
230                        skip = 1;
231
232                tithekkinox = 0;
233        }
234
235        if(skip == 1)
236        {
237                freetithekcontent(node);
238                return 1;
239        }
240
241        free(tmp); tmp = NULL;
242        free(cmd), cmd = NULL;
243               
244        return 0;
245}
246
247struct tithek* addtithek(char *line, int len, int count, struct tithek* last, int pay)
248{
249        //debug(1000, "in");
250        struct tithek *newnode = NULL, *prev = NULL, *node = NULL;
251        int ret = 0;
252
253        if(line == NULL) return NULL;
254
255        newnode = (struct tithek*)calloc(1, sizeof(struct tithek));
256        if(newnode == NULL)
257        {
258                err("no memory");
259                return NULL;
260        }
261
262        ret = addtithekcontent(newnode, line, len, count, pay);
263        if(ret == 1)
264        {
265                free(newnode);
266                return NULL;
267        }
268
269        node = tithek;
270
271        if(last == NULL)
272        {
273                while(node != NULL)
274                {
275                        prev = node;
276                        node = node->next;
277                }
278        }
279        else
280        {
281                prev = last;
282                node = last->next;
283        }
284
285        if(prev == NULL)
286                tithek = newnode;
287        else
288        {
289                prev->next = newnode;
290                newnode->prev = prev;
291        }
292        newnode->next = node;
293        if(node != NULL) node->prev = newnode;
294
295        //debug(1000, "out");
296        return newnode;
297}
298
299struct tithek* createtithek(struct tithek* update, char* title, char* link, char* pic, char* localname, char* menutitle, int flag)
300{
301        int pay = 0;
302        struct tithek* tnode = NULL;
303        char* tmpstr = NULL;
304       
305        pay = getconfigint("tithek_pay", NULL);
306
307        title = stringreplacechar(title, '#', ' ');
308        link = stringreplacechar(link, '#', ' ');
309        pic = stringreplacechar(pic, '#', ' ');
310        localname = stringreplacechar(localname, '#', ' ');
311        menutitle = stringreplacechar(menutitle, '#', ' ');
312       
313        tmpstr = ostrcat(tmpstr, title, 1, 0);
314        tmpstr = ostrcat(tmpstr, "#", 1, 0);
315        tmpstr = ostrcat(tmpstr, link, 1, 0);
316        tmpstr = ostrcat(tmpstr, "#", 1, 0);
317        tmpstr = ostrcat(tmpstr, pic, 1, 0);
318        tmpstr = ostrcat(tmpstr, "#", 1, 0);
319        tmpstr = ostrcat(tmpstr, localname, 1, 0);
320        tmpstr = ostrcat(tmpstr, "#", 1, 0);
321        tmpstr = ostrcat(tmpstr, menutitle, 1, 0);
322        tmpstr = ostrcat(tmpstr, "#", 1, 0);
323        tmpstr = ostrcat(tmpstr, oitoa(flag), 1, 1);
324
325        tmpstr = string_replace_all("\n", "", tmpstr, 1);
326        tmpstr = string_replace_all("\r", "", tmpstr, 1);
327
328        if(update != NULL)
329        {
330                freetithekcontent(update);
331                addtithekcontent(update, tmpstr, strlen(tmpstr), 1, pay);
332                tnode = update;
333        }
334        else
335                tnode = addtithek(tmpstr, strlen(tmpstr), 1, NULL, pay);
336
337        free(tmpstr);
338
339        return tnode;
340}
341
342int readtithek(const char* filename)
343{
344        debug(1000, "in");
345        FILE *fd = NULL;
346        char *fileline = NULL;
347        int linecount = 0, len = 0, pay = 0;
348        struct tithek* last = NULL, *tmplast = NULL;
349
350        fileline = malloc(MINMALLOC);
351        if(fileline == NULL)
352        {
353                err("no memory");
354                return 1;
355        }
356
357        fd = fopen(filename, "r");
358        if(fd == NULL)
359        {
360                perr("can't open %s", filename);
361                free(fileline);
362                return 1;
363        }
364
365        pay = getconfigint("tithek_pay", NULL);
366
367        while(fgets(fileline, MINMALLOC, fd) != NULL)
368        {
369                if(fileline[0] == '\n')
370                        continue;
371                len = strlen(fileline) - 1;
372                if(fileline[len] == '\n')
373                        fileline[len] = '\0';
374                if(fileline[len - 1] == '\r')
375                        fileline[len - 1] = '\0';
376
377                linecount++;
378
379                if(last == NULL) last = tmplast;
380                last = addtithek(fileline, len + 2, linecount, last, pay);
381                if(last != NULL) tmplast = last;
382        }
383
384        free(fileline);
385        fclose(fd);
386        return linecount;
387}
388
389int deltithek(char* link)
390{
391        debug(1000, "in");
392        int ret = 1;
393
394        struct tithek *node = tithek, *prev = tithek;
395
396        while(node != NULL)
397        {
398                if(ostrcmp(link, node->link) == 0)
399                {
400                        ret = 0;
401                        if(node == tithek)
402                        {
403                                tithek = node->next;
404                                if(tithek != NULL)
405                                        tithek->prev = NULL;
406                        }
407                        else
408                        {
409                                prev->next = node->next;
410                                if(node->next != NULL)
411                                        node->next->prev = prev;
412                        }
413
414                        freetithekcontent(node);
415
416                        free(node);
417                        node = NULL;
418
419                        break;
420                }
421
422                prev = node;
423                node = node->next;
424        }
425
426        debug(1000, "out");
427        return ret;
428}
429
430void freetithek()
431{
432        debug(1000, "in");
433        struct tithek *node = tithek, *prev = tithek;
434
435        while(node != NULL)
436        {
437                prev = node;
438                node = node->next;
439                if(prev != NULL)
440                        deltithek(prev->link);
441        }
442
443        debug(1000, "out");
444}
445
446void tithekdownloadthread(struct stimerthread* timernode, struct download* node, int flag)
447{
448        int defpic = 0;
449
450        tithekdownloadcount++;
451
452        if(node != NULL)
453        {
454                m_lock(&status.tithekmutex, 20);
455                if(file_exist(node->filename))
456                {
457                        m_unlock(&status.tithekmutex, 20);
458                        goto end;
459                }
460
461                FILE *fd; fd = fopen(node->filename, "w");
462                if(fd != NULL) fclose(fd);
463                m_unlock(&status.tithekmutex, 20);
464
465                gethttpreal(node->host, node->page, node->port, node->filename, node->auth, NULL, 0, NULL, NULL, node->timeout, 0);
466
467                if(tithekrun == 0)
468                        unlink(node->filename);
469                else
470                {
471                        //check file size
472                        /*
473                        off64_t checkpic = getfilesize(node->filename);
474                        if(checkpic < 200) defpic = 1;
475                        */
476
477                        //check file is gif or html
478                        if(defpic == 0)
479                        {
480                                char* tmp = NULL;
481                                tmp = readbintomem(node->filename, 3);
482                                if(ostrncmp("GIF", tmp, 3) == 0) defpic = 1; //gif
483                                if(ostrncmp("<", tmp, 1) == 0) defpic = 1; //html
484                                free(tmp); tmp = NULL;
485                        }
486
487                        if(defpic == 1)
488                        {
489                                m_lock(&status.tithekmutex, 20);
490                                unlink(node->filename);
491                                symlink("/var/usr/local/share/titan/plugins/tithek/default.jpg", node->filename);
492                                m_unlock(&status.tithekmutex, 20);
493                        }
494                }
495
496end:
497                free(node->host); node->host = NULL;
498                free(node->page); node->page = NULL;
499                free(node->filename); node->filename = NULL;
500                free(node->auth); node->auth = NULL;
501        }
502
503        free(node); node = NULL;
504
505        tithekdownloadcount--;
506        tithekdownloadrun = 1;
507}
508
509char* tithekdownload(char* link, char* localname, char* pw, int pic, int flag)
510{
511        int ret = 1, port = 80, timeout = 10000;
512        char* ip = NULL, *pos = NULL, *path = NULL;
513        char* tmpstr = NULL, *localfile = NULL;
514
515        if(link == NULL) return NULL;
516
517        ip = string_replace("http://", "", (char*)link, 0);
518        // tithek security
519        ip = string_replace_all("imageshack.us/md/up/grd/", "atemio.dyndns.tv/", ip, 1);
520
521        if(ip != NULL)
522                pos = strchr(ip, '/');
523        if(pos != NULL)
524        {
525                pos[0] = '\0';
526                path = pos + 1;
527        }
528
529        if(ostrstr(ip, ":") != NULL)
530        {
531                ip = oregex("http://(.*):.*", link);
532                port = atoi(oregex("http://.*:(.*)/.*", link));
533        }
534
535        tmpstr = ostrcat(path, NULL, 0, 0);
536
537        if(flag == 0)
538        {
539                localfile = ostrcat(TITHEKPATH, "/", 0, 0);
540                if(localname == NULL)
541                        localfile = ostrcat(localfile, basename(tmpstr), 1, 0);
542                else
543                        localfile = ostrcat(localfile, localname, 1, 0);
544        }
545        else
546        {
547                localfile = ostrcat(getconfig("rec_streampath", NULL), "/", 0, 0);
548                if(localname == NULL)
549                        localfile = ostrcat(localfile, basename(tmpstr), 1, 0);
550                else
551                        localfile = ostrcat(localfile, localname, 1, 0);
552        }
553
554/*
555        debug(99, "---------------------------------------");
556        debug(99, "link: %s", link);
557        debug(99, "localname: %s", localname);
558        debug(99, "---------------------------------------");
559        debug(99, "ip: %s", ip);
560        debug(99, "port: %d", port);
561        debug(99, "path: %s", path);
562        debug(99, "localfile: %s", localfile);
563//      debug(99, "pw: %s", pw);
564        debug(99, "---------------------------------------");
565*/
566        if(flag == 0)
567        {
568                if(localfile != NULL && !file_exist(localfile))
569                {
570                        if(pic == 1)
571                        {
572                                if(tithekdownloadcount >= 24) //start max 24 threads
573                                        gethttp(ip, path, port, localfile, pw, timeout, NULL, 0);
574                                else
575                                {
576                                        //dnode is freed in thread
577                                        struct download* dnode = calloc(1, sizeof(struct download));
578                                        if(dnode != NULL)
579                                        {
580                                                dnode->host = ostrcat(ip, NULL, 0, 0);
581                                                dnode->page = ostrcat(path, NULL, 0, 0);
582                                                dnode->port = port;
583                                                dnode->filename = ostrcat(localfile, NULL, 0, 0);
584                                                dnode->auth = ostrcat(pw, NULL, 0, 0);
585                                                dnode->connfd = -1;
586                                                dnode->ret = -1;
587                                                dnode->timeout = timeout;
588                                                addtimer(&tithekdownloadthread, START, 100, 1, (void*)dnode, NULL, NULL);
589                                        }
590                                }
591                        }
592                        else
593                                gethttp(ip, path, port, localfile, pw, timeout, NULL, 0);                       
594                }
595        }
596        else
597        {
598       
599                if(localfile != NULL && file_exist(localfile))
600                        ret = textbox(_("Message"), _("File exist, overwrite?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
601
602                if(localfile != NULL && ret == 1)
603                        screendownload("Download", ip, path, port, localfile, pw, timeout, 0);
604        }
605
606        free(ip); ip = NULL;
607        free(tmpstr); tmpstr = NULL;
608
609        return localfile;
610}
611
612int createtithekplay(char* titheklink, struct skin* grid, struct skin* listbox, struct skin* countlabel, int flag)
613{
614        int gridbr = 0, posx = 0, count = 0, sumcount = 0, count1 = 0, pagecount = 0, skip = 0;
615        int localfile = 0;
616        struct skin* tmp = NULL;
617        char* tithekfile = NULL;
618        char* tmpstr = NULL;
619
620        if(!ostrncmp("http://", titheklink, 7))
621                tithekfile = tithekdownload(titheklink, NULL, HTTPAUTH, 0, 0);
622        else
623        {
624                tithekfile = ostrcat(titheklink, NULL, 0, 0);
625                localfile = 1;
626        }
627
628        delmarkedscreennodes(grid, 1);
629        freetithek();
630//      if(readtithek(tithekfile) != 0) return 1;
631        int linecount = readtithek(tithekfile);
632//      if(linecount == 0) return 1;
633       
634        struct tithek* titheknode = tithek;
635
636        int height = 500;
637        int width = 590;
638        int picheight = 480;
639        int picwidth = 570;
640        int zcount = 2;
641        int fontsize = 25;
642        int pcount = 2;
643
644        if(getconfigint("tithek_cover", NULL) == 0 || getconfigint("tithek_view", NULL) == 0)
645        {
646                if(linecount > 2)
647                {
648                        height = 280;
649                        width = 390;
650                        picheight = 230;
651                        picwidth = 370;
652                        zcount = 3;
653                        fontsize = 20;
654                        pcount = 6;
655                }
656         
657                if(linecount > 8)
658                {
659                        height = 180;
660                        width = 295;
661                        picheight = 130;
662                        picwidth = 270;
663                        zcount = 4;
664                        fontsize = 18;
665                        pcount = 12;
666                }
667
668                if(linecount > 19)
669                {
670                        height = 140;
671                        width = 235;
672                        picheight = 90;
673                        picwidth = 210;
674                        zcount = 5;
675                        fontsize = 16;
676                        pcount = 20;
677                }
678       
679                if(linecount > 25)
680                {
681                        height = 111;
682                        width = 196;
683                        picheight = 60;
684                        picwidth = 150;
685                        zcount = 6;
686                        fontsize = 14;
687                        pcount = 30;
688                }
689        }
690       
691        if((getconfigint("tithek_cover", NULL) == 1 && flag == 3) || (getconfigint("tithek_view", NULL) == 1 && flag != 3))
692        {
693                height = 500;
694                width = 590;
695                picheight = 480;
696                picwidth = 570;
697                zcount = 2;
698                fontsize = 25;
699                pcount = 2;
700        }
701
702        if((getconfigint("tithek_cover", NULL) == 2 && flag == 3) || (getconfigint("tithek_view", NULL) == 2 && flag != 3))
703        {
704                height = 280;
705                width = 390;
706                picheight = 230;
707                picwidth = 370;
708                zcount = 3;
709                fontsize = 20;
710                pcount = 6;
711        }
712
713        if((getconfigint("tithek_cover", NULL) == 3 && flag == 3) || (getconfigint("tithek_view", NULL) == 3 && flag != 3))
714        {
715                height = 180;
716                width = 295;
717                picheight = 130;
718                picwidth = 270;
719                zcount = 4;
720                fontsize = 18;
721                pcount = 12;
722        }
723
724        if((getconfigint("tithek_cover", NULL) == 4 && flag == 3) || (getconfigint("tithek_view", NULL) == 4 && flag != 3))
725        {
726                height = 140;
727                width = 235;
728                picheight = 90;
729                picwidth = 210;
730                zcount = 5;
731                fontsize = 16;
732                pcount = 20;
733        }
734
735        if((getconfigint("tithek_cover", NULL) == 5 && flag == 3) || (getconfigint("tithek_view", NULL) == 5 && flag != 3))
736        {
737                height = 111;
738                width = 196;
739                picheight = 60;
740                picwidth = 150;
741                zcount = 6;
742                fontsize = 14;
743                pcount = 30;
744        }
745
746        if(getconfigint("tithek_pic_ratio", NULL) == 1)
747        {
748                picwidth = 2;
749                picheight = 2;
750        }
751                       
752        while(titheknode != NULL)
753        {
754                tmp = addlistbox(grid, listbox, tmp, 1);
755                if(tmp != NULL)
756                {
757                        skip = 0;
758                        sumcount++;
759                        count++;
760                        count1++;
761                        if(gridbr == 0)
762                                tmp->type = GRIDBR;
763                        gridbr = 1;
764                        tmp->wrap = YES;
765
766                        tmp->picheight = picheight;
767                        tmp->picwidth = picwidth;
768                                                               
769                        tmp->fontsize = fontsize;
770                        tmp->height = height;
771                        tmp->width = width;
772                        tmp->prozwidth = 0;
773                        //tmp->bgcol = 0xffffff;
774                        tmp->bgspace = 1;
775                        tmp->vspace = 10;
776                        tmp->hspace = 10;
777                        tmp->posx = posx;
778                        //tmp->fontcol = 0x0000ff;
779                        tmp->halign = CENTER;
780                        tmp->valign = TEXTBOTTOM;
781                        changetext(tmp, titheknode->title);
782                        tmp->handle = (char*)titheknode;
783                        posx += tmp->width;
784                        if(count >= zcount)
785                        {
786                                count = 0;
787                                posx = 0;
788                                gridbr = 0;
789                        }
790                       
791                        if(count1 >= pcount)
792                        {
793                                count1 = 0;
794                                pagecount++;
795                                skip = 1;
796                        }
797                }
798                titheknode = titheknode->next;
799        }
800
801        if(skip == 0)
802                pagecount++;
803
804        tmpstr = oitoa(sumcount);
805
806        char* tmpstr1 = ostrcat(_("found"), NULL, 0, 0);
807        tmpstr1 = ostrcat(tmpstr1, " ", 1, 0);
808        tmpstr1 = ostrcat(tmpstr1, tmpstr, 1, 0);
809        free(tmpstr); tmpstr = NULL;
810        tmpstr1 = ostrcat(tmpstr1, " ", 1, 0);
811        tmpstr1 = ostrcat(tmpstr1, _("Results"), 1, 0);
812        changetext(countlabel, tmpstr1);
813        free(tmpstr1); tmpstr1 = NULL;
814
815        if(localfile == 0)
816                unlink(tithekfile);
817       
818        free(tithekfile); tithekfile = NULL;
819        return pagecount;
820}
821
822void removefav(char* title, char* link, char* pic, char* localname, char* menutitle, int flag)
823{
824        int count = 0, i = 0;
825        char* tmpstr = NULL, *tmpstr1 = NULL, *input = NULL;
826        struct splitstr* ret = NULL;
827
828        input = ostrcat(input, title, 1, 0);
829        input = ostrcat(input, "#", 1, 0);
830        input = ostrcat(input, link, 1, 0);
831        input = ostrcat(input, "#", 1, 0);
832        input = ostrcat(input, pic, 1, 0);
833        input = ostrcat(input, "#", 1, 0);
834        input = ostrcat(input, localname, 1, 0);
835        input = ostrcat(input, "#", 1, 0);
836        input = ostrcat(input, menutitle, 1, 0);
837        input = ostrcat(input, "#", 1, 0);
838        input = ostrcat(input, oitoa(flag), 1, 1);
839       
840        tmpstr = readfiletomem(getconfig("tithek_fav", NULL), 0);
841       
842        ret = strsplit(tmpstr, "\n", &count);
843
844        if(ret != NULL)
845        {
846                for(i = 0; i < count; i++)
847                {
848                        if(ostrcmp((ret[i]).part, input) != 0)
849                        {
850                                tmpstr1 = ostrcat(tmpstr1, ret[i].part, 1, 0);
851                                tmpstr1 = ostrcat(tmpstr1, "\n", 1, 0);
852                        }
853                        else
854                                printf("remove: %s\n", ret[i].part);
855                }
856        }
857
858        if(tmpstr1 != NULL && strlen(tmpstr1) > 0)
859                tmpstr1[strlen(tmpstr1) - 1] = '\0';
860
861        if(tmpstr1 == NULL)
862                writesys(getconfig("tithek_fav", NULL), "", 0);
863        else
864                writesys(getconfig("tithek_fav", NULL), tmpstr1, 0);
865
866        free(ret); ret = NULL;
867        free(tmpstr); tmpstr = NULL;
868        free(tmpstr1); tmpstr1 = NULL;
869        free(input); input = NULL;
870}
871
872void addfav(char* title, char* link, char* pic, char* localname, char* menutitle, int flag)
873{
874        int count = 0, i = 0;
875        char* tmpstr = NULL, *tmpstr1 = NULL, *input = NULL;
876        struct splitstr* ret = NULL;
877
878        input = ostrcat(input, title, 1, 0);
879        input = ostrcat(input, "#", 1, 0);
880        input = ostrcat(input, link, 1, 0);
881        input = ostrcat(input, "#", 1, 0);
882        input = ostrcat(input, pic, 1, 0);
883        input = ostrcat(input, "#", 1, 0);
884        input = ostrcat(input, localname, 1, 0);
885        input = ostrcat(input, "#", 1, 0);
886        input = ostrcat(input, menutitle, 1, 0);
887        input = ostrcat(input, "#", 1, 0);
888        input = ostrcat(input, oitoa(flag), 1, 1);
889        // tithek security
890        input = string_replace_all("http://atemio.dyndns.tv/", "http://imageshack.us/md/up/grd/", input, 1);
891       
892        tmpstr1 = ostrcat(tmpstr1, input, 1, 0);
893        tmpstr1 = ostrcat(tmpstr1, "\n", 1, 0);
894
895        tmpstr = readfiletomem(getconfig("tithek_fav", NULL), 0);
896       
897        ret = strsplit(tmpstr, "\n", &count);
898
899        if(ret != NULL)
900        {
901                for(i = 0; i < count; i++)
902                {
903                        if(ostrcmp((ret[i]).part, input) != 0)
904                        {
905                                tmpstr1 = ostrcat(tmpstr1, ret[i].part, 1, 0);
906                                tmpstr1 = ostrcat(tmpstr1, "\n", 1, 0);
907                        }
908                }
909        }
910
911        if(tmpstr1 != NULL && strlen(tmpstr1) > 0)
912                tmpstr1[strlen(tmpstr1) - 1] = '\0';
913
914        writesys(getconfig("tithek_fav", NULL), tmpstr1, 0);
915
916        free(ret); ret = NULL;
917        free(tmpstr); tmpstr = NULL;
918        free(tmpstr1); tmpstr1 = NULL;
919        free(input); input = NULL;
920}
921
922void cacheplay(char* link, char* filename, int flag)
923{
924        struct skin* load = getscreen("loadingproz");
925        struct skin* proztext = getscreennode(load, "proztext");
926
927        drawscreen(load, 0, 0);
928        int port = 80, count = 0, mcount = 0;
929        off64_t size = 0, msize = 0;
930        char* host = NULL, *pos = NULL, *path = NULL, *file = NULL, *tmpstr = NULL;
931        host = string_replace("http://", "", (char*)link, 0);
932
933        if(host != NULL)
934                pos = strchr(host, '/');
935        if(pos != NULL)
936        {
937                pos[0] = '\0';
938                path = pos + 1;
939        }
940
941        file = ostrcat(getconfig("rec_streampath", NULL), "/.cache.", 0, 0);
942        file = ostrcat(file, filename, 1, 0);
943
944        if(ostrstr(host, ":") != NULL)
945        {
946                host = oregex("http://(.*):.*", link);
947                port = atoi(oregex("http://.*:(.*)/.*", link));
948        }
949
950        debug(99, "---------------------------------------");
951        debug(99, "link: %s", link);
952        debug(99, "---------------------------------------");
953        debug(99, "host: %s", host);
954        debug(99, "port: %d", port);
955        debug(99, "path: %s", path);
956        debug(99, "local: %s", file);
957        debug(99, "---------------------------------------");
958       
959       
960        struct download* dnode = NULL;
961        dnode = calloc(1, sizeof(struct download));
962        if(dnode == NULL)
963        {
964                err("no mem");
965                return;
966        }               
967        dnode->host = host;
968        dnode->page = path;
969        dnode->port = port;
970        dnode->filename = file;
971        dnode->auth = NULL;
972        dnode->connfd = -1;
973        dnode->ret = -1;
974        dnode->timeout = 30000;
975       
976        addtimer(&gethttpstruct, START, 1000, 1, (void*)dnode, NULL, NULL);
977
978        if(flag == 1)
979        {
980                mcount = 120;
981                msize = 10485760;
982        }
983        else if(flag == 2)
984        {
985                mcount = 240;
986                msize = 20971520;
987        }
988        else if(flag == 3)
989        {
990                mcount = 360;
991                msize = 31457280;
992        }
993                       
994        while(count < mcount || size >= msize)
995        {
996                sleep(1);
997                count++;
998                if(file_exist(file))
999                        size = getfilesize(file);
1000
1001                int proz = 0;
1002                int proz1 = size * 100 / msize;
1003                debug(99, "size (%dprozent)", proz1);
1004
1005                int proz2 = count * 100 / mcount;
1006                debug(99, "time (%dprozent)", proz2);
1007               
1008                if(proz1 > proz2)
1009                        proz = proz1;
1010                else
1011                        proz = proz2;
1012
1013                debug(99, "cacheing...(%lldkb) (%dprozent)", size / 1024, proz);
1014
1015                if(size >= msize)
1016                        break;
1017                if(count >= mcount)
1018                        break;
1019               
1020                tmpstr = ostrcat(_("please wait..."), " (", 0, 0);
1021                tmpstr = ostrcat(tmpstr, oitoa(proz), 1, 1);
1022                tmpstr = ostrcat(tmpstr, "%)", 1, 0);
1023                clearscreen(load);
1024                changetext(proztext, tmpstr);
1025                drawscreen(load, 0, 0);
1026                free(tmpstr), tmpstr = NULL;
1027        }
1028
1029        screenplay(file, filename, 2, 0);
1030        sockclose(&dnode->connfd);
1031        free(dnode); dnode = NULL;
1032
1033        tmpstr = ostrcat(tmpstr, _("Remove Cachefile ?"), 1, 0);
1034        tmpstr = ostrcat(tmpstr, "\n\n", 1, 0);
1035        tmpstr = ostrcat(tmpstr, file, 1, 0);
1036       
1037        if(textbox(_("Message"), tmpstr, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0) == 1)
1038        {
1039                unlink(file);
1040        }
1041        free(tmpstr), tmpstr = NULL;
1042        free(file), file = NULL;
1043        free(host), host = NULL;
1044}
1045
1046void backgrounddl(char* link, char* filename)
1047{
1048        int port = 80, ret = 0;
1049        char* host = NULL, *pos = NULL, *path = NULL, *file = NULL, *tmpstr = NULL;
1050        host = string_replace("http://", "", (char*)link, 0);
1051
1052        if(host != NULL)
1053                pos = strchr(host, '/');
1054        if(pos != NULL)
1055        {
1056                pos[0] = '\0';
1057                path = pos + 1;
1058        }
1059
1060        file = ostrcat(getconfig("rec_streampath", NULL), "/", 0, 0);
1061        file = ostrcat(file, filename, 1, 0);
1062
1063        if(ostrstr(host, ":") != NULL)
1064        {
1065                host = oregex("http://(.*):.*", link);
1066                port = atoi(oregex("http://.*:(.*)/.*", link));
1067        }
1068
1069        debug(99, "---------------------------------------");
1070        debug(99, "link: %s", link);
1071        debug(99, "---------------------------------------");
1072        debug(99, "host: %s", host);
1073        debug(99, "port: %d", port);
1074        debug(99, "path: %s", path);
1075        debug(99, "local: %s", file);
1076        debug(99, "---------------------------------------");
1077       
1078        ret = startbgdownload(host, path, port, file, NULL, 30000, 1);
1079        if(ret == 1)
1080                textbox(_("Message"), _("Can't start download.\nPlease try later."), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
1081                                       
1082        free(tmpstr), tmpstr = NULL;
1083        free(file), file = NULL;
1084        free(host), host = NULL;
1085}
1086       
1087void submenu(struct skin* listbox, struct skin* load, char* title)
1088{
1089        int flag = 0;
1090        if(status.security == 1 || checkbox("WHITEBOX") == 1)
1091        {
1092                drawscreen(load, 0, 0);
1093                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1094                char* tmpstr1 = NULL;
1095
1096                if(((struct tithek*)listbox->select->handle)->flag == 2)
1097                {
1098                        if(tmpstr != NULL) tmpstr1 = ostrcat(tmpstr, NULL, 0, 0);
1099                }                                               
1100                else if(((struct tithek*)listbox->select->handle)->flag == 4)
1101                {
1102                        if(tmpstr != NULL) tmpstr1 = youtube(tmpstr, NULL, NULL, 1);
1103                }                                               
1104                else if(((struct tithek*)listbox->select->handle)->flag == 5)
1105                {
1106                        if(tmpstr != NULL) tmpstr1 = rtl2now(tmpstr, "http://rtl2now.rtl2.de", "rtl2now", 1);
1107                }
1108                else if(((struct tithek*)listbox->select->handle)->flag == 6)
1109                {
1110                        if(tmpstr != NULL) tmpstr1 = rtl2now(tmpstr, "http://www.superrtlnow.de", "superrtlnow", 1);
1111                }
1112                else if(((struct tithek*)listbox->select->handle)->flag == 7)
1113                {
1114                        if(tmpstr != NULL) tmpstr1 = rtl2now(tmpstr, "http://rtl-now.rtl.de", "rtlnow", 1);
1115                }
1116                else if(((struct tithek*)listbox->select->handle)->flag == 8)
1117                {
1118                        if(tmpstr != NULL) tmpstr1 = rtl2now(tmpstr, "http://www.voxnow.de", "voxnow", 1);
1119                }
1120                else if(((struct tithek*)listbox->select->handle)->flag == 12)
1121                {
1122                        if(tmpstr != NULL) tmpstr1 = myvideo(tmpstr, NULL, NULL, 1);
1123                }
1124                else if(((struct tithek*)listbox->select->handle)->flag == 14)
1125                {
1126                        if(tmpstr != NULL) tmpstr1 = kinox(tmpstr, NULL, NULL, 1);
1127                }
1128                else if(((struct tithek*)listbox->select->handle)->flag == 15)
1129                {
1130                        if(tmpstr != NULL) tmpstr1 = kinox(tmpstr, NULL, NULL, 2);
1131                }
1132                else if(((struct tithek*)listbox->select->handle)->flag == 16)
1133                {
1134                        if(tmpstr != NULL) tmpstr1 = rtl2now(tmpstr, "http://www.superrtlnow.de", "superrtlnow", 1);
1135                }
1136                else if(((struct tithek*)listbox->select->handle)->flag == 17)
1137                {
1138                        if(tmpstr != NULL) tmpstr1 = rtl2now(tmpstr, "http://rtl-now.rtl.de", "rtlnow", 1);
1139                }
1140                else if(((struct tithek*)listbox->select->handle)->flag == 18)
1141                {
1142                        if(tmpstr != NULL) tmpstr1 = rtl2now(tmpstr, "http://www.voxnow.de", "voxnow", 1);
1143                }
1144                else if(((struct tithek*)listbox->select->handle)->flag == 19)
1145                {
1146                        if(tmpstr != NULL) tmpstr1 = rtl2now(tmpstr, "http://rtl2now.rtl2.de", "rtl2now", 1);
1147                }
1148                else if(((struct tithek*)listbox->select->handle)->flag == 20)
1149                {
1150                        if(tmpstr != NULL) tmpstr1 = kinox(tmpstr, NULL, NULL, 3);
1151                }
1152                else if(((struct tithek*)listbox->select->handle)->flag == 24)
1153                {
1154                        if(tmpstr != NULL) tmpstr1 = kinox(tmpstr, NULL, NULL, 4);
1155                }
1156                else if(((struct tithek*)listbox->select->handle)->flag == 25)
1157                {
1158                        if(tmpstr != NULL) tmpstr1 = kinox(tmpstr, NULL, NULL, 5);
1159                }
1160                else if(((struct tithek*)listbox->select->handle)->flag == 26)
1161                {
1162                        if(tmpstr != NULL) tmpstr1 = kinox(tmpstr, NULL, NULL, 6);
1163                }
1164                else if(((struct tithek*)listbox->select->handle)->flag == 27)
1165                {
1166                        if(tmpstr != NULL) tmpstr1 = kinox(tmpstr, NULL, NULL, 7);
1167                }
1168                else if(((struct tithek*)listbox->select->handle)->flag == 38)
1169                {
1170                        if(tmpstr != NULL) tmpstr1 = mlehd(tmpstr);
1171                }
1172                else if(((struct tithek*)listbox->select->handle)->flag == 50)
1173                {
1174                        if(tmpstr != NULL) tmpstr1 = beeg(tmpstr);
1175                }
1176
1177                free(tmpstr); tmpstr = NULL;
1178
1179                if(ostrcmp(title, "TiThek - Internet Radio") == 0)
1180                        flag = 4;
1181
1182                if(tmpstr1 != NULL)
1183                {
1184                        char* filename = ostrcat(title, "_", 0, 0);
1185                        filename = ostrcat(filename, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1186                        filename = ostrcat(filename, ".mp4", 1, 0);
1187                        filename = string_replace_all(" ", ".", filename, 1);
1188                        filename = string_replace_all("-", "_", filename, 1);
1189                        filename = string_replace_all("._.", "_", filename, 1);
1190                        debug(99, "filename: %s", filename);
1191                               
1192                        char* keyconf = NULL;
1193                        char* skintitle = "Choice Playback";
1194                        struct menulist* mlist = NULL, *mbox = NULL;
1195                       
1196                        addmenulist(&mlist, "Streaming Playback (default)", NULL, NULL, 0, 0);
1197                       
1198                        if(!ostrncmp("http://", tmpstr1, 7))
1199                        {
1200                                if(flag == 4)
1201                                {
1202                                        addmenulist(&mlist, "Streaming Playback Caching (0.5MB)", NULL, NULL, 0, 0);
1203                                        addmenulist(&mlist, "Streaming Playback Caching (1MB)", NULL, NULL, 0, 0);
1204                                }       
1205                                else if(!ostrncmp("http://", tmpstr1, 7))
1206                                {
1207//                                      addmenulist(&mlist, "Streaming Playback Caching (1MB)", NULL, NULL, 0, 0);
1208//                                      addmenulist(&mlist, "Streaming Playback Caching (2MB)", NULL, NULL, 0, 0);
1209//                                      addmenulist(&mlist, "Streaming Playback Caching (3MB)", NULL, NULL, 0, 0);
1210//                                      addmenulist(&mlist, "Streaming Playback Caching (4MB)", NULL, NULL, 0, 0);
1211                                        addmenulist(&mlist, "Streaming Playback Caching (5MB)", NULL, NULL, 0, 0);
1212                                        addmenulist(&mlist, "Streaming Playback Caching (7.5MB)", NULL, NULL, 0, 0);
1213                                        addmenulist(&mlist, "Streaming Playback Caching (10MB)", NULL, NULL, 0, 0);
1214                                        if(file_exist(getconfig("rec_streampath", NULL)))
1215                                        {
1216//                                              addmenulist(&mlist, "File Caching Playback (10MB / 120s)", NULL, NULL, 0, 0);
1217//                                              addmenulist(&mlist, "File Caching Playback (20MB / 240s)", NULL, NULL, 0, 0);
1218//                                              addmenulist(&mlist, "File Caching Playback (30MB / 360s)", NULL, NULL, 0, 0);
1219//                                              if(file_exist("/var/swap/etc/.tithekdownload") || status.expertmodus >= 11)
1220                                                if(file_exist("/var/swap/etc/.codecpack"))
1221                                                {
1222                                                        addmenulist(&mlist, "Download Full File", NULL, NULL, 0, 0);
1223                                                        addmenulist(&mlist, "Download Full File (background)", NULL, NULL, 0, 0);
1224                                                }
1225                                        }
1226                                }
1227                        }
1228                        mbox = menulistbox(mlist, NULL, skintitle, NULL, NULL, 1, 0);
1229                        if(mbox != NULL) keyconf = mbox->name;
1230                        if(ostrcmp(keyconf, "Streaming Playback (default)") == 0)
1231                        {
1232                                addconfigtmp("playerbuffersize", "0");
1233                                screenplay(tmpstr1, filename, 2, flag);
1234                                delconfigtmp("playerbuffersize");
1235                        }
1236                        else if(ostrcmp(keyconf, "Streaming Playback Caching (0.5MB)") == 0)
1237                        {
1238                                addconfigtmp("playerbuffersize", "524288");
1239                                screenplay(tmpstr1, filename, 2, flag);
1240                                delconfigtmp("playerbuffersize");
1241                        }
1242                        else if(ostrcmp(keyconf, "Streaming Playback Caching (1MB)") == 0)
1243                        {
1244                                addconfigtmp("playerbuffersize", "1048576");
1245                                screenplay(tmpstr1, filename, 2, flag);
1246                                delconfigtmp("playerbuffersize");
1247                        }
1248                        else if(ostrcmp(keyconf, "Streaming Playback Caching (2MB)") == 0)
1249                        {
1250                                addconfigtmp("playerbuffersize", "2097152");
1251                                screenplay(tmpstr1, filename, 2, flag);
1252                                delconfigtmp("playerbuffersize");
1253                        }
1254                        else if(ostrcmp(keyconf, "Streaming Playback Caching (3MB)") == 0)
1255                        {
1256                                addconfigtmp("playerbuffersize", "3145728");
1257                                screenplay(tmpstr1, filename, 2, flag);
1258                                delconfigtmp("playerbuffersize");
1259                        }
1260                        else if(ostrcmp(keyconf, "Streaming Playback Caching (4MB)") == 0)
1261                        {
1262                                addconfigtmp("playerbuffersize", "4194304");
1263                                screenplay(tmpstr1, filename, 2, flag);
1264                                delconfigtmp("playerbuffersize");
1265                        }
1266                        else if(ostrcmp(keyconf, "Streaming Playback Caching (5MB)") == 0)
1267                        {
1268                                addconfigtmp("playerbuffersize", "5242880");
1269                                screenplay(tmpstr1, filename, 2, flag);
1270                                delconfigtmp("playerbuffersize");
1271                        }
1272                        else if(ostrcmp(keyconf, "Streaming Playback Caching (7.5MB)") == 0)
1273                        {
1274                                addconfigtmp("playerbuffersize", "7864320");
1275                                screenplay(tmpstr1, filename, 2, flag);
1276                                delconfigtmp("playerbuffersize");
1277                        }
1278                        else if(ostrcmp(keyconf, "Streaming Playback Caching (10MB)") == 0)
1279                        {
1280                                addconfigtmp("playerbuffersize", "10485760");
1281                                screenplay(tmpstr1, filename, 2, flag);
1282                                delconfigtmp("playerbuffersize");
1283                        }
1284                        else if(ostrcmp(keyconf, "File Caching Playback (10MB / 120s)") == 0)
1285                        {
1286                                cacheplay(tmpstr1, filename, 1);
1287                        }
1288                        else if(ostrcmp(keyconf, "File Caching Playback (20MB / 240s)") == 0)
1289                        {
1290                                cacheplay(tmpstr1, filename, 2);
1291                        }
1292                        else if(ostrcmp(keyconf, "File Caching Playback (30MB / 360s)") == 0)
1293                        {
1294                                cacheplay(tmpstr1, filename, 3);
1295                        }
1296                        else if(ostrcmp(keyconf, "Download Full File") == 0)
1297                        {
1298                                char* search = textinput("Search", filename);
1299                                if(search != NULL)
1300                                {       
1301                                        char* tmpstr2 = tithekdownload(tmpstr1, search, NULL, 0, 1);
1302//                                              drawscreen(grid, 0, 0);
1303                                        free(tmpstr2); tmpstr2 = NULL;
1304                               
1305                                        if(textbox(_("Message"), _("Start playback"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0) == 1)
1306                                        {
1307                                                tmpstr2 = ostrcat(getconfig("rec_streampath", NULL), "/", 0, 0);
1308                                                tmpstr2 = ostrcat(tmpstr2, search, 1, 0);
1309                                                screenplay(tmpstr2, filename, 2, flag);
1310                                                free(tmpstr2); tmpstr2 = NULL;
1311                                        }
1312                                }
1313                                free(search), search = NULL;
1314                        }
1315                        else if(ostrcmp(keyconf, "Download Full File (background)") == 0)
1316                        {
1317                                char* search = textinput("Search", filename);
1318                                if(search != NULL)
1319                                        backgrounddl(tmpstr1, search);
1320                                free(search), search = NULL;
1321                        }
1322                         
1323                        free(filename), filename = NULL;
1324                        freemenulist(mlist, 1); mlist = NULL;
1325                }
1326                else
1327                        textbox(_("Message"), _("Can't get Streamurl !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
1328               
1329                free(tmpstr1); tmpstr1 = NULL;
1330        }
1331        else
1332                textbox(_("Message"), _("Registration needed, please contact Atemio !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 200, 0, 0);
1333}
1334
1335void screentithekplay(char* titheklink, char* title, int first)
1336{
1337        if(!file_exist("/var/swap/player"))
1338                mkdir("/var/swap/player", 0777);
1339
1340        char* disclaimer = NULL;
1341        disclaimer = ostrcat(disclaimer, "/var/swap/player/tithek_disclaimer_accepted", 1, 0);
1342                               
1343        if(!file_exist(disclaimer))
1344        {
1345                char* tmpstr = gethttp("atemio.dyndns.tv", "/mediathek/disclaimer.txt", 80, NULL, HTTPAUTH, 5000, NULL, 0);
1346                if(textbox(_("TitanNit Tithek disclaimer"), _(tmpstr), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1100, 650, 0, 0) == 1)
1347                {
1348                        writesys(disclaimer, tmpstr, 0);                               
1349                        free(tmpstr), tmpstr = NULL;
1350                }
1351                else
1352                {
1353                        free(tmpstr), tmpstr = NULL;
1354                        free(disclaimer), disclaimer = NULL;
1355                        return;
1356                }
1357        }
1358        free(disclaimer), disclaimer = NULL;
1359
1360        int rcret = -1, oaktline = 1, oaktpage = -1, ogridcol = 0;
1361
1362        writesysint("/proc/sys/vm/drop_caches", 3, 0);
1363       
1364        if(first == 1)
1365        {
1366                delallfiles("/tmp/tithek", NULL);
1367                mkdir("/tmp/tithek", 777);
1368                if(status.mcaktiv == 0)
1369                {
1370                        rcret = servicestop(status.aktservice, 1, 1);
1371                        if(rcret == 1) return;
1372                }
1373        }
1374
1375        struct skin* grid = getscreen("titheklist");
1376        struct skin* listbox = getscreennode(grid, "listbox");
1377        struct skin* countlabel = getscreennode(grid, "countlabel");
1378        struct skin* countpage = getscreennode(grid, "countpage");
1379        struct skin* load = getscreen("loading");
1380        struct skin* tmp = NULL;
1381        char* tithekpic = NULL;
1382        drawscreen(load, 0, 0);
1383       
1384        if(titheklink == NULL) return;
1385       
1386        listbox->aktpage = -1;
1387        listbox->aktline = 1;
1388        listbox->gridcol = 0;
1389        listbox->select = NULL;
1390
1391        int pagecount = createtithekplay(titheklink, grid, listbox, countlabel, first);
1392        if(pagecount == 0) return;
1393
1394        changetitle(grid, _(title));
1395        drawscreen(grid, 0, 0);
1396        addscreenrc(grid, listbox);
1397                               
1398        while(1)
1399        {
1400                changetitle(grid, _(title));
1401                if(listbox->select != NULL && listbox->select->handle != NULL)
1402                {
1403                        tmp = listbox->select;
1404                        while(tmp != NULL)
1405                        {
1406
1407                                if(tmp->pagecount != listbox->aktpage) break;
1408
1409                                char* tmpstr = ostrcat(_("Page"), NULL, 0, 0);
1410                                tmpstr = ostrcat(tmpstr, " ( ", 1, 0);
1411                                tmpstr = ostrcat(tmpstr, oitoa(tmp->pagecount), 1, 1);
1412                                tmpstr = ostrcat(tmpstr, " / ", 1, 0);
1413                                tmpstr = ostrcat(tmpstr, oitoa(pagecount), 1, 1);
1414                                tmpstr = ostrcat(tmpstr, _(" )"), 1, 0);
1415                                changetext(countpage, tmpstr);
1416                                free(tmpstr); tmpstr = NULL;
1417       
1418                                if(tmp->handle != NULL)
1419                                {
1420                                        tithekpic = tithekdownload(((struct tithek*)tmp->handle)->pic, ((struct tithek*)tmp->handle)->localname, "aXBrLUdaRmg6RkhaVkJHaG56ZnZFaEZERlRHenVpZjU2NzZ6aGpHVFVHQk5Iam0=", 1, 0);
1421
1422                                        /* not working with thread download
1423                                        off64_t checkpic = getfilesize(tithekpic);
1424                       
1425                                        if(checkpic < 1000)
1426                                        {
1427                                                free(tithekpic); tithekpic = NULL;
1428                                                tithekpic = ostrcat("/var/usr/local/share/titan/plugins/tithek/default.jpg", NULL, 0, 0);
1429                                        }
1430                                        */
1431                       
1432                                        changepic(tmp, tithekpic);
1433                                        free(tithekpic); tithekpic = NULL;
1434                                }
1435                                tmp = tmp->prev;
1436                        }
1437                        tmp = listbox->select;
1438                        if(tmp != NULL) tmp = tmp->next;
1439                        while(tmp != NULL)
1440                        {
1441                                if(tmp->pagecount != listbox->aktpage) break;
1442                                if(tmp->handle != NULL)
1443                                {
1444                                        tithekpic = tithekdownload(((struct tithek*)tmp->handle)->pic, ((struct tithek*)tmp->handle)->localname, "aXBrLUdaRmg6RkhaVkJHaG56ZnZFaEZERlRHenVpZjU2NzZ6aGpHVFVHQk5Iam0=", 1, 0);
1445
1446                                        /* not working with thread download
1447                                        off64_t checkpic = getfilesize(tithekpic);
1448
1449                                        if(checkpic < 1000)
1450                                        {
1451                                                free(tithekpic); tithekpic = NULL;
1452                                                tithekpic = ostrcat("/var/usr/local/share/titan/plugins/tithek/default.jpg", NULL, 0, 0);
1453                                        }
1454                                        */
1455
1456                                        changepic(tmp, tithekpic);
1457                                        free(tithekpic); tithekpic = NULL;
1458                                }
1459                                tmp = tmp->next;
1460                        }
1461                }
1462               
1463                int count = getfilecount(TITHEKPATH);
1464                if(count > 500)
1465                        delallfiles(TITHEKPATH, ".jpg");
1466
1467                drawscreen(grid, 0, 0);
1468waitrcstart:
1469                rcret = waitrc(grid, 2000, 2);
1470
1471                if(rcret == RCTIMEOUT)
1472                {
1473                        if(tithekdownloadrun == 1)
1474                        {
1475                                tithekdownloadrun = 0;
1476                                drawscreen(grid, 0, 0);
1477                        }
1478                        goto waitrcstart;
1479                }
1480
1481                if(rcret == getrcconfigint("rcblue", NULL))
1482                {
1483                        tithekexit = 1;
1484                        break;
1485                }
1486
1487                if(rcret == getrcconfigint("rcexit", NULL)) break;
1488                if(rcret == getrcconfigint("rcmenu", NULL))
1489                {
1490                        screentithek_settings();
1491
1492                        int pagecount = createtithekplay(titheklink, grid, listbox, countlabel, first);
1493                        if(pagecount == 0 || tithekexit == 1) break;
1494
1495                        listbox->aktpage = oaktpage;
1496                        listbox->aktline = oaktline;
1497                        listbox->gridcol = ogridcol;
1498                        addscreenrc(grid, listbox);
1499                        drawscreen(grid, 0, 0);
1500                }
1501               
1502                if(rcret == getrcconfigint("rcred", NULL))
1503                {
1504                        if(listbox->select != NULL && listbox->select->handle != NULL)
1505                        {
1506
1507                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->title, NULL, 0, 0);
1508                                debug(99, "tmpstr: %s", tmpstr);
1509                                tmpstr = string_replace("-1 (de)", "", tmpstr, 1);
1510                                tmpstr = string_replace("-1 (en)", "", tmpstr, 1);
1511                                tmpstr = string_replace("-1 (\?\?)", "", tmpstr, 1);
1512                                tmpstr = string_replace("-2 (de)", "", tmpstr, 1);
1513                                tmpstr = string_replace("-2 (en)", "", tmpstr, 1);
1514                                tmpstr = string_replace("-2 (\?\?)", "", tmpstr, 1);
1515                                tmpstr = string_replace("-3 (de)", "", tmpstr, 1);
1516                                tmpstr = string_replace("-3 (en)", "", tmpstr, 1);
1517                                tmpstr = string_replace("-3 (\?\?)", "", tmpstr, 1);
1518                                tmpstr = string_replace(" (de)", "", tmpstr, 1);
1519                                tmpstr = string_replace(" (en)", "", tmpstr, 1);
1520                                tmpstr = string_replace(" (\?\?)", "", tmpstr, 1);
1521                                tmpstr = string_replace_all("_", " ", tmpstr, 1);
1522                                tmpstr = string_replace_all("-", " ", tmpstr, 1);
1523                                tmpstr = string_replace_all(".", " ", tmpstr, 1);                               
1524                                debug(99, "tmpstr: %s", tmpstr);
1525
1526                                int check = playrcred(tmpstr, NULL, 1, 0, 99);
1527                                if(check == 2)
1528                                {
1529                                        if(kinox_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, "KinoX - Search", tmpstr, 0) == 0)
1530                                        {
1531                                                oaktpage = listbox->aktpage;
1532                                                oaktline = listbox->aktline;
1533                                                ogridcol = listbox->gridcol;
1534                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1535                                                char* tmpstr1 = ostrcat("KinoX - Search", " - ", 0, 0);
1536                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1537                                                screentithekplay(tmpstr, tmpstr2, 0);
1538                                                free(tmpstr); tmpstr = NULL;
1539                                                free(tmpstr2); tmpstr2 = NULL;
1540                       
1541                                                int pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1542                                                if(pagecount == 0 || tithekexit == 1) break;
1543
1544                                                listbox->aktpage = oaktpage;
1545                                                listbox->aktline = oaktline;
1546                                                listbox->gridcol = ogridcol;
1547                                                addscreenrc(grid, listbox);
1548                                        }
1549                                }
1550                                else if(check == 3)
1551                                {
1552                                        if(solarmovie_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, "SolarMovies - Movie - Search", tmpstr, 0) == 0)
1553                                        {
1554                                                oaktpage = listbox->aktpage;
1555                                                oaktline = listbox->aktline;
1556                                                ogridcol = listbox->gridcol;
1557                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1558                                                char* tmpstr1 = ostrcat("SolarMovies - Movie - Search", " - ", 0, 0);
1559                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1560                                                screentithekplay(tmpstr, tmpstr2, 0);
1561                                                free(tmpstr); tmpstr = NULL;
1562                                                free(tmpstr2); tmpstr2 = NULL;
1563                       
1564                                                int pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1565                                                if(pagecount == 0 || tithekexit == 1) break;
1566
1567                                                listbox->aktpage = oaktpage;
1568                                                listbox->aktline = oaktline;
1569                                                listbox->gridcol = ogridcol;
1570                                                addscreenrc(grid, listbox);
1571                                        }
1572                                }
1573                                else if(check == 4)
1574                                {
1575                                        if(solarmovie_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, "SolarMovies - Tv - Search", tmpstr, 1) == 0)
1576                                        {
1577                                                oaktpage = listbox->aktpage;
1578                                                oaktline = listbox->aktline;
1579                                                ogridcol = listbox->gridcol;
1580                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1581                                                char* tmpstr1 = ostrcat("SolarMovies - Tv - Search", " - ", 0, 0);
1582                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1583                                                screentithekplay(tmpstr, tmpstr2, 0);
1584                                                free(tmpstr); tmpstr = NULL;
1585                                                free(tmpstr2); tmpstr2 = NULL;
1586                       
1587                                                int pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1588                                                if(pagecount == 0 || tithekexit == 1) break;
1589
1590                                                listbox->aktpage = oaktpage;
1591                                                listbox->aktline = oaktline;
1592                                                listbox->gridcol = ogridcol;
1593                                                addscreenrc(grid, listbox);
1594                                        }
1595                                }
1596                                else if(check == 5)
1597                                {
1598                                        if(youtube_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, "Youtube - Search", tmpstr) == 0)
1599                                        {
1600                                                oaktpage = listbox->aktpage;
1601                                                oaktline = listbox->aktline;
1602                                                ogridcol = listbox->gridcol;
1603                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1604                                                char* tmpstr1 = ostrcat("Youtube - Search", " - ", 0, 0);
1605                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1606                                                screentithekplay(tmpstr, tmpstr2, 0);
1607                                                free(tmpstr); tmpstr = NULL;
1608                                                free(tmpstr2); tmpstr2 = NULL;
1609                       
1610                                                int pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1611                                                if(pagecount == 0 || tithekexit == 1) break;
1612
1613                                                listbox->aktpage = oaktpage;
1614                                                listbox->aktline = oaktline;
1615                                                listbox->gridcol = ogridcol;
1616                                                addscreenrc(grid, listbox);
1617                                        }
1618                                }
1619                                else if((((struct tithek*)listbox->select->handle)->flag == 13))
1620                                {
1621                                        if(myvideo_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, "MyVideo - Search", tmpstr) == 0)
1622                                        {
1623                                                oaktpage = listbox->aktpage;
1624                                                oaktline = listbox->aktline;
1625                                                ogridcol = listbox->gridcol;
1626                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1627                                                char* tmpstr1 = ostrcat("MyVideo - Search", " - ", 0, 0);
1628                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1629                                                screentithekplay(tmpstr, tmpstr2, 0);
1630                                                free(tmpstr); tmpstr = NULL;
1631                                                free(tmpstr2); tmpstr2 = NULL;
1632                       
1633                                                int pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1634                                                if(pagecount == 0 || tithekexit == 1) break;
1635
1636                                                listbox->aktpage = oaktpage;
1637                                                listbox->aktline = oaktline;
1638                                                listbox->gridcol = ogridcol;
1639                                                addscreenrc(grid, listbox);
1640                                        }
1641                                }
1642
1643                                free(tmpstr), tmpstr = NULL;
1644                        }
1645                }
1646                else if(rcret == getrcconfigint("rcok", NULL))
1647                {
1648                        if(listbox->select != NULL && listbox->select->handle != NULL)
1649                        {
1650                                clearscreen(grid);
1651
1652                                if((((struct tithek*)listbox->select->handle)->flag == 2) || (((struct tithek*)listbox->select->handle)->flag == 4) || (((struct tithek*)listbox->select->handle)->flag == 5) || (((struct tithek*)listbox->select->handle)->flag == 6) || (((struct tithek*)listbox->select->handle)->flag == 7) || (((struct tithek*)listbox->select->handle)->flag == 8) || (((struct tithek*)listbox->select->handle)->flag == 12) || (((struct tithek*)listbox->select->handle)->flag == 14) || (((struct tithek*)listbox->select->handle)->flag == 15) || (((struct tithek*)listbox->select->handle)->flag == 16) || (((struct tithek*)listbox->select->handle)->flag == 17) || (((struct tithek*)listbox->select->handle)->flag == 18) || (((struct tithek*)listbox->select->handle)->flag == 19) || (((struct tithek*)listbox->select->handle)->flag == 20) || (((struct tithek*)listbox->select->handle)->flag == 24) || (((struct tithek*)listbox->select->handle)->flag == 25) || (((struct tithek*)listbox->select->handle)->flag == 26) || (((struct tithek*)listbox->select->handle)->flag == 27) || (((struct tithek*)listbox->select->handle)->flag == 38) || (((struct tithek*)listbox->select->handle)->flag == 50))
1653                                {
1654                                        submenu(listbox, load, title);
1655                                        drawscreen(grid, 0, 0);
1656                                }
1657                                else if((((struct tithek*)listbox->select->handle)->flag == 9) || (((struct tithek*)listbox->select->handle)->flag == 10) || (((struct tithek*)listbox->select->handle)->flag == 11))
1658                                {
1659                                        if(youtube_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL) == 0)
1660                                        {
1661                                                oaktpage = listbox->aktpage;
1662                                                oaktline = listbox->aktline;
1663                                                ogridcol = listbox->gridcol;
1664                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1665                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
1666                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1667                                                screentithekplay(tmpstr, tmpstr2, 0);
1668                                                free(tmpstr); tmpstr = NULL;
1669                                                free(tmpstr2); tmpstr2 = NULL;
1670                       
1671                                                int pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1672                                                if(pagecount == 0 || tithekexit == 1) break;
1673
1674                                                listbox->aktpage = oaktpage;
1675                                                listbox->aktline = oaktline;
1676                                                listbox->gridcol = ogridcol;
1677                                                addscreenrc(grid, listbox);
1678                                        }
1679                                }
1680                                else if((((struct tithek*)listbox->select->handle)->flag == 13))
1681                                {
1682                                        if(myvideo_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL) == 0)
1683                                        {
1684                                                oaktpage = listbox->aktpage;
1685                                                oaktline = listbox->aktline;
1686                                                ogridcol = listbox->gridcol;
1687                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1688                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
1689                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1690                                                screentithekplay(tmpstr, tmpstr2, 0);
1691                                                free(tmpstr); tmpstr = NULL;
1692                                                free(tmpstr2); tmpstr2 = NULL;
1693                       
1694                                                int pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1695                                                if(pagecount == 0 || tithekexit == 1) break;
1696
1697                                                listbox->aktpage = oaktpage;
1698                                                listbox->aktline = oaktline;
1699                                                listbox->gridcol = ogridcol;
1700                                                addscreenrc(grid, listbox);
1701                                        }
1702                                }
1703                                else if((((struct tithek*)listbox->select->handle)->flag == 21))
1704                                {
1705                                        if(kinox_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL, 0) == 0)
1706                                        {
1707                                                oaktpage = listbox->aktpage;
1708                                                oaktline = listbox->aktline;
1709                                                ogridcol = listbox->gridcol;
1710                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1711                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
1712                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1713                                                screentithekplay(tmpstr, tmpstr2, 0);
1714                                                free(tmpstr); tmpstr = NULL;
1715                                                free(tmpstr2); tmpstr2 = NULL;
1716
1717                                                int pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1718                                                if(pagecount == 0 || tithekexit == 1) break;
1719
1720                                                listbox->aktpage = oaktpage;
1721                                                listbox->aktline = oaktline;
1722                                                listbox->gridcol = ogridcol;
1723                                                addscreenrc(grid, listbox);
1724                                        }
1725                                }
1726                                else if((((struct tithek*)listbox->select->handle)->flag == 33))
1727                                {
1728                                        if(movie4k_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL, 0) == 0)
1729                                        {
1730                                                oaktpage = listbox->aktpage;
1731                                                oaktline = listbox->aktline;
1732                                                ogridcol = listbox->gridcol;
1733                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1734                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
1735                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1736                                                screentithekplay(tmpstr, tmpstr2, 0);
1737                                                free(tmpstr); tmpstr = NULL;
1738                                                free(tmpstr2); tmpstr2 = NULL;
1739
1740                                                int pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1741                                                if(pagecount == 0 || tithekexit == 1) break;
1742
1743                                                listbox->aktpage = oaktpage;
1744                                                listbox->aktline = oaktline;
1745                                                listbox->gridcol = ogridcol;
1746                                                addscreenrc(grid, listbox);
1747                                        }
1748                                }                               
1749                                else if(((struct tithek*)listbox->select->handle)->flag == 29)
1750                                {
1751                                        if(solarmovie_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL, 0) == 0)
1752                                        {
1753                                                oaktpage = listbox->aktpage;
1754                                                oaktline = listbox->aktline;
1755                                                ogridcol = listbox->gridcol;
1756                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1757                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
1758                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1759                                                screentithekplay(tmpstr, tmpstr2, 0);
1760                                                free(tmpstr); tmpstr = NULL;
1761                                                free(tmpstr2); tmpstr2 = NULL;
1762
1763                                                int pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1764                                                if(pagecount == 0 || tithekexit == 1) break;
1765
1766                                                listbox->aktpage = oaktpage;
1767                                                listbox->aktline = oaktline;
1768                                                listbox->gridcol = ogridcol;
1769                                                addscreenrc(grid, listbox);
1770                                        }
1771                                }
1772                                else if(((struct tithek*)listbox->select->handle)->flag == 30)
1773                                {
1774                                        if(solarmovie_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL, 1) == 0)
1775                                        {
1776                                                oaktpage = listbox->aktpage;
1777                                                oaktline = listbox->aktline;
1778                                                ogridcol = listbox->gridcol;
1779                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1780                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
1781                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1782                                                screentithekplay(tmpstr, tmpstr2, 0);
1783                                                free(tmpstr); tmpstr = NULL;
1784                                                free(tmpstr2); tmpstr2 = NULL;
1785
1786                                                int pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1787                                                if(pagecount == 0 || tithekexit == 1) break;
1788
1789                                                listbox->aktpage = oaktpage;
1790                                                listbox->aktline = oaktline;
1791                                                listbox->gridcol = ogridcol;
1792                                                addscreenrc(grid, listbox);
1793                                        }
1794                                }
1795                                else if((((struct tithek*)listbox->select->handle)->flag == 31))
1796                                {
1797                                        if(kinox_search_cast(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL) == 0)
1798                                        {
1799                                                oaktpage = listbox->aktpage;
1800                                                oaktline = listbox->aktline;
1801                                                ogridcol = listbox->gridcol;
1802                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1803                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
1804                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1805                                                screentithekplay(tmpstr, tmpstr2, 0);
1806                                                free(tmpstr); tmpstr = NULL;
1807                                                free(tmpstr2); tmpstr2 = NULL;
1808
1809                                                int pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1810                                                if(pagecount == 0 || tithekexit == 1) break;
1811
1812                                                listbox->aktpage = oaktpage;
1813                                                listbox->aktline = oaktline;
1814                                                listbox->gridcol = ogridcol;
1815                                                addscreenrc(grid, listbox);
1816                                        }
1817                                }
1818                                else if((((struct tithek*)listbox->select->handle)->flag == 32))
1819                                {
1820                                        if(kinox_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL, 1) == 0)
1821                                        {
1822                                                oaktpage = listbox->aktpage;
1823                                                oaktline = listbox->aktline;
1824                                                ogridcol = listbox->gridcol;
1825                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1826                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
1827                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1828                                                screentithekplay(tmpstr, tmpstr2, 0);
1829                                                free(tmpstr); tmpstr = NULL;
1830                                                free(tmpstr2); tmpstr2 = NULL;
1831
1832                                                int pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1833                                                if(pagecount == 0 || tithekexit == 1) break;
1834
1835                                                listbox->aktpage = oaktpage;
1836                                                listbox->aktline = oaktline;
1837                                                listbox->gridcol = ogridcol;
1838                                                addscreenrc(grid, listbox);
1839                                        }
1840                                }
1841                                else if((((struct tithek*)listbox->select->handle)->flag == 33))
1842                                {
1843                                        if(movie4k_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL, 1) == 0)
1844                                        {
1845                                                oaktpage = listbox->aktpage;
1846                                                oaktline = listbox->aktline;
1847                                                ogridcol = listbox->gridcol;
1848                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1849                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
1850                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1851                                                screentithekplay(tmpstr, tmpstr2, 0);
1852                                                free(tmpstr); tmpstr = NULL;
1853                                                free(tmpstr2); tmpstr2 = NULL;
1854
1855                                                int pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 3);
1856                                                if(pagecount == 0 || tithekexit == 1) break;
1857
1858                                                listbox->aktpage = oaktpage;
1859                                                listbox->aktline = oaktline;
1860                                                listbox->gridcol = ogridcol;
1861                                                addscreenrc(grid, listbox);
1862                                        }
1863                                }
1864                                else if((((struct tithek*)listbox->select->handle)->flag == 34) || (((struct tithek*)listbox->select->handle)->flag == 35))
1865                                {
1866                                        if(movie4k_hoster(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title) == 0)
1867                                        {
1868                                                oaktpage = listbox->aktpage;
1869                                                oaktline = listbox->aktline;
1870                                                ogridcol = listbox->gridcol;
1871                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1872                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
1873                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1874                                                screentithekplay(tmpstr, tmpstr2, 0);
1875                                                free(tmpstr); tmpstr = NULL;
1876                                                free(tmpstr2); tmpstr2 = NULL;
1877
1878                                                int pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1879                                                if(pagecount == 0 || tithekexit == 1) break;
1880
1881                                                listbox->aktpage = oaktpage;
1882                                                listbox->aktline = oaktline;
1883                                                listbox->gridcol = ogridcol;
1884                                                addscreenrc(grid, listbox);
1885                                        }
1886                                }
1887                                else if((((struct tithek*)listbox->select->handle)->flag == 22))
1888                                {
1889                                        if(kinox_hoster(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title) == 0)
1890                                        {
1891                                                oaktpage = listbox->aktpage;
1892                                                oaktline = listbox->aktline;
1893                                                ogridcol = listbox->gridcol;
1894                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1895                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
1896                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1897                                                screentithekplay(tmpstr, tmpstr2, 0);
1898                                                free(tmpstr); tmpstr = NULL;
1899                                                free(tmpstr2); tmpstr2 = NULL;
1900
1901                                                int pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 3);
1902                                                if(pagecount == 0 || tithekexit == 1) break;
1903
1904                                                listbox->aktpage = oaktpage;
1905                                                listbox->aktline = oaktline;
1906                                                listbox->gridcol = ogridcol;
1907                                                addscreenrc(grid, listbox);
1908                                        }
1909                                }
1910                                else if((((struct tithek*)listbox->select->handle)->flag == 28))
1911                                {
1912                                        if(solarmovie_hoster(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title) == 0)
1913                                        {
1914                                                oaktpage = listbox->aktpage;
1915                                                oaktline = listbox->aktline;
1916                                                ogridcol = listbox->gridcol;
1917                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1918                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
1919                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1920                                                screentithekplay(tmpstr, tmpstr2, 0);
1921                                                free(tmpstr); tmpstr = NULL;
1922                                                free(tmpstr2); tmpstr2 = NULL;
1923                       
1924                                                int pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 3);
1925                                                if(pagecount == 0 || tithekexit == 1) break;
1926
1927                                                listbox->aktpage = oaktpage;
1928                                                listbox->aktline = oaktline;
1929                                                listbox->gridcol = ogridcol;
1930                                                addscreenrc(grid, listbox);
1931                                        }
1932                                }
1933                                else if((((struct tithek*)listbox->select->handle)->flag == 23))
1934                                {
1935                                        if(kinox_hoster_series(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title) == 0)
1936                                        {
1937                                                oaktpage = listbox->aktpage;
1938                                                oaktline = listbox->aktline;
1939                                                ogridcol = listbox->gridcol;
1940                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1941                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
1942                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1943                                                screentithekplay(tmpstr, tmpstr2, 0);
1944                                                free(tmpstr); tmpstr = NULL;
1945                                                free(tmpstr2); tmpstr2 = NULL;
1946                       
1947                                                int pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1948                                                if(pagecount == 0 || tithekexit == 1) break;
1949
1950                                                listbox->aktpage = oaktpage;
1951                                                listbox->aktline = oaktline;
1952                                                listbox->gridcol = ogridcol;
1953                                                addscreenrc(grid, listbox);
1954                                        }
1955                                }
1956                                else if((((struct tithek*)listbox->select->handle)->flag == 36) || (((struct tithek*)listbox->select->handle)->flag == 37))
1957                                {
1958                                        if(movie4k_series(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title) == 0)
1959                                        {
1960                                                oaktpage = listbox->aktpage;
1961                                                oaktline = listbox->aktline;
1962                                                ogridcol = listbox->gridcol;
1963                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1964                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
1965                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1966                                                screentithekplay(tmpstr, tmpstr2, 0);
1967                                                free(tmpstr); tmpstr = NULL;
1968                                                free(tmpstr2); tmpstr2 = NULL;
1969                       
1970                                                int pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1971                                                if(pagecount == 0 || tithekexit == 1) break;
1972
1973                                                listbox->aktpage = oaktpage;
1974                                                listbox->aktline = oaktline;
1975                                                listbox->gridcol = ogridcol;
1976                                                addscreenrc(grid, listbox);
1977                                        }
1978                                }
1979                                else if((((struct tithek*)listbox->select->handle)->flag == 39))
1980                                {
1981                                        if(movie4k_series_listed(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title) == 0)
1982                                        {
1983                                                oaktpage = listbox->aktpage;
1984                                                oaktline = listbox->aktline;
1985                                                ogridcol = listbox->gridcol;
1986                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1987                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
1988                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1989                                                screentithekplay(tmpstr, tmpstr2, 0);
1990                                                free(tmpstr); tmpstr = NULL;
1991                                                free(tmpstr2); tmpstr2 = NULL;
1992                       
1993                                                int pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1994                                                if(pagecount == 0 || tithekexit == 1) break;
1995
1996                                                listbox->aktpage = oaktpage;
1997                                                listbox->aktline = oaktline;
1998                                                listbox->gridcol = ogridcol;
1999                                                addscreenrc(grid, listbox);
2000                                        }
2001                                }
2002                                else if((((struct tithek*)listbox->select->handle)->flag == 40))
2003                                {
2004                                        if(movie4k_hoster_series(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title) == 0)
2005                                        {
2006                                                oaktpage = listbox->aktpage;
2007                                                oaktline = listbox->aktline;
2008                                                ogridcol = listbox->gridcol;
2009                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
2010                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
2011                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
2012                                                screentithekplay(tmpstr, tmpstr2, 0);
2013                                                free(tmpstr); tmpstr = NULL;
2014                                                free(tmpstr2); tmpstr2 = NULL;
2015                       
2016                                                int pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
2017                                                if(pagecount == 0 || tithekexit == 1) break;
2018
2019                                                listbox->aktpage = oaktpage;
2020                                                listbox->aktline = oaktline;
2021                                                listbox->gridcol = ogridcol;
2022                                                addscreenrc(grid, listbox);
2023                                        }
2024                                }
2025                                else if((((struct tithek*)listbox->select->handle)->flag == 66))
2026                                {
2027                                        textbox(_("Message"), _("The hoster is not yet supported for the time !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 5, 0);
2028                                        continue;
2029                                }       
2030                                else if((((struct tithek*)listbox->select->handle)->flag == 3))
2031                                {
2032                                        int pincheck = 0;
2033                                        if(((struct tithek*)listbox->select->handle)->flag == 1000)
2034                                                pincheck = screenpincheck(0, NULL);
2035                                        if(pincheck == 0)
2036                                        {
2037                                                oaktpage = listbox->aktpage;
2038                                                oaktline = listbox->aktline;
2039                                                ogridcol = listbox->gridcol;
2040                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
2041                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);                                     
2042                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
2043                                                screentithekplay(tmpstr, tmpstr2, 3);
2044                                                free(tmpstr); tmpstr = NULL;
2045                                                free(tmpstr2); tmpstr2 = NULL; 
2046
2047                                                int pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
2048                                                if(pagecount == 0 || tithekexit == 1) break;
2049
2050                                                listbox->aktpage = oaktpage;
2051                                                listbox->aktline = oaktline;
2052                                                listbox->gridcol = ogridcol;
2053                                                addscreenrc(grid, listbox);
2054                                        }
2055                                }
2056                                else
2057                                {
2058                                        int pincheck = 0;
2059                                        if(((struct tithek*)listbox->select->handle)->flag == 1000)
2060                                                pincheck = screenpincheck(0, NULL);
2061                                        if(pincheck == 0)
2062                                        {
2063                                                oaktpage = listbox->aktpage;
2064                                                oaktline = listbox->aktline;
2065                                                ogridcol = listbox->gridcol;
2066                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
2067                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);                                     
2068                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
2069                                                screentithekplay(tmpstr, tmpstr2, 0);
2070                                                free(tmpstr); tmpstr = NULL;
2071                                                free(tmpstr2); tmpstr2 = NULL; 
2072
2073                                                int pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
2074                                                if(pagecount == 0 || tithekexit == 1) break;
2075
2076                                                listbox->aktpage = oaktpage;
2077                                                listbox->aktline = oaktline;
2078                                                listbox->gridcol = ogridcol;
2079                                                addscreenrc(grid, listbox);
2080                                        }
2081                                }
2082                                drawscreen(grid, 0, 0);
2083//                              sleep(1);
2084                        }                       
2085                }
2086                else if(rcret == getrcconfigint("rcyellow", NULL) && ostrcmp(title, "TiThek - Favoriten") == 0)
2087                {
2088                        if(textbox(_("Message"), _("Remove this Favorite ?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 5, 0) == 1)
2089                        {
2090                                removefav(((struct tithek*)listbox->select->handle)->title, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->pic, ((struct tithek*)listbox->select->handle)->localname, ((struct tithek*)listbox->select->handle)->menutitle, ((struct tithek*)listbox->select->handle)->flag);             
2091                                int pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
2092                                if(pagecount == 0) return;
2093                                       
2094                                drawscreen(grid, 0, 0);
2095                        }
2096                }
2097                else if(rcret == getrcconfigint("rcgreen", NULL) && ostrcmp(title, "TiThek - Favoriten") != 0)
2098                {
2099                        if(textbox(_("Message"), _("Add this link as Favorite ?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 5, 0) == 1)
2100                        {
2101                                addfav(((struct tithek*)listbox->select->handle)->title, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->pic, ((struct tithek*)listbox->select->handle)->localname, ((struct tithek*)listbox->select->handle)->menutitle, ((struct tithek*)listbox->select->handle)->flag);         
2102                        }
2103                }
2104        }
2105
2106        delmarkedscreennodes(grid, 1);
2107        delownerrc(grid);
2108        clearscreen(grid);
2109
2110        if(first == 1)
2111        {
2112                freetithek();
2113                delallfiles("/tmp/tithek", ".list");
2114                if(status.mcaktiv == 0)
2115                        servicecheckret(servicestart(status.lastservice->channel, NULL, NULL, 0), 0);
2116        }
2117}
2118
2119#endif
Note: See TracBrowser for help on using the repository browser.