1 | #ifndef LETWATCH_H |
---|
2 | #define LETWATCH_H |
---|
3 | |
---|
4 | char* letwatch(char* link) |
---|
5 | { |
---|
6 | debug(99, "link: %s", link); |
---|
7 | int debuglevel = getconfigint("debuglevel", NULL); |
---|
8 | char* url = NULL, *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/letwatch1_get"); |
---|
13 | unlink("/tmp/letwatch2_get_jsunpack"); |
---|
14 | unlink("/tmp/letwatch3_streamlink"); |
---|
15 | ///////////// |
---|
16 | char* tmplink = NULL, *pos = NULL, *path = NULL; |
---|
17 | |
---|
18 | tmplink = ostrcat(link, NULL, 0, 0); |
---|
19 | |
---|
20 | if(ostrstr(link, "/Out/?s=") != NULL) |
---|
21 | { |
---|
22 | tmplink = string_replace("/Out/?s=", "", tmplink, 1); |
---|
23 | debug(99, "remove out string: %s", tmplink); |
---|
24 | } |
---|
25 | |
---|
26 | |
---|
27 | if(tmplink == NULL || ostrncmp("http", tmplink, 4)) |
---|
28 | { |
---|
29 | textbox(_("Message"), _("Hoster Url not http:// or https://") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
30 | goto end; |
---|
31 | } |
---|
32 | |
---|
33 | tmphost = string_replace("http://", "", tmplink, 0); |
---|
34 | tmphost = string_replace("https://", "", tmphost, 1); |
---|
35 | free(tmplink) , tmplink = NULL; |
---|
36 | |
---|
37 | if(tmphost != NULL) |
---|
38 | pos = strchr(tmphost, '/'); |
---|
39 | if(pos != NULL) |
---|
40 | { |
---|
41 | pos[0] = '\0'; |
---|
42 | path = pos + 1; |
---|
43 | } |
---|
44 | |
---|
45 | url = ostrcat(tmphost, "/embed-", 0, 0); |
---|
46 | url = ostrcat(url, path, 1, 0); |
---|
47 | url = ostrcat(url, "-640x400.html", 1, 0); |
---|
48 | |
---|
49 | // free(path), path = NULL; |
---|
50 | |
---|
51 | debug(99, "url: %s", link); |
---|
52 | tmpstr = gethttps(url, NULL, NULL, NULL, NULL, NULL, 1); |
---|
53 | titheklog(debuglevel, "/tmp/letwatch1_get", NULL, NULL, NULL, tmpstr); |
---|
54 | |
---|
55 | tmpstr = jsunpack(tmpstr); |
---|
56 | titheklog(debuglevel, "/tmp/letwatch2_get_jsunpack", NULL, NULL, NULL, tmpstr); |
---|
57 | |
---|
58 | if(tmpstr == NULL) |
---|
59 | { |
---|
60 | textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
61 | goto end; |
---|
62 | } |
---|
63 | |
---|
64 | if(ostrstr(tmpstr, "404 Not Found") != NULL) |
---|
65 | { |
---|
66 | textbox(_("Message"), _("The video no longer exists") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
67 | goto end; |
---|
68 | } |
---|
69 | |
---|
70 | if(ostrstr(tmpstr, "Video is processing now.") != NULL) |
---|
71 | { |
---|
72 | textbox(_("Message"), _("Video is processing now. Conversion stage...") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
73 | goto end; |
---|
74 | } |
---|
75 | |
---|
76 | // streamlink = string_resub("[{l:\"", "\"", tmpstr, 0); |
---|
77 | streamlink = oregex(".*(http://.*v.flv).*", tmpstr); |
---|
78 | |
---|
79 | titheklog(debuglevel, "/tmp/letwatch3_streamlink", NULL, NULL, NULL, streamlink); |
---|
80 | |
---|
81 | free(tmpstr); tmpstr = NULL; |
---|
82 | |
---|
83 | end: |
---|
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 |
---|