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

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

update tithek

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