source: titan/plugins/tithek/xvidstage.h @ 24319

Last change on this file since 24319 was 24319, checked in by obi, 10 years ago

[tithek] update and add hoster movshare

File size: 9.7 KB
Line 
1#ifndef XVIDSTAGE_H
2#define XVIDSTAGE_H
3
4char* xvidstage(char* host, char* file, char* hosterurl)
5{
6        debug(99, "in host: %s file: %s", host, file);
7        int debuglevel = getconfigint("debuglevel", NULL);
8        char* tmphost = NULL;
9        char* tmpfile = NULL;
10        char* tmpstr = NULL;
11        char* send = NULL;
12        char* ip = NULL;
13        char* streamlink = NULL;
14
15        char* cookie = NULL;           
16        char* id = NULL;
17        char* fname = NULL;
18        char* op = NULL;
19        char* hash = NULL;
20        char* hashline = NULL;
21        char* hashlen = NULL;
22        char* referer = NULL;
23        char* usr_login = NULL;
24        char* imhuman = NULL;
25        char* post = NULL;
26
27        char* b36code = NULL;
28        char* base = NULL;
29        char* search = NULL;
30
31        char* tmpstr2 = NULL;
32        char* tmpstr3 = NULL;
33        char* charlist = NULL;
34
35        unlink("/tmp/xvidstage1_get");
36        unlink("/tmp/xvidstage2_post");
37
38        if(host == NULL || file == NULL) return NULL;
39
40//      tmphost = ostrcat("www.", host, 0, 0);
41        tmphost = ostrcat(host, NULL, 0, 0);
42        tmpfile = ostrcat("/", file, 0, 0);
43        debug(99, "tmphost: %s", tmphost);
44        ip = get_ip(tmphost);
45        debug(99, "tmphost: %s", tmphost);
46        debug(99, "tmpfile: %s", tmpfile);
47        debug(99, "ip: %s", ip);
48
49        send = ostrcat(send, "GET ", 1, 0);
50        send = ostrcat(send, tmpfile, 1, 0);
51        send = ostrcat(send, " HTTP/1.1\r\nHost: ", 1, 0);     
52        send = ostrcat(send, tmphost, 1, 0);
53        send = ostrcat(send, "\r\nUser-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.99 Safari/535.1\r\nConnection: close\r\nAccept-Encoding: gzip\r\n\r\n", 1, 0);       
54        debug(99, "send: %s", send);
55
56        tmpstr = gethttpreal(tmphost, tmpfile, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
57        debug(99, "tmpstr: %s", tmpstr);
58        titheklog(debuglevel, "/tmp/xvidstage1_get", NULL, tmpstr);
59
60        free(send); send = NULL;
61
62//      sleep(1);
63        if(tmpstr == NULL)
64        {
65                textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
66                goto end;
67        }
68
69        cookie = string_resub("Set-Cookie: afc=", ";", tmpstr, 0);     
70        debug(99, "cookie: %s", cookie);
71
72        //get hash from tmpstr
73        char* pos1 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"fname\" value=");
74        fname = getxmlentry(pos1, "value=");
75        debug(99, "fname: %s", fname);
76        if(fname == NULL) goto end;
77
78        char* pos2 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"id\" value=");
79        id = getxmlentry(pos2, "value=");
80        debug(99, "id: %s", id);
81        if(id == NULL) goto end;
82
83        char* pos3 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"op\" value=");
84        op = getxmlentry(pos3, "value=");
85        debug(99, "op: %s", op);
86
87        char* pos4 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"rand\" value=");
88        hashline = getxmlentry(pos4, "value=");
89        debug(99, "hashline: %s", hashline);
90
91        char* pos5 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"referer\" value=");
92        referer = getxmlentry(pos5, "value=");
93        debug(99, "referer: %s", referer);
94
95        char* pos6 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"imhuman\" value=");
96        imhuman = getxmlentry(pos6, "value=");
97        debug(99, "imhuman: %s", imhuman);
98
99        char* pos7 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"usr_login\" value=");
100        usr_login = getxmlentry(pos7, "value=");
101        debug(99, "usr_login: %s", usr_login);
102       
103        free(tmpstr); tmpstr = NULL;
104        if(op == NULL) goto end;
105
106        hash = ostrcat(hash, "hash=", 1, 0);
107        hash = ostrcat(hash, hashline, 1, 0);
108        hash = ostrcat(hash, "&imhuman=Proceed+to+video%22+id%3D%22btn_download&k=Search...%22+size%3D16+onfocus%3D%22%24%28this%29.val%28%27%27%29.css%28%27color%27%2C%27%23333%27%29%3B%22+onblur%3D%22if%28%24%28this%29.val%28%29%3D%3D%27%27%29%24%28this%29.val%28%27Search...%27%29.css%28%27color%27%2C%27%27%29%22+id%3D%22search_top", 1, 0);
109        hash = ostrcat(hash, "&usr_login=", 1, 0);     
110        hash = ostrcat(hash, usr_login, 1, 0);
111        hash = ostrcat(hash, "&referer=", 1, 0);
112        hash = ostrcat(hash, referer, 1, 0);
113        hash = ostrcat(hash, "&fname=", 1, 0);
114        hash = ostrcat(hash, fname, 1, 0);
115        hash = ostrcat(hash, "&id=", 1, 0);     
116        hash = ostrcat(hash, id, 1, 0);
117        hash = ostrcat(hash, "&op=download1", 1, 0);
118        hash = ostrcat(hash, op, 1, 0);
119        debug(99, "hash: %s", hash);
120        hashlen = oitoa(strlen(hash));
121
122        send = ostrcat(send, "POST ", 1, 0);
123        send = ostrcat(send, tmpfile, 1, 0);
124        send = ostrcat(send, " HTTP/1.1\r\nContent-Length: ", 1, 0);
125        send = ostrcat(send, hashlen, 1, 0);
126        send = ostrcat(send, "\r\nAccept-Encoding: gzip\r\nConnection: close\r\nUser-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.99 Safari/535.1\r\nHost: ", 1, 0);
127        send = ostrcat(send, tmphost, 1, 0);
128        send = ostrcat(send, "\r\nCookie: afc=", 1, 0);
129        send = ostrcat(send, cookie, 1, 0);
130        send = ostrcat(send, "\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n", 1, 0);
131        send = ostrcat(send, hash, 1, 0);
132        debug(99, "send: %s", send);
133
134        //send and receive answer
135        post = gethttpreal(tmphost, tmpfile, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
136        debug(99, "post: %s", post);
137        titheklog(debuglevel, "/tmp/xvidstage2_post", NULL, post);
138
139// hier wird nun ein captcha bild auth verlangt geht also erstmal nicht mehr
140        if(tmpstr == NULL)
141        {
142                textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
143                goto end;
144        }
145       
146        tmpstr = string_resub(";return p}('", ");'", post, 0);
147        titheklog(debuglevel, "/tmp/xvidstage3_tmpstr", NULL, tmpstr);
148       
149        post = string_replace_all(tmpstr, "", post, 1);
150        post = string_replace_all(";return p}(');'", "", post, 1);
151        titheklog(debuglevel, "/tmp/xvidstage4_tmpstr", NULL, post);
152
153        free(tmpstr),tmpstr = NULL;
154        free(b36code),b36code = NULL;
155        tmpstr = string_resub(";return p}('", ");'", post, 0);
156        titheklog(debuglevel, "/tmp/xvidstage5_tmpstr", NULL, tmpstr);
157
158        b36code = oregex(".*;',[0-9]{2,2},[0-9]{2,2},'(.*)'.split.*", post);
159       
160        b36code = string_replace_all("||", "| |", b36code, 1);
161        titheklog(debuglevel, "/tmp/xvidstage6_tmpstr", NULL, b36code);
162       
163        struct splitstr* ret1 = NULL;
164        int count = 0;
165        int i = 0;
166        ret1 = strsplit(b36code, "|", &count);
167
168        charlist = ostrcat(charlist, "\"", 1, 0);
169        charlist = ostrcat(charlist, "|", 1, 0);
170        charlist = ostrcat(charlist, "'", 1, 0);
171        charlist = ostrcat(charlist, "|", 1, 0);
172        charlist = ostrcat(charlist, ".", 1, 0);
173        charlist = ostrcat(charlist, "|", 1, 0);
174        charlist = ostrcat(charlist, ";", 1, 0);
175        charlist = ostrcat(charlist, "|", 1, 0);
176        charlist = ostrcat(charlist, ":", 1, 0);
177        charlist = ostrcat(charlist, "|", 1, 0);
178        charlist = ostrcat(charlist, "=", 1, 0);
179        charlist = ostrcat(charlist, "|", 1, 0);
180        charlist = ostrcat(charlist, ",", 1, 0);
181        charlist = ostrcat(charlist, "|", 1, 0);
182        charlist = ostrcat(charlist, " ", 1, 0);
183        charlist = ostrcat(charlist, "|", 1, 0);
184        charlist = ostrcat(charlist, "\\", 1, 0);
185        charlist = ostrcat(charlist, "|", 1, 0);
186        charlist = ostrcat(charlist, "/", 1, 0);
187        charlist = ostrcat(charlist, "|", 1, 0);
188        charlist = ostrcat(charlist, "(", 1, 0);
189        charlist = ostrcat(charlist, "|", 1, 0);
190        charlist = ostrcat(charlist, ")", 1, 0);
191
192        for(i = 0; i < count; i++)
193        {
194                if(ostrstr((&ret1[i])->part, " ") != NULL)
195                {
196                        printf("continue\n");
197                        continue;
198                }
199                char* x = oltostr(i, 36);
200
201                struct splitstr* ret2 = NULL;
202                int count2 = 0;
203                int i2 = 0;
204                tmpstr2 = ostrcat(charlist, NULL, 0, 0);
205                ret2 = strsplit(tmpstr2, "|", &count2);
206                for(i2 = 0; i2 < count2; i2++)
207                {
208                        struct splitstr* ret3 = NULL;
209                        int count3 = 0;
210                        int i3 = 0;
211                        tmpstr3 = ostrcat(charlist, NULL, 0, 0);
212                        ret3 = strsplit(tmpstr3, "|", &count3);
213                        for(i3 = 0; i3 < count3; i3++)
214                        {
215                                debug(99, "-----------------------------------------------");
216                                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);
217
218                                base = ostrcat(base, (&ret2[i2])->part, 1, 0);
219                                base = ostrcat(base, x, 1, 0);
220                                base = ostrcat(base, (&ret3[i3])->part, 1, 0);         
221                                search = ostrcat(search, (&ret2[i2])->part, 1, 0);
222                                search = ostrcat(search, (&ret1[i])->part, 1, 0);
223                                search = ostrcat(search, (&ret3[i3])->part, 1, 0);
224                                tmpstr = string_replace_all(base, search, tmpstr, 1);
225                                free(base), base = NULL;
226                                free(search), search = NULL;
227                        }
228                        free(ret3), ret3 = NULL;
229                        free(tmpstr3), tmpstr3 = NULL;
230                }
231                free(ret2), ret2 = NULL;
232                free(tmpstr2), tmpstr2 = NULL;
233                free(x);
234        }
235        free(ret1), ret1 = NULL;
236        free(b36code), b36code = NULL;
237        free(post), post = NULL;
238        free(charlist), charlist = NULL;
239
240        titheklog(debuglevel, "/tmp/xvidstage7_tmpstr_last", NULL, tmpstr);
241
242        streamlink = oregex(".*file.*(http:.*video.flv).*image.*", tmpstr);
243        if(streamlink == NULL)
244                streamlink = oregex(".*file.*(http:.*video.mp4).*image.*", tmpstr);                             
245
246        if(streamlink == NULL)
247                streamlink = oregex(".*file.*(http:.*video.mkv).*image.*", tmpstr);
248
249        if(streamlink == NULL)
250                streamlink = oregex(".*file.*(http:.*video.avi).*image.*", tmpstr);
251
252        if(streamlink == NULL)
253                streamlink = oregex(".*src=.*(http:.*video.mp4).*\".*", tmpstr);
254
255        if(streamlink == NULL)
256                streamlink = oregex(".*src=.*(http:.*video.mkv).*\".*", tmpstr);
257
258        if(streamlink == NULL)
259                streamlink = oregex(".*src=.*(http:.*video.avi).*\".*", tmpstr);
260               
261        if(streamlink == NULL)
262                streamlink = oregex(".*value=.*(http:.*video.mp4).*\".*", tmpstr);                             
263
264        if(streamlink == NULL)
265                streamlink = oregex(".*value=.*(http:.*video.mkv).*\".*", tmpstr);
266
267        if(streamlink == NULL)
268                streamlink = oregex(".*value=.*(http:.*video.avi).*\".*", tmpstr);                     
269
270        titheklog(debuglevel, "/tmp/xvidstage8_streamlink", NULL, streamlink);
271
272        free(tmpstr); tmpstr = NULL;
273
274end:
275
276        free(cookie); cookie = NULL;
277        free(hash), hash = NULL;
278        free(hashlen), hashlen = NULL;
279        free(op), op = NULL;
280        free(id), id = NULL;
281        free(fname), fname = NULL;
282               
283        free(tmphost); tmphost = NULL;
284        free(tmpfile); tmpfile = NULL;
285        free(tmpstr); tmpstr = NULL;
286        free(send); send = NULL;
287        free(ip); ip = NULL;
288
289        return streamlink;
290}
291
292#endif
Note: See TracBrowser for help on using the repository browser.