1 | #ifndef ARD_H |
---|
2 | #define ARD_H |
---|
3 | |
---|
4 | char* ard(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, *nummer = NULL; |
---|
9 | char* tmpstr2 = NULL, *title = NULL, *pic = NULL, *part1 = NULL, *part2 = NULL; |
---|
10 | |
---|
11 | ip = string_replace("http://", "", (char*)link, 0); |
---|
12 | |
---|
13 | if(ip != NULL) |
---|
14 | pos = strchr(ip, '/'); |
---|
15 | if(pos != NULL) |
---|
16 | { |
---|
17 | pos[0] = '\0'; |
---|
18 | path = pos + 1; |
---|
19 | } |
---|
20 | |
---|
21 | tmpstr = gethttp(ip, path, 80, NULL, NULL, 10000, NULL, 0); |
---|
22 | titheklog(debuglevel, "/tmp/tithek/ard1_tmpstr", NULL, NULL, NULL,tmpstr); |
---|
23 | |
---|
24 | tmpstr2 = string_resub("_mediaStreamArray\":[", "],\"_sortierArray\"", tmpstr, 0); |
---|
25 | titheklog(debuglevel, "/tmp/tithek/ard2_tmpstr2", NULL, NULL, NULL, tmpstr2); |
---|
26 | |
---|
27 | tmpstr2 = string_replace_all("{", "\n", tmpstr2, 1); |
---|
28 | titheklog(debuglevel, "/tmp/tithek/ard3_tmpstr2", NULL, NULL, NULL, tmpstr2); |
---|
29 | |
---|
30 | int count = 0, i = 0; |
---|
31 | struct splitstr* ret1 = NULL; |
---|
32 | struct menulist* mlist = NULL, *mbox = NULL; |
---|
33 | ret1 = strsplit(string_decode(tmpstr2, 0), "\n", &count); |
---|
34 | for(i = 0; i < count; i++) |
---|
35 | { |
---|
36 | if(ret1[i].part != NULL && ostrstr(ret1[i].part, "_quality") != NULL) |
---|
37 | { |
---|
38 | |
---|
39 | if(ostrstr(ret1[i].part, "f4m") != NULL) |
---|
40 | pic = ostrcat("f4m.png", NULL, 0, 0); |
---|
41 | else if(ostrstr(ret1[i].part, "mp4") != NULL) |
---|
42 | pic = ostrcat("mp4.png", NULL, 0, 0); |
---|
43 | else if(ostrstr(ret1[i].part, "3gp") != NULL) |
---|
44 | pic = ostrcat("3gp.png", NULL, 0, 0); |
---|
45 | else if(ostrstr(ret1[i].part, "flv") != NULL) |
---|
46 | pic = ostrcat("flv.png", NULL, 0, 0); |
---|
47 | |
---|
48 | if(ostrstr(ret1[i].part, "_quality\":3") != NULL) |
---|
49 | nummer = ostrcat("high", NULL, 0, 0); |
---|
50 | else if(ostrstr(ret1[i].part, "_quality\":2") != NULL) |
---|
51 | nummer = ostrcat("middle", NULL, 0, 0); |
---|
52 | else if(ostrstr(ret1[i].part, "_quality\":1") != NULL) |
---|
53 | nummer = ostrcat("low", NULL, 0, 0); |
---|
54 | else if(ostrstr(ret1[i].part, "_quality\":0") != NULL) |
---|
55 | nummer = ostrcat("verylow", NULL, 0, 0); |
---|
56 | else if(ostrstr(ret1[i].part, "_quality\":\"auto") != NULL) |
---|
57 | nummer = ostrcat("auto", NULL, 0, 0); |
---|
58 | |
---|
59 | if(ostrstr(ret1[i].part, "http://") != NULL) |
---|
60 | { |
---|
61 | streamurl = oregex(".*\"_stream\":\"(http://.*.mp4).*", ret1[i].part); |
---|
62 | title = ostrcat("Http Stream (", NULL, 0, 0); |
---|
63 | title = ostrcat(title, nummer, 1, 0); |
---|
64 | title = ostrcat(title, ")", 1, 0); |
---|
65 | |
---|
66 | debug(99, "(%d) title: %s streamurl: %s\n", i, title, streamurl); |
---|
67 | addmenulist(&mlist, title, streamurl, pic, 0, 0); |
---|
68 | } |
---|
69 | else if(ostrstr(ret1[i].part, "rtmp://") != NULL) |
---|
70 | { |
---|
71 | part1 = oregex(".*\"_server\":\"(rtmp://.*)\"}.*", ret1[i].part); |
---|
72 | part2 = oregex(".*\"_stream\":\"(mp4:.*)\"}.*", ret1[i].part); |
---|
73 | |
---|
74 | part1 = stringreplacecharonce(part1, '"', '\0'); |
---|
75 | streamurl = ostrcat(part1, part2, 0, 0); |
---|
76 | |
---|
77 | title = ostrcat("RTMP Stream (", NULL, 0, 0); |
---|
78 | title = ostrcat(title, nummer, 1, 0); |
---|
79 | title = ostrcat(title, ")", 1, 0); |
---|
80 | |
---|
81 | debug(99, "(%d) title: %s streamurl: %s\n", i, title, streamurl); |
---|
82 | addmenulist(&mlist, title, streamurl, pic, 0, 0); |
---|
83 | } |
---|
84 | free(part1), part1 = NULL; |
---|
85 | free(part2), part2 = NULL; |
---|
86 | free(title), title = NULL; |
---|
87 | free(pic), pic = NULL; |
---|
88 | free(nummer), nummer = NULL; |
---|
89 | free(streamurl), streamurl = NULL; |
---|
90 | } |
---|
91 | } |
---|
92 | free(ret1), ret1 = NULL; |
---|
93 | |
---|
94 | if(mlist != NULL) |
---|
95 | { |
---|
96 | mbox = menulistbox(mlist, NULL, _("Stream Menu"), _("Choose your Streaming Format from the following list"), NULL, NULL, 1, 0); |
---|
97 | if(mbox != NULL) |
---|
98 | { |
---|
99 | free(streamurl), streamurl = NULL; |
---|
100 | |
---|
101 | debug(99, "mbox->name %s", mbox->name); |
---|
102 | debug(99, "mbox->text %s", mbox->text); |
---|
103 | streamurl = ostrcat(mbox->text, NULL, 0, 0); |
---|
104 | |
---|
105 | } |
---|
106 | } |
---|
107 | free(tmpstr); tmpstr = NULL; |
---|
108 | free(tmpstr2), tmpstr2 = NULL; |
---|
109 | free(ip), ip = NULL; |
---|
110 | |
---|
111 | titheklog(debuglevel, "/tmp/tithek/ard4_streamurl", NULL, NULL, NULL, streamurl); |
---|
112 | |
---|
113 | debug(99, "streamurl: %s", streamurl); |
---|
114 | return streamurl; |
---|
115 | } |
---|
116 | |
---|
117 | int ard_search_local(struct skin* grid, struct skin* listbox, struct skin* countlabel, struct skin* load, char* link, char* title, char* searchstr, int flag) |
---|
118 | { |
---|
119 | char* tmpstr = NULL, *tmpstr1 = NULL, *line = NULL, *menu = NULL, *search = NULL; |
---|
120 | int ret = 1, count = 0, i = 0; |
---|
121 | |
---|
122 | if(listbox == NULL || listbox->select == NULL || listbox->select->handle == NULL) |
---|
123 | return ret; |
---|
124 | |
---|
125 | if(searchstr == NULL) |
---|
126 | search = textinputhist(_("Search"), " ", "searchhist"); |
---|
127 | else |
---|
128 | search = textinputhist(_("Search"), searchstr, "searchhist"); |
---|
129 | |
---|
130 | if(search != NULL) |
---|
131 | { |
---|
132 | drawscreen(load, 0, 0); |
---|
133 | |
---|
134 | strstrip(search); |
---|
135 | string_tolower(search); |
---|
136 | |
---|
137 | tmpstr = gethttp("atemio.dyndns.tv", "/mediathek/ard/streams/ard.all-sorted.list", 80, NULL, HTTPAUTH, 5000, NULL, 0); |
---|
138 | |
---|
139 | struct splitstr* ret1 = NULL; |
---|
140 | ret1 = strsplit(tmpstr, "\n", &count); |
---|
141 | |
---|
142 | if(ret1 != NULL) |
---|
143 | { |
---|
144 | int max = count; |
---|
145 | for(i = 0; i < max; i++) |
---|
146 | { |
---|
147 | |
---|
148 | tmpstr1 = ostrcat(ret1[i].part, NULL, 0, 0); |
---|
149 | tmpstr1 = stringreplacecharonce(tmpstr1, '#', '\0'); |
---|
150 | string_tolower(tmpstr1); |
---|
151 | |
---|
152 | if(ostrstr(tmpstr1, search) != NULL) |
---|
153 | { |
---|
154 | printf("found: %s\n", ret1[i].part); |
---|
155 | int rcret = waitrc(NULL, 10, 0); |
---|
156 | if(rcret == getrcconfigint("rcexit", NULL)) break; |
---|
157 | |
---|
158 | line = ostrcat(line, ret1[i].part, 1, 0); |
---|
159 | line = ostrcat(line, "\n", 0, 0); |
---|
160 | } |
---|
161 | free(tmpstr1), tmpstr1 = NULL; |
---|
162 | } |
---|
163 | free(ret1), ret1 = NULL; |
---|
164 | |
---|
165 | if(line != NULL) |
---|
166 | { |
---|
167 | line = string_replace_all("http://atemio.dyndns.tv/", "http://imageshack.us/md/up/grd/", line, 1); |
---|
168 | menu = ostrcat("/tmp/tithek/ard.search.list", NULL, 0, 0); |
---|
169 | writesys(menu, line, 0); |
---|
170 | struct tithek* tnode = (struct tithek*)listbox->select->handle; |
---|
171 | createtithek(tnode, tnode->title, menu, tnode->pic, tnode->localname, tnode->menutitle, tnode->flag); |
---|
172 | ret = 0; |
---|
173 | } |
---|
174 | } |
---|
175 | free(tmpstr), tmpstr = NULL; |
---|
176 | } |
---|
177 | free(search), search = NULL; |
---|
178 | return ret; |
---|
179 | } |
---|
180 | |
---|
181 | #endif |
---|