1 | #ifndef TITHEK_GLOBAL_H |
---|
2 | #define TITHEK_GLOBAL |
---|
3 | |
---|
4 | #include <curl/curl.h> |
---|
5 | |
---|
6 | char* hoster(char* url) |
---|
7 | { |
---|
8 | debug(99, "url: %s", url); |
---|
9 | char* streamurl = NULL, *tmplink = NULL; |
---|
10 | |
---|
11 | tmplink = ostrcat(url, NULL, 0, 0); |
---|
12 | string_tolower(tmplink); |
---|
13 | |
---|
14 | if(ostrstr(tmplink, "sockshare") != NULL) |
---|
15 | streamurl = putlocker(url); |
---|
16 | else if(ostrstr(tmplink, "putlocker") != NULL) |
---|
17 | streamurl = firedrive(url); |
---|
18 | else if(ostrstr(tmplink, "filenuke") != NULL) |
---|
19 | streamurl = filenuke(url); |
---|
20 | else if(ostrstr(tmplink, "streamcloud") != NULL) |
---|
21 | streamurl = streamcloud(url); |
---|
22 | else if(ostrstr(tmplink, "vidstream") != NULL) |
---|
23 | streamurl = vidstream(url); |
---|
24 | else if(ostrstr(tmplink, "flashx") != NULL) |
---|
25 | streamurl = flashx(url); |
---|
26 | else if(ostrstr(tmplink, "xvidstage") != NULL) |
---|
27 | streamurl = xvidstage(url); |
---|
28 | else if(ostrstr(tmplink, "nowvideo") != NULL) |
---|
29 | streamurl = nowvideo(url); |
---|
30 | else if(ostrstr(tmplink, "movshare") != NULL) |
---|
31 | streamurl = movshare(url); |
---|
32 | else if(ostrstr(tmplink, "movreel") != NULL) |
---|
33 | streamurl = movreel(url); |
---|
34 | else if(ostrstr(tmplink, "novamov") != NULL) |
---|
35 | streamurl = novamov(url); |
---|
36 | else if(ostrstr(tmplink, "divxstage") != NULL || ostrstr(tmplink, "cloudtime") != NULL) |
---|
37 | streamurl = divxstage(url); |
---|
38 | else if(ostrstr(tmplink, "primeshare") != NULL) |
---|
39 | streamurl = primeshare(url); |
---|
40 | else if(ostrstr(tmplink, "faststream") != NULL || ostrstr(tmplink, "fastvideo") != NULL) |
---|
41 | streamurl = faststream(url); |
---|
42 | else if(ostrstr(tmplink, "played") != NULL) |
---|
43 | streamurl = played(url); |
---|
44 | else if(ostrstr(tmplink, "videoweed") != NULL) |
---|
45 | streamurl = videoweed(url); |
---|
46 | else if(ostrstr(tmplink, "firedrive") != NULL) |
---|
47 | streamurl = firedrive(url); |
---|
48 | else if(ostrstr(tmplink, "shared") != NULL) |
---|
49 | streamurl = shared(url); |
---|
50 | else if(ostrstr(tmplink, "thefile") != NULL) |
---|
51 | streamurl = thefile(url); |
---|
52 | else if(ostrstr(tmplink, "youtu") != NULL) |
---|
53 | streamurl = youtube(url); |
---|
54 | else if(ostrstr(tmplink, "myvideo") != NULL) |
---|
55 | streamurl = myvideo(url); |
---|
56 | else if(ostrstr(tmplink, "promptfile") != NULL) |
---|
57 | streamurl = promptfile(url); |
---|
58 | else if(ostrstr(tmplink, "letwatch") != NULL || ostrstr(tmplink, "realvid") != NULL) |
---|
59 | streamurl = letwatch(url); |
---|
60 | else if(ostrstr(tmplink, "vidbull") != NULL) |
---|
61 | streamurl = vidbull(url); |
---|
62 | else if(ostrstr(tmplink, "vodlocker") != NULL) |
---|
63 | streamurl = vodlocker(url); |
---|
64 | else if(ostrstr(tmplink, "vidto") != NULL) |
---|
65 | streamurl = vidto(url); |
---|
66 | else if(ostrstr(tmplink, "amazon") != NULL) |
---|
67 | streamurl = amazon(url); |
---|
68 | else if(ostrstr(tmplink, "thevideo") != NULL) |
---|
69 | streamurl = thevideo(url); |
---|
70 | else if(ostrstr(tmplink, "mightyupload") != NULL) |
---|
71 | streamurl = mightyupload(url); |
---|
72 | else if(ostrstr(tmplink, "cloudzilla") != NULL) |
---|
73 | streamurl = cloudzilla(url); |
---|
74 | else if(ostrstr(tmplink, "vivo") != NULL) |
---|
75 | streamurl = vivo(url); |
---|
76 | else if(ostrstr(tmplink, "streamlive") != NULL) |
---|
77 | streamurl = streamlive(url, -1); |
---|
78 | else if(ostrstr(tmplink, "cricfree") != NULL) |
---|
79 | streamurl = cricfree(url, 0); |
---|
80 | else if(ostrstr(tmplink, "zerocast") != NULL) |
---|
81 | streamurl = zerocast(url, 0); |
---|
82 | else if(ostrstr(tmplink, "p2pcast") != NULL) |
---|
83 | streamurl = p2pcast(url); |
---|
84 | else |
---|
85 | { |
---|
86 | char* cmd = NULL; |
---|
87 | cmd = ostrcat("/tmp/localhoster/hoster.sh ", url, 0, 0); |
---|
88 | streamurl = command(cmd); |
---|
89 | free(cmd), cmd = NULL; |
---|
90 | if(streamurl == NULL) |
---|
91 | textbox(_("Message"), _("The hoster is not yet supported !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 5, 0); |
---|
92 | } |
---|
93 | |
---|
94 | debug(99, "Streamurl1: %s", streamurl); |
---|
95 | |
---|
96 | streamurl = string_replace_all("amp;", "", streamurl, 1); |
---|
97 | debug(99, "Streamurl2: %s", streamurl); |
---|
98 | |
---|
99 | free(tmplink), tmplink = NULL; |
---|
100 | if(ostrncmp("http", streamurl, 4) && ostrncmp("rtmp", streamurl, 4) && ostrncmp("mms", streamurl, 3) && ostrncmp("rtsp", streamurl, 4)) |
---|
101 | { |
---|
102 | printf("Streamurl3: not http*|rtmp*|mms*|rtsp* Streamurl: %s\n", streamurl); |
---|
103 | free(streamurl),streamurl = NULL; |
---|
104 | } |
---|
105 | |
---|
106 | return streamurl; |
---|
107 | } |
---|
108 | |
---|
109 | struct MemoryStruct { |
---|
110 | char *memory; |
---|
111 | size_t size; |
---|
112 | }; |
---|
113 | |
---|
114 | static size_t |
---|
115 | WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp) |
---|
116 | { |
---|
117 | size_t realsize = size * nmemb; |
---|
118 | struct MemoryStruct *mem = (struct MemoryStruct *)userp; |
---|
119 | |
---|
120 | mem->memory = realloc(mem->memory, mem->size + realsize + 1); |
---|
121 | if(mem->memory == NULL) { |
---|
122 | /* out of memory! */ |
---|
123 | printf("not enough memory (realloc returned NULL)\n"); |
---|
124 | return 0; |
---|
125 | } |
---|
126 | |
---|
127 | memcpy(&(mem->memory[mem->size]), contents, realsize); |
---|
128 | mem->size += realsize; |
---|
129 | mem->memory[mem->size] = 0; |
---|
130 | |
---|
131 | return realsize; |
---|
132 | } |
---|
133 | |
---|
134 | // flag = 0 (without header in output) |
---|
135 | // flag = 1 (with header in output) |
---|
136 | char* gethttps(char* url, char* localfile, char* data, char* user, char* pass, char* referer, int flag) |
---|
137 | { |
---|
138 | debug(99, "url: %s", url); |
---|
139 | |
---|
140 | int debuglevel = getconfigint("debuglevel", NULL); |
---|
141 | |
---|
142 | char* tmpstr = NULL; |
---|
143 | FILE *fp; |
---|
144 | |
---|
145 | CURL *curl_handle; |
---|
146 | CURLcode res; |
---|
147 | |
---|
148 | struct MemoryStruct chunk; |
---|
149 | |
---|
150 | chunk.memory = malloc(1); /* will be grown as needed by the realloc above */ |
---|
151 | chunk.size = 0; /* no data at this point */ |
---|
152 | |
---|
153 | curl_global_init(CURL_GLOBAL_ALL); |
---|
154 | |
---|
155 | /* init the curl session */ |
---|
156 | curl_handle = curl_easy_init(); |
---|
157 | if(curl_handle) |
---|
158 | { |
---|
159 | if(localfile != NULL) |
---|
160 | fp = fopen(localfile,"wb"); |
---|
161 | |
---|
162 | /* specify URL to get */ |
---|
163 | curl_easy_setopt(curl_handle, CURLOPT_URL, url); |
---|
164 | |
---|
165 | if(user != NULL && pass != NULL) |
---|
166 | { |
---|
167 | curl_easy_setopt(curl_handle, CURLOPT_USERNAME, user); |
---|
168 | curl_easy_setopt(curl_handle, CURLOPT_PASSWORD, pass); |
---|
169 | curl_easy_setopt(curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_ANY); |
---|
170 | } |
---|
171 | if(data == NULL) |
---|
172 | curl_easy_setopt(curl_handle, CURLOPT_HTTPGET, 1L); |
---|
173 | else |
---|
174 | curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, data); |
---|
175 | if(flag == 1) |
---|
176 | curl_easy_setopt(curl_handle, CURLOPT_HEADER, 1L); |
---|
177 | curl_easy_setopt(curl_handle, CURLOPT_CONNECTTIMEOUT, 5); |
---|
178 | curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, 20); |
---|
179 | /* send all data to this function */ |
---|
180 | if(localfile == NULL) |
---|
181 | curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback); |
---|
182 | else |
---|
183 | curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, NULL); |
---|
184 | |
---|
185 | /* we pass our 'chunk' struct to the callback function */ |
---|
186 | if(localfile == NULL) |
---|
187 | curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk); |
---|
188 | else |
---|
189 | curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, fp); |
---|
190 | |
---|
191 | /* some servers don't like requests that are made without a user-agent field, so we provide one */ |
---|
192 | curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0"); |
---|
193 | // curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Maxthon/4.4.7.3000 Chrome/30.0.1599.101 Safari/537.36"); |
---|
194 | |
---|
195 | // This is occassionally required to stop CURL from verifying the peers certificate. |
---|
196 | // CURLOPT_SSL_VERIFYHOST may also need to be TRUE or FALSE if |
---|
197 | // CURLOPT_SSL_VERIFYPEER is disabled (it defaults to 2 - check the existence of a |
---|
198 | // common name and also verify that it matches the hostname provided) |
---|
199 | #ifdef MIPSEL |
---|
200 | curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 1L); |
---|
201 | #else |
---|
202 | curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0L); |
---|
203 | #endif |
---|
204 | |
---|
205 | curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0L); |
---|
206 | if(debuglevel == 99) |
---|
207 | curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1); |
---|
208 | curl_easy_setopt(curl_handle, CURLOPT_COOKIEFILE, "/mnt/network/cookies"); |
---|
209 | curl_easy_setopt(curl_handle, CURLOPT_COOKIEJAR, "/mnt/network/cookies"); |
---|
210 | curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1L); |
---|
211 | if(referer == NULL) |
---|
212 | curl_easy_setopt(curl_handle, CURLOPT_AUTOREFERER, 1L); |
---|
213 | else |
---|
214 | curl_easy_setopt(curl_handle, CURLOPT_REFERER, referer); |
---|
215 | |
---|
216 | /* get it! */ |
---|
217 | res = curl_easy_perform(curl_handle); |
---|
218 | /* check for errors */ |
---|
219 | if(res != CURLE_OK) |
---|
220 | { |
---|
221 | err("failed: %s", curl_easy_strerror(res)); |
---|
222 | printf("curl error\n"); |
---|
223 | } |
---|
224 | else |
---|
225 | { |
---|
226 | /* |
---|
227 | * Now, our chunk.memory points to a memory block that is chunk.size |
---|
228 | * bytes big and contains the remote file. |
---|
229 | * |
---|
230 | * Do something nice with it! |
---|
231 | */ |
---|
232 | printf("%lu bytes retrieved\n", (long)chunk.size); |
---|
233 | } |
---|
234 | |
---|
235 | /* cleanup curl stuff */ |
---|
236 | curl_easy_cleanup(curl_handle); |
---|
237 | if(localfile != NULL) |
---|
238 | fclose(fp); |
---|
239 | } |
---|
240 | |
---|
241 | tmpstr = ostrcat(chunk.memory, NULL, 0, 0); |
---|
242 | free(chunk.memory); |
---|
243 | /* we're done with libcurl, so clean it up */ |
---|
244 | curl_global_cleanup(); |
---|
245 | |
---|
246 | if(localfile != NULL) |
---|
247 | free(tmpstr), tmpstr = NULL; |
---|
248 | return tmpstr; |
---|
249 | } |
---|
250 | |
---|
251 | char* string_decode3(char* input) |
---|
252 | { |
---|
253 | if(input == NULL) return input; |
---|
254 | |
---|
255 | input = string_replace_all("Ä", "Ä", input, 1); |
---|
256 | input = string_replace_all("ä", "ä", input, 1); |
---|
257 | input = string_replace_all("É", "É", input, 1); |
---|
258 | input = string_replace_all("é", "é", input, 1); |
---|
259 | input = string_replace_all("Ö", "Ö", input, 1); |
---|
260 | input = string_replace_all("ö", "ö", input, 1); |
---|
261 | input = string_replace_all("Ü", "Ü", input, 1); |
---|
262 | input = string_replace_all("ü", "ü", input, 1); |
---|
263 | input = string_replace_all("ß", "ß", input, 1); |
---|
264 | input = string_replace_all("&", "&", input, 1); |
---|
265 | |
---|
266 | input = string_replace_all("Ä", "Ä", input, 1); |
---|
267 | input = string_replace_all("ä", "ä", input, 1); |
---|
268 | input = string_replace_all("É", "É", input, 1); |
---|
269 | input = string_replace_all("é", "é", input, 1); |
---|
270 | input = string_replace_all("Ö", "Ö", input, 1); |
---|
271 | input = string_replace_all("ö", "ö", input, 1); |
---|
272 | input = string_replace_all("Ü", "Ü", input, 1); |
---|
273 | input = string_replace_all("ü", "ü", input, 1); |
---|
274 | input = string_replace_all("ß", "ß", input, 1); |
---|
275 | input = string_replace_all("&", "&", input, 1); |
---|
276 | |
---|
277 | return input; |
---|
278 | } |
---|
279 | |
---|
280 | char* getfilekey(char* w, char* i, char* s, char* e) |
---|
281 | { |
---|
282 | char* ret = NULL; |
---|
283 | |
---|
284 | if(w == NULL || i == NULL || s == NULL || e == NULL) |
---|
285 | return NULL; |
---|
286 | |
---|
287 | int a = 0, b = 0, c = 0; |
---|
288 | int a1 = 0, b1 = 0; |
---|
289 | |
---|
290 | int lw = strlen(w); |
---|
291 | int li = strlen(i); |
---|
292 | int ls = strlen(s); |
---|
293 | |
---|
294 | if(lw < 5 || li < 5 || ls < 5) |
---|
295 | return NULL; |
---|
296 | |
---|
297 | char ca[lw + li + ls - 14]; |
---|
298 | char cb[16]; |
---|
299 | |
---|
300 | ca[lw + li + ls - 15] = '\0'; |
---|
301 | cb[15] = '\0'; |
---|
302 | |
---|
303 | while(1) |
---|
304 | { |
---|
305 | if(a < 5) |
---|
306 | { |
---|
307 | cb[b1] = w[a]; |
---|
308 | b1++; |
---|
309 | } |
---|
310 | else if(a < lw) |
---|
311 | { |
---|
312 | ca[a1] = w[a]; |
---|
313 | a1++; |
---|
314 | } |
---|
315 | a++; |
---|
316 | |
---|
317 | if(b < 5) |
---|
318 | { |
---|
319 | cb[b1] = i[b]; |
---|
320 | b1++; |
---|
321 | } |
---|
322 | else if(b < li) |
---|
323 | { |
---|
324 | ca[a1] = i[b]; |
---|
325 | a1++; |
---|
326 | } |
---|
327 | b++; |
---|
328 | |
---|
329 | if(c < 5) |
---|
330 | { |
---|
331 | cb[b1] = s[c]; |
---|
332 | b1++; |
---|
333 | } |
---|
334 | else if(c < ls) |
---|
335 | { |
---|
336 | ca[a1] = s[c]; |
---|
337 | a1++; |
---|
338 | } |
---|
339 | c++; |
---|
340 | |
---|
341 | if(lw + li + ls == a1 + b1) |
---|
342 | break; |
---|
343 | } |
---|
344 | |
---|
345 | b = 0; |
---|
346 | int d = 0; |
---|
347 | char cc[a1 / 2 + 1]; |
---|
348 | char casub[3] = {'\0'}; |
---|
349 | cc[a1 / 2] = '\0'; |
---|
350 | |
---|
351 | for(a = 0; a < a1; a += 2) |
---|
352 | { |
---|
353 | int c = -1; |
---|
354 | |
---|
355 | if(cb[b] % 2) c = 1; |
---|
356 | |
---|
357 | casub[0] = ca[a]; |
---|
358 | casub[1] = ca[a + 1]; |
---|
359 | |
---|
360 | cc[d] = strtol(casub, '\0', 36) - c; |
---|
361 | b++; d++; |
---|
362 | if(b >= b1) b = 0; |
---|
363 | } |
---|
364 | |
---|
365 | char* r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL; |
---|
366 | char* pos = ostrstr(cc, ");}('"); |
---|
367 | if(pos != NULL) |
---|
368 | { |
---|
369 | r1 = string_resub(");}('", "'", pos, 0); |
---|
370 | pos = ostrstr(pos + 5, ",'"); |
---|
371 | if(pos != NULL) |
---|
372 | { |
---|
373 | r2 = string_resub(",'", "'", pos, 0); |
---|
374 | pos = ostrstr(pos + 2, ",'"); |
---|
375 | if(pos != NULL) |
---|
376 | { |
---|
377 | r3 = string_resub(",'", "'", pos, 0); |
---|
378 | pos = ostrstr(pos + 2, ",'"); |
---|
379 | if(pos != NULL) |
---|
380 | { |
---|
381 | r4 = string_resub(",'", "'", pos, 0); |
---|
382 | ret = getfilekey(r1, r2, r3, r4); |
---|
383 | } |
---|
384 | } |
---|
385 | } |
---|
386 | } |
---|
387 | else |
---|
388 | { |
---|
389 | ret = string_resub("ll=\"", "\"", cc, 0); |
---|
390 | if(ret == NULL) |
---|
391 | ret = string_resub("filekey=\"", "\"", cc, 0); |
---|
392 | } |
---|
393 | |
---|
394 | free(r1); r1 = NULL; |
---|
395 | free(r2); r2 = NULL; |
---|
396 | free(r3); r3 = NULL; |
---|
397 | free(r4); r4 = NULL; |
---|
398 | |
---|
399 | return ret; |
---|
400 | } |
---|
401 | |
---|
402 | int screenlistbox(struct skin* grid, struct skin* listbox,struct skin* countlabel, char* title, char* titheklink, int* pagecount, int* tithekexit, int* oaktpage, int* oaktline, int* ogridcol, int flag, int cflag) |
---|
403 | { |
---|
404 | char* tmpstr = NULL, *tmpstr1 = NULL, *tmpstr2 = NULL; |
---|
405 | |
---|
406 | *oaktpage = listbox->aktpage; |
---|
407 | *oaktline = listbox->aktline; |
---|
408 | *ogridcol = listbox->gridcol; |
---|
409 | tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0); |
---|
410 | |
---|
411 | if(title != NULL) |
---|
412 | tmpstr1 = ostrcat(title, " - ", 0, 0); |
---|
413 | else |
---|
414 | tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0); |
---|
415 | |
---|
416 | tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0); |
---|
417 | screentithekplay(tmpstr, tmpstr2, flag); |
---|
418 | free(tmpstr); tmpstr = NULL; |
---|
419 | free(tmpstr2); tmpstr2 = NULL; |
---|
420 | |
---|
421 | *pagecount = createtithekplay(titheklink, grid, listbox, countlabel, cflag); |
---|
422 | // if(pagecount == 0 || tithekexit == 1) break; |
---|
423 | if(*pagecount == 0 || *tithekexit == 1) return 0; |
---|
424 | |
---|
425 | listbox->aktpage = *oaktpage; |
---|
426 | listbox->aktline = *oaktline; |
---|
427 | listbox->gridcol = *ogridcol; |
---|
428 | addscreenrc(grid, listbox); |
---|
429 | |
---|
430 | return 1; |
---|
431 | } |
---|
432 | |
---|
433 | int all_search_local(struct skin* grid, struct skin* listbox, struct skin* countlabel, struct skin* load, char* link, char* title, char* searchstr, int flag) |
---|
434 | { |
---|
435 | char* tmpstr = NULL, *tmpstr1 = NULL, *line = NULL, *menu = NULL, *search = NULL; |
---|
436 | int ret = 1, count = 0, i = 0; |
---|
437 | |
---|
438 | if(listbox == NULL || listbox->select == NULL || listbox->select->handle == NULL) |
---|
439 | return ret; |
---|
440 | |
---|
441 | if(searchstr == NULL) |
---|
442 | search = textinputhist(_("Search"), " ", "searchhist"); |
---|
443 | else |
---|
444 | search = textinputhist(_("Search"), searchstr, "searchhist"); |
---|
445 | |
---|
446 | if(search != NULL) |
---|
447 | { |
---|
448 | drawscreen(load, 0, 0); |
---|
449 | |
---|
450 | strstrip(search); |
---|
451 | string_tolower(search); |
---|
452 | |
---|
453 | tmpstr = gethttp("atemio.dyndns.tv", "/mediathek/all/all-sorted.list", 80, NULL, HTTPAUTH, 5000, NULL, 0); |
---|
454 | |
---|
455 | struct splitstr* ret1 = NULL; |
---|
456 | ret1 = strsplit(tmpstr, "\n", &count); |
---|
457 | |
---|
458 | if(ret1 != NULL) |
---|
459 | { |
---|
460 | int max = count; |
---|
461 | for(i = 0; i < max; i++) |
---|
462 | { |
---|
463 | |
---|
464 | tmpstr1 = ostrcat(ret1[i].part, NULL, 0, 0); |
---|
465 | tmpstr1 = stringreplacecharonce(tmpstr1, '#', '\0'); |
---|
466 | string_tolower(tmpstr1); |
---|
467 | |
---|
468 | if(ostrstr(tmpstr1, search) != NULL) |
---|
469 | { |
---|
470 | printf("found: %s\n", ret1[i].part); |
---|
471 | int rcret = waitrc(NULL, 10, 0); |
---|
472 | if(rcret == getrcconfigint("rcexit", NULL)) break; |
---|
473 | |
---|
474 | line = ostrcat(line, ret1[i].part, 1, 0); |
---|
475 | line = ostrcat(line, "\n", 0, 0); |
---|
476 | } |
---|
477 | free(tmpstr1), tmpstr1 = NULL; |
---|
478 | } |
---|
479 | free(ret1), ret1 = NULL; |
---|
480 | |
---|
481 | if(line != NULL) |
---|
482 | { |
---|
483 | line = string_replace_all("http://atemio.dyndns.tv/", "http://imageshack.us/md/up/grd/", line, 1); |
---|
484 | menu = ostrcat("/tmp/tithek/all.search.list", NULL, 0, 0); |
---|
485 | writesys(menu, line, 0); |
---|
486 | struct tithek* tnode = (struct tithek*)listbox->select->handle; |
---|
487 | createtithek(tnode, tnode->title, menu, tnode->pic, tnode->localname, tnode->menutitle, tnode->flag); |
---|
488 | ret = 0; |
---|
489 | } |
---|
490 | } |
---|
491 | free(tmpstr), tmpstr = NULL; |
---|
492 | } |
---|
493 | free(search), search = NULL; |
---|
494 | return ret; |
---|
495 | } |
---|
496 | |
---|
497 | char* jsunpack(char* input) |
---|
498 | { |
---|
499 | int debuglevel = getconfigint("debuglevel", NULL); |
---|
500 | |
---|
501 | if(input == NULL) return input; |
---|
502 | |
---|
503 | char* b36code = NULL, *search = NULL, *charlist = NULL, *base = NULL, *tmpstr2 = NULL, *tmpstr3 = NULL, *tmpstr = NULL, *packed = NULL; |
---|
504 | |
---|
505 | unlink("/tmp/jsunpack1_packed"); |
---|
506 | unlink("/tmp/jsunpack2_tmpstr"); |
---|
507 | unlink("/tmp/jsunpack3_b36code"); |
---|
508 | unlink("/tmp/jsunpack4_tmpstr_last"); |
---|
509 | |
---|
510 | while(ostrstr(input, "eval(function(p,a,c,k,e,d){") != NULL) |
---|
511 | { |
---|
512 | packed = string_resub("eval(function(p,a,c,k,e,d){", "))", input, 0); |
---|
513 | titheklog(debuglevel, "/tmp/jsunpack1_packed", NULL, NULL, NULL, packed); |
---|
514 | |
---|
515 | // tmpstr = string_resub(";return p}('", ");'", packed, 0); |
---|
516 | // tmpstr = oregex(".*;return p}(.*)',[0-9]{2,2},[0-9]{2,2},'.*'.split.*", packed); |
---|
517 | tmpstr = oregex(".*;return p}(.*)',[0-9]{1,3},[0-9]{1,3},'.*'.split.*", packed); |
---|
518 | |
---|
519 | debug(99, "tmpstr: %s", tmpstr); |
---|
520 | titheklog(debuglevel, "/tmp/jsunpack2_tmpstr", NULL, NULL, NULL, tmpstr); |
---|
521 | |
---|
522 | // b36code = oregex(".*;',[0-9]{2,2},[0-9]{2,2},'(.*)'.split.*", packed); |
---|
523 | b36code = oregex(".*',[0-9]{1,3},[0-9]{1,3},'(.*)'.split.*", packed); |
---|
524 | |
---|
525 | b36code = string_replace_all("||", "| |", b36code, 1); |
---|
526 | debug(99, "b36code: %s", b36code); |
---|
527 | titheklog(debuglevel, "/tmp/jsunpack3_b36code", NULL, NULL, NULL, b36code); |
---|
528 | |
---|
529 | if(!ostrncmp("|", b36code, 1)) |
---|
530 | b36code = ostrcat(" ", b36code, 0, 1); |
---|
531 | |
---|
532 | struct splitstr* ret1 = NULL; |
---|
533 | int count = 0; |
---|
534 | int i = 0; |
---|
535 | ret1 = strsplit(b36code, "|", &count); |
---|
536 | |
---|
537 | charlist = ostrcat(charlist, "\"", 1, 0); |
---|
538 | charlist = ostrcat(charlist, "|", 1, 0); |
---|
539 | charlist = ostrcat(charlist, "'", 1, 0); |
---|
540 | charlist = ostrcat(charlist, "|", 1, 0); |
---|
541 | charlist = ostrcat(charlist, ".", 1, 0); |
---|
542 | charlist = ostrcat(charlist, "|", 1, 0); |
---|
543 | charlist = ostrcat(charlist, ";", 1, 0); |
---|
544 | charlist = ostrcat(charlist, "|", 1, 0); |
---|
545 | charlist = ostrcat(charlist, ":", 1, 0); |
---|
546 | charlist = ostrcat(charlist, "|", 1, 0); |
---|
547 | charlist = ostrcat(charlist, "=", 1, 0); |
---|
548 | charlist = ostrcat(charlist, "|", 1, 0); |
---|
549 | charlist = ostrcat(charlist, ",", 1, 0); |
---|
550 | charlist = ostrcat(charlist, "|", 1, 0); |
---|
551 | charlist = ostrcat(charlist, " ", 1, 0); |
---|
552 | charlist = ostrcat(charlist, "|", 1, 0); |
---|
553 | charlist = ostrcat(charlist, "\\", 1, 0); |
---|
554 | charlist = ostrcat(charlist, "|", 1, 0); |
---|
555 | charlist = ostrcat(charlist, "/", 1, 0); |
---|
556 | charlist = ostrcat(charlist, "|", 1, 0); |
---|
557 | charlist = ostrcat(charlist, "(", 1, 0); |
---|
558 | charlist = ostrcat(charlist, "|", 1, 0); |
---|
559 | charlist = ostrcat(charlist, ")", 1, 0); |
---|
560 | charlist = ostrcat(charlist, "'", 1, 0); |
---|
561 | charlist = ostrcat(charlist, "%", 1, 0); |
---|
562 | |
---|
563 | for(i = 0; i < count; i++) |
---|
564 | { |
---|
565 | if(ostrstr((&ret1[i])->part, " ") != NULL) |
---|
566 | { |
---|
567 | printf("continue\n"); |
---|
568 | continue; |
---|
569 | } |
---|
570 | char* x = oltostr(i, 36); |
---|
571 | |
---|
572 | struct splitstr* ret2 = NULL; |
---|
573 | int count2 = 0; |
---|
574 | int i2 = 0; |
---|
575 | tmpstr2 = ostrcat(charlist, NULL, 0, 0); |
---|
576 | ret2 = strsplit(tmpstr2, "|", &count2); |
---|
577 | for(i2 = 0; i2 < count2; i2++) |
---|
578 | { |
---|
579 | struct splitstr* ret3 = NULL; |
---|
580 | int count3 = 0; |
---|
581 | int i3 = 0; |
---|
582 | tmpstr3 = ostrcat(charlist, NULL, 0, 0); |
---|
583 | ret3 = strsplit(tmpstr3, "|", &count3); |
---|
584 | for(i3 = 0; i3 < count3; i3++) |
---|
585 | { |
---|
586 | debug(99, "-----------------------------------------------"); |
---|
587 | debug(99, "replace %s%s%s <> %s%s%s",(&ret2[i2])->part, x, (&ret3[i3])->part, (&ret2[i2])->part, (&ret1[i])->part, (&ret3[i3])->part); |
---|
588 | |
---|
589 | base = ostrcat(base, (&ret2[i2])->part, 1, 0); |
---|
590 | base = ostrcat(base, x, 1, 0); |
---|
591 | base = ostrcat(base, (&ret3[i3])->part, 1, 0); |
---|
592 | search = ostrcat(search, (&ret2[i2])->part, 1, 0); |
---|
593 | search = ostrcat(search, (&ret1[i])->part, 1, 0); |
---|
594 | search = ostrcat(search, (&ret3[i3])->part, 1, 0); |
---|
595 | tmpstr = string_replace_all(base, search, tmpstr, 1); |
---|
596 | free(base), base = NULL; |
---|
597 | free(search), search = NULL; |
---|
598 | } |
---|
599 | free(ret3), ret3 = NULL; |
---|
600 | free(tmpstr3), tmpstr3 = NULL; |
---|
601 | } |
---|
602 | free(ret2), ret2 = NULL; |
---|
603 | free(tmpstr2), tmpstr2 = NULL; |
---|
604 | free(x); |
---|
605 | } |
---|
606 | free(ret1), ret1 = NULL; |
---|
607 | |
---|
608 | titheklog(debuglevel, "/tmp/jsunpack4_tmpstr_last", NULL, NULL, NULL, tmpstr); |
---|
609 | |
---|
610 | if(tmpstr == NULL) |
---|
611 | input = string_replace("eval(function(p,a,c,k,e,d){", "eval(function(p,a,c,k,e,d-extracted-error){", input, 1); |
---|
612 | else |
---|
613 | { |
---|
614 | input = string_replace("eval(function(p,a,c,k,e,d){", "eval(function(p,a,c,k,e,d-extracted){", input, 1); |
---|
615 | input = string_replace(packed, tmpstr, input, 1); |
---|
616 | } |
---|
617 | free(tmpstr),tmpstr = NULL; |
---|
618 | free(packed), packed = NULL; |
---|
619 | free(b36code), b36code = NULL; |
---|
620 | free(charlist), charlist = NULL; |
---|
621 | } |
---|
622 | |
---|
623 | return input; |
---|
624 | } |
---|
625 | |
---|
626 | void localparser_init(char* titheklink, char* tithekfile) |
---|
627 | { |
---|
628 | char* tmpstr = NULL, *tmpstr1 = NULL, *tmpstr2 = NULL, *cmd = NULL, *line = NULL, *path = NULL; |
---|
629 | |
---|
630 | if(ostrcmp("http://atemio.dyndns.tv/mediathek/mainmenu.list", titheklink) == 0) |
---|
631 | { |
---|
632 | // path = createpluginpath("/tithek", 0); |
---|
633 | // path = ostrcat(path, "/parser", 1, 0); |
---|
634 | path = ostrcat("/tmp/localparser", 0, 0); |
---|
635 | |
---|
636 | if(!file_exist("/tmp/hoster")) |
---|
637 | mkdir("/tmp/hoster", 0777); |
---|
638 | if(!file_exist("/mnt/parser")) |
---|
639 | mkdir("/mnt/parser", 0777); |
---|
640 | if(!file_exist(path)) |
---|
641 | mkdir(path, 0777); |
---|
642 | |
---|
643 | unlink("/tmp/parser.tar"); |
---|
644 | gethttp("atemio.dyndns.tv", "/mediathek/parser_free.tar", 80, "/tmp/parser.tar", HTTPAUTH, 5000, NULL, 0); |
---|
645 | |
---|
646 | cmd = ostrcat("tar -xvf /tmp/parser.tar -C ", path, 0, 0); |
---|
647 | system(cmd); |
---|
648 | free(cmd), cmd = NULL; |
---|
649 | |
---|
650 | if(file_exist("/mnt/swapextensions/etc/.codecpack") || file_exist("/var/swap/etc/.codecpack") || file_exist("/var/etc/.codecpack")) |
---|
651 | { |
---|
652 | unlink("/tmp/parser.tar"); |
---|
653 | gethttp("atemio.dyndns.tv", "/mediathek/parser_secret.tar", 80, "/tmp/parser.tar", HTTPAUTH, 5000, NULL, 0); |
---|
654 | cmd = ostrcat("tar -xvf /tmp/parser.tar -C ", path, 0, 0); |
---|
655 | system(cmd); |
---|
656 | free(cmd), cmd = NULL; |
---|
657 | } |
---|
658 | |
---|
659 | unlink("/tmp/hoster.tar"); |
---|
660 | gethttp("atemio.dyndns.tv", "/mediathek/hoster.tar", 80, "/tmp/hoster.tar", HTTPAUTH, 5000, NULL, 0); |
---|
661 | cmd = ostrcat("tar -xvf /tmp/hoster.tar -C ", "/tmp/hoster", 0, 0); |
---|
662 | system(cmd); |
---|
663 | free(cmd), cmd = NULL; |
---|
664 | |
---|
665 | cmd = ostrcat("chmod -R 755 ", path, 0, 0); |
---|
666 | system(cmd); |
---|
667 | free(cmd), cmd = NULL; |
---|
668 | |
---|
669 | cmd = ostrcat("chmod -R 755 /tmp/hoster", NULL, 0, 0); |
---|
670 | system(cmd); |
---|
671 | free(cmd), cmd = NULL; |
---|
672 | |
---|
673 | cmd = ostrcat("ls -1 ", path, 0, 0); |
---|
674 | cmd = ostrcat(cmd, "/*.sh", 1, 0); |
---|
675 | |
---|
676 | free(path), path = NULL; |
---|
677 | tmpstr1 = command("ls -1 /mnt/parser/*.sh"); |
---|
678 | tmpstr2 = command(cmd); |
---|
679 | free(cmd), cmd = NULL; |
---|
680 | tmpstr = ostrcat(tmpstr1, "\n", 0, 0); |
---|
681 | tmpstr = ostrcat(tmpstr, tmpstr2, 1, 0); |
---|
682 | |
---|
683 | int count = 0, i = 0; |
---|
684 | struct splitstr* ret1 = NULL; |
---|
685 | ret1 = strsplit(tmpstr, "\n", &count); |
---|
686 | |
---|
687 | int max = count; |
---|
688 | for(i = 0; i < max; i++) |
---|
689 | { |
---|
690 | if(file_exist(ret1[i].part) && cmpfilenameext(ret1[i].part, ".sh") == 0) |
---|
691 | { |
---|
692 | cmd = ostrcat(ret1[i].part, " ", 0, 0); |
---|
693 | cmd = ostrcat(cmd, ret1[i].part, 1, 0); |
---|
694 | cmd = ostrcat(cmd, " init", 1, 0); |
---|
695 | line = command(cmd); |
---|
696 | printf("[tithek] add main menuentry: %s\n", line); |
---|
697 | debug(10, "add main menuentry: %s", line); |
---|
698 | writesys(tithekfile, line, 3); |
---|
699 | free(cmd), cmd = NULL; |
---|
700 | free(line), line = NULL; |
---|
701 | } |
---|
702 | } |
---|
703 | free(ret1), ret1 = NULL; |
---|
704 | free(tmpstr), tmpstr = NULL; |
---|
705 | free(tmpstr1), tmpstr1 = NULL; |
---|
706 | free(tmpstr2), tmpstr2 = NULL; |
---|
707 | } |
---|
708 | } |
---|
709 | |
---|
710 | char* localparser_hoster(char* link) |
---|
711 | { |
---|
712 | debug(99, "link: %s", link); |
---|
713 | int debuglevel = getconfigint("debuglevel", NULL); |
---|
714 | int ret = 1; |
---|
715 | char* tmpstr = NULL, *streamurl = NULL; |
---|
716 | |
---|
717 | tmpstr = command(link); |
---|
718 | tmpstr = string_newline(tmpstr); |
---|
719 | |
---|
720 | if(ostrstr(link, ".sh play ") != NULL) |
---|
721 | streamurl = ostrcat(tmpstr, NULL, 0, 0); |
---|
722 | else if(ostrstr(link, ".sh hoster ") != NULL) |
---|
723 | streamurl = hoster(tmpstr); |
---|
724 | |
---|
725 | free(tmpstr), tmpstr = NULL; |
---|
726 | |
---|
727 | return streamurl; |
---|
728 | } |
---|
729 | |
---|
730 | int localparser_search(struct skin* grid, struct skin* listbox, struct skin* countlabel, struct skin* load, char* link, char* title, char* searchstr, int flag) |
---|
731 | { |
---|
732 | char* tmpstr = NULL, *tmpstr1 = NULL, *line = NULL, *menu = NULL, *search = NULL; |
---|
733 | int ret = 1, count = 0, i = 0; |
---|
734 | |
---|
735 | if(listbox == NULL || listbox->select == NULL || listbox->select->handle == NULL) |
---|
736 | return ret; |
---|
737 | |
---|
738 | if(searchstr == NULL) |
---|
739 | search = textinputhist(_("Search"), " ", "searchhist"); |
---|
740 | else |
---|
741 | search = textinputhist(_("Search"), searchstr, "searchhist"); |
---|
742 | |
---|
743 | if(search != NULL) |
---|
744 | { |
---|
745 | drawscreen(load, 0, 0); |
---|
746 | |
---|
747 | strstrip(search); |
---|
748 | string_tolower(search); |
---|
749 | |
---|
750 | char* cmd = ostrcat(link, search, 0, 0); |
---|
751 | char* filename = command(cmd); |
---|
752 | filename = string_newline(filename); |
---|
753 | tmpstr = readfiletomem(filename, 1); |
---|
754 | free(cmd), cmd = NULL; |
---|
755 | |
---|
756 | if(tmpstr != NULL) |
---|
757 | { |
---|
758 | tmpstr = string_replace_all("http://atemio.dyndns.tv/", "http://imageshack.us/md/up/grd/", tmpstr, 1); |
---|
759 | menu = ostrcat(filename, NULL, 0, 0); |
---|
760 | // writesys(menu, tmpstr, 0); |
---|
761 | struct tithek* tnode = (struct tithek*)listbox->select->handle; |
---|
762 | createtithek(tnode, tnode->title, menu, tnode->pic, tnode->localname, tnode->menutitle, tnode->flag); |
---|
763 | ret = 0; |
---|
764 | } |
---|
765 | |
---|
766 | free(filename), filename = NULL; |
---|
767 | free(tmpstr), tmpstr = NULL; |
---|
768 | } |
---|
769 | free(search), search = NULL; |
---|
770 | return ret; |
---|
771 | } |
---|
772 | |
---|
773 | #endif |
---|