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

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

[tithek] fix putlocker / sockshare

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