source: titan/plugins/tithek/vidstream.h @ 19878

Last change on this file since 19878 was 19878, checked in by obi, 11 years ago

update tithek

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