source: titan/plugins/tithek/divxstage.h @ 26912

Last change on this file since 26912 was 24460, checked in by nit, 10 years ago

[titan] testfix divexstage

File size: 5.0 KB
Line 
1#ifndef DIVXSTAGE_H
2#define DIVXSTAGE_H
3
4char* divxstage(char* link)
5{
6        debug(99, "link: %s", link);
7        int debuglevel = getconfigint("debuglevel", NULL);
8        char* tmphost = NULL;
9        char* tmppath = NULL;
10        char* tmpstr = NULL;
11        char* send = NULL;
12        char* ip = NULL;
13        char* streamlink = NULL;
14        char* filekey = NULL;
15        char* file = NULL;
16
17        if(link == NULL) return NULL;
18
19        unlink("/tmp/divxstage1_get");
20        unlink("/tmp/divxstage2_get");
21       
22/////////////
23        char* tmplink = NULL, *pos = NULL, *path = NULL;
24
25        tmplink = ostrcat(link, NULL, 0, 0);
26
27        if(ostrstr(link, "/Out/?s=") != NULL)
28        {
29                tmplink = string_replace("/Out/?s=", "", tmplink, 1);
30                debug(99, "remove out string: %s", tmplink);
31        }
32       
33
34        if(tmplink == NULL || ostrncmp("http://", tmplink, 7))
35        {
36                textbox(_("Message"), _("Hoster Url not http://") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
37                goto end;
38        }
39
40        tmphost = string_replace("http://", "", tmplink, 0);
41        free(tmplink) , tmplink = NULL;
42
43        if(tmphost != NULL)
44                pos = strchr(tmphost, '/');
45        if(pos != NULL)
46        {
47                pos[0] = '\0';
48                path = pos + 1;
49        }
50
51        tmppath = ostrcat("/", path, 0, 0);
52//      free(path), path = NULL;
53
54/////////////
55/*
56        tmphost = ostrcat("www.", host, 0, 0);
57        tmphost = ostrcat(tmphost, ".eu", 1, 0);
58
59        tmppath = ostrcat("/video/", file, 0, 0);
60       
61        debug(99, "tmphost: %s", tmphost);
62        ip = get_ip(tmphost);
63        debug(99, "ip: %s", ip);
64        debug(99, "tmppath: %s", tmppath);
65*/
66        send = ostrcat(send, "GET ", 1, 0);
67        send = ostrcat(send, tmppath, 1, 0);
68        send = ostrcat(send, " HTTP/1.1\r\nHost: ", 1, 0);
69        send = ostrcat(send, tmphost, 1, 0);
70        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);
71        debug(99, "send: %s", send);
72
73        tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
74        debug(99, "tmpstr: %s", tmpstr);
75        titheklog(debuglevel, "/tmp/divxstage1_get", NULL, tmpstr);
76
77        if(ostrstr(tmpstr, "The file is being transfered to our other servers. This may take few minutes.") != NULL)
78        {
79                textbox(_("Message"), _("The file is being transfered to our other servers. This may take few minutes.") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
80                goto end;
81        }
82
83        file = string_replace("/video/", "", tmppath, 0);
84        if(file == NULL)
85                file = string_resub("login.php?return=/video/", "\">Log In", tmpstr, 0);
86        if(file == NULL)
87                file = string_resub("<a href=\"/share.php?id=", "&title=", tmpstr, 0);
88        if(file == NULL)
89                file = string_resub("flashvars.file=\"", "\";", tmpstr, 0);
90       
91        char* r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL;
92        pos = ostrstr(tmpstr, ");}('");
93        if(pos != NULL)
94        {
95                r1 = string_resub(");}('", "'", pos, 0);
96                pos = ostrstr(pos + 5, ",'");
97                if(pos != NULL)
98                {
99                        r2 = string_resub(",'", "'", pos, 0);
100                        pos = ostrstr(pos + 2, ",'");
101                        if(pos != NULL)
102                        {
103                                r3 = string_resub(",'", "'", pos, 0);
104                                pos = ostrstr(pos + 2, ",'");
105                                if(pos != NULL)
106                                        r4 = string_resub(",'", "'", pos, 0);
107                        }
108                }
109        }
110       
111        filekey = getfilekey(r1, r2, r3, r4);
112       
113        free(r1); r1 = NULL;
114        free(r2); r2 = NULL;
115        free(r3); r3 = NULL;
116        free(r4); r4 = NULL;
117       
118        if(filekey == NULL)
119                filekey = string_resub("flashvars.filekey=\"", "\";", tmpstr, 0);
120
121        if(filekey == NULL)
122        {
123                char* searchstr = string_resub("flashvars.filekey=", ";", tmpstr, 0);
124                debug(99, "searchstr: %s", searchstr);
125                searchstr = ostrcat(searchstr, "=\"", 1, 0);
126                filekey = string_resub(searchstr, "\";", tmpstr, 0);
127        }
128        debug(99, "filekey: %s", filekey);
129
130
131        free(tmppath), tmppath = NULL;
132        tmppath = ostrcat("/api/player.api.php?file=", file, 0, 0);
133        tmppath = ostrcat(tmppath, "&key=", 1, 0);
134        tmppath = ostrcat(tmppath, filekey, 1, 0);
135
136        free(send), send = NULL;
137        send = ostrcat(send, "GET ", 1, 0);
138        send = ostrcat(send, tmppath, 1, 0);
139        send = ostrcat(send, " HTTP/1.1\r\nHost: ", 1, 0);
140        send = ostrcat(send, tmphost, 1, 0);
141        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);
142        debug(99, "send: %s", send);
143        free(tmpstr), tmpstr = NULL;
144        tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
145        debug(99, "tmpstr: %s", tmpstr);
146        titheklog(debuglevel, "/tmp/divxstage2_get", NULL, tmpstr);
147
148        if(tmpstr == NULL)
149        {
150                textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
151                goto end;
152        }
153
154        streamlink = string_resub("url=", "&", tmpstr, 0);
155        debug(99, "streamlink1: %s", streamlink);
156        htmldecode(streamlink, streamlink);
157        debug(99, "streamlink2: %s", streamlink);
158       
159end:
160        free(tmphost); tmphost = NULL;
161        free(tmppath); tmppath = NULL;
162        free(tmpstr); tmpstr = NULL;
163        free(send); send = NULL;
164        free(filekey); filekey = NULL;
165        free(ip); ip = NULL;
166
167        return streamlink;
168}
169
170#endif
Note: See TracBrowser for help on using the repository browser.