1 | #ifndef STREAMCLOAD_H |
---|
2 | #define STREAMCLOAD_H |
---|
3 | |
---|
4 | char* 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 | if(tmpstr == NULL) |
---|
39 | { |
---|
40 | textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
41 | goto end; |
---|
42 | } |
---|
43 | |
---|
44 | cookie = string_resub("Set-Cookie: afc=", ";", tmpstr, 0); |
---|
45 | debug(99, "cookie: %s", cookie); |
---|
46 | |
---|
47 | //get hash from tmpstr |
---|
48 | char* pos1 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"fname\" value="); |
---|
49 | fname = getxmlentry(pos1, "value="); |
---|
50 | debug(99, "fname: %s", fname); |
---|
51 | if(fname == NULL) goto end; |
---|
52 | |
---|
53 | char* pos2 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"id\" value="); |
---|
54 | id = getxmlentry(pos2, "value="); |
---|
55 | debug(99, "id: %s", id); |
---|
56 | if(id == NULL) goto end; |
---|
57 | |
---|
58 | char* pos3 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"op\" value="); |
---|
59 | op = getxmlentry(pos3, "value="); |
---|
60 | |
---|
61 | char* pos4 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"hash\" value="); |
---|
62 | hashline = getxmlentry(pos4, "value="); |
---|
63 | |
---|
64 | char* pos5 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"referer\" value="); |
---|
65 | referer = getxmlentry(pos5, "value="); |
---|
66 | |
---|
67 | char* pos6 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"imhuman\" value="); |
---|
68 | imhuman = getxmlentry(pos6, "value="); |
---|
69 | |
---|
70 | char* pos7 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"usr_login\" value="); |
---|
71 | usr_login = getxmlentry(pos7, "value="); |
---|
72 | |
---|
73 | free(tmpstr); tmpstr = NULL; |
---|
74 | debug(99, "op: %s", op); |
---|
75 | if(op == NULL) goto end; |
---|
76 | |
---|
77 | hash = ostrcat(hash, "hash=", 1, 0); |
---|
78 | hash = ostrcat(hash, hashline, 1, 0); |
---|
79 | hash = ostrcat(hash, "&imhuman=Weiter+zum+Video", 1, 0); |
---|
80 | hash = ostrcat(hash, "&usr_login=", 1, 0); |
---|
81 | hash = ostrcat(hash, usr_login, 1, 0); |
---|
82 | hash = ostrcat(hash, "&referer=", 1, 0); |
---|
83 | hash = ostrcat(hash, referer, 1, 0); |
---|
84 | hash = ostrcat(hash, "&fname=", 1, 0); |
---|
85 | hash = ostrcat(hash, fname, 1, 0); |
---|
86 | hash = ostrcat(hash, "&id=", 1, 0); |
---|
87 | hash = ostrcat(hash, id, 1, 0); |
---|
88 | hash = ostrcat(hash, "&op=", 1, 0); |
---|
89 | hash = ostrcat(hash, op, 1, 0); |
---|
90 | debug(99, "hash: %s", hash); |
---|
91 | hashlen = oitoa(strlen(hash)); |
---|
92 | |
---|
93 | send = ostrcat(send, "POST ", 1, 0); |
---|
94 | send = ostrcat(send, tmpfile, 1, 0); |
---|
95 | send = ostrcat(send, " HTTP/1.1\r\nContent-Length: ", 1, 0); |
---|
96 | send = ostrcat(send, hashlen, 1, 0); |
---|
97 | 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); |
---|
98 | send = ostrcat(send, tmphost, 1, 0); |
---|
99 | send = ostrcat(send, "\r\nCookie: afc=", 1, 0); |
---|
100 | send = ostrcat(send, cookie, 1, 0); |
---|
101 | send = ostrcat(send, "\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n", 1, 0); |
---|
102 | send = ostrcat(send, hash, 1, 0); |
---|
103 | debug(99, "send: %s", send); |
---|
104 | |
---|
105 | tmpstr = gethttpreal(tmphost, tmpfile, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1); |
---|
106 | free(send), send = NULL; |
---|
107 | debug(99, "tmpstr: %s", tmpstr); |
---|
108 | titheklog(debuglevel, "/tmp/streamcould2_post", NULL, tmpstr); |
---|
109 | |
---|
110 | if(tmpstr == NULL) |
---|
111 | { |
---|
112 | textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
113 | goto end; |
---|
114 | } |
---|
115 | |
---|
116 | // streamlink = oregex(".*file: \".*(http:.*video.mp4).*\".*", tmpstr); |
---|
117 | streamlink = string_resub("file: \"", "\"", tmpstr, 0); |
---|
118 | titheklog(debuglevel, "/tmp/streamcould3_streamlink", NULL, streamlink); |
---|
119 | |
---|
120 | end: |
---|
121 | |
---|
122 | free(tmphost); tmphost = NULL; |
---|
123 | free(tmpfile); tmpfile = NULL; |
---|
124 | free(tmpstr); tmpstr = NULL; |
---|
125 | free(send); send = NULL; |
---|
126 | free(hash), hash = NULL; |
---|
127 | free(hashlen), hashlen = NULL; |
---|
128 | free(op), op = NULL; |
---|
129 | free(id), id = NULL; |
---|
130 | free(fname), fname = NULL; |
---|
131 | free(ip); ip = NULL; |
---|
132 | free(cookie); cookie = NULL; |
---|
133 | free(cmd); cmd = NULL; |
---|
134 | return streamlink; |
---|
135 | } |
---|
136 | |
---|
137 | #endif |
---|