1 | #ifndef BEEG_H |
---|
2 | #define BEEG_H |
---|
3 | |
---|
4 | char* 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, 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, 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 | |
---|
41 | int 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 | menu = ostrcat("/tmp/tithek/beeg.search.list", NULL, 0, 0); |
---|
92 | writesys(menu, line, 0); |
---|
93 | struct tithek* tnode = (struct tithek*)listbox->select->handle; |
---|
94 | createtithek(tnode, tnode->title, menu, tnode->pic, tnode->localname, tnode->menutitle, tnode->flag); |
---|
95 | ret = 0; |
---|
96 | } |
---|
97 | } |
---|
98 | free(tmpstr), tmpstr = NULL; |
---|
99 | } |
---|
100 | free(search), search = NULL; |
---|
101 | return ret; |
---|
102 | } |
---|
103 | |
---|
104 | #endif |
---|