source: titan/plugins/tithek/beeg.h @ 39581

Last change on this file since 39581 was 28962, checked in by obi, 10 years ago

[tithek] update tvtoast

File size: 2.7 KB
Line 
1#ifndef BEEG_H
2#define BEEG_H
3
4char* beeg(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;
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/beeg1_tmpstr", NULL, NULL, NULL, tmpstr);
22
23        if(tmpstr != NULL)
24        {
25                streamurl = string_resub("'file': '","',",tmpstr,0);
26        }
27
28        free(tmpstr); tmpstr = NULL;
29        free(ip), ip = NULL;
30
31        titheklog(debuglevel, "/tmp/beeg2_streamurl", NULL, NULL, NULL, streamurl);
32
33// segfault munmap_chunk(): invalid pointer
34//      free(pos), pos = NULL;
35//      free(path), path = NULL;
36
37        debug(99, "streamurl: %s", streamurl); 
38        return streamurl;
39}
40
41int beeg_search_local(struct skin* grid, struct skin* listbox, struct skin* countlabel, struct skin* load, char* link, char* title, char* searchstr, int flag)
42{
43        char* tmpstr = NULL, *tmpstr1 = NULL, *line = NULL, *menu = NULL, *search = NULL;
44        int ret = 1, count = 0, i = 0;
45
46        if(listbox == NULL || listbox->select == NULL || listbox->select->handle == NULL)
47                return ret;
48
49        if(searchstr == NULL)
50                search = textinputhist(_("Search"), " ", "searchhist");
51        else
52                search = textinputhist(_("Search"), searchstr, "searchhist");
53
54        if(search != NULL)
55        {
56                drawscreen(load, 0, 0);
57
58                strstrip(search);
59                string_tolower(search);
60
61                tmpstr = gethttp("atemio.dyndns.tv", "/mediathek/beeg/streams/beeg.all-sorted.list", 80, NULL, HTTPAUTH, 5000, NULL, 0);
62
63                struct splitstr* ret1 = NULL;
64                ret1 = strsplit(tmpstr, "\n", &count);
65
66                if(ret1 != NULL)
67                {
68                        int max = count;
69                        for(i = 0; i < max; i++)
70                        {
71                       
72                                tmpstr1 = ostrcat(ret1[i].part, NULL, 0, 0);
73                                tmpstr1 = stringreplacecharonce(tmpstr1, '#', '\0');
74                                string_tolower(tmpstr1);
75
76                                if(ostrstr(tmpstr1, search) != NULL)
77                                {
78                                        printf("found: %s\n", ret1[i].part);
79                                        int rcret = waitrc(NULL, 10, 0);
80                                        if(rcret == getrcconfigint("rcexit", NULL)) break;
81
82                                        line = ostrcat(line, ret1[i].part, 1, 0);
83                                        line = ostrcat(line, "\n", 0, 0);
84                                }
85                                free(tmpstr1), tmpstr1 = NULL;                         
86                        }
87                        free(ret1), ret1 = NULL;
88
89                        if(line != NULL)
90                        {
91                                line = string_replace_all("http://atemio.dyndns.tv/", "http://imageshack.us/md/up/grd/", line, 1);
92                                menu = ostrcat("/tmp/tithek/beeg.search.list", NULL, 0, 0);
93                                writesys(menu, line, 0);
94                                struct tithek* tnode = (struct tithek*)listbox->select->handle;
95                                createtithek(tnode, tnode->title, menu, tnode->pic, tnode->localname, tnode->menutitle, tnode->flag);
96                                ret = 0;
97                        }
98                }
99                free(tmpstr), tmpstr = NULL;
100        }
101        free(search), search = NULL;
102        return ret;
103}
104
105#endif
Note: See TracBrowser for help on using the repository browser.