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

Last change on this file since 41274 was 41274, checked in by obi, 6 years ago

update tithel add hoster streamlist

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