source: titan/plugins/tithek/xvideos.h @ 25160

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

add xvideos to search local list

File size: 2.8 KB
Line 
1#ifndef XVIDEOS_H
2#define XVIDEOS_H
3
4char* xvideos(char* link)
5{
6        debug(99, "link %s", link);
7        int debuglevel = getconfigint("debuglevel", NULL);
8        char* ip = NULL, *pos = NULL, *path = NULL, *streamurl = NULL, *tmpstr = NULL;
9       
10        ip = string_replace("http://", "", (char*)link, 0);
11
12        if(ip != NULL)
13                pos = strchr(ip, '/');
14        if(pos != NULL)
15        {
16                pos[0] = '\0';
17                path = pos + 1;
18        }
19
20        tmpstr = gethttp(ip, path, 80, NULL, NULL, 10000, NULL, 0);
21       
22        writesys("/var/usr/local/share/titan/plugins/tithek/xvideos1_tmpstr", tmpstr, 0);
23       
24        htmldecode(tmpstr, tmpstr);
25        writesys("/var/usr/local/share/titan/plugins/tithek/xvideos2_tmpstr", tmpstr, 0);
26
27        titheklog(debuglevel, "/tmp/xvideos1_tmpstr", NULL, tmpstr);
28
29        if(tmpstr != NULL)
30        {
31                streamurl = string_resub("flv_url=","&",tmpstr,0);
32        }
33
34        free(tmpstr); tmpstr = NULL;
35        free(ip), ip = NULL;
36
37        titheklog(debuglevel, "/tmp/xvideos2_streamurl", NULL, streamurl);
38
39// segfault munmap_chunk(): invalid pointer
40//      free(pos), pos = NULL;
41//      free(path), path = NULL;
42
43        debug(99, "streamurl: %s", streamurl); 
44        return streamurl;
45}
46
47int xvideos_search_local(struct skin* grid, struct skin* listbox, struct skin* countlabel, struct skin* load, char* link, char* title, char* searchstr, int flag)
48{
49        char* tmpstr = NULL, *tmpstr1 = NULL, *line = NULL, *menu = NULL, *search = NULL;
50        int ret = 1, count = 0, i = 0;
51
52        if(listbox == NULL || listbox->select == NULL || listbox->select->handle == NULL)
53                return ret;
54
55        if(searchstr == NULL)
56                search = textinputhist("Search", " ", "searchhist");
57        else
58                search = textinputhist("Search", searchstr, "searchhist");
59
60        if(search != NULL)
61        {
62                drawscreen(load, 0, 0);
63
64                strstrip(search);
65                string_tolower(search);
66
67                tmpstr = gethttp("atemio.dyndns.tv", "/mediathek/xvideos/streams/xvideos.all-sorted.list", 80, NULL, HTTPAUTH, 5000, NULL, 0);
68
69                struct splitstr* ret1 = NULL;
70                ret1 = strsplit(tmpstr, "\n", &count);
71
72                if(ret1 != NULL)
73                {
74                        int max = count;
75                        for(i = 0; i < max; i++)
76                        {
77                       
78                                tmpstr1 = ostrcat(ret1[i].part, NULL, 0, 0);
79                                tmpstr1 = stringreplacecharonce(tmpstr1, '#', '\0');
80                                string_tolower(tmpstr1);
81
82                                if(ostrstr(tmpstr1, search) != NULL)
83                                {
84                                        printf("found: %s\n", ret1[i].part);
85                                        int rcret = waitrc(NULL, 10, 0);
86                                        if(rcret == getrcconfigint("rcexit", NULL)) break;
87
88                                        line = ostrcat(line, ret1[i].part, 1, 0);
89                                        line = ostrcat(line, "\n", 0, 0);
90                                }
91                                free(tmpstr1), tmpstr1 = NULL;                         
92                        }
93                        free(ret1), ret1 = NULL;
94
95                        if(line != NULL)
96                        {
97                                menu = ostrcat("/tmp/tithek/xvideos.search.list", NULL, 0, 0);
98                                writesys(menu, line, 0);
99                                struct tithek* tnode = (struct tithek*)listbox->select->handle;
100                                createtithek(tnode, tnode->title, menu, tnode->pic, tnode->localname, tnode->menutitle, tnode->flag);
101                                ret = 0;
102                        }
103                }
104                free(tmpstr), tmpstr = NULL;
105        }
106        free(search), search = NULL;
107        return ret;
108}
109
110#endif
Note: See TracBrowser for help on using the repository browser.