source: titan/plugins/tithek/putlocker.h @ 24310

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

fix

File size: 5.7 KB
Line 
1#ifndef PUTLOCKER_H
2#define PUTLOCKER_H
3
4char* putlocker(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, *tmpfile = NULL, *tmpstr = NULL, *send = NULL, *hash = NULL, *hashstr = NULL, *hashlen = NULL;
9        char* ip = NULL, *phpsessid = NULL, *serverid = NULL, *usender = NULL, *streamlink = NULL, *streamlink1 = NULL, *tmpstr2 = NULL;
10
11        unlink("/tmp/putlocker1_tmpstr_get");
12        unlink("/tmp/putlocker2_tmpstr_post");
13        unlink("/tmp/putlocker3_tmpstr_get");
14        unlink("/tmp/putlocker4_streamlink");
15
16        if(host == NULL || file == NULL) return NULL;
17
18        tmphost = ostrcat("www.", host, 0, 0);
19        tmpfile = ostrcat("/file/", file, 0, 0);
20        debug(99, "tmphost: %s", tmphost);
21        ip = get_ip(tmphost);
22        debug(99, "ip: %s", ip);
23        debug(99, "tmpfile: %s", tmpfile);
24
25        send = ostrcat(send, "GET ", 1, 0);
26        send = ostrcat(send, tmpfile, 1, 0);
27        send = ostrcat(send, " HTTP/1.1\r\nHost: ", 1, 0);     
28        send = ostrcat(send, tmphost, 1, 0);
29        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);       
30        debug(99, "send: %s", send);
31
32        tmpstr = gethttpreal(tmphost, tmpfile, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
33        free(send); send = NULL;
34        debug(99, "tmpstr: %s", tmpstr);
35        titheklog(debuglevel, "/tmp/putlocker1_tmpstr_get", NULL, tmpstr);
36       
37        phpsessid = getxmlentry(tmpstr, "PHPSESSID=");
38        debug(99, "phpsessid: %s", phpsessid);
39        serverid = getxmlentry(tmpstr, "SERVERID=");
40        debug(99, "serverid: %s", serverid);
41        usender = getxmlentry(tmpstr, "usender=");
42        debug(99, "usender: %s", usender);
43
44        //get hash from tmpstr
45        char* pos = ostrstr(tmpstr, "<input type=\"hidden\" value=");
46        hashstr = getxmlentry(pos, "value=");
47// free(tmpstr) after getxml or segfault...
48        free(tmpstr); tmpstr = NULL;
49        debug(99, "hashstr: %s", hashstr);
50        if(hashstr == NULL) goto end;
51
52        hash = ostrcat(hash, "hash=", 1, 0);   
53        hash = ostrcat(hash, hashstr, 1, 0);
54        hash = ostrcat(hash, "&confirm=Continue+as+Free+User", 1, 0);
55        debug(99, "hash: %s", hash);
56
57        hashlen = oitoa(strlen(hash));
58        debug(99, "hashlen: %s", hashlen);
59
60        //create send string
61        send = ostrcat(send, "POST /file/", 1, 0);
62        send = ostrcat(send, file, 1, 0);
63        send = ostrcat(send, " HTTP/1.1\r\nContent-Length: ", 1, 0);
64        send = ostrcat(send, hashlen, 1, 0);
65        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);
66        send = ostrcat(send, tmphost, 1, 0);
67        send = ostrcat(send, "\r\nCookie: usender=", 1, 0);
68        send = ostrcat(send, usender, 1, 0);
69        send = ostrcat(send, " SERVERID=", 1, 0);
70        send = ostrcat(send, serverid, 1, 0);
71        send = ostrcat(send, " PHPSESSID=", 1, 0);
72        send = ostrcat(send, phpsessid, 1, 0);
73        send = ostrcat(send, "\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n", 1, 0);
74        send = ostrcat(send, hash, 1, 0);
75        debug(99, "send: %s", send);
76
77//      sleep(7);
78        tmpstr = gethttpreal(tmphost, tmpfile, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
79        free(send); send = NULL;
80        debug(99, "tmpstr: %s", tmpstr);
81        titheklog(debuglevel, "/tmp/putlocker2_tmpstr_post", NULL, tmpstr);
82       
83        if(ostrstr(tmpstr, "warning_message") != NULL)
84        {
85                tmpstr2 = string_resub("<div class='warning_message'>", "</div>", tmpstr, 0);
86                tmpstr2 = strstrip(tmpstr2);
87                if(tmpstr2 == NULL || strlen(tmpstr2) == 0)
88                        tmpstr2 = ostrcat(_("The page is temporarily unavailable"), NULL, 0, 0);
89                textbox(_("Message"), _(tmpstr2) , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
90                goto end;
91        }
92
93        if(phpsessid == NULL || serverid == NULL) goto end;                     
94
95        //get streamlink
96        if(ostrstr(tmpstr, "playlist:") != NULL)
97                streamlink = getxmlentry(tmpstr, "playlist: '");
98        else
99        {
100                streamlink = string_resub("/get_file.php", "\">Download File</a>", tmpstr, 0);
101                streamlink1 = ostrcat("http://www.", host, 0, 0);
102                streamlink1 = ostrcat(streamlink1, "/get_file.php", 1, 0);
103                streamlink1 = ostrcat(streamlink1, streamlink, 1, 0);
104                debug(99, "stream downloadlink: %s", streamlink1);
105                goto end;
106        }
107        debug(99, "streamlink: %s", streamlink);
108
109        if(streamlink != NULL)
110        {
111                char* pos = strchr(streamlink, '\'');
112                if(pos != NULL) pos[0] = '\0';
113        }
114        free(tmpstr); tmpstr = NULL;
115
116        if(streamlink == NULL) goto end;
117
118        //create send string
119        send = ostrcat(send, "GET ", 1, 0);
120        send = ostrcat(send, streamlink, 1, 0);
121        send = ostrcat(send, " HTTP/1.1\r\nAccept-Encoding: identity\r\nHost: ", 1, 0);
122        send = ostrcat(send, tmphost, 1, 0);
123        send = ostrcat(send, "\r\nCookie: SERVERID=", 1, 0);
124        send = ostrcat(send, serverid, 1, 0);
125        send = ostrcat(send, "PHPSESSID=", 1, 0);
126        send = ostrcat(send, phpsessid, 1, 0);
127        send = ostrcat(send, "\r\nConnection: close\r\nUser-Agent: Python-urllib/2.6\r\n\r\n", 1, 0);
128
129//      sleep(5);
130       
131        tmpstr = gethttpreal(tmphost, tmpfile, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 0);
132        free(send); send = NULL;
133        debug(99, "tmpstr: %s", tmpstr);
134        titheklog(debuglevel, "/tmp/putlocker3_tmpstr_get", NULL, tmpstr);
135
136        //get streamlink1
137        streamlink1 = getxmlentry(tmpstr, "url=");
138        titheklog(debuglevel, "/tmp/putlocker4_streamlink", NULL, streamlink1);
139
140        free(tmpstr); tmpstr = NULL;
141
142end:
143        free(tmphost); tmphost = NULL;
144        free(tmpfile); tmpfile = NULL;
145        free(tmpstr); tmpstr = NULL;
146        free(tmpstr2); tmpstr2 = NULL;
147        free(send); send = NULL;
148        free(hash); hash = NULL;
149        free(hashstr); hashstr = NULL;
150        free(hashlen); hashlen = NULL; 
151        free(ip); ip = NULL;
152        free(phpsessid); phpsessid = NULL;
153        free(serverid); serverid = NULL;
154        free(usender); usender = NULL;
155        free(streamlink); streamlink = NULL;
156
157        return streamlink1;
158}
159
160#endif
Note: See TracBrowser for help on using the repository browser.