source: titan/plugins/tithek/streamcloud.h @ 19879

Last change on this file since 19879 was 19879, checked in by obi, 10 years ago

[tithek] update debug system

File size: 4.8 KB
Line 
1#ifndef STREAMCLOAD_H
2#define STREAMCLOAD_H
3
4char* streamcloud(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* id = NULL;
12        char* fname = NULL;
13        char* op = NULL;
14        char* hash = NULL;
15        char* hashline = NULL;
16        char* hashlen = NULL;
17        char* referer = NULL;
18        char* usr_login = NULL;
19        char* imhuman = NULL;   
20        char* ip = NULL;
21        char* cookie = NULL;
22        char* cmd = NULL;
23        char* streamlink = NULL;
24
25        if(host == NULL || file == NULL) return NULL;
26
27        tmphost = ostrcat(tmphost, host, 1, 0);
28        tmpfile = ostrcat("/", file, 0, 0);
29       
30        debug(99, "tmphost: %s", tmphost);
31        ip = get_ip(tmphost);
32        debug(99, "ip: %s", ip);
33        debug(99, "tmpfile: %s", tmpfile);
34
35        send = ostrcat(send, "GET /", 1, 0);
36        send = ostrcat(send, file, 1, 0);
37        send = ostrcat(send, " HTTP/1.1\r\nHost: ", 1, 0);
38        send = ostrcat(send, host, 1, 0);
39        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);
40        debug(99, "send: %s", send);
41
42        tmpstr = gethttpreal(tmphost, tmpfile, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
43
44        if(getconfigint("debuglevel", NULL) == 99)
45                writesys("/tmp/streamcould1_tmpstr", tmpstr, 0);
46/*
47        old code       
48        cmd = ostrcat(cmd, "echo -e \"", 1, 0);
49        cmd = ostrcat(cmd, send, 1, 0);
50        cmd = ostrcat(cmd, "\" | /var/usr/local/share/titan/plugins/tithek/netcat ", 1, 0);
51        cmd = ostrcat(cmd, host, 1, 0);
52        cmd = ostrcat(cmd, " 80", 1, 0);
53        debug(99, "cmd: %s", cmd);
54        free(tmpstr), tmpstr = NULL;
55        tmpstr = command(cmd);
56*/
57        cookie = string_resub("Set-Cookie: afc=", ";", tmpstr, 0);     
58        debug(99, "cookie: %s", cookie);
59 
60        sleep(20);
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=Weiter+zum+Video", 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=", 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, file, 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, host, 1, 0);
117        send = ostrcat(send, "\r\nCookie: afc=", 1, 0);
118        send = ostrcat(send, cookie, 1, 0);
119        send = ostrcat(send, "\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n", 1, 0);
120        send = ostrcat(send, hash, 1, 0);
121        debug(99, "send: %s", send);
122
123        free(tmpstr), tmpstr = NULL;
124        tmpstr = gethttpreal(tmphost, tmpfile, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 0);
125        if(getconfigint("debuglevel", NULL) == 99)
126                writesys("/tmp/streamcould2_tmpstr_post", tmpstr, 0);
127
128//      streamlink = oregex(".*file: \".*(http:.*video.mp4).*\".*", tmpstr);
129        streamlink = string_resub("file: \"", "\"", tmpstr, 0);
130        if(getconfigint("debuglevel", NULL) == 99)
131                writesys("/tmp/streamcould3_streamlink", streamlink, 0);
132
133        free(tmpstr); tmpstr = NULL;
134
135end:
136
137        free(tmphost); tmphost = NULL;
138        free(tmpfile); tmpfile = NULL;
139        free(tmpstr); tmpstr = NULL;
140        free(send); send = NULL;
141        free(hash), hash = NULL;
142        free(hashlen), hashlen = NULL;
143        free(op), op = NULL;
144        free(id), id = NULL;
145        free(fname), fname = NULL;
146        free(ip); ip = NULL;
147        free(cookie); cookie = NULL;
148        free(cmd); cmd = NULL; 
149        return streamlink;
150}
151
152#endif
Note: See TracBrowser for help on using the repository browser.