source: titan/plugins/tithek/vidbull.h @ 42657

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

fix warnings

File size: 3.1 KB
Line 
1#ifndef VIDBULL_H
2#define VIDBULL_H
3
4char* vidbull(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/vidbull1_get");
13        unlink("/tmp/vidbull2_post");
14        unlink("/tmp/vidbull3_post");
15        unlink("/tmp/vidbull4_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        tmppath = ostrcat("/", path, 0, 0);
47//      tmppath = string_replace_all(".html", "", tmppath, 1);
48
49//      tmphost = ostrcat("www.", tmphost, 0 ,1);
50
51        send = ostrcat(send, "GET ", 1, 0);
52        send = ostrcat(send, tmppath, 1, 0);
53        send = ostrcat(send, " HTTP/1.1\r\n", 1, 0);
54        send = ostrcat(send, "Host: ", 1, 0);
55        send = ostrcat(send, tmphost, 1, 0);
56        send = ostrcat(send, "\r\nUser-Agent: Mozilla/5.0 (Linux; Android 4.4; Nexus 5 Build/BuildID) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36\r\n\r\n", 1, 0);
57        send = ostrcat(send, "Connection: close\r\n", 1, 0);
58        send = ostrcat(send, "Accept-Encoding: gzip\r\n\r\n", 1, 0);
59        debug(99, "send: %s", send);
60
61        tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
62        free(send), send = NULL;
63        debug(99, "tmpstr: %s", tmpstr);
64        titheklog(debuglevel, "/tmp/vidbull1_get", NULL, NULL, NULL, tmpstr);
65
66        if(tmpstr == NULL)
67        {
68                textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
69                goto end;
70        }
71
72        if(ostrstr(tmpstr, "File Not Found") != NULL)
73        {
74                textbox(_("Message"), _("The video no longer exists") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
75                goto end;
76        }
77
78        streamlink = string_resub("<source src=\"", "\"", tmpstr, 0);
79        titheklog(debuglevel, "/tmp/vidbull4_streamlink", NULL, NULL, NULL, streamlink);
80
81        free(tmpstr); tmpstr = NULL;
82
83end:
84
85        free(error); error = NULL;
86        free(tmphost); tmphost = NULL;
87        free(tmppath); tmppath = NULL;
88        free(tmpstr); tmpstr = NULL;
89        free(send); send = NULL;
90        free(hash), hash = NULL;
91        free(hashlen), hashlen = NULL;
92        free(hashmsg), hashmsg = NULL;
93        free(id), id = NULL;
94        free(fname), fname = NULL;
95        free(ip); ip = NULL;
96
97        return streamlink;
98}
99
100#endif
Note: See TracBrowser for help on using the repository browser.