source: titan/plugins/tithek/tvtoast.h @ 36092

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

update tvtoast

File size: 17.6 KB
Line 
1#ifndef TVTOAST_H
2#define TVTOAST_H
3
4char* streamlive(char* link, int incount)
5{
6        debug(99, "streamlive(%d) link=%s", incount, link);
7
8        int debuglevel = getconfigint("debuglevel", NULL);
9        char* streamurl = NULL, *tmpstr = NULL, *tmpstr1 = NULL;
10        char* streamer = NULL;
11        char* playpath = NULL;
12        char* swfurl = NULL;
13        char* app = NULL;
14        char* token = NULL;
15        char* tmpurl = NULL;
16        char* host = NULL;
17        char* path = NULL;
18
19        tmpstr = gethttps(link, NULL, NULL, NULL, NULL, NULL, 1);
20        free(host), host = NULL;
21        free(path), path = NULL;
22        host = string_resub("http://", "/", link, 0);
23        path = string_replace_all(host, "", link, 0);
24        path = string_replace_all("http://", "", path, 1);
25        path = string_replace_all(" ", "%20", path, 1);
26        titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast4_tmpstr", oitoa(incount), host, path, tmpstr);
27
28        tmpurl = string_resub("src='", "'", tmpstr, 0);
29        free(tmpstr), tmpstr = NULL;                                           
30       
31        tmpstr = gethttps(tmpurl, NULL, NULL, NULL, NULL, NULL, 1);
32        free(host), host = NULL;
33        free(path), path = NULL;
34        host = string_resub("http://", "/", tmpurl, 0);
35        path = string_replace_all(host, "", tmpurl, 0);
36        path = string_replace_all("http://", "", path, 1);
37        path = string_replace_all(" ", "%20", path, 1);
38        titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast5_tmpstr", oitoa(incount), host, path, tmpstr);
39       
40        streamer = string_resub("streamer: \"", "\"", tmpstr, 0);
41        streamer = string_replace_all("\\", "", streamer, 1);
42        debug(99, "tvtoast5_tmpstr%d streamer=%s", incount, streamer)
43
44        playpath = string_resub("file: \"", "\"", tmpstr, 0);
45        playpath = string_replace_all(".flv", "", playpath, 1);
46        debug(99, "tvtoast5_tmpstr%d playpath=%s", incount, playpath)
47
48        swfurl = string_resub("type: 'flash', src: '", "'", tmpstr, 0);
49        swfurl = string_replace_all("//", "http://", swfurl, 1);
50        debug(99, "tvtoast5_tmpstr%d swfurl=%s", incount, swfurl)
51
52        app = ostrcat(streamer, NULL, 0, 0);
53        tmpstr1 = string_resub("rtmp://", "/", app, 0);
54        app = string_replace(tmpstr1, "", app, 0);
55        free(tmpstr1), tmpstr1 = NULL;
56        app = string_replace_all("rtmp:///", "", app, 1);
57        debug(99, "tvtoast5_tmpstr%d app5=%s", incount, app)
58
59        tmpurl = string_resub("getJSON(\"", "\"", tmpstr, 0);
60        tmpurl = string_replace_all("//", "http://", tmpurl, 1);
61        free(tmpstr), tmpstr = NULL;
62
63        tmpstr = gethttps(tmpurl, NULL, NULL, NULL, NULL, NULL, 1);
64        free(host), host = NULL;
65        free(path), path = NULL;
66        host = string_resub("http://", "/", tmpurl, 0);
67        path = string_replace_all(host, "", tmpurl, 0);
68        path = string_replace_all("http://", "", path, 1);
69        path = string_replace_all(" ", "%20", path, 1);
70        titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast6_tmpstr", oitoa(incount), host, path, tmpstr);
71
72        token = string_resub("{\"token\":\"", "\"", tmpstr, 0);
73
74        streamurl = ostrcat(streamer, " app=", 0, 0);
75        streamurl = ostrcat(streamurl, app, 1, 0);
76        streamurl = ostrcat(streamurl, " playpath=", 1, 0);
77        streamurl = ostrcat(streamurl, playpath, 1, 0);
78        streamurl = ostrcat(streamurl, " swfUrl=", 1, 0);
79        streamurl = ostrcat(streamurl, swfurl, 1, 0);
80        streamurl = ostrcat(streamurl, " live=1", 1, 0);
81        streamurl = ostrcat(streamurl, " timeout=15", 1, 0);
82        streamurl = ostrcat(streamurl, " token=", 1, 0);
83        streamurl = ostrcat(streamurl, token, 1, 0);
84        streamurl = ostrcat(streamurl, " pageUrl=", 1, 0);
85        streamurl = ostrcat(streamurl, tmpurl, 1, 0);
86
87/*
88        rtmp://163.172.8.19:1935/edge/_definst_/?xs=_we_Mzcxamx1aXJsamNzamVufDE0NDY5MDkxODF8OTUuOTEuNi4yNXw1NjNjYzM3ZGIxNTU1fGQzOTYwODlmYjQyOGViYjRhZGQ0YjU3NDgwODY1Zjk2Nzk5ZTE4OWU. app=edge/_definst_/?xs=_we_Mzcxamx1aXJsamNzamVufDE0NDY5MDkxODF8OTUuOTEuNi4yNXw1NjNjYzM3ZGIxNTU1fGQzOTYwODlmYjQyOGViYjRhZGQ0YjU3NDgwODY1Zjk2Nzk5ZTE4OWU. playpath=371jluirljcsjen swfUrl=http://www.streamlive.to/ads/embed/player_ilive_embed.swf live=1 timeout=15 token=Qb582083d22804a892ce37092f7f3d2d pageUrl=http://www.streamlive.to/server.php?id=1446822781
89*/
90
91        free(streamer), streamer = NULL;
92        free(app), app = NULL;
93        free(playpath), playpath = NULL;
94        free(swfurl), swfurl = NULL;
95        free(token), token = NULL;
96        free(host), host = NULL;
97        free(path), path = NULL;
98
99        debug(99, "streamurl %s", streamurl);
100        return streamurl;
101}
102
103char* zerocast(char* link, int incount)
104{
105        debug(99, "zerocast(%d) link=%s ", incount, link);
106        char* streamurl = NULL;
107        char* host = NULL;
108
109        host = string_resub("http://", "/", link, 0);
110        free(host), host = NULL;
111
112        debug(99, "streamurl %s", streamurl);
113        return streamurl;
114}
115
116char* usachannels(char* link, int incount)
117{
118        debug(99, "usachannels(%d) link=%s", incount, link);
119        char* streamurl = NULL;
120        char* host = NULL;
121
122        host = string_resub("http://", "/", link, 0);
123        free(host), host = NULL;
124
125        debug(99, "streamurl %s", streamurl);
126        return streamurl;
127}
128
129char* cricfree(char* link, int incount)
130{
131        debug(99, "cricfree(%d) link=%s", incount, link);
132        int debuglevel = getconfigint("debuglevel", NULL);
133
134        char* url = NULL;
135        char* token = NULL;
136        char* streamurl = NULL;
137        char* tmpstr = NULL;
138        char* fid = NULL;
139        char* width = NULL;
140        char* height = NULL;
141        char* pageurl = NULL;
142        char* swfurl = NULL;
143        char* host = NULL;
144        char* path = NULL;
145
146        tmpstr = gethttps(link, NULL, NULL, NULL, NULL, NULL, 1);
147        host = string_resub("http://", "/", link, 0);
148        path = string_replace_all(host, "", link, 0);
149        path = string_replace_all("http://", "", path, 1);
150        path = string_replace_all(" ", "%20", path, 1);
151        titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast4_tmpstr", oitoa(incount), host, path, tmpstr);
152
153//<script type='text/javascript'>id='espnuk'; width='620'; height='490';</script><script type='text/javascript' src='http://theactionlive.com/livegamecr.js'></script>
154//document.write('<iframe width="'+width+'" height="'+height+'" scrolling="no" frameborder="0" marginheight="0" marginwidth="0" allowtransparency="true" src="http://theactionlive.com/livegamecr2.php?id='+id+'&width='+width+'&height='+height+'&stretching='+stretching+'"></iframe>');
155
156        fid = string_resub("id='", "'", tmpstr, 0);
157        width = string_resub("v_width=", ";", tmpstr, 0);
158        height = string_resub("v_height=", ";", tmpstr, 0);
159        url = string_resub("src='", "'", tmpstr, 0);
160
161        if(width == NULL)
162                width = string_resub("width='", "'", tmpstr, 0);
163        if(height == NULL)
164                height = string_resub("height='", "'", tmpstr, 0);
165
166        if(width == NULL)
167                width = string_resub("var width = '", "'", tmpstr, 0);
168        if(height == NULL)
169                height = string_resub("var height = '", "'", tmpstr, 0);
170
171        debug(99, "fid=%s width=%s height=%s", fid, width, height);
172
173        tmpstr = gethttps(url, NULL, NULL, NULL, NULL, link, 1);
174        free(host), host = NULL;
175        free(path), path = NULL;
176        host = string_resub("http://", "/", url, 0);
177        path = string_replace_all(host, "", url, 0);
178        path = string_replace_all("http://", "", path, 1);
179        path = string_replace_all(" ", "%20", path, 1);
180        titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast5_tmpstr", oitoa(incount), host, path, tmpstr);
181
182        pageurl = string_resub("src=\"", "\"", tmpstr, 0);
183        pageurl = string_replace_all(" ", "", pageurl, 1);
184        pageurl = string_replace_all("+v_", "+", pageurl, 1);
185        pageurl = string_replace("'+fid+'", "'+id+'", pageurl, 1);
186        pageurl = string_replace("'+id+'", fid, pageurl, 1);
187        pageurl = string_replace("'+width+'", width, pageurl, 1);
188        pageurl = string_replace("'+height+'", height, pageurl, 1);
189        pageurl = string_replace("'+stretching+'", "", pageurl, 1);
190
191        tmpstr = gethttps(pageurl, NULL, NULL, NULL, NULL, link, 1);
192        free(host), host = NULL;
193        free(path), path = NULL;
194        host = string_resub("http://", "/", pageurl, 0);
195        path = string_replace_all(host, "", pageurl, 0);
196        path = string_replace_all("http://", "", path, 1);
197        path = string_replace_all(" ", "%20", path, 1);
198        titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast6_tmpstr", oitoa(incount), host, path, tmpstr);
199
200        url = string_resub("file: \"", "\"", tmpstr, 0);
201
202        if(url == NULL)
203        {
204//              biggestplayer.me
205//              url: http://biggestplayer.me/playercr.js, file=tithek_global.h, func=gethttps, line=124
206
207                fid = string_resub("id='", "'", tmpstr, 0);
208                url = string_resub("src='", "'", tmpstr, 0);
209
210                debug(99, "fid=%s url=%s", fid, url);
211
212                url = string_replace_all(" ", "", url, 1);
213                url = string_replace_all("+v_", "+", url, 1);
214                url = string_replace_all("'+", "+", url, 1);
215                url = string_replace_all("+'", "+", url, 1);
216                url = string_replace("+fid+", "+id+", url, 1);
217                url = string_replace("+id+", fid, url, 1);
218                url = string_replace("+width+", width, url, 1);
219                url = string_replace("+height+", height, url, 1);
220                url = string_replace("+stretching+", "", url, 1);
221
222                tmpstr = gethttps(url, NULL, NULL, NULL, NULL, link, 1);
223                free(host), host = NULL;
224                free(path), path = NULL;
225                host = string_resub("http://", "/", url, 0);
226                path = string_replace_all(host, "", url, 0);
227                path = string_replace_all("http://", "", path, 1);
228                path = string_replace_all(" ", "%20", path, 1);
229                titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast7_tmpstr", oitoa(incount), host, path, tmpstr);
230
231//              url: http://biggestplayer.me/streamcrnoscrape.php?id=+id+&width=&height=,
232
233                url = string_resub("src=\"", "\"", tmpstr, 0);         
234                url = string_replace_all(" ", "", url, 1);
235                url = string_replace_all("+v_", "+", url, 1);
236                url = string_replace_all("'+", "+", url, 1);
237                url = string_replace_all("+'", "+", url, 1);
238                url = string_replace("+fid+", "+id+", url, 1);
239                url = string_replace("+id+", fid, url, 1);
240                url = string_replace("+width+", width, url, 1);
241                url = string_replace("+height+", height, url, 1);
242                url = string_replace("+stretching+", "", url, 1);
243
244                tmpstr = gethttps(url, NULL, NULL, NULL, NULL, pageurl, 1);
245                free(host), host = NULL;
246                free(path), path = NULL;
247                host = string_resub("http://", "/", url, 0);
248                path = string_replace_all(host, "", url, 0);
249                path = string_replace_all("http://", "", path, 1);
250                path = string_replace_all(" ", "%20", path, 1);
251                titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast8_tmpstr", oitoa(incount), host, path, tmpstr);
252                streamurl = string_resub("file: \"", "\"", tmpstr, 0);
253/*
254                http://178.18.31.52:8081/liverepeater/224731/playlist.m3u8?wmsAuthSign=c2VydmVyX3RpbWU9MTEvNi8yMDE1IDM6MDc6MDIgUE0maGFzaF92YWx1ZT1TUUJsM3JoVWNLKzIwVytTdVdRVThRPT0mdmFsaWRtaW51dGVzPTQ=
255*/
256        }
257        else
258        {
259
260                token = string_resub("securetoken: \"", "\"", tmpstr, 0);
261                debug(99, "token: %s", token);
262
263                streamurl = ostrcat(streamurl, url, 1, 0);
264                streamurl = ostrcat(streamurl, " swfUrl=http://p.jwpcdn.com/6/11/jwplayer.flash.swf", 1, 0);
265        //      streamurl = ostrcat(streamurl, swfurl, 1, 0);
266                streamurl = ostrcat(streamurl, " live=1", 1, 0);
267                streamurl = ostrcat(streamurl, " token=", 1, 0);
268                streamurl = ostrcat(streamurl, token, 1, 0);
269                streamurl = ostrcat(streamurl, " timeout=15", 1, 0);
270                streamurl = ostrcat(streamurl, " swfVfy=1", 1, 0);
271                streamurl = ostrcat(streamurl, " pageUrl=", 1, 0);
272                streamurl = ostrcat(streamurl, pageurl, 1, 0);
273/*
274                rtmp://31.220.2.148/redirect/espnusa swfUrl=http://p.jwpcdn.com/6/11/jwplayer.flash.swf live=1 token=%Zrey(nKa@#Z timeout=14 swfVfy=1 pageUrl=http://yotv.co/embed.php?live=espnusa&vw=620&vh=490
275                rtmp://31.220.2.148/redirect/espn2 swfUrl=http://p.jwpcdn.com/6/11/jwplayer.flash.swf live=1 token=%Zrey(nKa@#Z timeout=15 swfVfy=1 pageUrl=http://www.yotv.co/embed.php?live=espn2&vw=620&vh=490
276                rtmp://31.220.2.148/redirect/tsnx2 swfUrl=http://p.jwpcdn.com/6/11/jwplayer.flash.swf live=1 token=%Zrey(nKa@#Z timeout=15 swfVfy=1 pageUrl=http://www.yotv.co/embed.php?live=tsnx2&vw=620&vh=490
277*/
278        }
279
280        free(host), host = NULL;
281        free(path), path = NULL;
282        free(url), url = NULL;
283        free(token), token = NULL;
284        free(tmpstr), tmpstr = NULL;
285        free(fid), fid = NULL;
286        free(width), width = NULL;
287        free(height), height = NULL;
288        free(pageurl), pageurl = NULL;
289        free(swfurl), swfurl = NULL;
290       
291        debug(99, "streamurl %s", streamurl);
292        return streamurl;
293}
294
295char* tvtoast(char* link)
296{
297        debug(99, "link %s", link);
298        int debuglevel = getconfigint("debuglevel", NULL);
299        char* streamurl = NULL, *tmpstr = NULL, *tmpstr1 = NULL;
300        char* title = NULL, *pic = NULL;
301        char* typemsg = NULL;
302        char* referer = NULL;
303        char* host = NULL;
304        char* path = NULL;
305        char* url = NULL;
306
307        system("rm -rf /var/usr/local/share/titan/plugins/tithek/tvtoast*");
308
309        host = string_resub("http://", "/", link, 0);
310        path = string_replace_all(host, "", link, 0);
311        path = string_replace_all("http://", "", path, 1);
312        path = string_replace_all(" ", "%20", path, 1);
313        tmpstr = gethttps(link, NULL, NULL, NULL, NULL, NULL, 1);
314        titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast1_tmpstr", "1", host, path, tmpstr);
315
316        tmpstr1 = string_resub("<ul class=\"player-top-links\">", "<div class=\"float-clear\"></div>", tmpstr, 0);
317        titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast2_tmpstr_tmpstr1_resub", "1", host, path, tmpstr1);
318        free(host), host = NULL;
319        free(path), path = NULL;
320                               
321        free(tmpstr), tmpstr = NULL;
322        printf("tmpstr1: %s\n",tmpstr1);
323
324        int count = 0, i = 0, incount = 0;     
325        struct splitstr* ret1 = NULL;
326        struct menulist* mlist = NULL, *mbox = NULL;
327        ret1 = strsplit(tmpstr1, "\n", &count);
328        for(i = 0; i < count; i++)
329        {
330                if(ret1[i].part != NULL && strlen(ret1[i].part) > 1)
331                {
332                        if(ostrstr(ret1[i].part, "http://tvtoast.com/") != NULL)
333                        {
334                                incount++;
335                                printf("####################### start (%d) ############################\n", incount);
336
337                                url = string_resub("<a href=\"", "\"", ret1[i].part, 0);
338                                url = string_replace_all(" ", "%20", url, 1);
339                                tmpstr = gethttps(referer, NULL, NULL, NULL, NULL, NULL, 1);
340                                host = string_resub("http://", "/", url, 0);
341                                path = string_replace_all(host, "", url, 0);
342                                path = string_replace_all("http://", "", path, 1);
343                                path = string_replace_all(" ", "%20", path, 1);
344                                titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast3_tmpstr", oitoa(incount), host, path, tmpstr);
345                                free(url), url = NULL;
346                                url = string_resub("src=\"", "\"", tmpstr, 0);                         
347                                typemsg = string_resub("http://", "/", url, 0);
348
349                                if(ostrstr(url, "www.streamlive.to") != NULL)
350                                        streamurl = streamlive(url, incount);
351
352                                if(ostrstr(url, "zerocast.tv") != NULL)
353                                        streamurl = zerocast(url, incount);
354
355                                if(ostrstr(url, "usachannels.tv") != NULL)
356                                        streamurl = usachannels(url, incount);
357
358                                if(ostrstr(url, "cricfree.sx") != NULL)
359                                        streamurl = cricfree(url, incount);
360
361                                debug(99, "streamurl%d streamurl: %s", incount, streamurl);
362
363////////////////////
364                                if(ostrstr(streamurl, "rtmp") != NULL)
365                                        title = ostrcat("Rtmpe Stream (", NULL, 0, 0);
366                                else
367                                        title = ostrcat("Http Stream (", NULL, 0, 0);
368
369                                title = ostrcat(title, oitoa(incount), 1, 1);
370                                title = ostrcat(title, ")", 1, 0);
371                                if(typemsg != NULL)
372                                {
373                                        title = ostrcat(title, " (", 1, 0);
374                                        title = ostrcat(title, typemsg, 1, 0);
375                                        title = ostrcat(title, ")", 1, 0);
376                                }
377                                pic = ostrcat("flv.png", NULL, 0, 0);
378                               
379                                if(streamurl != NULL)
380                                {
381                                        debug(199, "(%d) title: %s streamurl: %s\n", i, title, streamurl);                                                                                                                                                                                                     
382                                        addmenulist(&mlist, title, streamurl, pic, 0, 0);
383                                }
384
385                                free(title), title = NULL;
386                                free(pic), pic = NULL;
387                                free(streamurl), streamurl = NULL;
388                                free(typemsg), typemsg = NULL;
389                                free(url), url = NULL;
390                                free(host), host = NULL;
391                                free(path), path = NULL;
392                                printf("####################### stop (%d) ############################\n", incount);
393                        }
394                }
395        }
396        free(ret1), ret1 = NULL;
397
398        if(mlist != NULL)
399        {
400                mbox = menulistbox(mlist, NULL, _("Stream Menu"), _("Choose your Streaming Format from the following list"), NULL, NULL, 1, 0);
401                if(mbox != NULL)
402                {
403                        free(streamurl), streamurl = NULL;
404
405                        debug(99, "mbox->name %s", mbox->name);
406                        debug(99, "mbox->text %s", mbox->text);
407                        streamurl = ostrcat(mbox->text, NULL, 0, 0);
408
409                }
410        }
411        free(tmpstr); tmpstr = NULL;
412        free(host), host = NULL;
413        free(path), path = NULL;
414        free(url), url = NULL;
415
416        titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast_tmpstr10_streamurl", NULL, NULL, NULL, tmpstr);
417
418        debug(99, "streamurl: %s", streamurl); 
419        return streamurl;
420}
421
422int tvtoast_search_local(struct skin* grid, struct skin* listbox, struct skin* countlabel, struct skin* load, char* link, char* title, char* searchstr, int flag)
423{
424        char* tmpstr = NULL, *tmpstr1 = NULL, *line = NULL, *menu = NULL, *search = NULL;
425        int ret = 1, count = 0, i = 0;
426
427        if(listbox == NULL || listbox->select == NULL || listbox->select->handle == NULL)
428                return ret;
429
430        if(searchstr == NULL)
431                search = textinputhist(_("Search"), " ", "searchhist");
432        else
433                search = textinputhist(_("Search"), searchstr, "searchhist");
434
435        if(search != NULL)
436        {
437                drawscreen(load, 0, 0);
438
439                strstrip(search);
440                string_tolower(search);
441
442                tmpstr = gethttp("atemio.dyndns.tv", "/mediathek/tvtoast/streams/tvtoast.all-sorted.list", 80, NULL, HTTPAUTH, 5000, NULL, 0);
443
444                struct splitstr* ret1 = NULL;
445                ret1 = strsplit(tmpstr, "\n", &count);
446
447                if(ret1 != NULL)
448                {
449                        int max = count;
450                        for(i = 0; i < max; i++)
451                        {
452                       
453                                tmpstr1 = ostrcat(ret1[i].part, NULL, 0, 0);
454                                tmpstr1 = stringreplacecharonce(tmpstr1, '#', '\0');
455                                string_tolower(tmpstr1);
456
457                                if(ostrstr(tmpstr1, search) != NULL)
458                                {
459                                        printf("found: %s\n", ret1[i].part);
460                                        int rcret = waitrc(NULL, 10, 0);
461                                        if(rcret == getrcconfigint("rcexit", NULL)) break;
462
463                                        line = ostrcat(line, ret1[i].part, 1, 0);
464                                        line = ostrcat(line, "\n", 0, 0);
465                                }
466                                free(tmpstr1), tmpstr1 = NULL;                         
467                        }
468                        free(ret1), ret1 = NULL;
469
470                        if(line != NULL)
471                        {
472                                line = string_replace_all("http://atemio.dyndns.tv/", "http://imageshack.us/md/up/grd/", line, 1);
473                                menu = ostrcat("/tmp/tithek/tvtoast.search.list", NULL, 0, 0);
474                                writesys(menu, line, 0);
475                                struct tithek* tnode = (struct tithek*)listbox->select->handle;
476                                createtithek(tnode, tnode->title, menu, tnode->pic, tnode->localname, tnode->menutitle, tnode->flag);
477                                ret = 0;
478                        }
479                }
480                free(tmpstr), tmpstr = NULL;
481        }
482        free(search), search = NULL;
483        return ret;
484}
485
486#endif
Note: See TracBrowser for help on using the repository browser.