source: titan/plugins/tithek/giga.h @ 36184

Last change on this file since 36184 was 36184, checked in by obi, 8 years ago

tithek enable giga

File size: 3.7 KB
Line 
1#ifndef GIGA_H
2#define GIGA_H
3
4char* giga(char* link)
5{
6        int debuglevel = getconfigint("debuglevel", NULL);
7        char* streamurl = NULL, *tmpstr = NULL, *title = NULL, *pic = NULL, *label = NULL;
8
9        tmpstr = gethttps(link, NULL, NULL, NULL, NULL, NULL, 1);
10        tmpstr = string_replace_all("\n", " ", tmpstr, 1);
11        tmpstr = string_replace_all("{file: \"", "\n{ile: \"", tmpstr, 1);
12       
13        int incount = 0, count = 0, i = 0;     
14        struct splitstr* ret1 = NULL;
15        struct menulist* mlist = NULL, *mbox = NULL;
16        ret1 = strsplit(tmpstr, "\n", &count);
17        for(i = 0; i < count; i++)
18        {
19                if(ostrstr(ret1[i].part, "{ile: \"") != NULL)
20                {
21                        incount++;
22                        free(streamurl), streamurl = NULL;                     
23                        streamurl = string_resub("{ile: \"", "\"", ret1[i].part, 0);
24       
25                        if(ostrstr(streamurl, "rtmp") != NULL)
26                                title = ostrcat("Rtmpe Stream (", NULL, 0, 0);
27                        else
28                                title = ostrcat("Http Stream (", NULL, 0, 0);
29       
30                        label = string_resub("label: \"", "\"", ret1[i].part, 0);
31                        title = ostrcat(title, label, 1, 0);
32                        title = ostrcat(title, ")", 1, 0);
33                       
34                        if(ostrstr(streamurl, "mp4") != NULL)
35                                pic = ostrcat("mp4.png", NULL, 0, 0);
36                        else
37                                pic = ostrcat("m3u8.png", NULL, 0, 0);
38
39                        if(streamurl != NULL)
40                        {
41                                debug(99, "(%d) title: %s streamurl: %s\n", i, title, streamurl);                                                                                                                                                                                                       
42                                addmenulist(&mlist, title, streamurl, pic, 0, 0);
43                        }
44
45                        free(label), label = NULL;
46                        free(title), title = NULL;
47                        free(pic), pic = NULL;
48                }
49        }
50        free(ret1), ret1 = NULL;
51        if(mlist != NULL)
52        {
53                mbox = menulistbox(mlist, NULL, _("Stream Menu"), _("Choose your Streaming Format from the following list"), NULL, NULL, 1, 0);
54                if(mbox != NULL)
55                {
56                        free(streamurl), streamurl = NULL;
57
58                        debug(99, "mbox->name %s", mbox->name);
59                        debug(99, "mbox->text %s", mbox->text);
60                        streamurl = ostrcat(mbox->text, NULL, 0, 0);
61
62                }
63        }
64
65        free(tmpstr), tmpstr = NULL;
66
67        debug(99, "streamurl %s", streamurl);
68        return streamurl;
69}
70
71int giga_search_local(struct skin* grid, struct skin* listbox, struct skin* countlabel, struct skin* load, char* link, char* title, char* searchstr, int flag)
72{
73        char* tmpstr = NULL, *tmpstr1 = NULL, *line = NULL, *menu = NULL, *search = NULL;
74        int ret = 1, count = 0, i = 0;
75
76        if(listbox == NULL || listbox->select == NULL || listbox->select->handle == NULL)
77                return ret;
78
79        if(searchstr == NULL)
80                search = textinputhist(_("Search"), " ", "searchhist");
81        else
82                search = textinputhist(_("Search"), searchstr, "searchhist");
83
84        if(search != NULL)
85        {
86                drawscreen(load, 0, 0);
87
88                strstrip(search);
89                string_tolower(search);
90
91                tmpstr = gethttp("atemio.dyndns.tv", "/mediathek/giga/streams/giga.all-sorted.list", 80, NULL, HTTPAUTH, 5000, NULL, 0);
92
93                struct splitstr* ret1 = NULL;
94                ret1 = strsplit(tmpstr, "\n", &count);
95
96                if(ret1 != NULL)
97                {
98                        int max = count;
99                        for(i = 0; i < max; i++)
100                        {
101                       
102                                tmpstr1 = ostrcat(ret1[i].part, NULL, 0, 0);
103                                tmpstr1 = stringreplacecharonce(tmpstr1, '#', '\0');
104                                string_tolower(tmpstr1);
105
106                                if(ostrstr(tmpstr1, search) != NULL)
107                                {
108                                        printf("found: %s\n", ret1[i].part);
109                                        int rcret = waitrc(NULL, 10, 0);
110                                        if(rcret == getrcconfigint("rcexit", NULL)) break;
111
112                                        line = ostrcat(line, ret1[i].part, 1, 0);
113                                        line = ostrcat(line, "\n", 0, 0);
114                                }
115                                free(tmpstr1), tmpstr1 = NULL;                         
116                        }
117                        free(ret1), ret1 = NULL;
118
119                        if(line != NULL)
120                        {
121                                line = string_replace_all("http://atemio.dyndns.tv/", "http://imageshack.us/md/up/grd/", line, 1);
122                                menu = ostrcat("/tmp/tithek/giga.search.list", NULL, 0, 0);
123                                writesys(menu, line, 0);
124                                struct tithek* tnode = (struct tithek*)listbox->select->handle;
125                                createtithek(tnode, tnode->title, menu, tnode->pic, tnode->localname, tnode->menutitle, tnode->flag);
126                                ret = 0;
127                        }
128                }
129                free(tmpstr), tmpstr = NULL;
130        }
131        free(search), search = NULL;
132        return ret;
133}
134
135#endif
Note: See TracBrowser for help on using the repository browser.