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

Last change on this file since 19468 was 19468, checked in by nit, 11 years ago

[titan] optimize

File size: 29.8 KB
Line 
1#ifndef TITHEK_H
2#define TITHEK_H
3
4#define TITHEKPATH "/tmp/tithek"
5
6//flag 0        - menu
7//flag 1        - menu pay hidden tithek_pay=0/1 0=hidden
8//flag 2        - http (default streamurl)
9//flag 4        - youtube
10//flag 5        - rtl2now
11//flag 6        - superrtlnow
12//flag 7        - rtlnow
13//flag 8        - voxnow
14//flag 9        - youtube suche 10
15//flag 10       - youtube suche 25
16//flag 11       - youtube suche 50
17//flag 12       - myvideo
18//flag 13       - myvideo search 50
19//flag 14       - kinox putlocker/sockshare
20//flag 15       - kinox filenuke
21//flag 16       - superrtlnow pay
22//flag 17       - rtlnow pay
23//flag 18       - voxnow pay
24//flag 19       - rtl2now pay
25//flag 20       - kinox StreamCloud
26//flag 21       - kinox search
27//flag 22       - kinox hoster
28//flag 23       - kinox hoster serie
29//flag 66   - coming soon dummy
30//flag 1000 - menu pincode
31//flag 9999 - menu hidden codecpack
32
33struct tithek
34{
35        char* title;
36        char* link;
37        char* pic;
38        char* localname;
39        char* menutitle;       
40        int flag;
41        struct tithek* prev;
42        struct tithek* next;
43};
44struct tithek *tithek = NULL;
45
46struct tithek* addtithek(char *line, int count, struct tithek* last)
47{
48        //debug(1000, "in");
49        struct tithek *newnode = NULL, *prev = NULL, *node = tithek;
50        char *link = NULL, *pic = NULL, *title = NULL, *localname = NULL, *menutitle = NULL, *cmd = NULL;
51        int ret = 0, skip = 0, i = 0;
52
53        if(line == NULL) return NULL;
54
55        newnode = (struct tithek*)calloc(1, sizeof(struct tithek));
56        if(newnode == NULL)
57        {
58                err("no memory");
59                return NULL;
60        }
61
62        link = malloc(MINMALLOC);
63        if(link == NULL)
64        {
65                err("no memory");
66                free(newnode);
67                return NULL;
68        }
69
70        pic = malloc(MINMALLOC);
71        if(pic == NULL)
72        {
73                err("no memory");
74                free(newnode);
75                free(link);
76                return NULL;
77        }
78
79        title = malloc(MINMALLOC);
80        if(title == NULL)
81        {
82                err("no memory");
83                free(newnode);
84                free(link);
85                free(pic);
86                return NULL;
87        }
88
89        localname = malloc(MINMALLOC);
90        if(localname == NULL)
91        {
92                err("no memory");
93                free(newnode);
94                free(link);
95                free(pic);
96                free(title);
97                return NULL;
98        }
99
100        menutitle = malloc(MINMALLOC);
101        if(menutitle == NULL)
102        {
103                err("no memory");
104                free(newnode);
105                free(link);
106                free(pic);
107                free(title);
108                free(localname);               
109                return NULL;
110        }
111
112        int pay = getconfigint("tithek_pay", NULL);
113
114        ret = sscanf(line, "%[^#]#%[^#]#%[^#]#%[^#]#%[^#]#%d", title, link, pic, localname, menutitle, &newnode->flag);
115                               
116        if(newnode->flag == 9999 && !file_exist("/var/swap/etc/.codecpack"))
117                skip = 1;
118        else if(newnode->flag == 16 && pay == 0)
119                skip = 1;
120        else if(newnode->flag == 17 && pay == 0)
121                skip = 1;
122        else if(newnode->flag == 18 && pay == 0)
123                skip = 1;
124        else if(newnode->flag == 19 && pay == 0)
125                skip = 1;
126        else if(newnode->flag == 1 && pay == 0)
127                skip = 1;
128        else if(newnode->flag == 9999)
129        {
130                char* tmp = NULL;
131
132                //cmd = ostrcat(cmd, "wget -s http://", 1, 0);
133                cmd = ostrcat(cmd, "kin", 1, 0);
134                cmd = ostrcat(cmd, "ox", 1, 0);
135                cmd = ostrcat(cmd, ".", 1, 0);
136                cmd = ostrcat(cmd, "to", 1, 0);
137
138                //if(system(cmd) != 0)
139                for(i = 0; i < 3; i++)
140                {
141                        free(tmp); tmp = NULL;
142                        tmp = gethttp(cmd, "/", 80, NULL, NULL, NULL, 0);
143                        if(tmp != NULL) break;
144                }
145                if(tmp == NULL)
146                        skip = 1;
147
148                free(tmp); tmp = NULL;
149                free(cmd), cmd = NULL;
150        }
151
152        if(skip == 1)
153        {
154                free(link);
155                free(pic);
156                free(title);
157                free(localname);
158                free(menutitle);
159                free(newnode);
160                return NULL;
161        }
162
163        if(ret != 6)
164        {
165                if(count > 0)
166                {
167                        err("tithek line %d not ok or double", count);
168                }
169                else
170                {
171                        err("add tithek");
172                }
173                free(link);
174                free(pic);
175                free(title);
176                free(localname);
177                free(menutitle);
178                free(newnode);
179                return NULL;
180        }
181
182        newnode->link = ostrshrink(link);
183        newnode->pic = ostrshrink(pic);
184        newnode->title = ostrshrink(title);
185        newnode->localname = ostrshrink(localname);
186        newnode->menutitle = ostrshrink(menutitle);
187
188        if(last == NULL)
189        {
190                while(node != NULL)
191                {
192                        prev = node;
193                        node = node->next;
194                }
195        }
196        else
197        {
198                prev = last;
199                node = last->next;
200        }
201
202        if(prev == NULL)
203                tithek = newnode;
204        else
205        {
206                prev->next = newnode;
207                newnode->prev = prev;
208        }
209        newnode->next = node;
210        if(node != NULL) node->prev = newnode;
211       
212        //debug(1000, "out");
213        return newnode;
214}
215
216int readtithek(const char* filename)
217{
218        debug(1000, "in");
219        FILE *fd = NULL;
220        char *fileline = NULL;
221        int linecount = 0;
222        struct tithek* last = NULL, *tmplast = NULL;
223
224        fileline = malloc(MINMALLOC);
225        if(fileline == NULL)
226        {
227                err("no memory");
228                return 0;
229        }
230
231        fd = fopen(filename, "r");
232        if(fd == NULL)
233        {
234                perr("can't open %s", filename);
235                free(fileline);
236                return 0;
237        }
238
239        while(fgets(fileline, MINMALLOC, fd) != NULL)
240        {
241                if(fileline[0] == '#' || fileline[0] == '\n')
242                        continue;
243                if(fileline[strlen(fileline) - 1] == '\n')
244                        fileline[strlen(fileline) - 1] = '\0';
245                if(fileline[strlen(fileline) - 1] == '\r')
246                        fileline[strlen(fileline) - 1] = '\0';
247
248                linecount++;
249
250                if(last == NULL) last = tmplast;
251                last = addtithek(fileline, linecount, last);
252                if(last != NULL) tmplast = last;
253        }
254
255        free(fileline);
256        fclose(fd);
257        return linecount;
258}
259
260int deltithek(char* link)
261{
262        debug(1000, "in");
263        int ret = 1;
264        struct tithek *node = tithek, *prev = tithek;
265
266        while(node != NULL)
267        {
268                if(ostrcmp(link, node->link) == 0)
269                {
270                        ret = 0;
271                        if(node == tithek)
272                        {
273                                tithek = node->next;
274                                if(tithek != NULL)
275                                        tithek->prev = NULL;
276                        }
277                        else
278                        {
279                                prev->next = node->next;
280                                if(node->next != NULL)
281                                        node->next->prev = prev;
282                        }
283
284                        free(node->link);
285                        node->link = NULL;
286
287                        free(node->pic);
288                        node->pic = NULL;
289
290                        free(node->title);
291                        node->title = NULL;
292
293                        free(node->localname);
294                        node->localname = NULL;
295
296                        free(node->menutitle);
297                        node->menutitle = NULL;
298
299                        free(node);
300                        node = NULL;
301
302                        break;
303                }
304
305                prev = node;
306                node = node->next;
307        }
308
309        debug(1000, "out");
310        return ret;
311}
312
313void freetithek()
314{
315        debug(1000, "in");
316        struct tithek *node = tithek, *prev = tithek;
317
318        while(node != NULL)
319        {
320                prev = node;
321                node = node->next;
322                if(prev != NULL)
323                        deltithek(prev->link);
324        }
325        debug(1000, "out");
326}
327
328char* tithekdownload(char* link, char* localname, char* pw, int pic, int flag)
329{
330        int ret = 1;
331        char* ip = NULL, *pos = NULL, *path = NULL;
332        char* tmpstr = NULL, *localfile = NULL;
333
334        if(link == NULL) return NULL;
335
336        ip = string_replace("http://", "", (char*)link, 0);
337
338        if(ip != NULL)
339                pos = strchr(ip, '/');
340        if(pos != NULL)
341        {
342                pos[0] = '\0';
343                path = pos + 1;
344        }
345
346        tmpstr = ostrcat(path, NULL, 0, 0);
347
348        if(flag == 0)
349        {
350                localfile = ostrcat(TITHEKPATH, "/", 0, 0);
351                if(localname == NULL)
352                        localfile = ostrcat(localfile, basename(tmpstr), 1, 0);
353                else
354                        localfile = ostrcat(localfile, localname, 1, 0);
355        }
356        else
357        {
358                localfile = ostrcat(getconfig("rec_path", NULL), "/", 0, 0);
359                if(localname == NULL)
360                        localfile = ostrcat(localfile, basename(tmpstr), 1, 0);
361                else
362                        localfile = ostrcat(localfile, localname, 1, 0);
363        }
364
365        if(flag == 0)
366        {
367                if(!file_exist(localfile))
368                {
369                        if(pic == 1)
370                                gethttp(ip, path, 80, localfile, pw, NULL, 0);
371                        else
372                                gethttp(ip, path, 80, localfile, pw, NULL, 0);                 
373                }
374        }
375        else
376        {
377                if(file_exist(localfile))
378                        ret = textbox(_("Message"), _("File exist, overwrite?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
379
380                if(ret == 1)
381                        screendownload("Download", ip, path, 80, localfile, pw, 0);
382        }
383
384        free(ip); ip = NULL;
385        free(tmpstr); tmpstr = NULL;
386
387        return localfile;
388}
389
390int createtithekplay(char* titheklink, struct skin* grid, struct skin* listbox, struct skin* countlabel)
391{
392        int gridbr = 0, posx = 0, count = 0, sumcount = 0, count1 = 0, pagecount = 0, skip = 0;
393        int localfile = 0;
394        struct skin* tmp = NULL;
395        char* tithekfile = NULL;
396        char* tmpstr = NULL;
397
398        if(ostrstr(titheklink, "http://") != NULL)
399                tithekfile = tithekdownload(titheklink, NULL, HTTPAUTH, 0, 0);
400        else
401        {
402                tithekfile = ostrcat(titheklink, NULL, 0, 0);
403                localfile = 1;
404        }
405
406        delmarkedscreennodes(grid, 1);
407        freetithek();
408//      if(readtithek(tithekfile) != 0) return 1;
409        int linecount = readtithek(tithekfile);
410//      if(linecount == 0) return 1;
411       
412        struct tithek* titheknode = tithek;
413
414        int height = 280;
415        int width = 390;
416        int picheight = 230;
417        int picwidth = 370;
418        int zcount = 3;
419        int fontsize = 20;
420        int pcount = 6;
421         
422        if(linecount > 8 && getconfigint("tithek_view", NULL) == 1)
423        {
424                height = 180;
425                width = 295;
426                picheight = 130;
427                picwidth = 270;
428                zcount = 4;
429                fontsize = 18;
430                pcount = 12;
431        }
432
433        while(titheknode != NULL)
434        {
435                tmp = addlistbox(grid, listbox, tmp, 1);
436                if(tmp != NULL)
437                {
438                        skip = 0;
439                        sumcount++;
440                        count++;
441                        count1++;
442                        if(gridbr == 0)
443                                tmp->type = GRIDBR;
444                        gridbr = 1;
445                        tmp->wrap = YES;
446
447                        tmp->picheight = picheight;
448                        tmp->picwidth = picwidth;
449
450                        tmp->fontsize = fontsize;
451                        tmp->height = height;
452                        tmp->width = width;
453                        tmp->prozwidth = 0;
454                        //tmp->bgcol = 0xffffff;
455                        tmp->bgspace = 1;
456                        tmp->vspace = 10;
457                        tmp->hspace = 10;
458                        tmp->posx = posx;
459                        //tmp->fontcol = 0x0000ff;
460                        tmp->halign = CENTER;
461                        tmp->valign = TEXTBOTTOM;
462                        changetext(tmp, titheknode->title);
463                        tmp->handle = (char*)titheknode;
464                        posx += tmp->width;
465                        if(count >= zcount)
466                        {
467                                count = 0;
468                                posx = 0;
469                                gridbr = 0;
470                        }
471                       
472                        if(count1 >= pcount)
473                        {
474                                count1 = 0;
475                                pagecount++;
476                                skip = 1;
477                        }
478                }
479                titheknode = titheknode->next;
480        }
481
482        if(skip == 0)
483                pagecount++;
484
485        tmpstr = oitoa(sumcount);
486
487        char* tmpstr1 = ostrcat(_("found"), NULL, 0, 0);
488        tmpstr1 = ostrcat(tmpstr1, " ", 1, 0);
489        tmpstr1 = ostrcat(tmpstr1, tmpstr, 1, 0);
490        free(tmpstr); tmpstr = NULL;
491        tmpstr1 = ostrcat(tmpstr1, " ", 1, 0);
492        tmpstr1 = ostrcat(tmpstr1, _("Results"), 1, 0);
493        changetext(countlabel, tmpstr1);
494        free(tmpstr1); tmpstr1 = NULL;
495
496        if(localfile == 0)
497                unlink(tithekfile);
498       
499        free(tithekfile); tithekfile = NULL;
500        return pagecount;
501}
502
503void removefav(char* title, char* link, char* pic, char* localname, char* menutitle, int flag)
504{
505        int count = 0, i = 0;
506        char* tmpstr = NULL, *tmpstr1 = NULL, *input = NULL;
507        struct splitstr* ret = NULL;
508
509        input = ostrcat(input, title, 1, 0);
510        input = ostrcat(input, "#", 1, 0);
511        input = ostrcat(input, link, 1, 0);
512        input = ostrcat(input, "#", 1, 0);
513        input = ostrcat(input, pic, 1, 0);
514        input = ostrcat(input, "#", 1, 0);
515        input = ostrcat(input, localname, 1, 0);
516        input = ostrcat(input, "#", 1, 0);
517        input = ostrcat(input, menutitle, 1, 0);
518        input = ostrcat(input, "#", 1, 0);
519        input = ostrcat(input, oitoa(flag), 1, 0);
520       
521        tmpstr = readfiletomem(getconfig("tithek_fav", NULL), 0);
522       
523        ret = strsplit(tmpstr, "\n", &count);
524
525        if(ret != NULL)
526        {
527                for(i = 0; i < count; i++)
528                {
529                        if(ostrcmp((ret[i]).part, input) != 0)
530                        {
531                                tmpstr1 = ostrcat(tmpstr1, ret[i].part, 1, 0);
532                                tmpstr1 = ostrcat(tmpstr1, "\n", 1, 0);
533                        }
534                        else
535                                printf("remove: %s\n", ret[i].part);
536                }
537        }
538
539        if(tmpstr1 != NULL && strlen(tmpstr1) > 0)
540                tmpstr1[strlen(tmpstr1) - 1] = '\0';
541
542        writesys(getconfig("tithek_fav", NULL), tmpstr1, 0);
543
544        free(ret); ret = NULL;
545        free(tmpstr); tmpstr = NULL;
546        free(tmpstr1); tmpstr1 = NULL;
547        free(input); input = NULL;
548}
549
550void addfav(char* title, char* link, char* pic, char* localname, char* menutitle, int flag)
551{
552        int count = 0, i = 0;
553        char* tmpstr = NULL, *tmpstr1 = NULL, *input = NULL;
554        struct splitstr* ret = NULL;
555
556        input = ostrcat(input, title, 1, 0);
557        input = ostrcat(input, "#", 1, 0);
558        input = ostrcat(input, link, 1, 0);
559        input = ostrcat(input, "#", 1, 0);
560        input = ostrcat(input, pic, 1, 0);
561        input = ostrcat(input, "#", 1, 0);
562        input = ostrcat(input, localname, 1, 0);
563        input = ostrcat(input, "#", 1, 0);
564        input = ostrcat(input, menutitle, 1, 0);
565        input = ostrcat(input, "#", 1, 0);
566        input = ostrcat(input, oitoa(flag), 1, 0);
567       
568        tmpstr1 = ostrcat(tmpstr1, input, 1, 0);
569        tmpstr1 = ostrcat(tmpstr1, "\n", 1, 0);
570
571        tmpstr = readfiletomem(getconfig("tithek_fav", NULL), 0);
572       
573        ret = strsplit(tmpstr, "\n", &count);
574
575        if(ret != NULL)
576        {
577                for(i = 0; i < count; i++)
578                {
579                        if(ostrcmp((ret[i]).part, input) != 0)
580                        {
581                                tmpstr1 = ostrcat(tmpstr1, ret[i].part, 1, 0);
582                                tmpstr1 = ostrcat(tmpstr1, "\n", 1, 0);
583                        }
584                }
585        }
586
587        if(tmpstr1 != NULL && strlen(tmpstr1) > 0)
588                tmpstr1[strlen(tmpstr1) - 1] = '\0';
589
590        writesys(getconfig("tithek_fav", NULL), tmpstr1, 0);
591
592        free(ret); ret = NULL;
593        free(tmpstr); tmpstr = NULL;
594        free(tmpstr1); tmpstr1 = NULL;
595        free(input); input = NULL;
596}
597
598void submenu(struct skin* listbox, struct skin* load)
599{
600        if(status.security == 1)
601        {
602                drawscreen(load, 0, 0);
603                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
604                char* tmpstr1 = NULL;
605
606                if(((struct tithek*)listbox->select->handle)->flag == 4)
607                {
608                        if(tmpstr != NULL) tmpstr1 = youtube(tmpstr, NULL, NULL, 1);
609                }                                               
610                else if(((struct tithek*)listbox->select->handle)->flag == 5)
611                {
612                        if(tmpstr != NULL) tmpstr1 = rtl2now(tmpstr, "http://rtl2now.rtl2.de", "rtl2now", 1);
613                }
614                else if(((struct tithek*)listbox->select->handle)->flag == 6)
615                {
616                        if(tmpstr != NULL) tmpstr1 = rtl2now(tmpstr, "http://www.superrtlnow.de", "superrtlnow", 1);
617                }
618                else if(((struct tithek*)listbox->select->handle)->flag == 7)
619                {
620                        if(tmpstr != NULL) tmpstr1 = rtl2now(tmpstr, "http://rtl-now.rtl.de", "rtlnow", 1);
621                }
622                else if(((struct tithek*)listbox->select->handle)->flag == 8)
623                {
624                        if(tmpstr != NULL) tmpstr1 = rtl2now(tmpstr, "http://www.voxnow.de", "voxnow", 1);
625                }
626                else if(((struct tithek*)listbox->select->handle)->flag == 12)
627                {
628                        if(tmpstr != NULL) tmpstr1 = myvideo(tmpstr, NULL, NULL, 1);
629                }
630                else if(((struct tithek*)listbox->select->handle)->flag == 14)
631                {
632                        if(tmpstr != NULL) tmpstr1 = kinox(tmpstr, NULL, NULL, 1);
633                }
634                else if(((struct tithek*)listbox->select->handle)->flag == 15)
635                {
636                        if(tmpstr != NULL) tmpstr1 = kinox(tmpstr, NULL, NULL, 2);
637                }
638                else if(((struct tithek*)listbox->select->handle)->flag == 16)
639                {
640                        if(tmpstr != NULL) tmpstr1 = rtl2now(tmpstr, "http://www.superrtlnow.de", "superrtlnow", 1);
641                }
642                else if(((struct tithek*)listbox->select->handle)->flag == 17)
643                {
644                        if(tmpstr != NULL) tmpstr1 = rtl2now(tmpstr, "http://rtl-now.rtl.de", "rtlnow", 1);
645                }
646                else if(((struct tithek*)listbox->select->handle)->flag == 18)
647                {
648                        if(tmpstr != NULL) tmpstr1 = rtl2now(tmpstr, "http://www.voxnow.de", "voxnow", 1);
649                }
650                else if(((struct tithek*)listbox->select->handle)->flag == 19)
651                {
652                        if(tmpstr != NULL) tmpstr1 = rtl2now(tmpstr, "http://rtl2now.rtl2.de", "rtl2now", 1);
653                }
654                else if(((struct tithek*)listbox->select->handle)->flag == 20)
655                {
656                        if(tmpstr != NULL) tmpstr1 = kinox(tmpstr, NULL, NULL, 3);
657                }
658
659                free(tmpstr); tmpstr = NULL;
660                       
661                if(tmpstr1 != NULL)
662                {
663                        if(textbox(_("Message"), _("Start playback"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0) == 1)
664                                screenplay(tmpstr1, 2, 0);                             
665                }
666                else
667                        textbox(_("Message"), _("Can't get Streamurl !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
668
669                free(tmpstr1); tmpstr1 = NULL;
670        }
671        else
672                textbox(_("Message"), _("Registration needed, please contact Atemio !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 200, 0, 0);
673}
674
675void screentithekplay(char* titheklink, char* title, int first)
676{
677        int rcret = -1, oaktline = 1, oaktpage = -1, ogridcol = 0;
678
679        if(!file_exist("/var/swap/player"))
680                mkdir("/var/swap/player", 0777);
681
682        writesysint("/proc/sys/vm/drop_caches", 3, 0);
683       
684        if(first == 1)
685        {
686                delallfiles("/tmp/tithek", NULL);
687                mkdir("/tmp/tithek", 777);
688                rcret = servicestop(status.aktservice, 1, 1);
689                if(rcret == 1) return;
690        }
691
692        status.hangtime = 99999;
693
694        struct skin* grid = getscreen("titheklist");
695        struct skin* listbox = getscreennode(grid, "listbox");
696        struct skin* countlabel = getscreennode(grid, "countlabel");
697        struct skin* countpage = getscreennode(grid, "countpage");
698        struct skin* load = getscreen("loading");
699        struct skin* tmp = NULL;
700        char* tithekpic = NULL;
701       
702        if(titheklink == NULL) return;
703       
704        listbox->aktpage = -1;
705        listbox->aktline = 1;
706        listbox->gridcol = 0;
707        listbox->select = NULL;
708
709//      if(createtithekplay(titheklink, grid, listbox, countlabel) != 0) return;
710        int pagecount = createtithekplay(titheklink, grid, listbox, countlabel);
711        if(pagecount == 0) return;
712
713        changetitle(grid, _(title));
714        drawscreen(grid, 0, 0);
715        addscreenrc(grid, listbox);
716                               
717        while(1)
718        {
719                changetitle(grid, _(title));
720                if(listbox->select != NULL && listbox->select->handle != NULL)
721                {
722                        tmp = listbox->select;
723                        while(tmp != NULL)
724                        {
725
726                                if(tmp->pagecount != listbox->aktpage) break;
727
728                                char* tmpstr = ostrcat(_("Page"), NULL, 0, 0);
729                                tmpstr = ostrcat(tmpstr, " ( ", 1, 0);
730                                tmpstr = ostrcat(tmpstr, oitoa(tmp->pagecount), 1, 0);
731                                tmpstr = ostrcat(tmpstr, " / ", 1, 0);
732                                tmpstr = ostrcat(tmpstr, oitoa(pagecount), 1, 0);       
733                                tmpstr = ostrcat(tmpstr, _(" )"), 1, 0);
734                                changetext(countpage, tmpstr);
735                                free(tmpstr); tmpstr = NULL;
736       
737                                if(tmp->handle != NULL)
738                                {
739                                        tithekpic = tithekdownload(((struct tithek*)tmp->handle)->pic, ((struct tithek*)tmp->handle)->localname, "aXBrLUdaRmg6RkhaVkJHaG56ZnZFaEZERlRHenVpZjU2NzZ6aGpHVFVHQk5Iam0=", 1, 0);
740
741                                        off64_t checkpic = getfilesize(tithekpic);
742                       
743                                        if(checkpic < 1000)
744                                        {
745                                                free(tithekpic); tithekpic = NULL;
746                                                tithekpic = ostrcat("/var/usr/local/share/titan/plugins/tithek/default.jpg", NULL, 0, 0);
747                                        }
748                       
749                                        changepic(tmp, tithekpic);
750                                        free(tithekpic); tithekpic = NULL;
751                                }
752                                tmp = tmp->prev;
753                        }
754                        tmp = listbox->select;
755                        while(tmp != NULL)
756                        {
757                                if(tmp->pagecount != listbox->aktpage) break;
758                                if(tmp->handle != NULL)
759                                {
760                                        tithekpic = tithekdownload(((struct tithek*)tmp->handle)->pic, ((struct tithek*)tmp->handle)->localname, "aXBrLUdaRmg6RkhaVkJHaG56ZnZFaEZERlRHenVpZjU2NzZ6aGpHVFVHQk5Iam0=", 1, 0);
761
762                                        off64_t checkpic = getfilesize(tithekpic);
763
764                                        if(checkpic < 1000)
765                                        {
766                                                free(tithekpic); tithekpic = NULL;
767                                                tithekpic = ostrcat("/var/usr/local/share/titan/plugins/tithek/default.jpg", NULL, 0, 0);
768                                        }
769
770                                        changepic(tmp, tithekpic);
771                                        free(tithekpic); tithekpic = NULL;
772                                }
773                                tmp = tmp->next;
774                        }
775
776                        drawscreen(grid, 0, 0);
777                }
778               
779                int count = getfilecount(TITHEKPATH);
780                if(count > 500)
781                        delallfiles(TITHEKPATH, ".jpg");
782               
783                rcret = waitrc(grid, 0, 0);
784
785                if(rcret == getrcconfigint("rcexit", NULL)) break;
786                if(rcret == getrcconfigint("rcmenu", NULL))
787                {
788                        screentithek_settings();
789                        createtithekplay(titheklink, grid, listbox, countlabel);
790                        drawscreen(grid, 0, 0);
791                }
792               
793                if(rcret == getrcconfigint("rcred", NULL))
794                {
795                        if(listbox->select != NULL && listbox->select->handle != NULL)
796                        {
797                                if(((struct tithek*)listbox->select->handle)->flag == 2)
798                                {
799                                        if(status.security == 1)
800                                        {
801                                                char* tmpstr = tithekdownload((((struct tithek*)listbox->select->handle)->link), NULL, NULL, 0, 1);
802                                                free(tmpstr); tmpstr = NULL;
803                                                drawscreen(grid, 0, 0);
804                                        }
805                                        else
806                                                textbox(_("Message"), _("Registration needed, please contact Atemio !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 200, 0, 0);
807                                }
808                                else if(((struct tithek*)listbox->select->handle)->flag == 4)
809                                {
810                                        if(status.security == 1)
811                                        {
812                                                char* tmpstr = NULL, *tmpstr1 = NULL, *tmpstr2 = NULL;
813                                                tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
814                                                if(tmpstr != NULL) tmpstr1 = youtube(tmpstr, NULL, NULL, 1);
815                                                tmpstr2 = changefilenameext(((struct tithek*)tmp->handle)->localname, ".mp4");
816                                                free(tmpstr); tmpstr = NULL;
817                                                       
818                                                if(tmpstr1 != NULL)
819                                                {
820                                                        char* tmpstr = tithekdownload(tmpstr1, tmpstr2, NULL, 0, 1);
821                                                        free(tmpstr); tmpstr = NULL;
822                                                        drawscreen(grid, 0, 0);
823                                                }
824                                                else
825                                                        textbox(_("Message"), _("Can't get Streamurl !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
826                                                free(tmpstr1); tmpstr1 = NULL;
827                                                free(tmpstr2); tmpstr2 = NULL;
828                                        }
829                                        else
830                                                textbox(_("Message"), _("Registration needed, please contact Atemio !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 200, 0, 0);
831                                }
832                        }
833                }
834                else if(rcret == getrcconfigint("rcok", NULL))
835                {
836                        if(listbox->select != NULL && listbox->select->handle != NULL)
837                        {
838                                clearscreen(grid);
839
840                                if(((struct tithek*)listbox->select->handle)->flag == 2)
841                                {
842                                        if(status.security == 1)
843                                        {
844                                                if(textbox(_("Message"), _("Start playback"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0) == 1)
845                                                {
846                                                        if(ostrcmp(title, "TiThek - Internet Radio") == 0)
847                                                        {
848                                                                screenplay((((struct tithek*)listbox->select->handle)->link), 2, 4);
849                                                        }
850                                                        else
851                                                                screenplay((((struct tithek*)listbox->select->handle)->link), 2, 0);
852                                                }                       
853                                        }
854                                        else
855                                                textbox(_("Message"), _("Registration needed, please contact Atemio !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 200, 0, 0);
856                                }
857                                else if((((struct tithek*)listbox->select->handle)->flag == 4) || (((struct tithek*)listbox->select->handle)->flag == 5) || (((struct tithek*)listbox->select->handle)->flag == 6) || (((struct tithek*)listbox->select->handle)->flag == 7) || (((struct tithek*)listbox->select->handle)->flag == 8) || (((struct tithek*)listbox->select->handle)->flag == 12) || (((struct tithek*)listbox->select->handle)->flag == 14) || (((struct tithek*)listbox->select->handle)->flag == 15) || (((struct tithek*)listbox->select->handle)->flag == 16) || (((struct tithek*)listbox->select->handle)->flag == 17) || (((struct tithek*)listbox->select->handle)->flag == 18) || (((struct tithek*)listbox->select->handle)->flag == 19) || (((struct tithek*)listbox->select->handle)->flag == 20))
858                                {
859                                        submenu(listbox, load);
860                                        drawscreen(grid, 0, 0);
861                                }
862                                else if((((struct tithek*)listbox->select->handle)->flag == 9) || (((struct tithek*)listbox->select->handle)->flag == 10) || (((struct tithek*)listbox->select->handle)->flag == 11))
863                                {
864                                        if(youtube_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title) == 0)
865                                        {
866                                                oaktpage = listbox->aktpage;
867                                                oaktline = listbox->aktline;
868                                                ogridcol = listbox->gridcol;
869                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
870                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
871                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
872                                                screentithekplay(tmpstr, tmpstr2, 0);
873                                                free(tmpstr); tmpstr = NULL;
874                                                free(tmpstr2); tmpstr2 = NULL;
875//                                      if(createtithekplay(titheklink, grid, listbox, countlabel) != 0) break;
876                                                int pagecount = createtithekplay(titheklink, grid, listbox, countlabel);
877                                                if(pagecount == 0) break;
878
879                                                listbox->aktpage = oaktpage;
880                                                listbox->aktline = oaktline;
881                                                listbox->gridcol = ogridcol;
882                                                addscreenrc(grid, listbox);
883                                        }
884                                }
885                                else if((((struct tithek*)listbox->select->handle)->flag == 13))
886                                {
887                                        if(myvideo_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title) == 0)
888                                        {
889                                                oaktpage = listbox->aktpage;
890                                                oaktline = listbox->aktline;
891                                                ogridcol = listbox->gridcol;
892                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
893                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
894                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
895                                                screentithekplay(tmpstr, tmpstr2, 0);
896                                                free(tmpstr); tmpstr = NULL;
897                                                free(tmpstr2); tmpstr2 = NULL;
898//                                      if(createtithekplay(titheklink, grid, listbox, countlabel) != 0) break;
899                                                int pagecount = createtithekplay(titheklink, grid, listbox, countlabel);
900                                                if(pagecount == 0) break;
901
902                                                listbox->aktpage = oaktpage;
903                                                listbox->aktline = oaktline;
904                                                listbox->gridcol = ogridcol;
905                                                addscreenrc(grid, listbox);
906                                        }
907                                }
908                                else if((((struct tithek*)listbox->select->handle)->flag == 21))
909                                {
910                                        if(kinox_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title) == 0)
911                                        {
912                                                oaktpage = listbox->aktpage;
913                                                oaktline = listbox->aktline;
914                                                ogridcol = listbox->gridcol;
915                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
916                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
917                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
918                                                screentithekplay(tmpstr, tmpstr2, 0);
919                                                free(tmpstr); tmpstr = NULL;
920                                                free(tmpstr2); tmpstr2 = NULL;
921//                                      if(createtithekplay(titheklink, grid, listbox, countlabel) != 0) break;
922                                                int pagecount = createtithekplay(titheklink, grid, listbox, countlabel);
923                                                if(pagecount == 0) break;
924
925                                                listbox->aktpage = oaktpage;
926                                                listbox->aktline = oaktline;
927                                                listbox->gridcol = ogridcol;
928                                                addscreenrc(grid, listbox);
929                                        }
930                                }
931                                else if((((struct tithek*)listbox->select->handle)->flag == 22))
932                                {
933                                        if(kinox_hoster(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title) == 0)
934                                        {
935                                                oaktpage = listbox->aktpage;
936                                                oaktline = listbox->aktline;
937                                                ogridcol = listbox->gridcol;
938                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
939                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
940                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
941                                                screentithekplay(tmpstr, tmpstr2, 0);
942                                                free(tmpstr); tmpstr = NULL;
943                                                free(tmpstr2); tmpstr2 = NULL;
944//                                      if(createtithekplay(titheklink, grid, listbox, countlabel) != 0) break;
945                                                int pagecount = createtithekplay(titheklink, grid, listbox, countlabel);
946                                                if(pagecount == 0) break;
947
948                                                listbox->aktpage = oaktpage;
949                                                listbox->aktline = oaktline;
950                                                listbox->gridcol = ogridcol;
951                                                addscreenrc(grid, listbox);
952                                        }
953                                }                       
954                                else if((((struct tithek*)listbox->select->handle)->flag == 23))
955                                {
956                                        if(kinox_hoster_series(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title) == 0)
957                                        {
958                                                oaktpage = listbox->aktpage;
959                                                oaktline = listbox->aktline;
960                                                ogridcol = listbox->gridcol;
961                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
962                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
963                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
964                                                screentithekplay(tmpstr, tmpstr2, 0);
965                                                free(tmpstr); tmpstr = NULL;
966                                                free(tmpstr2); tmpstr2 = NULL;
967//                                      if(createtithekplay(titheklink, grid, listbox, countlabel) != 0) break;
968                                                int pagecount = createtithekplay(titheklink, grid, listbox, countlabel);
969                                                if(pagecount == 0) break;
970
971                                                listbox->aktpage = oaktpage;
972                                                listbox->aktline = oaktline;
973                                                listbox->gridcol = ogridcol;
974                                                addscreenrc(grid, listbox);
975                                        }
976                                }
977                                else if((((struct tithek*)listbox->select->handle)->flag == 66))
978                                {
979                                        textbox(_("Message"), _("The hoster is not yet supported for the time !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 5, 0);
980                                        continue;
981                                }       
982                                else
983                                {
984                                        int pincheck = 0;
985                                        if(((struct tithek*)listbox->select->handle)->flag == 1000)
986                                                pincheck = screenpincheck(0, NULL);
987                                        if(pincheck == 0)
988                                        {
989                                                oaktpage = listbox->aktpage;
990                                                oaktline = listbox->aktline;
991                                                ogridcol = listbox->gridcol;
992                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
993                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);                                     
994                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
995                                                screentithekplay(tmpstr, tmpstr2, 0);
996                                                free(tmpstr); tmpstr = NULL;
997                                                free(tmpstr2); tmpstr2 = NULL; 
998//                                              if(createtithekplay(titheklink, grid, listbox, countlabel) != 0) break;
999                                                int pagecount = createtithekplay(titheklink, grid, listbox, countlabel);
1000                                                if(pagecount == 0) break;
1001
1002                                                listbox->aktpage = oaktpage;
1003                                                listbox->aktline = oaktline;
1004                                                listbox->gridcol = ogridcol;
1005                                                addscreenrc(grid, listbox);
1006                                        }
1007                                }
1008                                drawscreen(grid, 0, 0);
1009                                sleep(1);
1010                        }                       
1011                }
1012                else if(rcret == getrcconfigint("rcyellow", NULL) && ostrcmp(title, "TiThek - Favoriten") == 0)
1013                {
1014                        if(textbox(_("Message"), _("Remove this Favorite ?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 5, 0) == 1)
1015                        {
1016                                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);             
1017                                int pagecount = createtithekplay(getconfig("tithek_fav", NULL), grid, listbox, countlabel);
1018                                if(pagecount == 0) return;
1019                                       
1020                                drawscreen(grid, 0, 0);
1021                        }
1022                }
1023                else if(rcret == getrcconfigint("rcgreen", NULL) && ostrcmp(title, "TiThek - Favoriten") != 0)
1024                {
1025                        if(textbox(_("Message"), _("Add this link as Favorite ?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 5, 0) == 1)
1026                        {
1027                                addfav(((struct tithek*)listbox->select->handle)->title, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->pic, ((struct tithek*)listbox->select->handle)->localname, ((struct tithek*)listbox->select->handle)->menutitle, ((struct tithek*)listbox->select->handle)->flag);         
1028                        }
1029                }
1030        }
1031
1032//      freetithek();
1033        delmarkedscreennodes(grid, 1);
1034        delownerrc(grid);
1035        clearscreen(grid);
1036
1037        if(first == 1)
1038        {
1039                delallfiles("/tmp/tithek", ".list");
1040                servicecheckret(servicestart(status.lastservice->channel, NULL, NULL, 0), 0);
1041        }
1042        status.hangtime = getconfigint("hangtime", NULL);
1043}
1044
1045#endif
Note: See TracBrowser for help on using the repository browser.