source: titan/plugins/tithek/myvideo.h @ 23760

Last change on this file since 23760 was 23760, checked in by obi, 11 years ago

[tithek] myvidso add lang error msg

File size: 8.5 KB
Line 
1#ifndef MYVIDEO_H
2#define MYVIDEO_H
3
4// flag 1 = getstreamurl
5
6char* myvideo(char* input, char* url, char* name, int flag)
7{
8        debug(99, "link(%d): %s", flag, input);
9        char* ip = NULL, *pos = NULL, *path = NULL, *pageUrl = NULL, *playpath = NULL, *video_id = NULL, *source = NULL, *streamurl = NULL, *tmpstr_uni = NULL, *b64 = NULL, *key = NULL, *newurl = NULL, *link = NULL, *tmpstr = NULL, *tmppath = NULL, *error = NULL;
10
11        if(flag == 1)
12        {
13                int count = 0;
14                struct splitstr* ret1 = NULL;
15                ret1 = strsplit(input, ";", &count);
16                if(ret1 != NULL && count >= 4)
17                {
18                        link = ostrcat(ret1[0].part, NULL, 0, 0);
19                        pageUrl = ostrcat(pageUrl, ret1[1].part, 1, 0);
20                        playpath = ostrcat(playpath, ret1[2].part, 1, 0);
21                        video_id = ostrcat(video_id, ret1[3].part, 1, 0);                                                                       
22                }
23                free(ret1), ret1 = NULL;
24        }       
25
26        ip = string_replace("http://", "", (char*)link, 0);
27
28        if(ip != NULL)
29                pos = strchr(ip, '/');
30        if(pos != NULL)
31        {
32                pos[0] = '\0';
33                path = pos + 1;
34        }
35
36        tmppath = ostrcat("watch/", video_id , 0, 0);
37        tmppath = ostrcat(tmppath, "/" , 1, 0);
38        tmpstr = gethttp(ip, tmppath, 80, NULL, NULL, 10000, NULL, 0);
39        error = string_resub("<div class='lContent lContNoBorder error sBold sCenter'>", "</div>", tmpstr, 0);
40
41        unlink("/tmp/myvideo_tmpstr");
42        unlink("/tmp/myvideo_tmpstr_uni");
43        unlink("/tmp/myvideo_tmpstr_error");
44
45        if(getconfigint("debuglevel", NULL) == 99)
46                writesys("/tmp/myvideo_tmpstr_error", tmpstr, 0);
47                               
48        if(ostrstr(error, "<div class='error sBold' id='error_screen_body'>") == NULL)
49        {
50                textbox(_("Message"), _(error) , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
51                debug(99, "error msg: %s", error);
52        }       
53       
54        debug(99, "error link: http://%s/%s", ip, tmppath);
55        free(tmpstr), tmpstr = NULL;
56        free(tmppath), tmppath = NULL;
57        free(error), error = NULL;
58       
59// not working tmpstr hat zusatzdaten im string
60        tmpstr = gethttp(ip, path, 80, NULL, NULL, 10000, NULL, 0);
61
62        debug(99, "link: http://%s/%s", ip, path);
63
64        if(getconfigint("debuglevel", NULL) == 99)
65                writesys("/tmp/myvideo_tmpstr", tmpstr, 0);
66
67/*
68// work start
69        unlink("/tmp/myvideo_tmp");
70        char* cmd = NULL;
71        cmd = ostrcat("wget \"", input, 0, 0);
72        cmd = ostrcat(cmd, "\" -O /tmp/myvideo_tmp", 1, 0);
73        system(cmd);
74        free(cmd), cmd = NULL;
75        tmpstr = readfiletomem("/tmp/myvideo_tmp", 0);
76// work end
77*/
78        if(flag == 1)
79        {
80                int count = 0;
81                struct splitstr* ret1 = NULL;
82                ret1 = strsplit(tmpstr, "=", &count);
83                int hlen = 0;
84
85                if(ret1 != NULL && count >= 2)
86                {
87//                      debug(99, "ret1[1].part=%s", (ret1[1]).part);
88                        hlen = strlen(ret1[1].part);
89                        tmpstr_uni = unhexlify(ret1[1].part);
90                }
91                free(ret1), ret1 = NULL;
92
93                b64 = ostrcat("c8407a08b3c71ea418ec9dc662f2a56e40cbd6d5a114aa50fb1e1079e17f2b83", MDString(video_id), 0, 1);
94                debug(99, "b64=%s", b64);
95
96                key = MDString(b64);
97                int slen = 0;
98                int klen = 0;
99                if(tmpstr_uni != NULL) slen = strlen(tmpstr_uni);
100                if(key != NULL) klen = strlen(key);
101               
102                if(tmpstr_uni != NULL)
103                {
104                        debug(99, "hexlen=%d", hlen);
105                        hlen /= 2;
106                        debug(99, "binlen=%d", hlen);
107                        debug(99, "keylen=%d", klen);
108                        debug(99, "b64=%s", b64);
109                        debug(99, "key=%s", key);
110
111                        rc4(tmpstr_uni, hlen, key, klen);
112
113                        debug(99, "encrypted=%s", tmpstr_uni);
114                        debug(99, "pageUrl: %s\n", pageUrl);
115                        debug(99, "playpath: %s\n", playpath);
116                        debug(99, "video_id: %s\n", video_id);
117                        //printf("tmpstr_uni: %s\n",tmpstr_uni);
118
119                        htmldecode(tmpstr_uni, tmpstr_uni);
120
121                        if(getconfigint("debuglevel", NULL) == 99)
122                                writesys("/tmp/myvideo_tmpstr_uni", tmpstr_uni, 0);
123
124                        if(ostrstr(tmpstr_uni, "connectionurl='rtmp"))
125                        {
126                                printf("found rtmpe:// stream\n");
127                                source = string_resub("source='", ".flv'", tmpstr_uni, 0);
128
129                                newurl = string_resub("connectionurl='", "'", tmpstr_uni, 0);
130       
131                                if(ostrstr(newurl, "myvideo2flash"))
132                                {
133                                        printf("change to rtmpt:// stream\n");
134                                        newurl = string_replace("rtmpe://", "rtmpt://", newurl, 1);
135                                }
136       
137                                streamurl = ostrcat(newurl, NULL, 0, 0);
138                                streamurl = ostrcat(streamurl, " ", 1, 0);
139                                streamurl = ostrcat(streamurl, "tcUrl=", 1, 0);
140                                streamurl = ostrcat(streamurl, newurl, 1, 0);
141                                streamurl = ostrcat(streamurl, " swfVfy=http://is4.myvideo.de/de/player/mingR11q/ming.swf ", 1, 0);
142                                streamurl = ostrcat(streamurl, pageUrl, 1, 0);
143                                streamurl = ostrcat(streamurl, " ", 1, 0);
144                                streamurl = ostrcat(streamurl, "playpath=flv:", 1, 0);
145                                streamurl = ostrcat(streamurl, source, 1, 0);           
146                        }
147                        else
148                        {               
149                                printf("rtmpe not found, change to *.flv stream\n");
150                                source = string_resub("source='", "'", tmpstr_uni, 0);
151       
152                                newurl = string_resub("path='", "'", tmpstr_uni, 0);
153       
154                                streamurl = ostrcat(newurl, source, 0, 0);
155                        }
156                }
157        }
158
159        free(key), key = NULL;         
160        free(b64), b64 = NULL;
161        free(tmpstr_uni), tmpstr_uni = NULL;           
162        free(url), url = NULL;
163        free(source), source = NULL;
164        free(tmpstr), tmpstr = NULL;
165        free(pageUrl), pageUrl = NULL;         
166        free(playpath), playpath = NULL;
167        free(ip), ip = NULL;
168        free(video_id), video_id = NULL;
169        free(newurl), newurl = NULL;
170// segfault munmap_chunk(): invalid pointer
171//      free(pos), pos = NULL;
172//      free(path), path = NULL;
173
174//      debug(99, "streamurl2: %s", streamurl);
175        return streamurl;
176}
177
178int myvideo_search(struct skin* grid, struct skin* listbox, struct skin* countlabel, struct skin* load, char* link, char* title, char* searchstr, int flag)
179{
180        int ret = 1;
181
182        if(listbox == NULL || listbox->select == NULL || listbox->select->handle == NULL)
183                return ret;
184
185        char* search = NULL;
186
187        if(flag == 0)
188        {
189                if(searchstr == NULL)
190                        search = textinputhist("Search", " ", "searchhist");
191                else
192                        search = textinputhist("Search", searchstr, "searchhist");
193        }
194
195        if(search != NULL || flag > 0)
196        {
197                drawscreen(load, 0, 0);
198                search = stringreplacechar(search, ' ', '+');
199                char* id = NULL;
200                char* line = NULL;
201                char* pic = NULL;
202                char* title = NULL;
203                char* menu = NULL;
204                char* path = NULL;
205                char* ip = ostrcat("www.myvideo.de", NULL, 0, 0);
206
207                if(flag == 0)
208                        path = ostrcat("Videos_A-Z?searchWord=", search, 0, 0);
209                else
210                        path = ostrcat("Top_100/Top_100_Single_Charts", NULL, 0, 0);
211               
212                char* tmpstr = gethttp(ip, path, 80, NULL, NULL, 10000, NULL, 0);
213                tmpstr = string_replace_all("<", "\n", tmpstr, 1);
214                tmpstr = string_replace_all(">", "\n", tmpstr, 1);
215
216                int count = 0;
217                int incount = 0;
218                int i = 0;
219                struct splitstr* ret1 = NULL;
220                ret1 = strsplit(tmpstr, "\n", &count);
221
222                if(ret1 != NULL)
223                {
224                        int max = count;
225                        for(i = 0; i < max; i++)
226                        {                                                               
227                                if(ostrstr(ret1[i].part, "img id='i") != NULL)
228                                {
229                                        debug(99, "---------------------------");
230                                        debug(99, "ret1[i].part: %s", ret1[i].part);
231                                        int rcret = waitrc(NULL, 10, 0);
232                                        if(rcret == getrcconfigint("rcexit", NULL)) break;
233                                        pic = oregex(".*longdesc='(.*)' class='vThumb.*", ret1[i].part);
234                                        id = oregex(".*img id='i(.*)' onload=.*", ret1[i].part);
235                                        title = oregex(".*alt='(.*)' onmouseover=.*", ret1[i].part);
236                                        debug(99, "title: %s", title);
237                                        debug(99, "pic: %s", pic);
238                                        debug(99, "id: %s", id);
239                                        debug(99, "---------------------------");
240
241                                        if(id != NULL)
242                                        {
243                                                incount += 1;
244                                                line = ostrcat(line, title, 1, 0);
245//                                              line = ostrcat(line, "#http://www.myvideo.de/dynamic/get_player_video_xml.php?flash_playertype=SER&ID=", 1, 0);
246// de fix
247                                                line = ostrcat(line, "#http://www.myvideo.de/dynamic/get_player_video_xml.php?domain=www.myvideo.de&flash_playertype=D&ds=1&autorun=yes&ID=", 1, 0);
248                                                line = ostrcat(line, id, 1, 0);
249//                                              line = ostrcat(line, "&_countlimit=4&autorun=yes;pageUrl=http://www.myvideo.de/watch/", 1, 0);                                                                         
250// de fix
251                                                line = ostrcat(line, "&_countlimit=4;pageUrl=http://www.myvideo.de/watch/", 1, 0);                                                                             
252                                                line = ostrcat(line, id, 1, 0);
253                                                line = ostrcat(line, "/;playpath=flv:movie24/a0/", 1, 0);
254                                                line = ostrcat(line, id, 1, 0);
255                                                line = ostrcat(line, ";", 1, 0);
256                                                line = ostrcat(line, id, 1, 0);                                                                                                                                                         
257                                                line = ostrcat(line, "#", 1, 0);
258                                                line = ostrcat(line, pic, 1, 0);
259                                                line = ostrcat(line, "#myvideo_search_", 1, 0);
260                                                line = ostrcat(line, oitoa(incount + time(NULL)), 1, 0);
261                                                line = ostrcat(line, ".jpg#MyVideo - Search#12\n", 1, 0);
262                                                free(ip), ip = NULL;
263                                                free(path), path = NULL;
264                                                free(title), title = NULL;
265                                        }
266
267                                }
268                        }
269                        free(ret1), ret1 = NULL;
270
271                        if(line != NULL)
272                        {
273                                menu = ostrcat("/tmp/tithek/myvideo.search.list", NULL, 0, 0);
274                                writesys(menu, line, 0);
275                                struct tithek* tnode = (struct tithek*)listbox->select->handle;
276                                createtithek(tnode, tnode->title, menu, tnode->pic, tnode->localname, tnode->menutitle, tnode->flag);
277                                ret = 0;
278                        }
279                }
280                free(tmpstr), tmpstr = NULL;
281        }
282        free(search), search = NULL;
283        return ret;
284}
285
286#endif
Note: See TracBrowser for help on using the repository browser.