1 | #ifndef VIDTO_H |
---|
2 | #define VIDTO_H |
---|
3 | |
---|
4 | char* vidto(char* link) |
---|
5 | { |
---|
6 | debug(99, "link: %s", link); |
---|
7 | int debuglevel = getconfigint("debuglevel", NULL); |
---|
8 | char* tmphost = NULL, *error = NULL, *tmppath = NULL, *tmpstr = NULL, *send = NULL, *id = NULL, *fname = NULL, *hashmsg = NULL, *hash = NULL, *hashlen = NULL, *ip = NULL, *streamlink = NULL; |
---|
9 | char* hashline = NULL, *referer = NULL, *usr_login = NULL, *imhuman = NULL, *cookie = NULL, *op = NULL; |
---|
10 | |
---|
11 | if(link == NULL) return NULL; |
---|
12 | |
---|
13 | unlink("/tmp/vidto1_get"); |
---|
14 | unlink("/tmp/vidto2_post"); |
---|
15 | unlink("/tmp/vidto3_post"); |
---|
16 | unlink("/tmp/vidto4_streamlink"); |
---|
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 | |
---|
49 | // free(path), path = NULL; |
---|
50 | |
---|
51 | send = ostrcat(send, "GET ", 1, 0); |
---|
52 | send = ostrcat(send, tmppath, 1, 0); |
---|
53 | send = ostrcat(send, " HTTP/1.1\r\n", 1, 0); |
---|
54 | send = ostrcat(send, "Host: ", 1, 0); |
---|
55 | send = ostrcat(send, tmphost, 1, 0); |
---|
56 | 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\n", 1, 0); |
---|
57 | send = ostrcat(send, "Connection: close\r\n", 1, 0); |
---|
58 | send = ostrcat(send, "Accept-Encoding: gzip\r\n\r\n", 1, 0); |
---|
59 | debug(99, "send: %s", send); |
---|
60 | |
---|
61 | tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1); |
---|
62 | free(send), send = NULL; |
---|
63 | debug(99, "tmpstr: %s", tmpstr); |
---|
64 | titheklog(debuglevel, "/tmp/vidto1_get", NULL, NULL, NULL, tmpstr); |
---|
65 | |
---|
66 | if(tmpstr == NULL) |
---|
67 | { |
---|
68 | textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
69 | goto end; |
---|
70 | } |
---|
71 | |
---|
72 | if(ostrstr(tmpstr, "404 Not Found") != NULL) |
---|
73 | { |
---|
74 | textbox(_("Message"), _("The video no longer exists") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
75 | goto end; |
---|
76 | } |
---|
77 | |
---|
78 | if(ostrstr(tmpstr, "The file you were looking for could not be found, sorry for any inconvenience") != NULL) |
---|
79 | { |
---|
80 | textbox(_("Message"), _("The file you were looking for could not be found, sorry for any inconvenience") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
81 | goto end; |
---|
82 | } |
---|
83 | |
---|
84 | waitmsgbar(10, 0, _("Connect with Hoster wait 10 seconds"), 1); |
---|
85 | |
---|
86 | cookie = string_resub("Set-Cookie: file_id=", ";", tmpstr, 0); |
---|
87 | debug(99, "cookie: %s", cookie); |
---|
88 | |
---|
89 | //get hash from tmpstr |
---|
90 | char* pos1 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"fname\" value="); |
---|
91 | fname = getxmlentry(pos1, "value="); |
---|
92 | debug(99, "fname: %s", fname); |
---|
93 | if(fname == NULL) |
---|
94 | { |
---|
95 | textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
96 | goto end; |
---|
97 | } |
---|
98 | |
---|
99 | char* pos2 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"id\" value="); |
---|
100 | id = getxmlentry(pos2, "value="); |
---|
101 | debug(99, "id: %s", id); |
---|
102 | if(id == NULL) goto end; |
---|
103 | |
---|
104 | char* pos3 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"op\" value="); |
---|
105 | op = getxmlentry(pos3, "value="); |
---|
106 | debug(99, "op1: %s", op); |
---|
107 | op = string_replace_all("download2", "download1", op, 1); |
---|
108 | debug(99, "op2: %s", op); |
---|
109 | |
---|
110 | char* pos4 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"hash\" value="); |
---|
111 | hashline = getxmlentry(pos4, "value="); |
---|
112 | |
---|
113 | // char* pos5 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"referer\" value="); |
---|
114 | // referer = getxmlentry(pos5, "value="); |
---|
115 | referer = htmlencode(link); |
---|
116 | referer = string_replace_all("/", "%2F", referer, 1); |
---|
117 | debug(99, "referer: %s", referer); |
---|
118 | |
---|
119 | char* pos6 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"imhuman\" value="); |
---|
120 | imhuman = getxmlentry(pos6, "value="); |
---|
121 | |
---|
122 | char* pos7 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"usr_login\" value="); |
---|
123 | usr_login = getxmlentry(pos7, "value="); |
---|
124 | |
---|
125 | free(tmpstr); tmpstr = NULL; |
---|
126 | debug(99, "op: %s", op); |
---|
127 | if(op == NULL) |
---|
128 | { |
---|
129 | textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
130 | goto end; |
---|
131 | } |
---|
132 | |
---|
133 | hash = ostrcat(hash, "hash=", 1, 0); |
---|
134 | hash = ostrcat(hash, hashline, 1, 0); |
---|
135 | hash = ostrcat(hash, "&imhuman=Proceed+to+video", 1, 0); |
---|
136 | // hash = ostrcat(hash, "&usr_login=", 1, 0); |
---|
137 | // hash = ostrcat(hash, usr_login, 1, 0); |
---|
138 | hash = ostrcat(hash, "&referer=", 1, 0); |
---|
139 | hash = ostrcat(hash, referer, 1, 0); |
---|
140 | hash = ostrcat(hash, "&fname=", 1, 0); |
---|
141 | hash = ostrcat(hash, fname, 1, 0); |
---|
142 | hash = ostrcat(hash, "&id=", 1, 0); |
---|
143 | hash = ostrcat(hash, id, 1, 0); |
---|
144 | hash = ostrcat(hash, "&op=", 1, 0); |
---|
145 | // hash = ostrcat(hash, op, 1, 0); |
---|
146 | hash = ostrcat(hash, "download1", 1, 0); |
---|
147 | debug(99, "hash: %s", hash); |
---|
148 | hashlen = oitoa(strlen(hash)); |
---|
149 | |
---|
150 | send = ostrcat(send, "POST ", 1, 0); |
---|
151 | send = ostrcat(send, tmppath, 1, 0); |
---|
152 | send = ostrcat(send, " HTTP/1.0\r\nContent-Length: ", 1, 0); |
---|
153 | send = ostrcat(send, hashlen, 1, 0); |
---|
154 | send = ostrcat(send, "\r\nAccept-Encoding: gzip", 1, 0); |
---|
155 | send = ostrcat(send, "\r\nHost: ", 1, 0); |
---|
156 | send = ostrcat(send, tmphost, 1, 0); |
---|
157 | send = ostrcat(send, "\r\nUser-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:30.0) Gecko/20100101 Firefox/30.0", 1, 0); |
---|
158 | send = ostrcat(send, "\r\nConnection: close", 1, 0); |
---|
159 | send = ostrcat(send, "\r\nReferer: ", 1, 0); |
---|
160 | send = ostrcat(send, link, 1, 0); |
---|
161 | send = ostrcat(send, "\r\nCookie: file_id=", 1, 0); |
---|
162 | send = ostrcat(send, cookie, 1, 0); |
---|
163 | send = ostrcat(send, "\r\nContent-Type: application/x-www-form-urlencoded", 1, 0); |
---|
164 | send = ostrcat(send, "\r\n\r\n", 1, 0); |
---|
165 | send = ostrcat(send, hash, 1, 0); |
---|
166 | debug(99, "send: %s", send); |
---|
167 | |
---|
168 | tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1); |
---|
169 | free(send), send = NULL; |
---|
170 | debug(99, "tmpstr: %s", tmpstr); |
---|
171 | titheklog(debuglevel, "/tmp/vidto2_post", NULL, NULL, NULL, tmpstr); |
---|
172 | |
---|
173 | if(tmpstr == NULL) |
---|
174 | { |
---|
175 | textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
176 | goto end; |
---|
177 | } |
---|
178 | |
---|
179 | if(ostrstr(tmpstr, "404 Not Found") != NULL) |
---|
180 | { |
---|
181 | textbox(_("Message"), _("The video no longer exists") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
182 | goto end; |
---|
183 | } |
---|
184 | |
---|
185 | |
---|
186 | streamlink = string_resub("var file_link = '", "'", tmpstr, 0); |
---|
187 | // not working then use filename video.mp4 |
---|
188 | |
---|
189 | titheklog(debuglevel, "/tmp/vidto4_streamlink", NULL, NULL, NULL, streamlink); |
---|
190 | |
---|
191 | free(tmpstr); tmpstr = NULL; |
---|
192 | |
---|
193 | end: |
---|
194 | |
---|
195 | free(error); error = NULL; |
---|
196 | free(tmphost); tmphost = NULL; |
---|
197 | free(tmppath); tmppath = NULL; |
---|
198 | free(tmpstr); tmpstr = NULL; |
---|
199 | free(send); send = NULL; |
---|
200 | free(hash), hash = NULL; |
---|
201 | free(hashlen), hashlen = NULL; |
---|
202 | free(hashmsg), hashmsg = NULL; |
---|
203 | free(id), id = NULL; |
---|
204 | free(fname), fname = NULL; |
---|
205 | free(ip); ip = NULL; |
---|
206 | |
---|
207 | return streamlink; |
---|
208 | } |
---|
209 | |
---|
210 | #endif |
---|