1 | #ifndef STREAMCLOAD_H |
---|
2 | #define STREAMCLOAD_H |
---|
3 | |
---|
4 | char* streamcloud(char* link) |
---|
5 | { |
---|
6 | debug(99, "link: %s", link); |
---|
7 | int debuglevel = getconfigint("debuglevel", NULL); |
---|
8 | char* tmphost = NULL, *tmppath = 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(link == NULL) return NULL; |
---|
16 | |
---|
17 | ///////////// |
---|
18 | char* tmplink = NULL, *pos = NULL, *path = NULL; |
---|
19 | |
---|
20 | tmplink = ostrcat(link, NULL, 0, 0); |
---|
21 | |
---|
22 | if(ostrstr(link, "/Out/?s=") != NULL) |
---|
23 | { |
---|
24 | tmplink = string_replace("/Out/?s=", "", tmplink, 1); |
---|
25 | debug(99, "remove out string: %s", tmplink); |
---|
26 | } |
---|
27 | |
---|
28 | |
---|
29 | if(tmplink == NULL || ostrncmp("http", tmplink, 4)) |
---|
30 | { |
---|
31 | textbox(_("Message"), _("Hoster Url not http:// or https://") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
32 | goto end; |
---|
33 | } |
---|
34 | |
---|
35 | tmphost = string_replace("http://", "", tmplink, 0); |
---|
36 | tmphost = string_replace("https://", "", tmphost, 1); |
---|
37 | free(tmplink) , tmplink = NULL; |
---|
38 | |
---|
39 | if(tmphost != NULL) |
---|
40 | pos = strchr(tmphost, '/'); |
---|
41 | if(pos != NULL) |
---|
42 | { |
---|
43 | pos[0] = '\0'; |
---|
44 | path = pos + 1; |
---|
45 | } |
---|
46 | |
---|
47 | tmppath = ostrcat("/", path, 0, 0); |
---|
48 | // free(path), path = NULL; |
---|
49 | |
---|
50 | ///////////// |
---|
51 | |
---|
52 | |
---|
53 | /* |
---|
54 | tmphost = ostrcat(host, NULL, 0, 0); |
---|
55 | tmppath = ostrcat("/", file, 0, 0); |
---|
56 | |
---|
57 | debug(99, "tmphost: %s", tmphost); |
---|
58 | ip = get_ip(tmphost); |
---|
59 | debug(99, "ip: %s", ip); |
---|
60 | debug(99, "tmppath: %s", tmppath); |
---|
61 | */ |
---|
62 | send = ostrcat(send, "GET ", 1, 0); |
---|
63 | send = ostrcat(send, tmppath, 1, 0); |
---|
64 | send = ostrcat(send, " HTTP/1.1\r\nHost: ", 1, 0); |
---|
65 | send = ostrcat(send, tmphost, 1, 0); |
---|
66 | 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); |
---|
67 | debug(99, "send: %s", send); |
---|
68 | |
---|
69 | tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1); |
---|
70 | free(send), send = NULL; |
---|
71 | debug(99, "tmpstr: %s", tmpstr); |
---|
72 | |
---|
73 | if(tmpstr != NULL && ostrstr(tmpstr, "<head><title>404 Not Found</title></head>") != NULL) |
---|
74 | { |
---|
75 | textbox(_("Message"), _("The page not found, file removed") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
76 | goto end; |
---|
77 | } |
---|
78 | |
---|
79 | if(tmpstr != NULL && ostrstr(tmpstr, "File Not Found") != NULL) |
---|
80 | { |
---|
81 | textbox(_("Message"), _("The page not found, file removed") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
82 | goto end; |
---|
83 | } |
---|
84 | |
---|
85 | // waitmsgbar(16, 0, _("Connect with Hoster wait 16 seconds"), 1); |
---|
86 | |
---|
87 | titheklog(debuglevel, "/tmp/streamcould1_get", NULL, NULL, NULL, tmpstr); |
---|
88 | |
---|
89 | if(tmpstr == NULL) |
---|
90 | { |
---|
91 | textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
92 | goto end; |
---|
93 | } |
---|
94 | |
---|
95 | cookie = string_resub("Set-Cookie: afc=", ";", tmpstr, 0); |
---|
96 | debug(99, "cookie: %s", cookie); |
---|
97 | |
---|
98 | //get hash from tmpstr |
---|
99 | char* pos1 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"fname\" value="); |
---|
100 | fname = getxmlentry(pos1, "value="); |
---|
101 | debug(99, "fname: %s", fname); |
---|
102 | if(fname == NULL) |
---|
103 | { |
---|
104 | textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
105 | goto end; |
---|
106 | } |
---|
107 | |
---|
108 | char* pos2 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"id\" value="); |
---|
109 | id = getxmlentry(pos2, "value="); |
---|
110 | debug(99, "id: %s", id); |
---|
111 | if(id == NULL) goto end; |
---|
112 | |
---|
113 | char* pos3 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"op\" value="); |
---|
114 | op = getxmlentry(pos3, "value="); |
---|
115 | debug(99, "op1: %s", op); |
---|
116 | op = string_replace_all("download2", "download1", op, 1); |
---|
117 | debug(99, "op2: %s", op); |
---|
118 | |
---|
119 | char* pos4 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"hash\" value="); |
---|
120 | hashline = getxmlentry(pos4, "value="); |
---|
121 | |
---|
122 | char* pos5 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"referer\" value="); |
---|
123 | referer = getxmlentry(pos5, "value="); |
---|
124 | |
---|
125 | char* pos6 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"imhuman\" value="); |
---|
126 | imhuman = getxmlentry(pos6, "value="); |
---|
127 | |
---|
128 | char* pos7 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"usr_login\" value="); |
---|
129 | usr_login = getxmlentry(pos7, "value="); |
---|
130 | |
---|
131 | free(tmpstr); tmpstr = NULL; |
---|
132 | debug(99, "op: %s", op); |
---|
133 | if(op == NULL) |
---|
134 | { |
---|
135 | textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
136 | goto end; |
---|
137 | } |
---|
138 | |
---|
139 | hash = ostrcat(hash, "hash=", 1, 0); |
---|
140 | hash = ostrcat(hash, hashline, 1, 0); |
---|
141 | // hash = ostrcat(hash, "&imhuman=Weiter+zum+Video", 1, 0); |
---|
142 | hash = ostrcat(hash, "&imhuman=Watch+video+now", 1, 0); |
---|
143 | hash = ostrcat(hash, "&usr_login=", 1, 0); |
---|
144 | hash = ostrcat(hash, usr_login, 1, 0); |
---|
145 | hash = ostrcat(hash, "&referer=", 1, 0); |
---|
146 | hash = ostrcat(hash, referer, 1, 0); |
---|
147 | hash = ostrcat(hash, "&fname=", 1, 0); |
---|
148 | hash = ostrcat(hash, fname, 1, 0); |
---|
149 | hash = ostrcat(hash, "&id=", 1, 0); |
---|
150 | hash = ostrcat(hash, id, 1, 0); |
---|
151 | hash = ostrcat(hash, "&op=", 1, 0); |
---|
152 | // hash = ostrcat(hash, op, 1, 0); |
---|
153 | hash = ostrcat(hash, "download2", 1, 0); |
---|
154 | debug(99, "hash: %s", hash); |
---|
155 | hashlen = oitoa(strlen(hash)); |
---|
156 | /* |
---|
157 | send = ostrcat(send, "POST ", 1, 0); |
---|
158 | send = ostrcat(send, tmppath, 1, 0); |
---|
159 | send = ostrcat(send, " HTTP/1.1\r\nContent-Length: ", 1, 0); |
---|
160 | send = ostrcat(send, hashlen, 1, 0); |
---|
161 | 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); |
---|
162 | send = ostrcat(send, tmphost, 1, 0); |
---|
163 | send = ostrcat(send, "\r\nCookie: afc=", 1, 0); |
---|
164 | send = ostrcat(send, cookie, 1, 0); |
---|
165 | send = ostrcat(send, "\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n", 1, 0); |
---|
166 | send = ostrcat(send, hash, 1, 0); |
---|
167 | debug(99, "send: %s", send); |
---|
168 | */ |
---|
169 | send = ostrcat(send, "POST ", 1, 0); |
---|
170 | send = ostrcat(send, tmppath, 1, 0); |
---|
171 | send = ostrcat(send, " HTTP/1.0\r\nContent-Length: ", 1, 0); |
---|
172 | send = ostrcat(send, hashlen, 1, 0); |
---|
173 | send = ostrcat(send, "\r\nAccept-Encoding: gzip", 1, 0); |
---|
174 | send = ostrcat(send, "\r\nHost: ", 1, 0); |
---|
175 | send = ostrcat(send, tmphost, 1, 0); |
---|
176 | send = ostrcat(send, "\r\nUser-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:30.0) Gecko/20100101 Firefox/30.0", 1, 0); |
---|
177 | send = ostrcat(send, "\r\nConnection: close", 1, 0); |
---|
178 | send = ostrcat(send, "\r\nReferer: ", 1, 0); |
---|
179 | send = ostrcat(send, link, 1, 0); |
---|
180 | // send = ostrcat(send, "\r\nCookie: ", 1, 0); |
---|
181 | // send = ostrcat(send, cokkie, 1, 0); |
---|
182 | send = ostrcat(send, "\r\nContent-Type: application/x-www-form-urlencoded", 1, 0); |
---|
183 | send = ostrcat(send, "\r\n\r\n", 1, 0); |
---|
184 | send = ostrcat(send, hash, 1, 0); |
---|
185 | debug(99, "send: %s", send); |
---|
186 | |
---|
187 | tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1); |
---|
188 | free(send), send = NULL; |
---|
189 | debug(99, "tmpstr: %s", tmpstr); |
---|
190 | titheklog(debuglevel, "/tmp/streamcould2_post", NULL, NULL, NULL, tmpstr); |
---|
191 | |
---|
192 | if(tmpstr == NULL) |
---|
193 | { |
---|
194 | textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
195 | goto end; |
---|
196 | } |
---|
197 | |
---|
198 | // streamlink = oregex(".*file: \".*(http:.*video.mp4).*\".*", tmpstr); |
---|
199 | streamlink = string_resub("file: \"", "\"", tmpstr, 0); |
---|
200 | titheklog(debuglevel, "/tmp/streamcould3_streamlink", NULL, NULL, NULL, streamlink); |
---|
201 | |
---|
202 | end: |
---|
203 | |
---|
204 | free(tmphost); tmphost = NULL; |
---|
205 | free(tmppath); tmppath = NULL; |
---|
206 | free(tmpstr); tmpstr = NULL; |
---|
207 | free(send); send = NULL; |
---|
208 | free(hash), hash = NULL; |
---|
209 | free(hashlen), hashlen = NULL; |
---|
210 | free(op), op = NULL; |
---|
211 | free(id), id = NULL; |
---|
212 | free(fname), fname = NULL; |
---|
213 | free(ip); ip = NULL; |
---|
214 | free(cookie); cookie = NULL; |
---|
215 | free(cmd); cmd = NULL; |
---|
216 | free(hashline), hashline = NULL; |
---|
217 | return streamlink; |
---|
218 | } |
---|
219 | |
---|
220 | #endif |
---|