source: titan/plugins/tithek/vodlocker.h @ 41939

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

fix warnings

File size: 3.4 KB
Line 
1#ifndef VODLOCKER_H
2#define VODLOCKER_H
3
4char* vodlocker(char* link)
5{
6        debug(99, "link: %s", link);
7        int debuglevel = getconfigint("debuglevel", NULL);
8        char* tmphost = NULL, *error = NULL, *tmppath = NULL, *tmpstr = NULL, *send = NULL, *id = NULL, *fname = NULL, *hashmsg = NULL, *hash = NULL, *hashlen = NULL, *ip = NULL, *streamlink = NULL;
9       
10        if(link == NULL) return NULL;
11
12        unlink("/tmp/vodlocker1_get");
13        unlink("/tmp/vodlocker2_post");
14        unlink("/tmp/vodlocker3_post");
15        unlink("/tmp/vodlocker4_streamlink");
16/////////////
17        char* tmplink = NULL, *pos = NULL, *path = NULL;
18
19        tmplink = ostrcat(link, NULL, 0, 0);
20
21        if(ostrstr(link, "/Out/?s=") != NULL)
22        {
23                tmplink = string_replace("/Out/?s=", "", tmplink, 1);
24                debug(99, "remove out string: %s", tmplink);
25        }
26
27
28        if(tmplink == NULL || ostrncmp("http", tmplink, 4))
29        {
30                textbox(_("Message"), _("Hoster Url not http:// or https://") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
31                goto end;
32        }
33
34        tmphost = string_replace("http://", "", tmplink, 0);
35        tmphost = string_replace("https://", "", tmphost, 1);
36        free(tmplink) , tmplink = NULL;
37
38        if(tmphost != NULL)
39                pos = strchr(tmphost, '/');
40        if(pos != NULL)
41        {
42                pos[0] = '\0';
43                path = pos + 1;
44        }
45
46        if(ostrstr(link, "embed-") != NULL)
47                tmppath = ostrcat("/", path, 0, 0);
48        else
49        {
50                tmppath = ostrcat("/embed-", path, 0, 0);
51                tmppath = ostrcat(tmppath, "-640x400.html", 1, 0);
52        }
53
54//      free(path), path = NULL;
55
56/////////////
57
58        send = ostrcat(send, "GET ", 1, 0);
59        send = ostrcat(send, tmppath, 1, 0);
60        send = ostrcat(send, " HTTP/1.1\r\n", 1, 0);
61        send = ostrcat(send, "Host: ", 1, 0);
62        send = ostrcat(send, tmphost, 1, 0);
63        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\n", 1, 0);
64        send = ostrcat(send, "Connection: close\r\n", 1, 0);
65        send = ostrcat(send, "Accept-Encoding: gzip\r\n\r\n", 1, 0);
66        debug(99, "send: %s", send);
67
68        tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
69        free(send), send = NULL;
70        debug(99, "tmpstr: %s", tmpstr);
71        titheklog(debuglevel, "/tmp/vodlocker1_get", NULL, NULL, NULL, tmpstr);
72
73        if(tmpstr == NULL)
74        {
75                textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
76                goto end;
77        }
78
79        if(ostrstr(tmpstr, "404 Not Found") != NULL)
80        {
81                textbox(_("Message"), _("The video no longer exists") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
82                goto end;
83        }
84
85        if(ostrstr(tmpstr, "Video encoding error") != NULL)
86        {
87                textbox(_("Message"), _("Video encoding error") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
88                goto end;
89        }
90
91        streamlink = string_resub("file: \"", "\"", tmpstr, 0);         
92
93        titheklog(debuglevel, "/tmp/vodlocker4_streamlink", NULL, NULL, NULL, streamlink);
94
95        free(tmpstr); tmpstr = NULL;
96
97end:
98
99        free(error); error = NULL;
100        free(tmphost); tmphost = NULL;
101        free(tmppath); tmppath = NULL;
102        free(tmpstr); tmpstr = NULL;
103        free(send); send = NULL;
104        free(hash), hash = NULL;
105        free(hashlen), hashlen = NULL;
106        free(hashmsg), hashmsg = NULL;
107        free(id), id = NULL;
108        free(fname), fname = NULL;
109        free(ip); ip = NULL;
110
111        return streamlink;
112}
113
114#endif
Note: See TracBrowser for help on using the repository browser.