1 | #ifndef MYVIDEO_H |
---|
2 | #define MYVIDEO_H |
---|
3 | |
---|
4 | // flag 1 = getstreamurl |
---|
5 | //http://www.myvideo.de/dynamic/get_player_video_xml.php?domain=www.myvideo.de&flash_playertype=D&ds=1&autorun=yes&ID=1770991 |
---|
6 | |
---|
7 | //http://www.myvideo.de/dynamic/get_player_video_xml.php?domain=www.myvideo.de&flash_playertype=D&ds=1&autorun=yes&ID=9693945 |
---|
8 | |
---|
9 | char* myvideo_hoster(char* link) |
---|
10 | { |
---|
11 | debug(99, "link: %s", link); |
---|
12 | char* streamurl = NULL; |
---|
13 | |
---|
14 | streamurl = hoster(link); |
---|
15 | debug(99, "streamurl1: %s", streamurl); |
---|
16 | |
---|
17 | streamurl = string_replace_all("amp;", "", streamurl, 1); |
---|
18 | debug(99, "streamurl2: %s", streamurl); |
---|
19 | |
---|
20 | return streamurl; |
---|
21 | } |
---|
22 | |
---|
23 | char* myvideo(char* link) |
---|
24 | { |
---|
25 | debug(99, "link: %s", link); |
---|
26 | int debuglevel = getconfigint("debuglevel", NULL); |
---|
27 | char* ip = NULL, *pos = NULL, *path = NULL, *tmplink = NULL, *pageUrl = NULL, *playpath = NULL, *video_id = NULL, *source = NULL, *streamurl = NULL, *tmpstr_uni = NULL, *b64 = NULL, *key = NULL, *newurl = NULL, *tmpstr = NULL, *tmppath = NULL, *error = NULL; |
---|
28 | int flag = 1; |
---|
29 | |
---|
30 | /* |
---|
31 | if(flag == 1) |
---|
32 | { |
---|
33 | int count = 0; |
---|
34 | struct splitstr* ret1 = NULL; |
---|
35 | ret1 = strsplit(input, ";", &count); |
---|
36 | if(ret1 != NULL && count >= 4) |
---|
37 | { |
---|
38 | link = ostrcat(ret1[0].part, NULL, 0, 0); |
---|
39 | pageUrl = ostrcat(pageUrl, ret1[1].part, 1, 0); |
---|
40 | playpath = ostrcat(playpath, ret1[2].part, 1, 0); |
---|
41 | video_id = ostrcat(video_id, ret1[3].part, 1, 0); |
---|
42 | } |
---|
43 | free(ret1), ret1 = NULL; |
---|
44 | } |
---|
45 | */ |
---|
46 | stringreplacechar(link, ';', '\0'); |
---|
47 | |
---|
48 | if(ostrstr(link, "/watch/") != NULL) |
---|
49 | { |
---|
50 | // video_id = oregex(".*/watch/.*(.*)/.*", link); |
---|
51 | video_id = string_resub("/watch/", "/", link, 0); |
---|
52 | tmplink = ostrcat("http://www.myvideo.de/dynamic/get_player_video_xml.php?domain=www.myvideo.de&flash_playertype=D&ds=1&autorun=yes&ID=", video_id, 0, 0); |
---|
53 | tmplink = ostrcat(tmplink, "&_countlimit=4;", 1, 0); |
---|
54 | free(video_id), video_id = NULL; |
---|
55 | } |
---|
56 | else |
---|
57 | tmplink = ostrcat(link, NULL, 0, 0); |
---|
58 | |
---|
59 | ip = string_replace("http://", "", tmplink, 0); |
---|
60 | |
---|
61 | if(ip != NULL) |
---|
62 | pos = strchr(ip, '/'); |
---|
63 | if(pos != NULL) |
---|
64 | { |
---|
65 | pos[0] = '\0'; |
---|
66 | path = pos + 1; |
---|
67 | } |
---|
68 | |
---|
69 | video_id = string_resub("&ID=", "&", tmplink, 0); |
---|
70 | |
---|
71 | tmppath = ostrcat("watch/", video_id , 0, 0); |
---|
72 | tmppath = ostrcat(tmppath, "/" , 1, 0); |
---|
73 | tmpstr = gethttp(ip, tmppath, 80, NULL, NULL, 10000, NULL, 0); |
---|
74 | error = string_resub("<div class='lContent lContNoBorder error sBold sCenter'>", "</div>", tmpstr, 0); |
---|
75 | |
---|
76 | unlink("/tmp/myvideo_tmpstr"); |
---|
77 | unlink("/tmp/myvideo_tmpstr_uni"); |
---|
78 | unlink("/tmp/myvideo_tmpstr_error"); |
---|
79 | |
---|
80 | titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/myvideo_tmpstr", NULL, NULL, NULL, tmpstr); |
---|
81 | |
---|
82 | titheklog(debuglevel, "/tmp/myvideo_tmpstr_error", NULL, NULL, NULL, tmpstr); |
---|
83 | |
---|
84 | if(ostrstr(error, "<div class='error sBold' id='error_screen_body'>") == NULL) |
---|
85 | { |
---|
86 | textbox(_("Message"), _(error) , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
87 | debug(99, "error msg: %s", error); |
---|
88 | } |
---|
89 | |
---|
90 | debug(99, "error link: http://%s/%s", ip, tmppath); |
---|
91 | free(tmpstr), tmpstr = NULL; |
---|
92 | free(tmppath), tmppath = NULL; |
---|
93 | free(error), error = NULL; |
---|
94 | |
---|
95 | // not working tmpstr hat zusatzdaten im string |
---|
96 | tmpstr = gethttp(ip, path, 80, NULL, NULL, 10000, NULL, 0); |
---|
97 | |
---|
98 | debug(99, "link: http://%s/%s", ip, path); |
---|
99 | titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/myvideo_tmpstr2", NULL, NULL, NULL, tmpstr); |
---|
100 | |
---|
101 | titheklog(debuglevel, "/tmp/myvideo_tmpstr", NULL, NULL, NULL, tmpstr); |
---|
102 | |
---|
103 | /* |
---|
104 | // work start |
---|
105 | unlink("/tmp/myvideo_tmp"); |
---|
106 | char* cmd = NULL; |
---|
107 | cmd = ostrcat("wget \"", input, 0, 0); |
---|
108 | cmd = ostrcat(cmd, "\" -O /tmp/myvideo_tmp", 1, 0); |
---|
109 | system(cmd); |
---|
110 | free(cmd), cmd = NULL; |
---|
111 | tmpstr = readfiletomem("/tmp/myvideo_tmp", 0); |
---|
112 | // work end |
---|
113 | */ |
---|
114 | if(flag == 1) |
---|
115 | { |
---|
116 | int count = 0; |
---|
117 | struct splitstr* ret1 = NULL; |
---|
118 | ret1 = strsplit(tmpstr, "=", &count); |
---|
119 | int hlen = 0; |
---|
120 | |
---|
121 | if(ret1 != NULL && count >= 2) |
---|
122 | { |
---|
123 | // debug(99, "ret1[1].part=%s", (ret1[1]).part); |
---|
124 | hlen = strlen(ret1[1].part); |
---|
125 | tmpstr_uni = unhexlify(ret1[1].part); |
---|
126 | } |
---|
127 | free(ret1), ret1 = NULL; |
---|
128 | |
---|
129 | b64 = ostrcat("c8407a08b3c71ea418ec9dc662f2a56e40cbd6d5a114aa50fb1e1079e17f2b83", MDString(video_id), 0, 1); |
---|
130 | debug(99, "b64=%s", b64); |
---|
131 | |
---|
132 | key = MDString(b64); |
---|
133 | int slen = 0; |
---|
134 | int klen = 0; |
---|
135 | if(tmpstr_uni != NULL) slen = strlen(tmpstr_uni); |
---|
136 | if(key != NULL) klen = strlen(key); |
---|
137 | |
---|
138 | if(tmpstr_uni != NULL) |
---|
139 | { |
---|
140 | debug(99, "hexlen=%d", hlen); |
---|
141 | hlen /= 2; |
---|
142 | debug(99, "binlen=%d", hlen); |
---|
143 | debug(99, "keylen=%d", klen); |
---|
144 | debug(99, "b64=%s", b64); |
---|
145 | debug(99, "key=%s", key); |
---|
146 | |
---|
147 | rc4(tmpstr_uni, hlen, key, klen); |
---|
148 | |
---|
149 | debug(99, "encrypted=%s", tmpstr_uni); |
---|
150 | debug(99, "pageUrl: %s\n", pageUrl); |
---|
151 | debug(99, "playpath: %s\n", playpath); |
---|
152 | debug(99, "video_id: %s\n", video_id); |
---|
153 | //printf("tmpstr_uni: %s\n",tmpstr_uni); |
---|
154 | |
---|
155 | htmldecode(tmpstr_uni, tmpstr_uni); |
---|
156 | |
---|
157 | titheklog(debuglevel, "/tmp/myvideo_tmpstr_uni", NULL, NULL, NULL, tmpstr_uni); |
---|
158 | |
---|
159 | if(ostrstr(tmpstr_uni, "connectionurl='rtmp")) |
---|
160 | { |
---|
161 | printf("found rtmpe:// stream\n"); |
---|
162 | source = string_resub("source='", ".flv'", tmpstr_uni, 0); |
---|
163 | |
---|
164 | newurl = string_resub("connectionurl='", "'", tmpstr_uni, 0); |
---|
165 | |
---|
166 | /* |
---|
167 | if(ostrstr(newurl, "myvideo2flash")) |
---|
168 | { |
---|
169 | printf("change to rtmpt:// stream\n"); |
---|
170 | newurl = string_replace("rtmpe://", "rtmpt://", newurl, 1); |
---|
171 | } |
---|
172 | */ |
---|
173 | newurl = string_replace("rtmpe://", "rtmp://", newurl, 1); |
---|
174 | |
---|
175 | streamurl = ostrcat(newurl, NULL, 0, 0); |
---|
176 | streamurl = ostrcat(streamurl, " ", 1, 0); |
---|
177 | streamurl = ostrcat(streamurl, "tcUrl=", 1, 0); |
---|
178 | streamurl = ostrcat(streamurl, newurl, 1, 0); |
---|
179 | streamurl = ostrcat(streamurl, " swfVfy=http://is4.myvideo.de/de/player/mingR11q/ming.swf ", 1, 0); |
---|
180 | streamurl = ostrcat(streamurl, pageUrl, 1, 0); |
---|
181 | streamurl = ostrcat(streamurl, " ", 1, 0); |
---|
182 | streamurl = ostrcat(streamurl, "playpath=flv:", 1, 0); |
---|
183 | streamurl = ostrcat(streamurl, source, 1, 0); |
---|
184 | } |
---|
185 | else |
---|
186 | { |
---|
187 | printf("rtmpe not found, change to *.flv stream\n"); |
---|
188 | source = string_resub("source='", "'", tmpstr_uni, 0); |
---|
189 | |
---|
190 | newurl = string_resub("path='", "'", tmpstr_uni, 0); |
---|
191 | |
---|
192 | streamurl = ostrcat(newurl, source, 0, 0); |
---|
193 | } |
---|
194 | } |
---|
195 | } |
---|
196 | |
---|
197 | free(key), key = NULL; |
---|
198 | free(b64), b64 = NULL; |
---|
199 | free(tmpstr_uni), tmpstr_uni = NULL; |
---|
200 | free(tmplink), tmplink = NULL; |
---|
201 | free(source), source = NULL; |
---|
202 | free(tmpstr), tmpstr = NULL; |
---|
203 | free(pageUrl), pageUrl = NULL; |
---|
204 | free(playpath), playpath = NULL; |
---|
205 | free(ip), ip = NULL; |
---|
206 | free(video_id), video_id = NULL; |
---|
207 | free(newurl), newurl = NULL; |
---|
208 | // segfault munmap_chunk(): invalid pointer |
---|
209 | // free(pos), pos = NULL; |
---|
210 | // free(path), path = NULL; |
---|
211 | |
---|
212 | // debug(99, "streamurl2: %s", streamurl); |
---|
213 | return streamurl; |
---|
214 | } |
---|
215 | |
---|
216 | int myvideo_search(struct skin* grid, struct skin* listbox, struct skin* countlabel, struct skin* load, char* link, char* title, char* searchstr, int flag) |
---|
217 | { |
---|
218 | int ret = 1; |
---|
219 | int debuglevel = getconfigint("debuglevel", NULL); |
---|
220 | |
---|
221 | if(listbox == NULL || listbox->select == NULL || listbox->select->handle == NULL) |
---|
222 | return ret; |
---|
223 | |
---|
224 | char* search = NULL; |
---|
225 | |
---|
226 | if(flag == 0) |
---|
227 | { |
---|
228 | if(searchstr == NULL) |
---|
229 | search = textinputhist(_("Search"), " ", "searchhist"); |
---|
230 | else |
---|
231 | search = textinputhist(_("Search"), searchstr, "searchhist"); |
---|
232 | } |
---|
233 | |
---|
234 | if(search != NULL || flag > 0) |
---|
235 | { |
---|
236 | drawscreen(load, 0, 0); |
---|
237 | search = stringreplacechar(search, ' ', '+'); |
---|
238 | char* id = NULL; |
---|
239 | char* line = NULL; |
---|
240 | char* pic = NULL; |
---|
241 | char* title = NULL; |
---|
242 | char* menu = NULL; |
---|
243 | char* path = NULL; |
---|
244 | char* ip = ostrcat("www.myvideo.de", NULL, 0, 0); |
---|
245 | |
---|
246 | if(flag == 0) |
---|
247 | path = ostrcat("Videos_A-Z?searchWord=", search, 0, 0); |
---|
248 | else |
---|
249 | path = ostrcat("Top_100/Top_100_Single_Charts", NULL, 0, 0); |
---|
250 | |
---|
251 | char* tmpstr = NULL; |
---|
252 | char* tmpstr1 = NULL; |
---|
253 | tmpstr = gethttp(ip, path, 80, NULL, NULL, 10000, NULL, 0); |
---|
254 | titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/myvideo1_search_tmpstr", NULL, NULL, NULL, tmpstr); |
---|
255 | |
---|
256 | if(flag == 0) |
---|
257 | { |
---|
258 | tmpstr = string_replace_all("<", "\n", tmpstr, 1); |
---|
259 | tmpstr = string_replace_all(">", "\n", tmpstr, 1); |
---|
260 | titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/myvideo2_search_tmpstr_replace", NULL, NULL, NULL, tmpstr); |
---|
261 | } |
---|
262 | else |
---|
263 | { |
---|
264 | tmpstr1 = string_resub("MV.contentLists.chartlist = {", "</script>", tmpstr, 0); |
---|
265 | titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/myvideo2_search_tmpstr1_resub", NULL, NULL, NULL, tmpstr1); |
---|
266 | free(tmpstr), tmpstr = NULL; |
---|
267 | tmpstr = ostrcat(tmpstr1, NULL, 0, 0); |
---|
268 | free(tmpstr1), tmpstr1 = NULL; |
---|
269 | } |
---|
270 | |
---|
271 | int count = 0; |
---|
272 | int incount = 0; |
---|
273 | int i = 0; |
---|
274 | struct splitstr* ret1 = NULL; |
---|
275 | ret1 = strsplit(tmpstr, "\n", &count); |
---|
276 | |
---|
277 | if(ret1 != NULL) |
---|
278 | { |
---|
279 | int max = count; |
---|
280 | for(i = 0; i < max; i++) |
---|
281 | { |
---|
282 | debug(99, "1111ret1[i].part=%s", ret1[i].part); |
---|
283 | |
---|
284 | if(ostrstr(ret1[i].part, "img id='i") != NULL) |
---|
285 | { |
---|
286 | debug(99, "---------------------------"); |
---|
287 | debug(99, "ret1[i].part: %s", ret1[i].part); |
---|
288 | int rcret = waitrc(NULL, 10, 0); |
---|
289 | if(rcret == getrcconfigint("rcexit", NULL)) break; |
---|
290 | pic = oregex(".*longdesc='(.*)' class='vThumb.*", ret1[i].part); |
---|
291 | id = oregex(".*img id='i(.*)' onload=.*", ret1[i].part); |
---|
292 | title = oregex(".*alt='(.*)' onmouseover=.*", ret1[i].part); |
---|
293 | debug(99, "title: %s", title); |
---|
294 | debug(99, "pic: %s", pic); |
---|
295 | debug(99, "id: %s", id); |
---|
296 | debug(99, "---------------------------"); |
---|
297 | } |
---|
298 | else if(ostrstr(ret1[i].part, "{\"id\":") != NULL) |
---|
299 | { |
---|
300 | debug(99, "---------------------------"); |
---|
301 | debug(99, "ret1[i].part: %s", ret1[i].part); |
---|
302 | int rcret = waitrc(NULL, 10, 0); |
---|
303 | if(rcret == getrcconfigint("rcexit", NULL)) break; |
---|
304 | // pic = oregex(".*{\"id\":(.*),\".*", ret1[i].part); |
---|
305 | // id = oregex(".*{\"id\":(.*),\".*", ret1[i].part); |
---|
306 | // title = oregex(".*alt='(.*)' onmouseover=.*", ret1[i].part); |
---|
307 | |
---|
308 | id = string_resub("{\"id\":", ",\"", ret1[i].part, 0); |
---|
309 | pic = string_resub("\"thumbnail\":\"", "\",", ret1[i].part, 0); |
---|
310 | title = string_resub("\"title\":\"", "\",", ret1[i].part, 0); |
---|
311 | pic = string_replace_all("\\", "", pic, 1); |
---|
312 | |
---|
313 | debug(99, "title: %s", title); |
---|
314 | debug(99, "pic: %s", pic); |
---|
315 | debug(99, "id: %s", id); |
---|
316 | debug(99, "---------------------------"); |
---|
317 | } |
---|
318 | if(id != NULL) |
---|
319 | { |
---|
320 | incount += 1; |
---|
321 | line = ostrcat(line, title, 1, 0); |
---|
322 | // line = ostrcat(line, "#http://www.myvideo.de/dynamic/get_player_video_xml.php?flash_playertype=SER&ID=", 1, 0); |
---|
323 | // de fix |
---|
324 | 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); |
---|
325 | line = ostrcat(line, id, 1, 0); |
---|
326 | // line = ostrcat(line, "&_countlimit=4&autorun=yes;pageUrl=http://www.myvideo.de/watch/", 1, 0); |
---|
327 | // de fix |
---|
328 | line = ostrcat(line, "&_countlimit=4;pageUrl=http://www.myvideo.de/watch/", 1, 0); |
---|
329 | line = ostrcat(line, id, 1, 0); |
---|
330 | line = ostrcat(line, "/;playpath=flv:movie24/a0/", 1, 0); |
---|
331 | line = ostrcat(line, id, 1, 0); |
---|
332 | line = ostrcat(line, ";", 1, 0); |
---|
333 | line = ostrcat(line, id, 1, 0); |
---|
334 | line = ostrcat(line, "#", 1, 0); |
---|
335 | line = ostrcat(line, pic, 1, 0); |
---|
336 | line = ostrcat(line, "#myvideo_search_", 1, 0); |
---|
337 | line = ostrcat(line, oitoa(incount + time(NULL)), 1, 0); |
---|
338 | line = ostrcat(line, ".jpg#MyVideo - Search#12\n", 1, 0); |
---|
339 | free(ip), ip = NULL; |
---|
340 | free(path), path = NULL; |
---|
341 | free(title), title = NULL; |
---|
342 | } |
---|
343 | free(title), title = NULL; |
---|
344 | free(pic), pic = NULL; |
---|
345 | free(id), id = NULL; |
---|
346 | } |
---|
347 | free(ret1), ret1 = NULL; |
---|
348 | |
---|
349 | if(line != NULL) |
---|
350 | { |
---|
351 | menu = ostrcat("/tmp/tithek/myvideo.search.list", NULL, 0, 0); |
---|
352 | writesys(menu, line, 0); |
---|
353 | struct tithek* tnode = (struct tithek*)listbox->select->handle; |
---|
354 | createtithek(tnode, tnode->title, menu, tnode->pic, tnode->localname, tnode->menutitle, tnode->flag); |
---|
355 | ret = 0; |
---|
356 | } |
---|
357 | } |
---|
358 | free(tmpstr), tmpstr = NULL; |
---|
359 | } |
---|
360 | free(search), search = NULL; |
---|
361 | return ret; |
---|
362 | } |
---|
363 | |
---|
364 | int myvideo_search_local(struct skin* grid, struct skin* listbox, struct skin* countlabel, struct skin* load, char* link, char* title, char* searchstr, int flag) |
---|
365 | { |
---|
366 | char* tmpstr = NULL, *tmpstr1 = NULL, *line = NULL, *menu = NULL, *search = NULL; |
---|
367 | int ret = 1, count = 0, i = 0; |
---|
368 | |
---|
369 | if(listbox == NULL || listbox->select == NULL || listbox->select->handle == NULL) |
---|
370 | return ret; |
---|
371 | |
---|
372 | if(searchstr == NULL) |
---|
373 | search = textinputhist(_("Search"), " ", "searchhist"); |
---|
374 | else |
---|
375 | search = textinputhist(_("Search"), searchstr, "searchhist"); |
---|
376 | |
---|
377 | if(search != NULL) |
---|
378 | { |
---|
379 | drawscreen(load, 0, 0); |
---|
380 | |
---|
381 | strstrip(search); |
---|
382 | string_tolower(search); |
---|
383 | |
---|
384 | tmpstr = gethttp("atemio.dyndns.tv", "/mediathek/myvideo/streams/myvideo.all-sorted.list", 80, NULL, HTTPAUTH, 5000, NULL, 0); |
---|
385 | |
---|
386 | struct splitstr* ret1 = NULL; |
---|
387 | ret1 = strsplit(tmpstr, "\n", &count); |
---|
388 | |
---|
389 | if(ret1 != NULL) |
---|
390 | { |
---|
391 | int max = count; |
---|
392 | for(i = 0; i < max; i++) |
---|
393 | { |
---|
394 | |
---|
395 | tmpstr1 = ostrcat(ret1[i].part, NULL, 0, 0); |
---|
396 | tmpstr1 = stringreplacecharonce(tmpstr1, '#', '\0'); |
---|
397 | string_tolower(tmpstr1); |
---|
398 | |
---|
399 | if(ostrstr(tmpstr1, search) != NULL) |
---|
400 | { |
---|
401 | printf("found: %s\n", ret1[i].part); |
---|
402 | int rcret = waitrc(NULL, 10, 0); |
---|
403 | if(rcret == getrcconfigint("rcexit", NULL)) break; |
---|
404 | |
---|
405 | line = ostrcat(line, ret1[i].part, 1, 0); |
---|
406 | line = ostrcat(line, "\n", 0, 0); |
---|
407 | } |
---|
408 | free(tmpstr1), tmpstr1 = NULL; |
---|
409 | } |
---|
410 | free(ret1), ret1 = NULL; |
---|
411 | |
---|
412 | if(line != NULL) |
---|
413 | { |
---|
414 | line = string_replace_all("http://atemio.dyndns.tv/", "http://imageshack.us/md/up/grd/", line, 1); |
---|
415 | menu = ostrcat("/tmp/tithek/myvideo.search.list", NULL, 0, 0); |
---|
416 | writesys(menu, line, 0); |
---|
417 | struct tithek* tnode = (struct tithek*)listbox->select->handle; |
---|
418 | createtithek(tnode, tnode->title, menu, tnode->pic, tnode->localname, tnode->menutitle, tnode->flag); |
---|
419 | ret = 0; |
---|
420 | } |
---|
421 | } |
---|
422 | free(tmpstr), tmpstr = NULL; |
---|
423 | } |
---|
424 | free(search), search = NULL; |
---|
425 | return ret; |
---|
426 | } |
---|
427 | |
---|
428 | #endif |
---|