source: titan/plugins/tithek/played.h @ 30011

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

[tithek] fix played hoster

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