source: titan/plugins/tithek/videoweed.h @ 39567

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

fix warnings

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