source: titan/plugins/tithek/faststream.h @ 41862

Last change on this file since 41862 was 38946, checked in by obi, 8 years ago

fix warnings

File size: 6.7 KB
Line 
1#ifndef FASTSTREAM_H
2#define FASTSTREAM_H
3
4char* faststream(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       
10        if(link == NULL) return NULL;
11
12        unlink("/tmp/faststream1_get");
13        unlink("/tmp/faststream2_post");
14        unlink("/tmp/faststream3_post");
15        unlink("/tmp/faststream4_streamlink");
16/////////////
17        char* tmplink = NULL, *pos = NULL, *path = NULL;
18
19        tmplink = ostrcat(link, NULL, 0, 0);
20
21        if(ostrstr(link, "/Out/?s=") != NULL)
22        {
23                tmplink = string_replace("/Out/?s=", "", tmplink, 1);
24                debug(99, "remove out string: %s", tmplink);
25        }
26       
27
28        if(tmplink == NULL || ostrncmp("http", tmplink, 4))
29        {
30                textbox(_("Message"), _("Hoster Url not http:// or https://") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
31                goto end;
32        }
33
34        tmphost = string_replace("http://", "", tmplink, 0);
35        tmphost = string_replace("https://", "", tmphost, 1);
36        free(tmplink) , tmplink = NULL;
37
38        if(tmphost != NULL)
39                pos = strchr(tmphost, '/');
40        if(pos != NULL)
41        {
42                pos[0] = '\0';
43                path = pos + 1;
44        }
45
46        tmppath = ostrcat("/", path, 0, 0);
47//      free(path), path = NULL;
48
49/////////////
50
51
52/*
53        tmphost = ostrcat("www.", host, 0, 0);
54        tmppath = ostrcat("/", file, 0, 0);
55        debug(99, "tmphost: %s", tmphost);
56        ip = get_ip(tmphost);
57        debug(99, "ip: %s", ip);
58        debug(99, "test host only: %s", get_ip(host));
59        debug(99, "tmppath: %s", tmppath);
60*/
61
62        send = ostrcat(send, "GET ", 1, 0);
63        send = ostrcat(send, tmppath, 1, 0);
64        send = ostrcat(send, " HTTP/1.1\r\nAccept-Encoding: identity\r\n", 1, 0);
65        send = ostrcat(send, "Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4\r\n", 1, 0);
66        send = ostrcat(send, "Host: ", 1, 0);
67        send = ostrcat(send, tmphost, 1, 0);
68        send = ostrcat(send, "\r\nUser-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3\r\n", 1, 0);
69        send = ostrcat(send, "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n", 1, 0);
70        send = ostrcat(send, "Connection: close\r\nCookie: xxx2=ok;\r\n\r\n", 1, 0);
71        debug(99, "send: %s", send);
72
73        tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
74        free(send), send = NULL;
75        debug(99, "tmpstr: %s", tmpstr);
76        titheklog(debuglevel, "/tmp/faststream1_get", NULL, NULL, NULL, tmpstr);
77
78        if(tmpstr == NULL)
79        {
80                textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
81                goto end;
82        }
83
84        if(tmpstr == NULL || ostrstr(tmpstr, "<title>The page is temporarily unavailable</title>") != NULL)
85        {
86                error = string_resub("<td align=\"center\" valign=\"middle\">", "</td>", tmpstr, 0);
87                string_deltags(error);
88                stringreplacechar(error, '|', '\0');
89                error = strstrip(error);
90                if(error == NULL || strlen(error) == 0)
91                        error = ostrcat(_("The page is temporarily unavailable"), error, 0, 1);
92                textbox(_("Message"), error, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 400, 0, 0);
93                goto end;
94        }
95
96        if(ostrstr(tmpstr, "<title>Direct IP access not allowed") != NULL)
97        {
98                error = string_resub("<title>", "</title>", tmpstr, 0);
99                string_deltags(error);
100                stringreplacechar(error, '|', '\0');
101                error = strstrip(error);
102                if(error == NULL || strlen(error) == 0)
103                        error = ostrcat(_("The page is temporarily unavailable"), error, 0, 1);
104                textbox(_("Message"), error, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 400, 0, 0);
105                goto end;
106        }
107
108        if(ostrstr(tmpstr, "Die von Ihnen angeforderte Datei konnte nicht gefunden werden..") != NULL)
109        {
110                textbox(_("Message"), _("The video no longer exists") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
111                goto end;
112        }
113
114        waitmsgbar(10, 0, _("Connect with Hoster wait 10 seconds"), 1);
115
116        //get hash from tmpstr
117        char* pos1 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"fname\" value=");
118        fname = getxmlentry(pos1, "value=");
119        debug(99, "fname: %s", fname);
120        if(fname == NULL) goto end;
121
122        char* pos2 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"id\" value=");
123        id = getxmlentry(pos2, "value=");
124        debug(99, "id: %s", id);
125        if(id == NULL) goto end;
126
127        char* pos3 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"hash\" value=");
128        hashmsg = getxmlentry(pos3, "value=");
129        free(tmpstr); tmpstr = NULL;
130        debug(99, "hashmsg: %s", hashmsg);
131        if(hashmsg == NULL) goto end;
132        free(tmpstr), tmpstr = NULL;
133
134        hash = ostrcat(hash, "fname=", 1, 0);
135        hash = ostrcat(hash, fname, 1, 0);
136        hash = ostrcat(hash, "&hash=", 1, 0);
137        hash = ostrcat(hash, hashmsg, 1, 0);
138        hash = ostrcat(hash, "&id=", 1, 0);     
139        hash = ostrcat(hash, id, 1, 0);
140        hash = ostrcat(hash, "&imhuman=", 1, 0);
141        hash = ostrcat(hash, "Proceed%20to%20video", 1, 0);
142        hash = ostrcat(hash, "&op=download1", 1, 0);
143        hash = ostrcat(hash, "&referer=&usr_login=", 1, 0);
144        debug(99, "hash: %s", hash);
145
146        hashlen = oitoa(strlen(hash));
147       
148        //create send string
149        send = ostrcat(send, "POST /", 1, 0);
150        send = ostrcat(send, id, 1, 0);
151        send = ostrcat(send, " HTTP/1.0\r\nContent-Length: ", 1, 0);
152        send = ostrcat(send, hashlen, 1, 0);
153        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);
154        send = ostrcat(send, tmphost, 1, 0);
155        send = ostrcat(send, "\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n", 1, 0);
156        send = ostrcat(send, hash, 1, 0);
157        debug(99, "send: %s", send);
158        free(hash), hash = NULL;
159
160        tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 0);
161        free(send), send = NULL;
162        debug(99, "tmpstr: %s", tmpstr);
163        titheklog(debuglevel, "/tmp/faststream2_post", NULL, NULL, NULL, tmpstr);
164
165        if(tmpstr == NULL)
166        {
167                textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
168                goto end;
169        }
170
171        streamlink = string_resub("file: \"", "\"", tmpstr, 0);         
172
173        titheklog(debuglevel, "/tmp/faststream4_streamlink", NULL, NULL, NULL, streamlink);
174
175        free(tmpstr); tmpstr = NULL;
176
177end:
178
179        free(error); error = NULL;
180        free(tmphost); tmphost = NULL;
181        free(tmppath); tmppath = NULL;
182        free(tmpstr); tmpstr = NULL;
183        free(send); send = NULL;
184        free(hash), hash = NULL;
185        free(hashlen), hashlen = NULL;
186        free(hashmsg), hashmsg = NULL;
187        free(id), id = NULL;
188        free(fname), fname = NULL;
189        free(ip); ip = NULL;
190
191        return streamlink;
192}
193
194#endif
Note: See TracBrowser for help on using the repository browser.