1 | #ifndef MYVIDEO_H |
---|
2 | #define MYVIDEO_H |
---|
3 | |
---|
4 | // flag 1 = getstreamurl |
---|
5 | |
---|
6 | char* myvideo(char* input, char* url, char* name, int flag) |
---|
7 | { |
---|
8 | debug(99, "link(%d): %s", flag, input); |
---|
9 | int debuglevel = getconfigint("debuglevel", NULL); |
---|
10 | char* ip = NULL, *pos = NULL, *path = NULL, *pageUrl = NULL, *playpath = NULL, *video_id = NULL, *source = NULL, *streamurl = NULL, *tmpstr_uni = NULL, *b64 = NULL, *key = NULL, *newurl = NULL, *link = NULL, *tmpstr = NULL, *tmppath = NULL, *error = NULL; |
---|
11 | |
---|
12 | if(flag == 1) |
---|
13 | { |
---|
14 | int count = 0; |
---|
15 | struct splitstr* ret1 = NULL; |
---|
16 | ret1 = strsplit(input, ";", &count); |
---|
17 | if(ret1 != NULL && count >= 4) |
---|
18 | { |
---|
19 | link = ostrcat(ret1[0].part, NULL, 0, 0); |
---|
20 | pageUrl = ostrcat(pageUrl, ret1[1].part, 1, 0); |
---|
21 | playpath = ostrcat(playpath, ret1[2].part, 1, 0); |
---|
22 | video_id = ostrcat(video_id, ret1[3].part, 1, 0); |
---|
23 | } |
---|
24 | free(ret1), ret1 = NULL; |
---|
25 | } |
---|
26 | |
---|
27 | ip = string_replace("http://", "", (char*)link, 0); |
---|
28 | |
---|
29 | if(ip != NULL) |
---|
30 | pos = strchr(ip, '/'); |
---|
31 | if(pos != NULL) |
---|
32 | { |
---|
33 | pos[0] = '\0'; |
---|
34 | path = pos + 1; |
---|
35 | } |
---|
36 | |
---|
37 | tmppath = ostrcat("watch/", video_id , 0, 0); |
---|
38 | tmppath = ostrcat(tmppath, "/" , 1, 0); |
---|
39 | tmpstr = gethttp(ip, tmppath, 80, NULL, NULL, 10000, NULL, 0); |
---|
40 | error = string_resub("<div class='lContent lContNoBorder error sBold sCenter'>", "</div>", tmpstr, 0); |
---|
41 | |
---|
42 | unlink("/tmp/myvideo_tmpstr"); |
---|
43 | unlink("/tmp/myvideo_tmpstr_uni"); |
---|
44 | unlink("/tmp/myvideo_tmpstr_error"); |
---|
45 | |
---|
46 | titheklog(debuglevel, "/tmp/myvideo_tmpstr_error", NULL, tmpstr); |
---|
47 | |
---|
48 | if(ostrstr(error, "<div class='error sBold' id='error_screen_body'>") == NULL) |
---|
49 | { |
---|
50 | textbox(_("Message"), _(error) , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
51 | debug(99, "error msg: %s", error); |
---|
52 | } |
---|
53 | |
---|
54 | debug(99, "error link: http://%s/%s", ip, tmppath); |
---|
55 | free(tmpstr), tmpstr = NULL; |
---|
56 | free(tmppath), tmppath = NULL; |
---|
57 | free(error), error = NULL; |
---|
58 | |
---|
59 | // not working tmpstr hat zusatzdaten im string |
---|
60 | tmpstr = gethttp(ip, path, 80, NULL, NULL, 10000, NULL, 0); |
---|
61 | |
---|
62 | debug(99, "link: http://%s/%s", ip, path); |
---|
63 | |
---|
64 | titheklog(debuglevel, "/tmp/myvideo_tmpstr", NULL, tmpstr); |
---|
65 | |
---|
66 | /* |
---|
67 | // work start |
---|
68 | unlink("/tmp/myvideo_tmp"); |
---|
69 | char* cmd = NULL; |
---|
70 | cmd = ostrcat("wget \"", input, 0, 0); |
---|
71 | cmd = ostrcat(cmd, "\" -O /tmp/myvideo_tmp", 1, 0); |
---|
72 | system(cmd); |
---|
73 | free(cmd), cmd = NULL; |
---|
74 | tmpstr = readfiletomem("/tmp/myvideo_tmp", 0); |
---|
75 | // work end |
---|
76 | */ |
---|
77 | if(flag == 1) |
---|
78 | { |
---|
79 | int count = 0; |
---|
80 | struct splitstr* ret1 = NULL; |
---|
81 | ret1 = strsplit(tmpstr, "=", &count); |
---|
82 | int hlen = 0; |
---|
83 | |
---|
84 | if(ret1 != NULL && count >= 2) |
---|
85 | { |
---|
86 | // debug(99, "ret1[1].part=%s", (ret1[1]).part); |
---|
87 | hlen = strlen(ret1[1].part); |
---|
88 | tmpstr_uni = unhexlify(ret1[1].part); |
---|
89 | } |
---|
90 | free(ret1), ret1 = NULL; |
---|
91 | |
---|
92 | b64 = ostrcat("c8407a08b3c71ea418ec9dc662f2a56e40cbd6d5a114aa50fb1e1079e17f2b83", MDString(video_id), 0, 1); |
---|
93 | debug(99, "b64=%s", b64); |
---|
94 | |
---|
95 | key = MDString(b64); |
---|
96 | int slen = 0; |
---|
97 | int klen = 0; |
---|
98 | if(tmpstr_uni != NULL) slen = strlen(tmpstr_uni); |
---|
99 | if(key != NULL) klen = strlen(key); |
---|
100 | |
---|
101 | if(tmpstr_uni != NULL) |
---|
102 | { |
---|
103 | debug(99, "hexlen=%d", hlen); |
---|
104 | hlen /= 2; |
---|
105 | debug(99, "binlen=%d", hlen); |
---|
106 | debug(99, "keylen=%d", klen); |
---|
107 | debug(99, "b64=%s", b64); |
---|
108 | debug(99, "key=%s", key); |
---|
109 | |
---|
110 | rc4(tmpstr_uni, hlen, key, klen); |
---|
111 | |
---|
112 | debug(99, "encrypted=%s", tmpstr_uni); |
---|
113 | debug(99, "pageUrl: %s\n", pageUrl); |
---|
114 | debug(99, "playpath: %s\n", playpath); |
---|
115 | debug(99, "video_id: %s\n", video_id); |
---|
116 | //printf("tmpstr_uni: %s\n",tmpstr_uni); |
---|
117 | |
---|
118 | htmldecode(tmpstr_uni, tmpstr_uni); |
---|
119 | |
---|
120 | titheklog(debuglevel, "/tmp/myvideo_tmpstr_uni", NULL, tmpstr_uni); |
---|
121 | |
---|
122 | if(ostrstr(tmpstr_uni, "connectionurl='rtmp")) |
---|
123 | { |
---|
124 | printf("found rtmpe:// stream\n"); |
---|
125 | source = string_resub("source='", ".flv'", tmpstr_uni, 0); |
---|
126 | |
---|
127 | newurl = string_resub("connectionurl='", "'", tmpstr_uni, 0); |
---|
128 | |
---|
129 | if(ostrstr(newurl, "myvideo2flash")) |
---|
130 | { |
---|
131 | printf("change to rtmpt:// stream\n"); |
---|
132 | newurl = string_replace("rtmpe://", "rtmpt://", newurl, 1); |
---|
133 | } |
---|
134 | |
---|
135 | streamurl = ostrcat(newurl, NULL, 0, 0); |
---|
136 | streamurl = ostrcat(streamurl, " ", 1, 0); |
---|
137 | streamurl = ostrcat(streamurl, "tcUrl=", 1, 0); |
---|
138 | streamurl = ostrcat(streamurl, newurl, 1, 0); |
---|
139 | streamurl = ostrcat(streamurl, " swfVfy=http://is4.myvideo.de/de/player/mingR11q/ming.swf ", 1, 0); |
---|
140 | streamurl = ostrcat(streamurl, pageUrl, 1, 0); |
---|
141 | streamurl = ostrcat(streamurl, " ", 1, 0); |
---|
142 | streamurl = ostrcat(streamurl, "playpath=flv:", 1, 0); |
---|
143 | streamurl = ostrcat(streamurl, source, 1, 0); |
---|
144 | } |
---|
145 | else |
---|
146 | { |
---|
147 | printf("rtmpe not found, change to *.flv stream\n"); |
---|
148 | source = string_resub("source='", "'", tmpstr_uni, 0); |
---|
149 | |
---|
150 | newurl = string_resub("path='", "'", tmpstr_uni, 0); |
---|
151 | |
---|
152 | streamurl = ostrcat(newurl, source, 0, 0); |
---|
153 | } |
---|
154 | } |
---|
155 | } |
---|
156 | |
---|
157 | free(key), key = NULL; |
---|
158 | free(b64), b64 = NULL; |
---|
159 | free(tmpstr_uni), tmpstr_uni = NULL; |
---|
160 | free(url), url = NULL; |
---|
161 | free(source), source = NULL; |
---|
162 | free(tmpstr), tmpstr = NULL; |
---|
163 | free(pageUrl), pageUrl = NULL; |
---|
164 | free(playpath), playpath = NULL; |
---|
165 | free(ip), ip = NULL; |
---|
166 | free(video_id), video_id = NULL; |
---|
167 | free(newurl), newurl = NULL; |
---|
168 | // segfault munmap_chunk(): invalid pointer |
---|
169 | // free(pos), pos = NULL; |
---|
170 | // free(path), path = NULL; |
---|
171 | |
---|
172 | // debug(99, "streamurl2: %s", streamurl); |
---|
173 | return streamurl; |
---|
174 | } |
---|
175 | |
---|
176 | int myvideo_search(struct skin* grid, struct skin* listbox, struct skin* countlabel, struct skin* load, char* link, char* title, char* searchstr, int flag) |
---|
177 | { |
---|
178 | int ret = 1; |
---|
179 | |
---|
180 | if(listbox == NULL || listbox->select == NULL || listbox->select->handle == NULL) |
---|
181 | return ret; |
---|
182 | |
---|
183 | char* search = NULL; |
---|
184 | |
---|
185 | if(flag == 0) |
---|
186 | { |
---|
187 | if(searchstr == NULL) |
---|
188 | search = textinputhist("Search", " ", "searchhist"); |
---|
189 | else |
---|
190 | search = textinputhist("Search", searchstr, "searchhist"); |
---|
191 | } |
---|
192 | |
---|
193 | if(search != NULL || flag > 0) |
---|
194 | { |
---|
195 | drawscreen(load, 0, 0); |
---|
196 | search = stringreplacechar(search, ' ', '+'); |
---|
197 | char* id = NULL; |
---|
198 | char* line = NULL; |
---|
199 | char* pic = NULL; |
---|
200 | char* title = NULL; |
---|
201 | char* menu = NULL; |
---|
202 | char* path = NULL; |
---|
203 | char* ip = ostrcat("www.myvideo.de", NULL, 0, 0); |
---|
204 | |
---|
205 | if(flag == 0) |
---|
206 | path = ostrcat("Videos_A-Z?searchWord=", search, 0, 0); |
---|
207 | else |
---|
208 | path = ostrcat("Top_100/Top_100_Single_Charts", NULL, 0, 0); |
---|
209 | |
---|
210 | char* tmpstr = gethttp(ip, path, 80, NULL, NULL, 10000, NULL, 0); |
---|
211 | tmpstr = string_replace_all("<", "\n", tmpstr, 1); |
---|
212 | tmpstr = string_replace_all(">", "\n", tmpstr, 1); |
---|
213 | |
---|
214 | int count = 0; |
---|
215 | int incount = 0; |
---|
216 | int i = 0; |
---|
217 | struct splitstr* ret1 = NULL; |
---|
218 | ret1 = strsplit(tmpstr, "\n", &count); |
---|
219 | |
---|
220 | if(ret1 != NULL) |
---|
221 | { |
---|
222 | int max = count; |
---|
223 | for(i = 0; i < max; i++) |
---|
224 | { |
---|
225 | if(ostrstr(ret1[i].part, "img id='i") != NULL) |
---|
226 | { |
---|
227 | debug(99, "---------------------------"); |
---|
228 | debug(99, "ret1[i].part: %s", ret1[i].part); |
---|
229 | int rcret = waitrc(NULL, 10, 0); |
---|
230 | if(rcret == getrcconfigint("rcexit", NULL)) break; |
---|
231 | pic = oregex(".*longdesc='(.*)' class='vThumb.*", ret1[i].part); |
---|
232 | id = oregex(".*img id='i(.*)' onload=.*", ret1[i].part); |
---|
233 | title = oregex(".*alt='(.*)' onmouseover=.*", ret1[i].part); |
---|
234 | debug(99, "title: %s", title); |
---|
235 | debug(99, "pic: %s", pic); |
---|
236 | debug(99, "id: %s", id); |
---|
237 | debug(99, "---------------------------"); |
---|
238 | |
---|
239 | if(id != NULL) |
---|
240 | { |
---|
241 | incount += 1; |
---|
242 | line = ostrcat(line, title, 1, 0); |
---|
243 | // line = ostrcat(line, "#http://www.myvideo.de/dynamic/get_player_video_xml.php?flash_playertype=SER&ID=", 1, 0); |
---|
244 | // de fix |
---|
245 | line = ostrcat(line, "#http://www.myvideo.de/dynamic/get_player_video_xml.php?domain=www.myvideo.de&flash_playertype=D&ds=1&autorun=yes&ID=", 1, 0); |
---|
246 | line = ostrcat(line, id, 1, 0); |
---|
247 | // line = ostrcat(line, "&_countlimit=4&autorun=yes;pageUrl=http://www.myvideo.de/watch/", 1, 0); |
---|
248 | // de fix |
---|
249 | line = ostrcat(line, "&_countlimit=4;pageUrl=http://www.myvideo.de/watch/", 1, 0); |
---|
250 | line = ostrcat(line, id, 1, 0); |
---|
251 | line = ostrcat(line, "/;playpath=flv:movie24/a0/", 1, 0); |
---|
252 | line = ostrcat(line, id, 1, 0); |
---|
253 | line = ostrcat(line, ";", 1, 0); |
---|
254 | line = ostrcat(line, id, 1, 0); |
---|
255 | line = ostrcat(line, "#", 1, 0); |
---|
256 | line = ostrcat(line, pic, 1, 0); |
---|
257 | line = ostrcat(line, "#myvideo_search_", 1, 0); |
---|
258 | line = ostrcat(line, oitoa(incount + time(NULL)), 1, 0); |
---|
259 | line = ostrcat(line, ".jpg#MyVideo - Search#12\n", 1, 0); |
---|
260 | free(ip), ip = NULL; |
---|
261 | free(path), path = NULL; |
---|
262 | free(title), title = NULL; |
---|
263 | } |
---|
264 | |
---|
265 | } |
---|
266 | } |
---|
267 | free(ret1), ret1 = NULL; |
---|
268 | |
---|
269 | if(line != NULL) |
---|
270 | { |
---|
271 | menu = ostrcat("/tmp/tithek/myvideo.search.list", NULL, 0, 0); |
---|
272 | writesys(menu, line, 0); |
---|
273 | struct tithek* tnode = (struct tithek*)listbox->select->handle; |
---|
274 | createtithek(tnode, tnode->title, menu, tnode->pic, tnode->localname, tnode->menutitle, tnode->flag); |
---|
275 | ret = 0; |
---|
276 | } |
---|
277 | } |
---|
278 | free(tmpstr), tmpstr = NULL; |
---|
279 | } |
---|
280 | free(search), search = NULL; |
---|
281 | return ret; |
---|
282 | } |
---|
283 | |
---|
284 | #endif |
---|