source: titan/plugins/tithek/nowvideo.h @ 24237

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

optimize

File size: 2.6 KB
Line 
1#ifndef NOWVIDEO_H
2#define NOWVIDEO_H
3
4char* nowvideo(char* host, char* file)
5{
6        debug(99, "in host: %s file: %s", host, file);
7        int debuglevel = getconfigint("debuglevel", NULL);
8        char* tmphost = NULL;
9        char* tmpfile = NULL;
10        char* tmpstr = NULL;
11        char* send = NULL;
12        char* ip = NULL;
13        char* streamlink = NULL;
14        char* filekey = NULL;
15       
16        if(host == NULL || file == NULL) return NULL;
17
18        tmphost = ostrcat(tmphost, host, 1, 0);
19        tmpfile = ostrcat("/video/", file, 0, 0);
20       
21        debug(99, "tmphost: %s", tmphost);
22        ip = get_ip(tmphost);
23        debug(99, "ip: %s", ip);
24        debug(99, "tmpfile: %s", tmpfile);
25
26        send = ostrcat(send, "GET /video/", 1, 0);
27        send = ostrcat(send, file, 1, 0);
28        send = ostrcat(send, " HTTP/1.1\r\nHost: ", 1, 0);
29        send = ostrcat(send, host, 1, 0);
30        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);
31        debug(99, "send: %s", send);
32
33        tmpstr = gethttpreal(tmphost, tmpfile, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
34
35        titheklog(debuglevel, "/tmp/nowvideo1", NULL, tmpstr);
36
37        if(ostrstr(tmpstr, "The file is being transfered to our other servers. This may take few minutes.") != NULL)
38        {
39                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);
40                goto end;
41        }
42
43        file = string_resub("flashvars.file=\"", "\";", tmpstr, 0);
44        filekey = string_resub("flashvars.filekey=\"", "\";", tmpstr, 0);
45
46        free(tmpfile), tmpfile = NULL;
47        tmpfile = ostrcat("/api/player.api.php?file=", file, 0, 0);
48        tmpfile = ostrcat(tmpfile, "&key=", 1, 0);
49        tmpfile = ostrcat(tmpfile, filekey, 1, 0);
50
51        free(send), send = NULL;
52        send = ostrcat(send, "GET ", 1, 0);
53        send = ostrcat(send, tmpfile, 1, 0);
54        send = ostrcat(send, " HTTP/1.1\r\nHost: ", 1, 0);
55        send = ostrcat(send, host, 1, 0);
56        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);
57        debug(99, "send: %s", send);
58        free(tmpstr), tmpstr = NULL;
59        tmpstr = gethttpreal(tmphost, tmpfile, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
60
61        titheklog(debuglevel, "/tmp/nowvideo2", NULL, tmpstr);
62
63        sleep(1);
64        streamlink = string_resub("url=", "&", tmpstr, 0);
65end:
66        free(tmphost); tmphost = NULL;
67        free(tmpfile); tmpfile = NULL;
68        free(tmpstr); tmpstr = NULL;
69        free(send); send = NULL;
70        free(filekey); filekey = NULL;
71        free(ip); ip = NULL;
72
73        return streamlink;
74}
75
76#endif
Note: See TracBrowser for help on using the repository browser.