source: titan/plugins/tithek/solarmovie.h @ 28962

Last change on this file since 28962 was 28962, checked in by obi, 10 years ago

[tithek] update tvtoast

File size: 15.9 KB
Line 
1#ifndef SOLARMOVIE_H
2#define SOLARMOVIE_H
3
4char* solarmovie(char* link)
5{
6        debug(99, "link: %s", link);
7        char* tmpstr = NULL, *tmpstr1 = NULL, *pos = NULL, *url = NULL, *streamurl = NULL, *tmphost = NULL, *tmppath = NULL;
8        char* error = NULL;
9
10        if(link == NULL || ostrncmp("http://", link, 7)) return NULL;
11
12        tmphost = string_replace("http://", "", (char*)link, 0);
13
14        if(tmphost != NULL)
15                pos = strchr(tmphost, '/');
16        if(pos != NULL)
17        {
18                pos[0] = '\0';
19                tmppath = pos + 1;
20        }
21       
22        char* send = ostrcat("GET /", NULL, 0, 0);
23        send = ostrcat(send, tmppath, 1, 0);
24        send = ostrcat(send, " HTTP/1.1\r\nHost: ", 1, 0);
25        send = ostrcat(send, tmphost, 1, 0);
26        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);
27        debug(99, "send: %s", send);
28
29        tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 0);
30        debug(99, "tmpstr: %s", tmpstr);
31        free(send); send = NULL;
32
33        if(tmpstr == NULL)
34        {
35                textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
36                goto end;
37        }
38
39        if(ostrstr(tmpstr, "<h2>404</h2>") != NULL)
40        {
41                error = string_resub("<strong>", "</strong>", tmpstr, 0);
42                string_deltags(error);
43                stringreplacechar(error, '|', '\0');
44                error = strstrip(error);
45                if(error == NULL || strlen(error) == 0)
46                        error = ostrcat(_("The page is temporarily unavailable"), error, 0, 1);
47                textbox(_("Message"), error, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 400, 0, 0);
48                goto end;
49        }
50           
51        string_strip_whitechars(tmpstr);
52        if(ostrstr(tmpstr, "<div class=\"thirdPartyEmbContainer\">") != NULL)
53        {
54                tmpstr1 = string_resub("<div class=\"thirdPartyEmbContainer\">", "</div>", tmpstr, 0);
55                stringreplacechar(tmpstr1, '\n', ' ');
56                url = string_resub("<center><iframe src=\"", "\"", tmpstr1, 0);
57                if(url == NULL || ostrncmp("http://", url, 7) == 1)
58                {
59                        free(url); url = NULL;
60                        url = oregex(".*src=\"(http://.*)&width.*", tmpstr1);
61                }
62        }
63        else
64        {
65                //char* tmpurl = oregex(".*<iframe name=\"service_frame\" class=\"service_frame\" src=\"(http://.*)\".*", tmpstr);
66                //url = oregex("(http://.*)\".*", tmpurl);
67                //free(tmpurl); tmpurl == NULL;
68                url = string_resub("<iframe name=\"service_frame\" class=\"service_frame\" src=\"", "\"", tmpstr, 0);
69                url = string_replace_all("embed", "file", url, 1);
70        }
71
72        streamurl = hoster(url);
73
74end:
75
76        free(error), error = NULL;
77        free(url), url = NULL;
78        free(tmpstr), tmpstr = NULL;
79        free(tmpstr1), tmpstr1 = NULL;
80        free(tmphost), tmphost = NULL;
81//      free(tmppath), tmppath = NULL;
82
83        return streamurl;
84}
85
86int solarmovie_search(struct skin* grid, struct skin* listbox, struct skin* countlabel, struct skin* load, char* link, char* title, char* searchstr, int flag)
87{
88        int debuglevel = getconfigint("debuglevel", NULL);
89        int ret = 1;
90        int incount = 0;
91               
92        if(listbox == NULL || listbox->select == NULL || listbox->select->handle == NULL)
93                return ret;
94
95        char* search = NULL;
96        if(searchstr == NULL)
97                search = textinputhist(_("Search"), " ", "searchhist");
98        else
99                search = textinputhist(_("Search"), searchstr, "searchhist");
100       
101        if(search != NULL)
102        {
103                drawscreen(load, 0, 0);
104                char* tmpstr = NULL;
105                char* tmpstr1 = NULL;
106                char* line = NULL;
107                char* pic = NULL;
108                char* title = NULL;
109                char* url = NULL;
110                char* ip = NULL;
111                char* path = NULL;
112                char* menu = NULL;
113                char* file = NULL;
114                char* file1 = NULL;
115                search = strstrip(search);
116                search = stringreplacechar(search, ' ', '+');
117                debug(99, "search: %s", search);
118
119                ip = ostrcat("www.solarmovie.so", NULL, 0, 0);
120                if(flag == 0)
121                        path = ostrcat("movie/search/", search, 0, 0);
122                else
123                        path = ostrcat("tv/search/", search, 0, 0);
124
125                tmpstr = gethttp(ip, path, 80, NULL, NULL, 10000, NULL, 0);
126                titheklog(debuglevel, "/tmp/solarmovie_tmpstr", NULL, NULL, NULL, tmpstr);
127
128                while(ostrstr(tmpstr, "<div class=\"typicalGrey coverGroup\">") != NULL)
129                {
130                        int rcret = waitrc(NULL, 10, 0);
131                        if(rcret == getrcconfigint("rcexit", NULL)) break;
132
133                        incount += 1;
134                        if(debuglevel == 99)
135                        {
136                                file = ostrcat("/tmp/solarmovie_tmpstr", oitoa(incount), 0, 1);
137                                writesys(file, tmpstr, 0);
138                        }
139                               
140                        tmpstr1 = string_resub("<div class=\"typicalGrey coverGroup\">", "</div>", tmpstr, 0);
141
142                        if(debuglevel == 99)
143                        {
144                                file1 = ostrcat("/tmp/solarmovie_tmpstr_resub", oitoa(incount), 0, 1);
145                                writesys(file1, tmpstr1, 0);
146                        }
147
148                        path = string_resub("href=\"", "\"", tmpstr1, 0);
149                        pic = string_resub("<img src=\"", "\"", tmpstr1, 0);
150                        title = string_resub("<a title=\"", "\"", tmpstr1, 0);
151       
152                        url = ostrcat("http://www.solarmovie.so", path, 0, 0);
153       
154                        debug(99, "---------------------------");
155                        debug(99, "pic: %s", pic);
156                        debug(99, "title: %s", title);
157                        debug(99, "url: %s", url);                                     
158                        debug(99, "---------------------------");
159       
160                        if(url != NULL)
161                        {
162                                line = ostrcat(line, title, 1, 0);
163                                line = ostrcat(line, "#", 1, 0);
164                                line = ostrcat(line, url, 1, 0);
165                                line = ostrcat(line, "#", 1, 0);
166                                line = ostrcat(line, pic, 1, 0);
167                                line = ostrcat(line, "#solarmovie_search_", 1, 0);
168                                line = ostrcat(line, oitoa(incount + time(NULL)), 1, 0);
169                                line = ostrcat(line, ".jpg#SolarMovie - Search#28\n", 1, 0);
170                        }
171                        free(url), url = NULL;
172                        free(path), path = NULL;
173                        free(title), title = NULL;
174                        free(pic), pic = NULL;         
175                        free(file), file = NULL;
176                        free(file1), file1 = NULL;
177
178                        tmpstr = string_replace("typicalGrey coverGroup", "", tmpstr, 1);
179                        free(tmpstr1), tmpstr1 = NULL;
180                }
181
182                if(line != NULL)
183                {
184                        line = string_replace_all("http://atemio.dyndns.tv/", "http://imageshack.us/md/up/grd/", line, 1);
185                        menu = ostrcat("/tmp/tithek/solarmovie.search.list", NULL, 0, 0);
186                        writesys(menu, line, 0);
187                        free(line); line = NULL;
188                       
189                        struct tithek* tnode = (struct tithek*)listbox->select->handle;
190                        createtithek(tnode, tnode->title,  menu, tnode->pic, tnode->localname, tnode->menutitle, tnode->flag);
191                        ret = 0;
192                }
193
194                free(tmpstr), tmpstr = NULL;
195                free(ip), ip = NULL;
196        }
197        free(search), search = NULL;
198        return ret;
199}
200
201int solarmovie_search_local(struct skin* grid, struct skin* listbox, struct skin* countlabel, struct skin* load, char* link, char* title, char* searchstr, int flag)
202{
203        char* tmpstr = NULL, *tmpstr1 = NULL, *line = NULL, *menu = NULL, *search = NULL;
204        int ret = 1, count = 0, i = 0;
205
206        if(listbox == NULL || listbox->select == NULL || listbox->select->handle == NULL)
207                return ret;
208
209        if(searchstr == NULL)
210                search = textinputhist(_("Search"), " ", "searchhist");
211        else
212                search = textinputhist(_("Search"), searchstr, "searchhist");
213
214        if(search != NULL)
215        {
216                drawscreen(load, 0, 0);
217
218                strstrip(search);
219                string_tolower(search);
220
221                tmpstr = gethttp("atemio.dyndns.tv", "/mediathek/solarmovie/streams/solarmovie.all-sorted.list", 80, NULL, HTTPAUTH, 5000, NULL, 0);
222
223                struct splitstr* ret1 = NULL;
224                ret1 = strsplit(tmpstr, "\n", &count);
225
226                if(ret1 != NULL)
227                {
228                        int max = count;
229                        for(i = 0; i < max; i++)
230                        {
231                       
232                                tmpstr1 = ostrcat(ret1[i].part, NULL, 0, 0);
233                                tmpstr1 = stringreplacecharonce(tmpstr1, '#', '\0');
234                                string_tolower(tmpstr1);
235
236                                if(ostrstr(tmpstr1, search) != NULL)
237                                {
238                                        printf("found: %s\n", ret1[i].part);
239                                        int rcret = waitrc(NULL, 10, 0);
240                                        if(rcret == getrcconfigint("rcexit", NULL)) break;
241
242                                        line = ostrcat(line, ret1[i].part, 1, 0);
243                                        line = ostrcat(line, "\n", 0, 0);
244                                }
245                                free(tmpstr1), tmpstr1 = NULL;                         
246                        }
247                        free(ret1), ret1 = NULL;
248
249                        if(line != NULL)
250                        {
251                                line = string_replace_all("http://atemio.dyndns.tv/", "http://imageshack.us/md/up/grd/", line, 1);
252                                menu = ostrcat("/tmp/tithek/solarmovie.search.list", NULL, 0, 0);
253                                writesys(menu, line, 0);
254                                struct tithek* tnode = (struct tithek*)listbox->select->handle;
255                                createtithek(tnode, tnode->title, menu, tnode->pic, tnode->localname, tnode->menutitle, tnode->flag);
256                                ret = 0;
257                        }
258                }
259                free(tmpstr), tmpstr = NULL;
260        }
261        free(search), search = NULL;
262        return ret;
263}
264
265int solarmovie_hoster(struct skin* grid, struct skin* listbox, struct skin* countlabel, struct skin* load, char* link, char* title)
266{
267        debug(99, "link: %s", link);
268        int debuglevel = getconfigint("debuglevel", NULL);
269        int ret = 1, series = 0;
270        char* pos = NULL, *etitle = NULL, *episode = NULL, *session = NULL, *update = NULL, *quality = NULL, *id = NULL, *line = NULL, *hname = NULL, *tmpstr = NULL, *url = NULL, *tmpstr1 = NULL, *tmphost = NULL, *tmphname = NULL;
271        char* pichname = NULL, *tmppath = NULL;
272        unlink("/tmp/tithek/get");
273        unlink("/tmp/tithek/get_zcat");
274        unlink("/tmp/tithek/get_zcat1");
275
276        if(listbox == NULL || listbox->select == NULL || listbox->select->handle == NULL)
277                return ret;
278
279        drawscreen(load, 0, 0);
280
281        tmphost = string_replace("http://", "", (char*)link, 0);
282
283        if(tmphost != NULL)
284                pos = strchr(tmphost, '/');
285        if(pos != NULL)
286        {
287                pos[0] = '\0';
288                tmppath = pos + 1;
289        }
290
291        tmpstr = gethttp(tmphost, tmppath, 80, NULL, NULL, 10000, NULL, 0);
292       
293        if(tmpstr == NULL)
294        {
295                textbox(_("Message"), _("This file doesn't exist, or has been removed") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
296                goto end;
297        }
298//      if(debuglevel == 99) system("cp -a /tmp/tithek/get /tmp/solarmovie1_tmpstr_get");
299
300//      tmpstr = command("cat /tmp/tithek/get");
301/*
302        if(ostrstr(tmpstr, "<!DOCTYPE") == NULL)
303        {
304                cmd = ostrcat(cmd, "cat /tmp/tithek/get | zcat", 1, 0);
305                debug(99, "cmd: %s", cmd);
306                free(tmpstr), tmpstr = NULL;
307                tmpstr = command(cmd);
308               
309                writesys("/tmp/tithek/get_zcat", tmpstr, 0);
310                free(cmd), cmd = NULL;
311        }
312//      else
313//              system("cp -a /tmp/tithek/get /tmp/tithek/get_zcat");
314*/
315
316writesys("/tmp/tithek/get_zcat", tmpstr, 0);
317
318
319
320        titheklog(debuglevel, "/tmp/solarmovie2_tmpstr_zcat", NULL, NULL, NULL, tmpstr);
321
322        if(ostrstr(link, "/tv/") != NULL && ostrstr(link, "/season-") == NULL && ostrstr(link, "/episode-") == NULL)   
323                series = 1;
324        else
325                series = 0;
326
327printf("series: %d\n", series);
328
329        if(series == 0)
330        {
331printf("11111111111111111111111111111\n");
332                series = 0;
333                if(tmpstr != NULL)
334                {
335//                      free(tmpstr), tmpstr = NULL;
336//                      tmpstr = command("cat /tmp/tithek/get_zcat");
337                        char* tmpcat = string_resub("<tbody>", "</tbody>", tmpstr, 0);
338       
339                        char* ptmpcat = ostrstr(tmpcat, "<td class=\"qualit");
340                        int i = 0, incount = 0;
341                        while(ptmpcat != NULL)
342                        {
343                                i++;
344                                tmpstr1 = ostrcat(tmpstr1, string_resub("<td class=\"qualit", "<div class=\"linkDetails\">", ptmpcat, 0), 1, 1);
345                                ptmpcat += 5;
346                                ptmpcat = ostrstr(ptmpcat, "<td class=\"qualit");
347       
348                                if(ptmpcat != NULL)
349                                {
350//                                      id = string_resub("<a href=\"/link/show/", "/", tmpstr1, 0);
351//                                      id = oregex(".*/link/show/(.*)/\">.*", tmpstr1);
352//                                      id = oregex(".*/link/show/(.*)/.*\">.*", tmpstr1);
353                                        char* tmpid = oregex(".*<a href=\"/link/(.*)/.*", tmpstr1);
354//                                      debug(99, "tmpid: %s", tmpid);
355                                        id = string_resub("show/", "/", tmpid, 0);
356                                        free(tmpid), tmpid = NULL;
357//                                      debug(99, "id: %s", id);
358//                                      debug(99, "#######################################################");
359
360
361                                        quality = string_resub("yCell\">", "</td>", tmpstr1, 0);
362                                        update = string_resub("oddCell\">", "</td>", tmpstr1, 0);
363                                        string_remove_whitechars(quality);
364                                        strstrip(quality);
365                                       
366//                                      tmphname = oregex(".*/\">(.*)</a>.*", tmpstr1);
367                                        tmphname = oregex(".*<a href=\"/link/show/.*\">(.*)</a>.*", tmpstr1);
368
369                                        string_remove_whitechars(tmphname);
370                                        strstrip(tmphname);
371
372                                        pichname = ostrcat(tmphname, NULL, 0, 0);
373                                        string_tolower(pichname);
374                                        pichname = stringreplacecharonce(pichname, '.', '\0');
375
376                                        int type = 43;
377                                        debug(99, "(%d/\?\?) %s id: %s quality: %s update: %s pic: %s", i, tmphname, id, quality, update, pichname);
378
379                                        incount += 1;
380                                        line = ostrcat(line, tmphname, 1, 0);
381                                        if(quality != NULL)
382                                        {
383                                                line = ostrcat(line, " (", 1, 0);                                       
384                                                line = ostrcat(line, quality, 1, 0);                                   
385                                                line = ostrcat(line, ")", 1, 0);                                       
386                                        }
387                                        if(update != NULL)
388                                        {
389                                                line = ostrcat(line, " (", 1, 0);                                       
390                                                line = ostrcat(line, update, 1, 0);                                     
391                                                line = ostrcat(line, ")", 1, 0);                                       
392                                        }                                       
393                                        line = ostrcat(line, "#", 1, 0);
394                                        line = ostrcat(line, "http://www.solarmovie.so/link/play/", 1, 0);
395                                        line = ostrcat(line, id, 1, 0);
396                                        line = ostrcat(line, "#", 1, 0);
397                                        line = ostrcat(line, "http://atemio.dyndns.tv/mediathek/menu/", 1, 0);
398                                        line = ostrcat(line, pichname, 1, 0);
399                                        line = ostrcat(line, ".jpg#solarmovie_", 1, 0);
400                                        line = ostrcat(line, pichname, 1, 0);
401                                        line = ostrcat(line, ".jpg#Solarmovie - ", 1, 0);
402                                        line = ostrcat(line, title, 1, 0);
403                                        line = ostrcat(line, "#", 1, 0);
404                                        line = ostrcat(line, oitoa(type), 1, 0);
405                                        line = ostrcat(line, "\n", 1, 0);
406                                        free(hname), hname = NULL;
407                                                               
408                                        free(pichname), pichname = NULL;               
409                                        free(tmphname), tmphname = NULL;
410                                        free(id), id = NULL;           
411                                }
412                        }
413                        free(tmpcat); tmpcat = NULL;
414                }       
415        }
416        else
417        {
418printf("22222222222222222222222222222222\n");
419       
420                series = 1;
421                if(tmpstr != NULL)
422                {
423//writesys("/tmp/tithek/get_zcat", tmpstr, 0);
424
425                        free(tmpstr), tmpstr = NULL;
426                        tmpstr = command("cat /tmp/tithek/get_zcat | grep episode- | grep -v Episode | grep -v 'linkCount typicalGrey'");
427                        writesys("/var/usr/local/share/titan/plugins/tithek/solarmovie8_tmpstr", tmpstr, 0);
428
429                        int count = 0;
430                        struct splitstr* ret1 = NULL;
431                        ret1 = strsplit(tmpstr, "\n", &count);
432                        int max = count;
433                        int i = 0, incount = 0;
434                        for(i = 0; i < max; i++)
435                        {
436//<a href="/tv/avatar-the-last-airbender-2005/season-3/episode-2/">The Headband</a>
437                                session = oregex(".*/season-([0-9]{1,2})/episode-.*", ret1[i].part);
438                                episode = oregex(".*/episode-([0-9]{1,2})/.*", ret1[i].part);
439                                etitle = oregex(".*>(.*)<.*", ret1[i].part);
440                                url = string_resub("\"", "\"", ret1[i].part, 0);
441
442                                incount += 1;
443                                line = ostrcat(line, _("Season"), 1, 0);
444                                line = ostrcat(line, " ", 1, 0);
445                                line = ostrcat(line, session, 1, 0);
446                                line = ostrcat(line, " ", 1, 0);
447                                line = ostrcat(line, _("Episode"), 1, 0);
448                                line = ostrcat(line, " ", 1, 0);
449                                line = ostrcat(line, episode, 1, 0);
450
451//                              line = ostrcat(line, "(s", 1, 0);
452//                              line = ostrcat(line, session, 1, 0);
453//                              line = ostrcat(line, "e", 1, 0);
454//                              line = ostrcat(line, episode, 1, 0);
455//                              line = ostrcat(line, ") ", 1, 0);
456//                              line = ostrcat(line, etitle, 1, 0);
457
458                                line = ostrcat(line, "#http://www.solarmovie.so", 1, 0);
459                                line = ostrcat(line, url, 1, 0);
460//                              line = ostrcat(line, ";", 1, 0);
461//                              line = ostrcat(line, session, 1, 0);
462//                              line = ostrcat(line, ";", 1, 0);
463//                              line = ostrcat(line, episode, 1, 0);
464                                line = ostrcat(line, "#", 1, 0);
465                                line = ostrcat(line, "http://atemio.dyndns.tv/mediathek/menu/s", 1, 0);
466                                line = ostrcat(line, session, 1, 0);
467                                line = ostrcat(line, "e", 1, 0);
468                                line = ostrcat(line, episode, 1, 0);
469                                line = ostrcat(line, ".jpg", 1, 0);                                                                                                                             
470                                line = ostrcat(line, "#s", 1, 0);
471                                line = ostrcat(line, session, 1, 0);
472                                line = ostrcat(line, "e", 1, 0);
473                                line = ostrcat(line, episode, 1, 0);
474                                line = ostrcat(line, ".jpg#Solarmovie - ", 1, 0);
475                                line = ostrcat(line, title, 1, 0);
476                                line = ostrcat(line, "#28\n", 1, 0);
477                                free(session), session = NULL;
478                                free(episode), episode = NULL;
479                                free(url), url = NULL; 
480                                free(etitle), etitle = NULL;   
481                        }
482                }
483        }
484        free(tmpstr), tmpstr = NULL;
485
486        if(line != NULL)
487        {
488                line = string_replace_all("http://atemio.dyndns.tv/", "http://imageshack.us/md/up/grd/", line, 1);
489                if(series == 0)
490                        tmpstr = ostrcat("/tmp/tithek/solarmovie.hoster.list", NULL, 0, 0);
491                else
492                        tmpstr = ostrcat("/tmp/tithek/solarmovie.hoster.ser.list", NULL, 0, 0);
493                writesys(tmpstr, line, 0);
494
495                titheklog(debuglevel, "/tmp/solarmovie8_line", NULL, NULL, NULL, line);
496                free(line); line = NULL;
497                                       
498                struct tithek* tnode = (struct tithek*)listbox->select->handle;
499                createtithek(tnode, tnode->title,  tmpstr, tnode->pic, tnode->localname, tnode->menutitle, tnode->flag);
500                ret = 0;
501        }
502end:
503        free(tmphost), tmphost = NULL;
504//      free(tmppath), tmppath = NULL;
505               
506        return ret;
507}
508#endif
Note: See TracBrowser for help on using the repository browser.