1 | #ifndef ZDF_H |
---|
2 | #define ZDF_H |
---|
3 | |
---|
4 | char* zdf(char* link) |
---|
5 | { |
---|
6 | debug(99, "link %s", link); |
---|
7 | char* ip = NULL, *pos = NULL, *path = NULL, *streamurl = NULL, *tmpstr = NULL, *tmpstr2 = NULL, *pic = NULL, *title = NULL, *tmpstr3 = NULL, *quali = NULL; |
---|
8 | |
---|
9 | ip = string_replace("http://", "", (char*)link, 0); |
---|
10 | |
---|
11 | if(ip != NULL) |
---|
12 | pos = strchr(ip, '/'); |
---|
13 | if(pos != NULL) |
---|
14 | { |
---|
15 | pos[0] = '\0'; |
---|
16 | path = pos + 1; |
---|
17 | } |
---|
18 | |
---|
19 | tmpstr = gethttp(ip, path, 80, NULL, NULL, 10000, NULL, 0); |
---|
20 | if(getconfigint("debuglevel", NULL) == 99) |
---|
21 | writesys("/tmp/zdf1_tmpstr", tmpstr, 0); |
---|
22 | |
---|
23 | if(getconfigint("debuglevel", NULL) == 99) |
---|
24 | writesys("/var/usr/local/share/titan/plugins/tithek/zdf1_tmpstr", tmpstr, 0); |
---|
25 | |
---|
26 | |
---|
27 | if(tmpstr != NULL) |
---|
28 | { |
---|
29 | if(ostrstr(tmpstr, "<div class=\"fsk\">") != NULL) |
---|
30 | { |
---|
31 | tmpstr2 = string_resub("<div class=\"fsk\">", "</div>", tmpstr, 0); |
---|
32 | tmpstr2 = string_replace(".", ".\n", tmpstr2, 1), |
---|
33 | textbox(_("Message"), tmpstr2, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 400, 0, 0); |
---|
34 | free(tmpstr2), tmpstr2 = NULL; |
---|
35 | } |
---|
36 | |
---|
37 | tmpstr2 = string_resub("<formitaeten>", "</formitaeten>", tmpstr, 0); |
---|
38 | stringreplacechar(tmpstr2, '\n', ' '); |
---|
39 | stringreplacechar(tmpstr2, '\t', ' '); |
---|
40 | string_strip_whitechars(tmpstr2); |
---|
41 | tmpstr2 = string_replace_all("<formitaet basetype", "\n\t<formitaet basetype", tmpstr2, 1); |
---|
42 | |
---|
43 | if(getconfigint("debuglevel", NULL) == 99) |
---|
44 | writesys("/var/usr/local/share/titan/plugins/tithek/zdf1_tmpstr2", tmpstr2, 0); |
---|
45 | |
---|
46 | int count = 0, i = 0; |
---|
47 | struct splitstr* ret1 = NULL; |
---|
48 | struct menulist* mlist = NULL, *mbox = NULL; |
---|
49 | ret1 = strsplit(string_decode(tmpstr2,0), "\n", &count); |
---|
50 | for(i = 0; i < count; i++) |
---|
51 | { |
---|
52 | if(ret1[i].part != NULL && strlen(ret1[i].part) > 1) |
---|
53 | { |
---|
54 | debug(99, "\nRound %d started, processing = %s",i,ret1[i].part); |
---|
55 | streamurl = string_resub("<url>", "</url>", ret1[i].part,0); |
---|
56 | |
---|
57 | if(ostrstr(ret1[i].part, "rtmp") != NULL) |
---|
58 | { |
---|
59 | char* ip1 = NULL, *pos1 = NULL, *path1 = NULL; |
---|
60 | ip1 = string_replace("http://", "", streamurl, 0); |
---|
61 | |
---|
62 | if(ip != NULL) |
---|
63 | pos1 = strchr(ip1, '/'); |
---|
64 | if(pos1 != NULL) |
---|
65 | { |
---|
66 | pos1[0] = '\0'; |
---|
67 | path1 = pos1 + 1; |
---|
68 | } |
---|
69 | |
---|
70 | free(streamurl), streamurl = NULL; |
---|
71 | tmpstr3 = gethttp(ip1, path1, 80, NULL, NULL, 10000, NULL, 0); |
---|
72 | streamurl = string_resub("<default-stream-url>", "</default-stream-url>", tmpstr3, 0); |
---|
73 | free(tmpstr3), tmpstr3 = NULL; |
---|
74 | free(ip1), ip1 = NULL; |
---|
75 | } |
---|
76 | |
---|
77 | title = string_resub("<formitaet basetype=\"", "\"",ret1[i].part,0); |
---|
78 | stringreplacechar(title, '_', ' '); |
---|
79 | |
---|
80 | if(ostrstr(ret1[i].part, "mp4") != NULL) |
---|
81 | pic = ostrcat("mp4.png", NULL, 0, 0); |
---|
82 | else if(ostrstr(ret1[i].part, "3gp") != NULL) |
---|
83 | pic = ostrcat("3gp.png", NULL, 0, 0); |
---|
84 | else if(ostrstr(ret1[i].part, "flv") != NULL) |
---|
85 | pic = ostrcat("flv.png", NULL, 0, 0); |
---|
86 | |
---|
87 | quali = string_resub("<quality>", "</quality>",ret1[i].part,0); |
---|
88 | |
---|
89 | if(title == NULL) |
---|
90 | { |
---|
91 | title = ostrcat(_("unknown"), NULL, 0, 0); |
---|
92 | title = ostrcat(title, " (", 1, 0); |
---|
93 | title = ostrcat(title, quali, 1, 0); |
---|
94 | title = ostrcat(title, ")", 1, 0); |
---|
95 | debug(99, "(%d) title: %s streamurl: %s\n", i, title, streamurl); |
---|
96 | debug(99, "(%d) ret1 %s\n",i, (ret1[i]).part); |
---|
97 | } |
---|
98 | else |
---|
99 | { |
---|
100 | title = ostrcat(title, " (", 1, 0); |
---|
101 | title = ostrcat(title, quali, 1, 0); |
---|
102 | title = ostrcat(title, ")", 1, 0); |
---|
103 | |
---|
104 | debug(99, "(%d) title: %s streamurl: %s\n", i, title, streamurl); |
---|
105 | addmenulist(&mlist, title, streamurl, pic, 0, 0); |
---|
106 | } |
---|
107 | free(quali), quali = NULL; |
---|
108 | free(title), title = NULL; |
---|
109 | free(pic), pic = NULL; |
---|
110 | free(streamurl), streamurl = NULL; |
---|
111 | } |
---|
112 | } |
---|
113 | free(ret1), ret1 = NULL; |
---|
114 | |
---|
115 | if(mlist != NULL){ |
---|
116 | mbox = menulistbox(mlist, NULL, NULL, NULL, NULL, 1, 0); |
---|
117 | if(mbox != NULL){ |
---|
118 | free(streamurl), streamurl = NULL; |
---|
119 | |
---|
120 | debug(99, "mbox->name %s", mbox->name); |
---|
121 | debug(99, "mbox->text %s", mbox->text); |
---|
122 | streamurl = ostrcat(mbox->text, NULL, 0, 0); |
---|
123 | |
---|
124 | } |
---|
125 | } |
---|
126 | } |
---|
127 | |
---|
128 | free(tmpstr); tmpstr = NULL; |
---|
129 | free(ip), ip = NULL; |
---|
130 | |
---|
131 | if(getconfigint("debuglevel", NULL) == 99) |
---|
132 | writesys("/tmp/zdf2_streamurl", streamurl, 0); |
---|
133 | |
---|
134 | // segfault munmap_chunk(): invalid pointer |
---|
135 | // free(pos), pos = NULL; |
---|
136 | // free(path), path = NULL; |
---|
137 | |
---|
138 | debug(99, "streamurl: %s", streamurl); |
---|
139 | return streamurl; |
---|
140 | } |
---|
141 | |
---|
142 | #endif |
---|