1 | #ifndef VIDSTREAM_H |
---|
2 | #define VIDSTREAM_H |
---|
3 | |
---|
4 | char* vidstream(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* id = NULL; |
---|
16 | char* fname = NULL; |
---|
17 | char* op = NULL; |
---|
18 | char* hash = NULL; |
---|
19 | char* hashline = NULL; |
---|
20 | char* hashlen = NULL; |
---|
21 | char* referer = NULL; |
---|
22 | char* usr_login = NULL; |
---|
23 | char* imhuman = NULL; |
---|
24 | |
---|
25 | if(host == NULL || file == NULL) return NULL; |
---|
26 | |
---|
27 | unlink("/tmp/vidstream1_get"); |
---|
28 | unlink("/tmp/vidstream2_post"); |
---|
29 | unlink("/tmp/vidstream3_streamlink"); |
---|
30 | |
---|
31 | tmphost = ostrcat(host, NULL, 0, 0); |
---|
32 | tmpfile = ostrcat("/", file, 0, 0); |
---|
33 | ip = get_ip(tmphost); |
---|
34 | debug(99, "tmpfile: %s", tmpfile); |
---|
35 | debug(99, "tmphost: %s", tmphost); |
---|
36 | debug(99, "ip: %s", ip); |
---|
37 | |
---|
38 | send = ostrcat(send, "GET ", 1, 0); |
---|
39 | send = ostrcat(send, tmpfile, 1, 0); |
---|
40 | send = ostrcat(send, " HTTP/1.1\r\nHost: ", 1, 0); |
---|
41 | send = ostrcat(send, tmphost, 1, 0); |
---|
42 | 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); |
---|
43 | debug(99, "send: %s", send); |
---|
44 | tmpstr = gethttpreal(tmphost, tmpfile, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1); |
---|
45 | debug(99, "tmpstr: %s", tmpstr); |
---|
46 | titheklog(debuglevel, "/tmp/vidstream1_get", NULL, tmpstr); |
---|
47 | |
---|
48 | sleep(1); |
---|
49 | |
---|
50 | if(ostrstr(tmpstr, "<b>File Not Found</b>") != NULL) |
---|
51 | { |
---|
52 | tmpstr = string_resub("<Center>", "</Center>", tmpstr, 1); |
---|
53 | string_deltags(tmpstr); |
---|
54 | tmpstr = string_replace("Terms", "\nTerms", tmpstr, 1); |
---|
55 | tmpstr = strstrip(tmpstr); |
---|
56 | if(tmpstr == NULL || strlen(tmpstr) == 0) |
---|
57 | tmpstr = ostrcat(_("The page is temporarily unavailable"), tmpstr, 0, 1); |
---|
58 | textbox(_("Message"), tmpstr, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 400, 0, 0); |
---|
59 | goto end; |
---|
60 | } |
---|
61 | |
---|
62 | //get hash from tmpstr |
---|
63 | char* pos1 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"fname\" value="); |
---|
64 | fname = getxmlentry(pos1, "value="); |
---|
65 | debug(99, "fname: %s", fname); |
---|
66 | if(fname == NULL) goto end; |
---|
67 | |
---|
68 | char* pos2 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"id\" value="); |
---|
69 | id = getxmlentry(pos2, "value="); |
---|
70 | debug(99, "id: %s", id); |
---|
71 | if(id == NULL) goto end; |
---|
72 | |
---|
73 | char* pos3 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"op\" value="); |
---|
74 | op = getxmlentry(pos3, "value="); |
---|
75 | |
---|
76 | char* pos4 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"hash\" value="); |
---|
77 | hashline = getxmlentry(pos4, "value="); |
---|
78 | |
---|
79 | char* pos5 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"referer\" value="); |
---|
80 | referer = getxmlentry(pos5, "value="); |
---|
81 | |
---|
82 | char* pos6 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"imhuman\" value="); |
---|
83 | imhuman = getxmlentry(pos6, "value="); |
---|
84 | |
---|
85 | char* pos7 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"usr_login\" value="); |
---|
86 | usr_login = getxmlentry(pos7, "value="); |
---|
87 | |
---|
88 | free(tmpstr); tmpstr = NULL; |
---|
89 | debug(99, "op: %s", op); |
---|
90 | if(op == NULL) goto end; |
---|
91 | |
---|
92 | hash = ostrcat(hash, "hash=", 1, 0); |
---|
93 | hash = ostrcat(hash, hashline, 1, 0); |
---|
94 | 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); |
---|
95 | hash = ostrcat(hash, "&usr_login=", 1, 0); |
---|
96 | hash = ostrcat(hash, usr_login, 1, 0); |
---|
97 | hash = ostrcat(hash, "&referer=", 1, 0); |
---|
98 | hash = ostrcat(hash, referer, 1, 0); |
---|
99 | hash = ostrcat(hash, "&fname=", 1, 0); |
---|
100 | hash = ostrcat(hash, fname, 1, 0); |
---|
101 | hash = ostrcat(hash, "&id=", 1, 0); |
---|
102 | hash = ostrcat(hash, id, 1, 0); |
---|
103 | hash = ostrcat(hash, "&op=download1", 1, 0); |
---|
104 | // hash = ostrcat(hash, op, 1, 0); |
---|
105 | debug(99, "hash: %s", hash); |
---|
106 | hashlen = oitoa(strlen(hash)); |
---|
107 | |
---|
108 | //create send string |
---|
109 | free(send), send = NULL; |
---|
110 | |
---|
111 | send = ostrcat(send, "POST ", 1, 0); |
---|
112 | send = ostrcat(send, tmpfile, 1, 0); |
---|
113 | send = ostrcat(send, " HTTP/1.1\r\nContent-Length: ", 1, 0); |
---|
114 | send = ostrcat(send, hashlen, 1, 0); |
---|
115 | 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); |
---|
116 | send = ostrcat(send, tmphost, 1, 0); |
---|
117 | send = ostrcat(send, "\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n", 1, 0); |
---|
118 | send = ostrcat(send, hash, 1, 0); |
---|
119 | debug(99, "send: %s", send); |
---|
120 | |
---|
121 | tmpstr = gethttpreal(tmphost, tmpfile, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1); |
---|
122 | debug(99, "tmpstr: %s", tmpstr); |
---|
123 | titheklog(debuglevel, "/tmp/vidstream2_post", NULL, tmpstr); |
---|
124 | |
---|
125 | sleep(1); |
---|
126 | streamlink = string_resub("file: \"", "\",", tmpstr, 0); |
---|
127 | |
---|
128 | titheklog(debuglevel, "/tmp/vidstream3_streamlink", NULL, streamlink); |
---|
129 | |
---|
130 | end: |
---|
131 | |
---|
132 | free(hash), hash = NULL; |
---|
133 | free(hashlen), hashlen = NULL; |
---|
134 | free(op), op = NULL; |
---|
135 | free(id), id = NULL; |
---|
136 | free(fname), fname = NULL; |
---|
137 | |
---|
138 | free(tmphost); tmphost = NULL; |
---|
139 | free(tmpfile); tmpfile = NULL; |
---|
140 | free(tmpstr); tmpstr = NULL; |
---|
141 | free(send); send = NULL; |
---|
142 | free(ip); ip = NULL; |
---|
143 | |
---|
144 | return streamlink; |
---|
145 | } |
---|
146 | |
---|
147 | #endif |
---|