source: titan/plugins/tithek/zdf.h @ 26912

Last change on this file since 26912 was 25161, checked in by obi, 10 years ago

fix

File size: 5.8 KB
Line 
1#ifndef ZDF_H
2#define ZDF_H
3
4char* zdf(char* link)
5{
6        debug(99, "link %s", link);
7        int debuglevel = getconfigint("debuglevel", NULL);
8        char* ip = NULL, *pos = NULL, *path = NULL, *streamurl = NULL, *tmpstr = NULL, *tmpstr2 = NULL, *pic = NULL, *title = NULL, *tmpstr3 = NULL, *quali = NULL;
9       
10        ip = string_replace("http://", "", (char*)link, 0);
11
12        if(ip != NULL)
13                pos = strchr(ip, '/');
14        if(pos != NULL)
15        {
16                pos[0] = '\0';
17                path = pos + 1;
18        }
19
20        tmpstr = gethttp(ip, path, 80, NULL, NULL, 10000, NULL, 0);
21        titheklog(debuglevel, "/tmp/zdf1_tmpstr", NULL, tmpstr);
22
23        if(tmpstr != NULL)
24        {
25                if(ostrstr(tmpstr, "<div class=\"fsk\">") != NULL)
26                {
27                        tmpstr2 = string_resub("<div class=\"fsk\">", "</div>", tmpstr, 0);
28                        tmpstr2 = string_replace(".", ".\n", tmpstr2, 1),
29                        textbox(_("Message"), tmpstr2, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 400, 0, 0);
30                        free(tmpstr2), tmpstr2 = NULL;
31                }
32
33                tmpstr2 = string_resub("<formitaeten>", "</formitaeten>", tmpstr, 0);
34                stringreplacechar(tmpstr2, '\n', ' ');
35                stringreplacechar(tmpstr2, '\t', ' ');
36                string_strip_whitechars(tmpstr2);
37                tmpstr2 = string_replace_all("<formitaet basetype", "\n\t<formitaet basetype", tmpstr2, 1);
38
39                titheklog(debuglevel, "/tmp/zdf1_tmpstr2", NULL, tmpstr);
40               
41                int count = 0, i = 0;   
42                struct splitstr* ret1 = NULL;
43                struct menulist* mlist = NULL, *mbox = NULL;
44                ret1 = strsplit(string_decode(tmpstr2,0), "\n", &count);
45                for(i = 0; i < count; i++)
46                {
47                        if(ret1[i].part != NULL && strlen(ret1[i].part) > 1)
48                        {
49                                debug(99, "\nRound %d started, processing = %s",i,ret1[i].part);
50                                streamurl = string_resub("<url>", "</url>", ret1[i].part,0);
51                               
52                                if(ostrstr(ret1[i].part, "rtmp") != NULL)
53                                {
54                                        char* ip1 = NULL, *pos1 = NULL, *path1 = NULL;
55                                        ip1 = string_replace("http://", "", streamurl, 0);
56                               
57                                        if(ip != NULL)
58                                                pos1 = strchr(ip1, '/');
59                                        if(pos1 != NULL)
60                                        {
61                                                pos1[0] = '\0';
62                                                path1 = pos1 + 1;
63                                        }
64
65                                        free(streamurl), streamurl = NULL;
66                                        tmpstr3 = gethttp(ip1, path1, 80, NULL, NULL, 10000, NULL, 0);
67                                        streamurl = string_resub("<default-stream-url>", "</default-stream-url>", tmpstr3, 0);
68                                        free(tmpstr3), tmpstr3 = NULL;
69                                        free(ip1), ip1 = NULL;
70                                }
71
72                                title = string_resub("<formitaet basetype=\"", "\"",ret1[i].part,0);
73                                stringreplacechar(title, '_', ' ');
74               
75                                if(ostrstr(ret1[i].part, "mp4") != NULL)
76                                        pic = ostrcat("mp4.png", NULL, 0, 0);
77                                else if(ostrstr(ret1[i].part, "3gp") != NULL)
78                                        pic = ostrcat("3gp.png", NULL, 0, 0);
79                                else if(ostrstr(ret1[i].part, "flv") != NULL)
80                                        pic = ostrcat("flv.png", NULL, 0, 0);
81
82                                quali = string_resub("<quality>", "</quality>",ret1[i].part,0);
83
84                                if(title == NULL)
85                                {
86                                        title = ostrcat(_("unknown"), NULL, 0, 0);
87                                        title = ostrcat(title, " (", 1, 0);
88                                        title = ostrcat(title, quali, 1, 0);
89                                        title = ostrcat(title, ")", 1, 0);
90                                        debug(99, "(%d) title: %s streamurl: %s\n", i, title, streamurl);
91                                        debug(99, "(%d) ret1 %s\n",i, (ret1[i]).part);
92                                }
93                                else
94                                {
95                                        title = ostrcat(title, " (", 1, 0);
96                                        title = ostrcat(title, quali, 1, 0);
97                                        title = ostrcat(title, ")", 1, 0);
98
99                                        debug(99, "(%d) title: %s streamurl: %s\n", i, title, streamurl);                                                                                                                                                                                                       
100                                        addmenulist(&mlist, title, streamurl, pic, 0, 0);
101                                }
102                                free(quali), quali = NULL;
103                                free(title), title = NULL;
104                                free(pic), pic = NULL;
105                                free(streamurl), streamurl = NULL;
106                        }
107                }
108                free(ret1), ret1 = NULL;
109
110                if(mlist != NULL)
111                {
112                        mbox = menulistbox(mlist, NULL, NULL, NULL, NULL, 1, 0);
113                        if(mbox != NULL)
114                        {
115                                free(streamurl), streamurl = NULL;
116
117                                debug(99, "mbox->name %s", mbox->name);
118                                debug(99, "mbox->text %s", mbox->text);
119                                streamurl = ostrcat(mbox->text, NULL, 0, 0);
120
121                        }
122                }
123        }
124
125        free(tmpstr); tmpstr = NULL;
126        free(ip), ip = NULL;
127
128        titheklog(debuglevel, "/tmp/zdf2_streamurl", NULL, streamurl);
129
130// segfault munmap_chunk(): invalid pointer
131//      free(pos), pos = NULL;
132//      free(path), path = NULL;
133
134        debug(99, "streamurl: %s", streamurl); 
135        return streamurl;
136}
137
138int zdf_search_local(struct skin* grid, struct skin* listbox, struct skin* countlabel, struct skin* load, char* link, char* title, char* searchstr, int flag)
139{
140        char* tmpstr = NULL, *tmpstr1 = NULL, *line = NULL, *menu = NULL, *search = NULL;
141        int ret = 1, count = 0, i = 0;
142
143        if(listbox == NULL || listbox->select == NULL || listbox->select->handle == NULL)
144                return ret;
145
146        if(searchstr == NULL)
147                search = textinputhist("Search", " ", "searchhist");
148        else
149                search = textinputhist("Search", searchstr, "searchhist");
150
151        if(search != NULL)
152        {
153                drawscreen(load, 0, 0);
154
155                strstrip(search);
156                string_tolower(search);
157
158                tmpstr = gethttp("atemio.dyndns.tv", "/mediathek/zdf/streams/zdf.all-sorted.list", 80, NULL, HTTPAUTH, 5000, NULL, 0);
159
160                struct splitstr* ret1 = NULL;
161                ret1 = strsplit(tmpstr, "\n", &count);
162
163                if(ret1 != NULL)
164                {
165                        int max = count;
166                        for(i = 0; i < max; i++)
167                        {
168                       
169                                tmpstr1 = ostrcat(ret1[i].part, NULL, 0, 0);
170                                tmpstr1 = stringreplacecharonce(tmpstr1, '#', '\0');
171                                string_tolower(tmpstr1);
172
173                                if(ostrstr(tmpstr1, search) != NULL)
174                                {
175                                        printf("found: %s\n", ret1[i].part);
176                                        int rcret = waitrc(NULL, 10, 0);
177                                        if(rcret == getrcconfigint("rcexit", NULL)) break;
178
179                                        line = ostrcat(line, ret1[i].part, 1, 0);
180                                        line = ostrcat(line, "\n", 0, 0);
181                                }
182                                free(tmpstr1), tmpstr1 = NULL;                         
183                        }
184                        free(ret1), ret1 = NULL;
185
186                        if(line != NULL)
187                        {
188                                line = string_replace_all("http://atemio.dyndns.tv/", "http://imageshack.us/md/up/grd/", line, 1);
189                                menu = ostrcat("/tmp/tithek/zdf.search.list", NULL, 0, 0);
190                                writesys(menu, line, 0);
191                                struct tithek* tnode = (struct tithek*)listbox->select->handle;
192                                createtithek(tnode, tnode->title, menu, tnode->pic, tnode->localname, tnode->menutitle, tnode->flag);
193                                ret = 0;
194                        }
195                }
196                free(tmpstr), tmpstr = NULL;
197        }
198        free(search), search = NULL;
199        return ret;
200}
201
202#endif
Note: See TracBrowser for help on using the repository browser.