source: titan/plugins/tithek/nbastream.h @ 39567

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

update tithek

File size: 12.0 KB
Line 
1#ifndef NBASTREAM_H
2#define NBASTREAM_H
3
4char* nbastream(char* link)
5{
6        debug(99, "link %s", link);
7        int debuglevel = getconfigint("debuglevel", NULL);
8        char* streamurl = NULL, *tmpstr = NULL, *tmpstr1 = NULL;
9        char* host = NULL;
10        char* path = NULL;
11        char* url1 = NULL;
12        char* url2 = NULL;
13        char* url3 = NULL;
14        char* url4 = NULL;
15        char* url5 = NULL;
16        char* id = NULL;
17        char* width = NULL;
18        char* height = NULL;
19        char* curlstring = NULL;
20        char* token = NULL;
21
22        system("rm -rf /var/usr/local/share/titan/plugins/tithek/nbastream*");
23/*
24        http://nbastream.net/philadelphia-76ers-at-oklahoma-city-thunder-live-stream.html
25        <iframe  src="streams/nbanhl8.html" width="680" height="400" scrolling="no" frameborder="0" allowfullscreen></iframe><br>
26*/
27        host = string_resub("http://", "/", link, 0);
28        path = string_replace_all(host, "", link, 0);
29        path = string_replace_all("http://", "", path, 1);
30        path = string_replace_all(" ", "%20", path, 1);
31        tmpstr = gethttps(link, NULL, NULL, NULL, NULL, NULL, 1);
32        titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/nbastream1_tmpstr", NULL, host, path, tmpstr);
33
34
35        url1 = string_resub("<iframe  src=\"", "\"", tmpstr, 0);
36        url1 = ostrcat("http://nbastream.net/", url1, 0, 1);
37
38/*
39        http://nbastream.net/streams/nbanhl8.html
40        <script type='text/javascript'>id='504917'; width='670'; height='390';</script><script type='text/javascript' src='http://js.p2pcast.tv/p2pcast/player.js'></script>
41*/
42        free(tmpstr), tmpstr = NULL;
43        tmpstr = gethttps(url1, NULL, NULL, NULL, NULL, NULL, 1);
44        free(host), host = NULL;
45        free(path), path = NULL;
46        host = string_resub("http://", "/", url1, 0);
47        path = string_replace_all(host, "", url1, 0);
48        path = string_replace_all("http://", "", path, 1);
49        path = string_replace_all(" ", "%20", path, 1);
50        titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/nbastream2_tmpstr", NULL, host, path, tmpstr);
51
52        url2 = string_resub("src='", "'", tmpstr, 0);
53        id = string_resub("id='", "'", tmpstr, 0);
54        width = string_resub("id='", "'", tmpstr, 0);
55        height = string_resub("id='", "'", tmpstr, 0);
56
57///////////////
58        char* url7 = ostrcat("http://www.google-analytics.com/analytics.js", NULL, 0, 0);
59        free(tmpstr), tmpstr = NULL;
60        tmpstr = gethttps(url7, NULL, NULL, NULL, NULL, link, 1);
61        free(host), host = NULL;
62        free(path), path = NULL;
63        host = string_resub("http://", "/", url7, 0);
64        path = string_replace_all(host, "", url7, 0);
65        path = string_replace_all("http://", "", path, 1);
66        path = string_replace_all(" ", "%20", path, 1);
67        titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/nbastream2a_tmpstr", NULL, host, path, tmpstr);
68///////////////
69
70/*
71        http://js.p2pcast.tv/p2pcast/player.js
72        document.write('<iframe allowfullscreen width="'+width+'" height="'+height+'" scrolling="no" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" allowtransparency="true" src="http://p2pcast.tv/stream.php?id='+id+'&live='+live+'&p2p='+p2p+'&stretching='+stretching+'"></iframe>');
73*/
74
75        free(tmpstr), tmpstr = NULL;
76        tmpstr = gethttps(url2, NULL, NULL, NULL, NULL, url1, 1);
77        free(host), host = NULL;
78        free(path), path = NULL;
79        host = string_resub("http://", "/", url2, 0);
80        path = string_replace_all(host, "", url2, 0);
81        path = string_replace_all("http://", "", path, 1);
82        path = string_replace_all(" ", "%20", path, 1);
83        titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/nbastream3_tmpstr", NULL, host, path, tmpstr);
84
85
86        char* url8 = ostrcat("http://ax2.adit-media.com/asw/fm.js?c=1033&a=0&f=&n=2019&r=141&d=9&adm=&q=&$=&s=901&ct=&z=0.4985966447275132&tt=0&tz=1&pu=http%3A%2F%2Fnbastream.net%2Fstreams%2Fnbanhl2.html&ru=http%3A%2F%2Fnbastream.net%2Forlando-magic-at-washington-wizards-live-stream.html&pi=1447548879638&ce=UTF-8&zpu=nbastream.net_nbastream.net__0_2&tpu=0", NULL, 0, 0);
87        free(tmpstr), tmpstr = NULL;
88        tmpstr = gethttps(url8, NULL, NULL, NULL, NULL, url1, 1);
89        free(host), host = NULL;
90        free(path), path = NULL;
91        host = string_resub("http://", "/", url7, 0);
92        path = string_replace_all(host, "", url7, 0);
93        path = string_replace_all("http://", "", path, 1);
94        path = string_replace_all(" ", "%20", path, 1);
95        titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/nbastream3a_tmpstr", NULL, host, path, tmpstr);
96
97/*
98        http://p2pcast.tv/stream.php?id=504917&live=0&p2p=0&stretching=uniform
99    curl = "aHR0cDovL2xpdmUucDJwY2FzdC50djo4MDEwL3R2Mi81MDQ5MTcubTN1OD9zZj1OVFl5TW1SbFpXTmpaVEV5TlE9PSZ0b2tlbj0=";
100        <script src="http://js.p2pcast.tv/p2pcast/pplayer.10.js"></script>
101*/
102/*
103
104        url3 = string_resub("src=\"", "\"", tmpstr, 0);
105        url3 = string_replace_all("'+id+'", id, url3, 1);
106        url3 = string_replace_all("'+live+'", "0", url3, 1);
107        url3 = string_replace_all("'+p2p+'", "0", url3, 1);
108        url3 = string_replace_all("'+stretching+'", "uniform", url3, 1);
109*/
110        url3 = ostrcat("http://p2pcast.tv/stream.php?id=", id, 0, 0);
111        url3 = ostrcat(url3, "&live=0&p2p=0&stretching=uniform", 1, 0);
112
113        free(tmpstr), tmpstr = NULL;
114        tmpstr = gethttps(url3, NULL, NULL, NULL, NULL, url1, 1);
115        free(host), host = NULL;
116        free(path), path = NULL;
117        host = string_resub("http://", "/", url3, 0);
118        path = string_replace_all(host, "", url3, 0);
119        path = string_replace_all("http://", "", path, 1);
120        path = string_replace_all(" ", "%20", path, 1);
121        titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/nbastream4_tmpstr", NULL, host, path, tmpstr);
122
123        if(tmpstr == NULL || ostrstr(tmpstr, "<html lang=\"en\" class=\"explore\">") != NULL)
124        {
125                tmpstr1 = string_resub("<h2>", "</h2>", tmpstr, 0);
126                textbox(_("Message"), tmpstr1 , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
127//              goto end;
128        }
129
130/*
131        http://js.p2pcast.tv/p2pcast/pplayer.10.js
132        var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t="";var n,r,i,s,o,u,a;var f=0;e=Base64._utf8_encode(e);while(f<e.length){n=e.charCodeAt(f++);r=e.charCodeAt(f++);i=e.charCodeAt(f++);s=n>>2;o=(n&3)<<4|r>>4;u=(r&15)<<2|i>>6;a=i&63;if(isNaN(r)){u=a=64}else if(isNaN(i)){a=64}t=t+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u)+this._keyStr.charAt(a)}return t},decode:function(e){var t="";var n,r,i;var s,o,u,a;var f=0;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(f<e.length){s=this._keyStr.indexOf(e.charAt(f++));o=this._keyStr.indexOf(e.charAt(f++));u=this._keyStr.indexOf(e.charAt(f++));a=this._keyStr.indexOf(e.charAt(f++));n=s<<2|o>>4;r=(o&15)<<4|u>>2;i=(u&3)<<6|a;t=t+String.fromCharCode(n);if(u!=64){t=t+String.fromCharCode(r)}if(a!=64){t=t+String.fromCharCode(i)}}t=Base64._utf8_decode(t);return t},_utf8_encode:function(e){e=e.replace(/\r\n/g,"\n");var t="";for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r<128){t+=String.fromCharCode(r)}else if(r>127&&r<2048){t+=String.fromCharCode(r>>6|192);t+=String.fromCharCode(r&63|128)}else{t+=String.fromCharCode(r>>12|224);t+=String.fromCharCode(r>>6&63|128);t+=String.fromCharCode(r&63|128)}}return t},_utf8_decode:function(e){var t="";var n=0;var r=c1=c2=0;while(n<e.length){r=e.charCodeAt(n);if(r<128){t+=String.fromCharCode(r);n++}else if(r>191&&r<224){c2=e.charCodeAt(n+1);t+=String.fromCharCode((r&31)<<6|c2&63);n+=2}else{c2=e.charCodeAt(n+1);c3=e.charCodeAt(n+2);t+=String.fromCharCode((r&15)<<12|(c2&63)<<6|c3&63);n+=3}}return t}}
133        var xurl = Base64.decode(curl);
134*/
135        curlstring = string_resub("curl = \"", "\"", tmpstr, 0);
136        if(curlstring == NULL)
137                curlstring = ostrcat("aHR0cDovL2xpdmUucDJwY2FzdC50djo4MDEwL3R2Mi81MDQ5MTcubTN1OD9zZj1OVFl5TW1SbFpXTmpaVEV5TlE9PSZ0b2tlbj0=", NULL, 0 ,0);
138        printf("curlstring input: %s\n", curlstring);
139        b64dec(curlstring, curlstring);
140        printf("curlstring decod: %s\n", curlstring);
141
142//aHR0cDovL2xpdmUucDJwY2FzdC50djo4MDEwL3R2Mi81MDQ5MTcubTN1OD9zZj1OVFl5TW1SbFpXTmpaVEV5TlE9PSZ0b2tlbj0=
143//decode base64 = http://live.p2pcast.tv:8010/tv2/504917.m3u8?sf=NTYyMmRlZWNjZTEyNQ==&token=
144/////////////////////
145/*
146//      http://js.p2pcast.tv/p2pcast/live.htm?channel=504715
147        url4 = ostrcat("http://js.p2pcast.tv/p2pcast/live.htm?channel=", id, 0, 0);
148        free(tmpstr), tmpstr = NULL;
149        tmpstr = gethttps(url4, NULL, NULL, NULL, NULL, url3, 1);
150        free(host), host = NULL;
151        free(path), path = NULL;
152        host = string_resub("http://", "/", url4, 0);
153        path = string_replace_all(host, "", url4, 0);
154        path = string_replace_all("http://", "", path, 1);
155        path = string_replace_all(" ", "%20", path, 1);
156        titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/nbastream5_tmpstr", NULL, host, path, tmpstr);
157*/
158//      url = oregex(".*<script src=\"(http://.*)\"></script>.*", tmpstr);
159        url5 = ostrcat("http://p2pcast.tv/getToken.php", NULL, 0, 0);
160        free(tmpstr), tmpstr = NULL;
161        tmpstr = gethttps(url5, NULL, NULL, NULL, NULL, url3, 1);
162        free(host), host = NULL;
163        free(path), path = NULL;
164        host = string_resub("http://", "/", url5, 0);
165        path = string_replace_all(host, "", url5, 0);
166        path = string_replace_all("http://", "", path, 1);
167        path = string_replace_all(" ", "%20", path, 1);
168        titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/nbastream6_tmpstr", NULL, host, path, tmpstr);
169
170//      {"token":"I-OAZrLqbye4LgcL6nhHkQ"}
171        token = string_resub("{\"token\":\"", "\"", tmpstr, 0);
172        printf("token: %s\n", token);
173
174        streamurl = ostrcat(curlstring, NULL, 0, 0);
175        streamurl = ostrcat(streamurl, token, 1, 0);
176
177        free(tmpstr), tmpstr = NULL;
178        tmpstr = gethttps(streamurl, NULL, NULL, NULL, NULL, "http://cdn.p2pcast.tv/jwplayer.flash.swf", 1);
179        free(host), host = NULL;
180        free(path), path = NULL;
181        host = string_resub("http://", "/", streamurl, 0);
182        path = string_replace_all(host, "", streamurl, 0);
183        path = string_replace_all("http://", "", path, 1);
184        path = string_replace_all(" ", "%20", path, 1);
185        titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/nbastream7_tmpstr", NULL, host, path, tmpstr);
186
187
188        if(streamurl != NULL)
189                streamurl = ostrcat(streamurl, "|User-Agent=libcurl-agent/1.0|Referer=http://cdn.p2pcast.tv/jwplayer.flash.swf", 1, 0);
190
191//end:
192
193        free(tmpstr), tmpstr = NULL;
194        free(tmpstr1), tmpstr1 = NULL;
195        free(host), host = NULL;
196        free(path), path = NULL;
197        free(url1), url1 = NULL;
198        free(url2), url2 = NULL;
199        free(url3), url3 = NULL;
200        free(url4), url4 = NULL;
201        free(url5), url5 = NULL;
202        free(id), id = NULL;
203        free(width), width = NULL;
204        free(height), height = NULL;
205        free(curlstring), curlstring = NULL;
206        free(token), token = NULL;
207
208        debug(99, "streamurl: %s", streamurl); 
209        return streamurl;
210}
211
212int nbastream_search_local(struct skin* grid, struct skin* listbox, struct skin* countlabel, struct skin* load, char* link, char* title, char* searchstr, int flag)
213{
214        char* tmpstr = NULL, *tmpstr1 = NULL, *line = NULL, *menu = NULL, *search = NULL;
215        int ret = 1, count = 0, i = 0;
216
217        if(listbox == NULL || listbox->select == NULL || listbox->select->handle == NULL)
218                return ret;
219
220        if(searchstr == NULL)
221                search = textinputhist(_("Search"), " ", "searchhist");
222        else
223                search = textinputhist(_("Search"), searchstr, "searchhist");
224
225        if(search != NULL)
226        {
227                drawscreen(load, 0, 0);
228
229                strstrip(search);
230                string_tolower(search);
231
232                tmpstr = gethttp("atemio.dyndns.tv", "/mediathek/nbastream/streams/nbastream.all-sorted.list", 80, NULL, HTTPAUTH, 5000, NULL, 0);
233
234                struct splitstr* ret1 = NULL;
235                ret1 = strsplit(tmpstr, "\n", &count);
236
237                if(ret1 != NULL)
238                {
239                        int max = count;
240                        for(i = 0; i < max; i++)
241                        {
242                       
243                                tmpstr1 = ostrcat(ret1[i].part, NULL, 0, 0);
244                                tmpstr1 = stringreplacecharonce(tmpstr1, '#', '\0');
245                                string_tolower(tmpstr1);
246
247                                if(ostrstr(tmpstr1, search) != NULL)
248                                {
249                                        printf("found: %s\n", ret1[i].part);
250                                        int rcret = waitrc(NULL, 10, 0);
251                                        if(rcret == getrcconfigint("rcexit", NULL)) break;
252
253                                        line = ostrcat(line, ret1[i].part, 1, 0);
254                                        line = ostrcat(line, "\n", 0, 0);
255                                }
256                                free(tmpstr1), tmpstr1 = NULL;                         
257                        }
258                        free(ret1), ret1 = NULL;
259
260                        if(line != NULL)
261                        {
262                                line = string_replace_all("http://atemio.dyndns.tv/", "http://imageshack.us/md/up/grd/", line, 1);
263                                menu = ostrcat("/tmp/tithek/nbastream.search.list", NULL, 0, 0);
264                                writesys(menu, line, 0);
265                                struct tithek* tnode = (struct tithek*)listbox->select->handle;
266                                createtithek(tnode, tnode->title, menu, tnode->pic, tnode->localname, tnode->menutitle, tnode->flag);
267                                ret = 0;
268                        }
269                }
270                free(tmpstr), tmpstr = NULL;
271        }
272        free(search), search = NULL;
273        return ret;
274}
275
276#endif
Note: See TracBrowser for help on using the repository browser.