source: titan/plugins/tithek/streamcloud.h @ 24310

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

fix

File size: 4.5 KB
Line 
1#ifndef STREAMCLOAD_H
2#define STREAMCLOAD_H
3
4char* streamcloud(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, *tmpfile = NULL, *tmpstr = NULL, *send = NULL, *id = NULL, *fname = NULL, *op = NULL, *hash = NULL, *cmd = NULL;
9        char* hashline = NULL, *hashlen = NULL, *referer = NULL, *usr_login = NULL, *imhuman = NULL, *ip = NULL, *cookie = NULL, *streamlink = NULL;
10
11        unlink("/tmp/streamcould1_get");
12        unlink("/tmp/streamcould2_post");
13        unlink("/tmp/streamcould3_streamlink");
14
15        if(host == NULL || file == NULL) return NULL;
16
17        tmphost = ostrcat(host, NULL, 0, 0);
18        tmpfile = ostrcat("/", file, 0, 0);
19
20        debug(99, "tmphost: %s", tmphost);
21        ip = get_ip(tmphost);
22        debug(99, "ip: %s", ip);
23        debug(99, "tmpfile: %s", tmpfile);
24
25        send = ostrcat(send, "GET ", 1, 0);
26        send = ostrcat(send, tmpfile, 1, 0);
27        send = ostrcat(send, " HTTP/1.1\r\nHost: ", 1, 0);
28        send = ostrcat(send, tmphost, 1, 0);
29        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);
30        debug(99, "send: %s", send);
31
32        tmpstr = gethttpreal(tmphost, tmpfile, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
33        free(send), send = NULL;
34        debug(99, "tmpstr: %s", tmpstr);
35        sleep(20);
36        titheklog(debuglevel, "/tmp/streamcould1_get", NULL, tmpstr);
37       
38        cookie = string_resub("Set-Cookie: afc=", ";", tmpstr, 0);     
39        debug(99, "cookie: %s", cookie);
40
41        //get hash from tmpstr
42        char* pos1 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"fname\" value=");
43        fname = getxmlentry(pos1, "value=");
44        debug(99, "fname: %s", fname);
45        if(fname == NULL) goto end;
46
47        char* pos2 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"id\" value=");
48        id = getxmlentry(pos2, "value=");
49        debug(99, "id: %s", id);
50        if(id == NULL) goto end;
51
52        char* pos3 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"op\" value=");
53        op = getxmlentry(pos3, "value=");
54
55        char* pos4 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"hash\" value=");
56        hashline = getxmlentry(pos4, "value=");
57
58        char* pos5 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"referer\" value=");
59        referer = getxmlentry(pos5, "value=");
60
61        char* pos6 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"imhuman\" value=");
62        imhuman = getxmlentry(pos6, "value=");
63
64        char* pos7 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"usr_login\" value=");
65        usr_login = getxmlentry(pos7, "value=");
66       
67        free(tmpstr); tmpstr = NULL;
68        debug(99, "op: %s", op);
69        if(op == NULL) goto end;
70
71        hash = ostrcat(hash, "hash=", 1, 0);
72        hash = ostrcat(hash, hashline, 1, 0);
73        hash = ostrcat(hash, "&imhuman=Weiter+zum+Video", 1, 0);
74        hash = ostrcat(hash, "&usr_login=", 1, 0);     
75        hash = ostrcat(hash, usr_login, 1, 0);
76        hash = ostrcat(hash, "&referer=", 1, 0);
77        hash = ostrcat(hash, referer, 1, 0);
78        hash = ostrcat(hash, "&fname=", 1, 0);
79        hash = ostrcat(hash, fname, 1, 0);
80        hash = ostrcat(hash, "&id=", 1, 0);     
81        hash = ostrcat(hash, id, 1, 0);
82        hash = ostrcat(hash, "&op=", 1, 0);
83        hash = ostrcat(hash, op, 1, 0);
84        debug(99, "hash: %s", hash);
85        hashlen = oitoa(strlen(hash));
86
87        send = ostrcat(send, "POST ", 1, 0);
88        send = ostrcat(send, tmpfile, 1, 0);
89        send = ostrcat(send, " HTTP/1.1\r\nContent-Length: ", 1, 0);
90        send = ostrcat(send, hashlen, 1, 0);
91        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);
92        send = ostrcat(send, tmphost, 1, 0);
93        send = ostrcat(send, "\r\nCookie: afc=", 1, 0);
94        send = ostrcat(send, cookie, 1, 0);
95        send = ostrcat(send, "\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n", 1, 0);
96        send = ostrcat(send, hash, 1, 0);
97        debug(99, "send: %s", send);
98
99        tmpstr = gethttpreal(tmphost, tmpfile, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
100        free(send), send = NULL;
101        debug(99, "tmpstr: %s", tmpstr);
102        titheklog(debuglevel, "/tmp/streamcould2_post", NULL, tmpstr);
103
104//      streamlink = oregex(".*file: \".*(http:.*video.mp4).*\".*", tmpstr);
105        streamlink = string_resub("file: \"", "\"", tmpstr, 0);
106        titheklog(debuglevel, "/tmp/streamcould3_streamlink", NULL, streamlink);
107
108end:
109
110        free(tmphost); tmphost = NULL;
111        free(tmpfile); tmpfile = NULL;
112        free(tmpstr); tmpstr = NULL;
113        free(send); send = NULL;
114        free(hash), hash = NULL;
115        free(hashlen), hashlen = NULL;
116        free(op), op = NULL;
117        free(id), id = NULL;
118        free(fname), fname = NULL;
119        free(ip); ip = NULL;
120        free(cookie); cookie = NULL;
121        free(cmd); cmd = NULL; 
122        return streamlink;
123}
124
125#endif
Note: See TracBrowser for help on using the repository browser.