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

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

[tithek] update tvtoast

File size: 4.9 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, 7))
34        {
35                textbox(_("Message"), _("Hoster Url not http://") , _("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        free(tmplink) , tmplink = NULL;
41
42        if(tmphost != NULL)
43                pos = strchr(tmphost, '/');
44        if(pos != NULL)
45        {
46                pos[0] = '\0';
47                path = pos + 1;
48        }
49
50        tmppath = ostrcat("/", path, 0, 0);
51//      free(path), path = NULL;
52
53/////////////
54
55
56/*
57        tmphost = ostrcat("www.", host, 0, 0);
58        tmphost = ostrcat(tmphost, ".com", 1, 0);
59
60        tmppath = ostrcat("/video/", file, 0, 0);
61       
62        debug(99, "tmphost: %s", tmphost);
63        ip = get_ip(tmphost);
64        debug(99, "ip: %s", ip);
65        debug(99, "tmppath: %s", tmppath);
66*/
67        send = ostrcat(send, "GET ", 1, 0);
68        send = ostrcat(send, tmppath, 1, 0);
69        send = ostrcat(send, " HTTP/1.1\r\nHost: ", 1, 0);
70        send = ostrcat(send, tmphost, 1, 0);
71        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);
72        debug(99, "send: %s", send);
73
74        tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
75        debug(99, "tmpstr: %s", tmpstr);
76        titheklog(debuglevel, "/tmp/videoweed1_get", NULL, NULL, NULL, tmpstr);
77
78        if(ostrstr(tmpstr, "The file is being transfered to our other servers. This may take few minutes.") != NULL)
79        {
80                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);
81                goto end;
82        }
83       
84        file = string_replace("/video/", "", tmppath, 0);
85        if(file == NULL)
86                file = string_resub("login.php?return=/video/", "\"", tmpstr, 0);
87        if(file == NULL)
88                file = string_resub("<a href=\"/share.php?id=", "&title=", tmpstr, 0);
89        if(file == NULL)
90                file = string_resub("flashvars.file=\"", "\";", tmpstr, 0);
91       
92        char* r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL;
93        pos = ostrstr(tmpstr, ");}('");
94        if(pos != NULL)
95        {
96                r1 = string_resub(");}('", "'", pos, 0);
97                pos = ostrstr(pos + 5, ",'");
98                if(pos != NULL)
99                {
100                        r2 = string_resub(",'", "'", pos, 0);
101                        pos = ostrstr(pos + 2, ",'");
102                        if(pos != NULL)
103                        {
104                                r3 = string_resub(",'", "'", pos, 0);
105                                pos = ostrstr(pos + 2, ",'");
106                                if(pos != NULL)
107                                        r4 = string_resub(",'", "'", pos, 0);
108                        }
109                }
110        }
111       
112        filekey = getfilekey(r1, r2, r3, r4);
113       
114        free(r1); r1 = NULL;
115        free(r2); r2 = NULL;
116        free(r3); r3 = NULL;
117        free(r4); r4 = NULL;
118       
119        if(filekey == NULL)
120                filekey = string_resub("flashvars.filekey=\"", "\";", tmpstr, 0);
121
122        if(filekey == NULL)
123        {
124                char* searchstr = string_resub("flashvars.filekey=", ";", tmpstr, 0);
125                debug(99, "searchstr: %s", searchstr);
126                searchstr = ostrcat(searchstr, "=\"", 1, 0);
127                filekey = string_resub(searchstr, "\";", tmpstr, 0);
128        }
129       
130        debug(99, "filekey: %s", filekey);
131
132        file = string_replace("/embed.php?v=", "", file, 1);
133        tmphost = string_replace("embed.", "", tmphost, 1);
134
135        free(tmppath), tmppath = NULL;
136        tmppath = ostrcat("/api/player.api.php?user=undefined&codes=1&file=", file, 0, 0);
137        tmppath = ostrcat(tmppath, "&pass=undefined&key=", 1, 0);
138        tmppath = ostrcat(tmppath, filekey, 1, 0);
139
140        free(send), send = NULL;
141        send = ostrcat(send, "GET ", 1, 0);
142        send = ostrcat(send, tmppath, 1, 0);
143        send = ostrcat(send, " HTTP/1.1\r\nHost: ", 1, 0);
144        send = ostrcat(send, tmphost, 1, 0);
145        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);
146        debug(99, "send: %s", send);
147        free(tmpstr), tmpstr = NULL;
148        tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
149        debug(99, "tmpstr: %s", tmpstr);
150        titheklog(debuglevel, "/tmp/videoweed2_get", NULL, NULL, NULL, tmpstr);
151
152        streamlink = string_resub("url=", "&", tmpstr, 0);
153        debug(99, "streamlink1: %s", streamlink);
154        htmldecode(streamlink, streamlink);
155        debug(99, "streamlink2: %s", streamlink);
156       
157end:
158        free(tmphost); tmphost = NULL;
159        free(tmppath); tmppath = NULL;
160        free(tmpstr); tmpstr = NULL;
161        free(send); send = NULL;
162        free(filekey); filekey = NULL;
163        free(ip); ip = NULL;
164
165        return streamlink;
166}
167
168#endif
Note: See TracBrowser for help on using the repository browser.