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

Last change on this file since 36938 was 36938, checked in by obi, 7 years ago

tithek fix https

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