[13931] | 1 | #ifndef TITHEK_H |
---|
| 2 | #define TITHEK_H |
---|
[14112] | 3 | |
---|
[14107] | 4 | #define TITHEKPATH "/tmp/tithek" |
---|
[13931] | 5 | |
---|
[14285] | 6 | //flag 0: not used |
---|
| 7 | //flag 1: not used |
---|
| 8 | //flag 2: streamlink allgemein |
---|
| 9 | //flag 4: streamlink youtube |
---|
| 10 | //flag 1000: menu with pin |
---|
[13931] | 11 | struct tithek |
---|
| 12 | { |
---|
| 13 | char* title; |
---|
| 14 | char* link; |
---|
| 15 | char* pic; |
---|
[14141] | 16 | char* localname; |
---|
| 17 | char* menutitle; |
---|
[13931] | 18 | int flag; |
---|
| 19 | struct tithek* prev; |
---|
| 20 | struct tithek* next; |
---|
| 21 | }; |
---|
| 22 | struct tithek *tithek = NULL; |
---|
| 23 | |
---|
| 24 | struct tithek* addtithek(char *line, int count, struct tithek* last) |
---|
| 25 | { |
---|
| 26 | //debug(1000, "in"); |
---|
| 27 | struct tithek *newnode = NULL, *prev = NULL, *node = tithek; |
---|
[14141] | 28 | char *link = NULL, *pic = NULL, *title = NULL, *localname = NULL, *menutitle = NULL; |
---|
[13931] | 29 | int ret = 0; |
---|
| 30 | |
---|
| 31 | if(line == NULL) return NULL; |
---|
| 32 | |
---|
| 33 | newnode = (struct tithek*)malloc(sizeof(struct tithek)); |
---|
| 34 | if(newnode == NULL) |
---|
| 35 | { |
---|
| 36 | err("no memory"); |
---|
| 37 | return NULL; |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | link = malloc(MINMALLOC); |
---|
| 41 | if(link == NULL) |
---|
| 42 | { |
---|
| 43 | err("no memory"); |
---|
| 44 | free(newnode); |
---|
| 45 | return NULL; |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | pic = malloc(MINMALLOC); |
---|
| 49 | if(pic == NULL) |
---|
| 50 | { |
---|
| 51 | err("no memory"); |
---|
| 52 | free(newnode); |
---|
| 53 | free(link); |
---|
| 54 | return NULL; |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | title = malloc(MINMALLOC); |
---|
| 58 | if(title == NULL) |
---|
| 59 | { |
---|
| 60 | err("no memory"); |
---|
| 61 | free(newnode); |
---|
| 62 | free(link); |
---|
| 63 | free(pic); |
---|
| 64 | return NULL; |
---|
| 65 | } |
---|
| 66 | |
---|
[14113] | 67 | localname = malloc(MINMALLOC); |
---|
| 68 | if(localname == NULL) |
---|
| 69 | { |
---|
| 70 | err("no memory"); |
---|
| 71 | free(newnode); |
---|
| 72 | free(link); |
---|
| 73 | free(pic); |
---|
| 74 | free(title); |
---|
| 75 | return NULL; |
---|
| 76 | } |
---|
| 77 | |
---|
[14141] | 78 | menutitle = malloc(MINMALLOC); |
---|
| 79 | if(menutitle == NULL) |
---|
| 80 | { |
---|
| 81 | err("no memory"); |
---|
| 82 | free(newnode); |
---|
| 83 | free(link); |
---|
| 84 | free(pic); |
---|
| 85 | free(title); |
---|
| 86 | free(localname); |
---|
| 87 | return NULL; |
---|
| 88 | } |
---|
| 89 | |
---|
[13931] | 90 | memset(newnode, 0, sizeof(struct tithek)); |
---|
| 91 | |
---|
[14141] | 92 | ret = sscanf(line, "%[^#]#%[^#]#%[^#]#%[^#]#%[^#]#%d", title, link, pic, localname, menutitle, &newnode->flag); |
---|
| 93 | if(ret != 6) |
---|
[13931] | 94 | { |
---|
| 95 | if(count > 0) |
---|
| 96 | { |
---|
| 97 | err("tithek line %d not ok or double", count); |
---|
| 98 | } |
---|
| 99 | else |
---|
| 100 | { |
---|
| 101 | err("add tithek"); |
---|
| 102 | } |
---|
| 103 | free(link); |
---|
| 104 | free(pic); |
---|
| 105 | free(title); |
---|
[14113] | 106 | free(localname); |
---|
[14141] | 107 | free(menutitle); |
---|
[13931] | 108 | free(newnode); |
---|
| 109 | return NULL; |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | newnode->link = ostrcat(link, "", 1, 0); |
---|
| 113 | newnode->pic = ostrcat(pic, "", 1, 0); |
---|
| 114 | newnode->title = ostrcat(title, "", 1, 0); |
---|
[14113] | 115 | newnode->localname = ostrcat(localname, "", 1, 0); |
---|
[14141] | 116 | newnode->menutitle = ostrcat(menutitle, "", 1, 0); |
---|
[13931] | 117 | |
---|
| 118 | if(last == NULL) |
---|
| 119 | { |
---|
| 120 | while(node != NULL) |
---|
| 121 | { |
---|
| 122 | prev = node; |
---|
| 123 | node = node->next; |
---|
| 124 | } |
---|
| 125 | } |
---|
| 126 | else |
---|
| 127 | { |
---|
| 128 | prev = last; |
---|
| 129 | node = last->next; |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | if(prev == NULL) |
---|
| 133 | tithek = newnode; |
---|
| 134 | else |
---|
| 135 | { |
---|
| 136 | prev->next = newnode; |
---|
| 137 | newnode->prev = prev; |
---|
| 138 | } |
---|
| 139 | newnode->next = node; |
---|
| 140 | if(node != NULL) node->prev = newnode; |
---|
| 141 | |
---|
| 142 | //debug(1000, "out"); |
---|
| 143 | return newnode; |
---|
| 144 | } |
---|
| 145 | |
---|
| 146 | int readtithek(const char* filename) |
---|
| 147 | { |
---|
| 148 | debug(1000, "in"); |
---|
| 149 | FILE *fd = NULL; |
---|
| 150 | char *fileline = NULL; |
---|
| 151 | int linecount = 0; |
---|
| 152 | struct tithek* last = NULL, *tmplast = NULL; |
---|
| 153 | |
---|
| 154 | fileline = malloc(MINMALLOC); |
---|
| 155 | if(fileline == NULL) |
---|
| 156 | { |
---|
| 157 | err("no memory"); |
---|
| 158 | return 1; |
---|
| 159 | } |
---|
| 160 | |
---|
| 161 | fd = fopen(filename, "r"); |
---|
| 162 | if(fd == NULL) |
---|
| 163 | { |
---|
| 164 | perr("can't open %s", filename); |
---|
| 165 | free(fileline); |
---|
| 166 | return 1; |
---|
| 167 | } |
---|
| 168 | |
---|
| 169 | while(fgets(fileline, MINMALLOC, fd) != NULL) |
---|
| 170 | { |
---|
| 171 | if(fileline[0] == '#' || fileline[0] == '\n') |
---|
| 172 | continue; |
---|
| 173 | if(fileline[strlen(fileline) - 1] == '\n') |
---|
| 174 | fileline[strlen(fileline) - 1] = '\0'; |
---|
| 175 | if(fileline[strlen(fileline) - 1] == '\r') |
---|
| 176 | fileline[strlen(fileline) - 1] = '\0'; |
---|
| 177 | |
---|
| 178 | linecount++; |
---|
| 179 | |
---|
| 180 | if(last == NULL) last = tmplast; |
---|
| 181 | last = addtithek(fileline, linecount, last); |
---|
| 182 | if(last != NULL) tmplast = last; |
---|
| 183 | } |
---|
| 184 | |
---|
| 185 | free(fileline); |
---|
| 186 | fclose(fd); |
---|
| 187 | return 0; |
---|
| 188 | } |
---|
| 189 | |
---|
| 190 | int deltithek(char* link) |
---|
| 191 | { |
---|
| 192 | debug(1000, "in"); |
---|
| 193 | int ret = 1; |
---|
| 194 | struct tithek *node = tithek, *prev = tithek; |
---|
| 195 | |
---|
| 196 | while(node != NULL) |
---|
| 197 | { |
---|
| 198 | if(ostrcmp(link, node->link) == 0) |
---|
| 199 | { |
---|
| 200 | ret = 0; |
---|
| 201 | if(node == tithek) |
---|
| 202 | { |
---|
| 203 | tithek = node->next; |
---|
| 204 | if(tithek != NULL) |
---|
| 205 | tithek->prev = NULL; |
---|
| 206 | } |
---|
| 207 | else |
---|
| 208 | { |
---|
| 209 | prev->next = node->next; |
---|
| 210 | if(node->next != NULL) |
---|
| 211 | node->next->prev = prev; |
---|
| 212 | } |
---|
| 213 | |
---|
| 214 | free(node->link); |
---|
| 215 | node->link = NULL; |
---|
| 216 | |
---|
| 217 | free(node->pic); |
---|
| 218 | node->pic = NULL; |
---|
| 219 | |
---|
| 220 | free(node->title); |
---|
| 221 | node->title = NULL; |
---|
| 222 | |
---|
[14113] | 223 | free(node->localname); |
---|
| 224 | node->localname = NULL; |
---|
| 225 | |
---|
[14141] | 226 | free(node->menutitle); |
---|
| 227 | node->menutitle = NULL; |
---|
| 228 | |
---|
[13931] | 229 | free(node); |
---|
| 230 | node = NULL; |
---|
| 231 | |
---|
| 232 | break; |
---|
| 233 | } |
---|
| 234 | |
---|
| 235 | prev = node; |
---|
| 236 | node = node->next; |
---|
| 237 | } |
---|
| 238 | |
---|
| 239 | debug(1000, "out"); |
---|
| 240 | return ret; |
---|
| 241 | } |
---|
| 242 | |
---|
| 243 | void freetithek() |
---|
| 244 | { |
---|
| 245 | debug(1000, "in"); |
---|
| 246 | struct tithek *node = tithek, *prev = tithek; |
---|
| 247 | |
---|
| 248 | while(node != NULL) |
---|
| 249 | { |
---|
| 250 | prev = node; |
---|
| 251 | node = node->next; |
---|
| 252 | if(prev != NULL) |
---|
| 253 | deltithek(prev->link); |
---|
| 254 | } |
---|
| 255 | debug(1000, "out"); |
---|
| 256 | } |
---|
| 257 | |
---|
[16371] | 258 | char* tithekdownload(char* link, char* localname, char* pw, int pic, int flag) |
---|
[13931] | 259 | { |
---|
[14073] | 260 | int ret = 1; |
---|
[13931] | 261 | char* ip = NULL, *pos = NULL, *path = NULL; |
---|
[16435] | 262 | char* tmpstr = NULL, *localfile = NULL; |
---|
[16455] | 263 | //unsigned char* buf = NULL; |
---|
[16371] | 264 | int channels = 0; |
---|
| 265 | unsigned long width = 0, height = 0, rowbytes = 0; |
---|
[13931] | 266 | |
---|
| 267 | if(link == NULL) return NULL; |
---|
| 268 | |
---|
| 269 | ip = string_replace("http://", "", (char*)link, 0); |
---|
| 270 | |
---|
| 271 | if(ip != NULL) |
---|
| 272 | pos = strchr(ip, '/'); |
---|
| 273 | if(pos != NULL) |
---|
| 274 | { |
---|
| 275 | pos[0] = '\0'; |
---|
| 276 | path = pos + 1; |
---|
| 277 | } |
---|
| 278 | |
---|
| 279 | tmpstr = ostrcat(path, NULL, 0, 0); |
---|
| 280 | |
---|
[14073] | 281 | if(flag == 0) |
---|
[14112] | 282 | { |
---|
[14113] | 283 | localfile = ostrcat(TITHEKPATH, "/", 0, 0); |
---|
[14119] | 284 | if(localname == NULL) |
---|
| 285 | localfile = ostrcat(localfile, basename(tmpstr), 1, 0); |
---|
| 286 | else |
---|
| 287 | localfile = ostrcat(localfile, localname, 1, 0); |
---|
[14112] | 288 | } |
---|
[14073] | 289 | else |
---|
| 290 | { |
---|
| 291 | localfile = ostrcat(getconfig("rec_path", NULL), "/", 0, 0); |
---|
[14119] | 292 | if(localname == NULL) |
---|
| 293 | localfile = ostrcat(localfile, basename(tmpstr), 1, 0); |
---|
| 294 | else |
---|
| 295 | localfile = ostrcat(localfile, localname, 1, 0); |
---|
[14073] | 296 | } |
---|
[13931] | 297 | |
---|
[14073] | 298 | if(flag == 0) |
---|
| 299 | { |
---|
[14101] | 300 | if(!file_exist(localfile)) |
---|
[16371] | 301 | { |
---|
| 302 | if(pic == 1) |
---|
| 303 | { |
---|
| 304 | gethttp(ip, path, 80, localfile, pw, NULL, 0); |
---|
[16455] | 305 | //buf = loadjpg(localfile, &width, &height, &rowbytes, &channels, 16); |
---|
| 306 | //savejpg(localfile, width, height, buf); |
---|
| 307 | //free(buf); buf = NULL; |
---|
[16371] | 308 | } |
---|
| 309 | else |
---|
| 310 | gethttp(ip, path, 80, localfile, pw, NULL, 0); |
---|
| 311 | } |
---|
[14073] | 312 | } |
---|
| 313 | else |
---|
| 314 | { |
---|
[14101] | 315 | if(file_exist(localfile)) |
---|
[14073] | 316 | ret = textbox(_("Message"), _("File exist, overwrite?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0); |
---|
| 317 | |
---|
| 318 | if(ret == 1) |
---|
[14291] | 319 | screendownload("Download", ip, path, 80, localfile, pw, 0); |
---|
[14073] | 320 | } |
---|
| 321 | |
---|
[13931] | 322 | free(ip); ip = NULL; |
---|
| 323 | free(tmpstr); tmpstr = NULL; |
---|
| 324 | |
---|
| 325 | return localfile; |
---|
| 326 | } |
---|
| 327 | |
---|
[14119] | 328 | int createtithekplay(char* titheklink, struct skin* grid, struct skin* listbox, struct skin* countlabel) |
---|
[13931] | 329 | { |
---|
[14001] | 330 | int gridbr = 0, posx = 0, count = 0, sumcount = 0; |
---|
[13931] | 331 | struct skin* tmp = NULL; |
---|
| 332 | char* tithekfile = NULL; |
---|
[13941] | 333 | char* tmpstr = NULL; |
---|
[13931] | 334 | |
---|
[16371] | 335 | tithekfile = tithekdownload(titheklink, NULL, HTTPAUTH, 0, 0); |
---|
[13931] | 336 | |
---|
[14001] | 337 | delmarkedscreennodes(grid, 1); |
---|
[13931] | 338 | freetithek(); |
---|
[14001] | 339 | if(readtithek(tithekfile) != 0) return 1; |
---|
| 340 | |
---|
[13931] | 341 | struct tithek* titheknode = tithek; |
---|
| 342 | |
---|
| 343 | while(titheknode != NULL) |
---|
| 344 | { |
---|
| 345 | tmp = addlistbox(grid, listbox, tmp, 1); |
---|
| 346 | if(tmp != NULL) |
---|
| 347 | { |
---|
[13941] | 348 | sumcount++; |
---|
[13931] | 349 | count++; |
---|
| 350 | if(gridbr == 0) |
---|
| 351 | tmp->type = GRIDBR; |
---|
| 352 | gridbr = 1; |
---|
| 353 | tmp->wrap = YES; |
---|
[14140] | 354 | |
---|
| 355 | tmp->picheight = 230; |
---|
| 356 | tmp->picwidth = 370; |
---|
| 357 | |
---|
[13936] | 358 | tmp->height = 280; |
---|
| 359 | tmp->width = 390; |
---|
[13931] | 360 | tmp->prozwidth = 0; |
---|
[13936] | 361 | //tmp->bgcol = 0xffffff; |
---|
| 362 | tmp->bgspace = 1; |
---|
[14140] | 363 | tmp->vspace = 10; |
---|
| 364 | tmp->hspace = 10; |
---|
[13931] | 365 | tmp->posx = posx; |
---|
[13936] | 366 | //tmp->fontcol = 0x0000ff; |
---|
[13931] | 367 | tmp->halign = CENTER; |
---|
| 368 | tmp->valign = TEXTBOTTOM; |
---|
| 369 | changetext(tmp, titheknode->title); |
---|
| 370 | tmp->handle = (char*)titheknode; |
---|
| 371 | posx += tmp->width; |
---|
[13934] | 372 | if(count >= 3) |
---|
[13931] | 373 | { |
---|
| 374 | count = 0; |
---|
| 375 | posx = 0; |
---|
| 376 | gridbr = 0; |
---|
| 377 | } |
---|
| 378 | } |
---|
| 379 | titheknode = titheknode->next; |
---|
| 380 | } |
---|
[14001] | 381 | |
---|
[13941] | 382 | tmpstr = oitoa(sumcount); |
---|
| 383 | changetext(countlabel, tmpstr); |
---|
| 384 | free(tmpstr); tmpstr = NULL; |
---|
[13931] | 385 | |
---|
[14001] | 386 | free(tithekfile); tithekfile = NULL; |
---|
| 387 | return 0; |
---|
| 388 | } |
---|
| 389 | |
---|
[14141] | 390 | void screentithekplay(char* titheklink, char* title, int first) |
---|
[14001] | 391 | { |
---|
| 392 | int rcret = -1, oaktline = 1, oaktpage = -1, ogridcol = 0; |
---|
[14073] | 393 | |
---|
[14001] | 394 | if(first == 1) |
---|
| 395 | { |
---|
[14030] | 396 | rcret = servicestop(status.aktservice, 1, 1); |
---|
[14001] | 397 | if(rcret == 1) return; |
---|
| 398 | } |
---|
| 399 | |
---|
| 400 | struct skin* grid = getscreen("titheklist"); |
---|
| 401 | struct skin* listbox = getscreennode(grid, "listbox"); |
---|
| 402 | struct skin* countlabel = getscreennode(grid, "countlabel"); |
---|
| 403 | struct skin* tmp = NULL; |
---|
| 404 | char* tithekpic = NULL; |
---|
| 405 | |
---|
[14119] | 406 | if(titheklink == NULL) return; |
---|
[14141] | 407 | |
---|
[14001] | 408 | listbox->aktpage = -1; |
---|
| 409 | listbox->aktline = 1; |
---|
| 410 | listbox->gridcol = 0; |
---|
[14155] | 411 | listbox->select = NULL; |
---|
[14001] | 412 | |
---|
[14119] | 413 | if(createtithekplay(titheklink, grid, listbox, countlabel) != 0) return; |
---|
[14141] | 414 | |
---|
[16512] | 415 | drawscreen(grid, 0, 0); |
---|
[13931] | 416 | addscreenrc(grid, listbox); |
---|
[14141] | 417 | |
---|
[13931] | 418 | while(1) |
---|
| 419 | { |
---|
[14141] | 420 | changetitle(grid, _(title)); |
---|
[13931] | 421 | if(listbox->select != NULL && listbox->select->handle != NULL) |
---|
| 422 | { |
---|
| 423 | tmp = listbox->select; |
---|
| 424 | while(tmp != NULL) |
---|
| 425 | { |
---|
| 426 | if(tmp->pagecount != listbox->aktpage) break; |
---|
| 427 | if(tmp->handle != NULL) |
---|
| 428 | { |
---|
[16371] | 429 | tithekpic = tithekdownload(((struct tithek*)tmp->handle)->pic, ((struct tithek*)tmp->handle)->localname, "aXBrLUdaRmg6RkhaVkJHaG56ZnZFaEZERlRHenVpZjU2NzZ6aGpHVFVHQk5Iam0=", 1, 0); |
---|
[15653] | 430 | changepicmem(tmp, tithekpic, 60, 0); |
---|
[13931] | 431 | free(tithekpic); tithekpic = NULL; |
---|
| 432 | } |
---|
| 433 | tmp = tmp->prev; |
---|
| 434 | } |
---|
| 435 | tmp = listbox->select; |
---|
| 436 | while(tmp != NULL) |
---|
| 437 | { |
---|
| 438 | if(tmp->pagecount != listbox->aktpage) break; |
---|
| 439 | if(tmp->handle != NULL) |
---|
| 440 | { |
---|
[16371] | 441 | tithekpic = tithekdownload(((struct tithek*)tmp->handle)->pic, ((struct tithek*)tmp->handle)->localname, "aXBrLUdaRmg6RkhaVkJHaG56ZnZFaEZERlRHenVpZjU2NzZ6aGpHVFVHQk5Iam0=", 1, 0); |
---|
[15653] | 442 | changepicmem(tmp, tithekpic, 60, 0); |
---|
[13931] | 443 | free(tithekpic); tithekpic = NULL; |
---|
| 444 | } |
---|
| 445 | tmp = tmp->next; |
---|
| 446 | } |
---|
| 447 | |
---|
[16512] | 448 | drawscreen(grid, 0, 0); |
---|
[13931] | 449 | } |
---|
[13941] | 450 | |
---|
[14107] | 451 | int count = getfilecount(TITHEKPATH); |
---|
| 452 | if(count > 500) |
---|
| 453 | delallfiles(TITHEKPATH, ".jpg"); |
---|
| 454 | |
---|
[13931] | 455 | rcret = waitrc(grid, 0, 0); |
---|
| 456 | |
---|
[14131] | 457 | if(rcret == getrcconfigint("rcexit", NULL)) break; |
---|
| 458 | |
---|
[14073] | 459 | if(rcret == getrcconfigint("rcred", NULL)) |
---|
| 460 | { |
---|
| 461 | if(listbox->select != NULL && listbox->select->handle != NULL) |
---|
| 462 | { |
---|
| 463 | if(((struct tithek*)listbox->select->handle)->flag == 2) |
---|
| 464 | { |
---|
[14243] | 465 | if(status.security == 1) |
---|
| 466 | { |
---|
[16371] | 467 | char* tmpstr = tithekdownload((((struct tithek*)listbox->select->handle)->link), NULL, NULL, 0, 1); |
---|
[14243] | 468 | free(tmpstr); tmpstr = NULL; |
---|
[16512] | 469 | drawscreen(grid, 0, 0); |
---|
[14243] | 470 | } |
---|
| 471 | else |
---|
| 472 | textbox(_("Message"), _("Registration needed, please contact Atemio !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 200, 0, 0); |
---|
[14073] | 473 | } |
---|
[14243] | 474 | else if(((struct tithek*)listbox->select->handle)->flag == 4) |
---|
| 475 | { |
---|
| 476 | if(status.security == 1) |
---|
| 477 | { |
---|
[14287] | 478 | char* tmpstr = NULL, *tmpstr1 = NULL, *tmpstr2 = NULL; |
---|
| 479 | tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0); |
---|
[14565] | 480 | if(tmpstr != NULL) tmpstr1 = getstreamurl(tmpstr, NULL, NULL, 1); |
---|
[14297] | 481 | tmpstr2 = changefilenameext(((struct tithek*)tmp->handle)->localname, ".mp4"); |
---|
[14243] | 482 | free(tmpstr); tmpstr = NULL; |
---|
| 483 | |
---|
| 484 | if(tmpstr1 != NULL) |
---|
| 485 | { |
---|
[16371] | 486 | char* tmpstr = tithekdownload(tmpstr1, tmpstr2, NULL, 0, 1); |
---|
[14243] | 487 | free(tmpstr); tmpstr = NULL; |
---|
[16512] | 488 | drawscreen(grid, 0, 0); |
---|
[14243] | 489 | } |
---|
| 490 | else |
---|
| 491 | textbox(_("Message"), _("Can't get Streamurl !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0); |
---|
| 492 | free(tmpstr1); tmpstr1 = NULL; |
---|
[14287] | 493 | free(tmpstr2); tmpstr2 = NULL; |
---|
[14243] | 494 | } |
---|
| 495 | else |
---|
| 496 | textbox(_("Message"), _("Registration needed, please contact Atemio !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 200, 0, 0); |
---|
| 497 | } |
---|
[14073] | 498 | } |
---|
| 499 | } |
---|
| 500 | |
---|
[13936] | 501 | if(rcret == getrcconfigint("rcok", NULL)) |
---|
| 502 | { |
---|
| 503 | if(listbox->select != NULL && listbox->select->handle != NULL) |
---|
| 504 | { |
---|
[14001] | 505 | clearscreen(grid); |
---|
[14165] | 506 | if(((struct tithek*)listbox->select->handle)->flag == 2) |
---|
[13943] | 507 | { |
---|
[14165] | 508 | if(status.security == 1) |
---|
| 509 | { |
---|
| 510 | if(textbox(_("Message"), _("Start playback"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0) == 1) |
---|
| 511 | screenplay((((struct tithek*)listbox->select->handle)->link), 2, 0); |
---|
| 512 | } |
---|
| 513 | else |
---|
| 514 | textbox(_("Message"), _("Registration needed, please contact Atemio !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 200, 0, 0); |
---|
[13943] | 515 | } |
---|
[14204] | 516 | else if(((struct tithek*)listbox->select->handle)->flag == 4) |
---|
[14097] | 517 | { |
---|
[14243] | 518 | if(status.security == 1) |
---|
[14135] | 519 | { |
---|
[14243] | 520 | char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0); |
---|
| 521 | char* tmpstr1 = NULL; |
---|
[14565] | 522 | if(tmpstr != NULL) tmpstr1 = getstreamurl(tmpstr, NULL, NULL, 1); |
---|
[14243] | 523 | free(tmpstr); tmpstr = NULL; |
---|
| 524 | |
---|
| 525 | if(tmpstr1 != NULL) |
---|
[14165] | 526 | { |
---|
| 527 | if(textbox(_("Message"), _("Start playback"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0) == 1) |
---|
[14243] | 528 | screenplay(tmpstr1, 2, 0); |
---|
[14165] | 529 | } |
---|
| 530 | else |
---|
[14243] | 531 | textbox(_("Message"), _("Can't get Streamurl !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0); |
---|
| 532 | free(tmpstr1); tmpstr1 = NULL; |
---|
[14135] | 533 | } |
---|
[14131] | 534 | else |
---|
[14243] | 535 | textbox(_("Message"), _("Registration needed, please contact Atemio !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 200, 0, 0); |
---|
[14258] | 536 | } |
---|
[14565] | 537 | else if((((struct tithek*)listbox->select->handle)->flag == 5) || (((struct tithek*)listbox->select->handle)->flag == 6) || (((struct tithek*)listbox->select->handle)->flag == 7) || (((struct tithek*)listbox->select->handle)->flag == 8)) |
---|
[14486] | 538 | { |
---|
| 539 | if(status.security == 1) |
---|
| 540 | { |
---|
| 541 | char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0); |
---|
| 542 | char* tmpstr1 = NULL; |
---|
[14572] | 543 | |
---|
[14565] | 544 | if(((struct tithek*)listbox->select->handle)->flag == 5) |
---|
[14572] | 545 | { |
---|
[14565] | 546 | if(tmpstr != NULL) tmpstr1 = getstreamurl(tmpstr, "http://rtl2now.rtl2.de", "rtl2now", 2); |
---|
[14572] | 547 | } |
---|
[14565] | 548 | else if(((struct tithek*)listbox->select->handle)->flag == 6) |
---|
[14572] | 549 | { |
---|
[14565] | 550 | if(tmpstr != NULL) tmpstr1 = getstreamurl(tmpstr, "http://www.superrtlnow.de", "superrtlnow", 2); |
---|
[14572] | 551 | } |
---|
[14565] | 552 | else if(((struct tithek*)listbox->select->handle)->flag == 7) |
---|
[14572] | 553 | { |
---|
[14565] | 554 | if(tmpstr != NULL) tmpstr1 = getstreamurl(tmpstr, "http://rtl-now.rtl.de", "rtlnow", 2); |
---|
[14572] | 555 | } |
---|
[14565] | 556 | else if(((struct tithek*)listbox->select->handle)->flag == 8) |
---|
[14572] | 557 | { |
---|
[14565] | 558 | if(tmpstr != NULL) tmpstr1 = getstreamurl(tmpstr, "http://www.voxnow.de", "voxnow", 2); |
---|
[14572] | 559 | } |
---|
[14565] | 560 | |
---|
[14486] | 561 | free(tmpstr); tmpstr = NULL; |
---|
| 562 | |
---|
| 563 | if(tmpstr1 != NULL) |
---|
| 564 | { |
---|
| 565 | if(textbox(_("Message"), _("Start playback"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0) == 1) |
---|
| 566 | screenplay(tmpstr1, 2, 0); |
---|
| 567 | } |
---|
| 568 | else |
---|
| 569 | textbox(_("Message"), _("Can't get Streamurl !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0); |
---|
| 570 | free(tmpstr1); tmpstr1 = NULL; |
---|
| 571 | } |
---|
| 572 | else |
---|
| 573 | textbox(_("Message"), _("Registration needed, please contact Atemio !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 200, 0, 0); |
---|
| 574 | } |
---|
[14001] | 575 | else |
---|
| 576 | { |
---|
[14148] | 577 | int pincheck = 0; |
---|
| 578 | if(((struct tithek*)listbox->select->handle)->flag == 1000) |
---|
| 579 | pincheck = screenpincheck(0, NULL); |
---|
| 580 | if(pincheck == 0) |
---|
| 581 | { |
---|
| 582 | oaktpage = listbox->aktpage; |
---|
| 583 | oaktline = listbox->aktline; |
---|
| 584 | ogridcol = listbox->gridcol; |
---|
| 585 | char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0); |
---|
| 586 | char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0); |
---|
| 587 | char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0); |
---|
| 588 | screentithekplay(tmpstr, tmpstr2, 0); |
---|
| 589 | free(tmpstr); tmpstr = NULL; |
---|
| 590 | free(tmpstr2); tmpstr2 = NULL; |
---|
| 591 | if(createtithekplay(titheklink, grid, listbox, countlabel) != 0) break; |
---|
| 592 | listbox->aktpage = oaktpage; |
---|
| 593 | listbox->aktline = oaktline; |
---|
| 594 | listbox->gridcol = ogridcol; |
---|
| 595 | addscreenrc(grid, listbox); |
---|
| 596 | } |
---|
[14001] | 597 | } |
---|
[16512] | 598 | drawscreen(grid, 0, 0); |
---|
[14141] | 599 | } |
---|
[14001] | 600 | } |
---|
[13931] | 601 | } |
---|
| 602 | |
---|
| 603 | freetithek(); |
---|
| 604 | delmarkedscreennodes(grid, 1); |
---|
| 605 | delownerrc(grid); |
---|
| 606 | clearscreen(grid); |
---|
[13934] | 607 | |
---|
[14001] | 608 | if(first == 1) |
---|
[14522] | 609 | { |
---|
| 610 | delallfiles("/tmp/tithek", ".list"); |
---|
[14610] | 611 | servicecheckret(servicestart(status.lastservice->channel, NULL, NULL, 0), 0); |
---|
[14522] | 612 | } |
---|
[13931] | 613 | } |
---|
| 614 | |
---|
[14513] | 615 | // flag 1 = youtube streamlink |
---|
| 616 | // flag 2 = rtlnow streamlinksrc |
---|
| 617 | // flag 3 = rtlnow streamlink |
---|
[14565] | 618 | char* getstreamurl(char* link, char* url, char* name, int flag) |
---|
[14097] | 619 | { |
---|
[14486] | 620 | debug(99, "link(%d): %s", flag, link); |
---|
[14097] | 621 | char* ip = NULL, *pos = NULL, *path = NULL; |
---|
[15299] | 622 | |
---|
[14097] | 623 | ip = string_replace("http://", "", (char*)link, 0); |
---|
| 624 | |
---|
| 625 | if(ip != NULL) |
---|
| 626 | pos = strchr(ip, '/'); |
---|
| 627 | if(pos != NULL) |
---|
| 628 | { |
---|
| 629 | pos[0] = '\0'; |
---|
| 630 | path = pos + 1; |
---|
| 631 | } |
---|
[14486] | 632 | |
---|
[14097] | 633 | char* tmpstr = NULL; |
---|
| 634 | tmpstr = gethttp(ip, path, 80, NULL, NULL, NULL, 0); |
---|
[14486] | 635 | char* streamurl = NULL; |
---|
| 636 | |
---|
| 637 | if(flag == 1) |
---|
[14097] | 638 | { |
---|
[16492] | 639 | tmpstr = string_resub("\": \"url=", "\", \"", tmpstr, 0); |
---|
[14486] | 640 | |
---|
[15299] | 641 | while(string_find(",url=", tmpstr)) |
---|
[14486] | 642 | tmpstr = string_replace(",url=", "\nurl=", tmpstr, 1); |
---|
| 643 | |
---|
[15299] | 644 | tmpstr = string_decode(tmpstr, 0); |
---|
[14486] | 645 | |
---|
| 646 | int count = 0; |
---|
| 647 | int i = 0; |
---|
| 648 | struct splitstr* ret1 = NULL; |
---|
| 649 | ret1 = strsplit(tmpstr, "\n", &count); |
---|
[15299] | 650 | if(ret1 != NULL) |
---|
| 651 | { |
---|
| 652 | int max = count; |
---|
| 653 | for(i = 0; i < max; i++) |
---|
[14486] | 654 | { |
---|
[15299] | 655 | if(string_find("type=video/mp4",(&ret1[i])->part)) |
---|
| 656 | { |
---|
| 657 | streamurl = ostrcat(streamurl, (&ret1[i])->part, 1, 0); |
---|
| 658 | int count2 = 0; |
---|
| 659 | struct splitstr* ret2 = NULL; |
---|
| 660 | ret2 = strsplit((&ret1[i])->part, "+", &count2); |
---|
| 661 | if(ret2 != NULL) |
---|
| 662 | { |
---|
| 663 | free(streamurl); |
---|
| 664 | streamurl = ostrcat("", (&ret2[0])->part, 0, 0); |
---|
| 665 | free(ret2); ret2 = NULL; |
---|
| 666 | } |
---|
| 667 | } |
---|
[14486] | 668 | } |
---|
[15299] | 669 | free(ret1); ret1 = NULL; |
---|
| 670 | |
---|
| 671 | streamurl = string_replace("url=", "", streamurl, 1); |
---|
[14486] | 672 | } |
---|
[15299] | 673 | free(tmpstr); tmpstr = NULL; |
---|
[14097] | 674 | } |
---|
[14486] | 675 | else if(flag == 2) |
---|
| 676 | { |
---|
[16492] | 677 | tmpstr = string_resub("data:'", "',", tmpstr, 0); |
---|
[14486] | 678 | debug(99, "tmpstr: %s", tmpstr); |
---|
[14097] | 679 | |
---|
[15299] | 680 | htmldecode(tmpstr, tmpstr); |
---|
| 681 | tmpstr = ostrcat(url, tmpstr, 0, 1); |
---|
| 682 | debug(99, "streamurl: %s", tmpstr); |
---|
| 683 | streamurl = getstreamurl(tmpstr, url, name, 3); |
---|
| 684 | free(tmpstr); tmpstr = NULL; |
---|
| 685 | } |
---|
[14513] | 686 | else if(flag == 3) |
---|
[14486] | 687 | { |
---|
[16492] | 688 | // string_resub("delivery=\"streaming\"><![CDATA[", "]]></filename>", tmpstr, 0); |
---|
| 689 | tmpstr = string_resub("rtmpe://", ".f4v", tmpstr, 0); |
---|
[16093] | 690 | char* tmpstr9 = NULL; |
---|
| 691 | tmpstr9 = ostrcat(tmpstr9, tmpstr, 1, 0); |
---|
| 692 | free(tmpstr), tmpstr = NULL; |
---|
| 693 | tmpstr = ostrcat("rtmpe://", tmpstr9, 0, 0); |
---|
| 694 | tmpstr = ostrcat(tmpstr, ".f4v", 1, 0); |
---|
| 695 | free(tmpstr9), tmpstr9 = NULL; |
---|
| 696 | |
---|
[14486] | 697 | debug(99, "tmpstr: %s", tmpstr); |
---|
[14097] | 698 | |
---|
[14486] | 699 | int count = 0; |
---|
| 700 | int i = 0; |
---|
| 701 | struct splitstr* ret1 = NULL; |
---|
| 702 | ret1 = strsplit(tmpstr, "/", &count); |
---|
[15299] | 703 | if(ret1 != NULL) |
---|
| 704 | { |
---|
| 705 | int max = count; |
---|
| 706 | char* link = NULL; |
---|
| 707 | char* path = NULL; |
---|
| 708 | for(i = 0; i < max; i++) |
---|
[14486] | 709 | { |
---|
[15299] | 710 | if(i < 3) |
---|
| 711 | { |
---|
| 712 | if(count > i) |
---|
| 713 | link = ostrcat(link, (&ret1[i])->part, 1, 0); |
---|
[14509] | 714 | |
---|
[15299] | 715 | if(i == 0) |
---|
| 716 | link = ostrcat(link, "//", 1, 0); |
---|
| 717 | else |
---|
| 718 | link = ostrcat(link, "/", 1, 0); |
---|
| 719 | } |
---|
[14486] | 720 | else |
---|
[15299] | 721 | { |
---|
| 722 | if(count > i) |
---|
| 723 | path = ostrcat(path, (&ret1[i])->part, 1, 0); |
---|
| 724 | if(i != max - 1) |
---|
| 725 | path = ostrcat(path, "/", 1, 0); |
---|
| 726 | } |
---|
[14486] | 727 | } |
---|
[15299] | 728 | free(ret1), ret1 = NULL; |
---|
| 729 | |
---|
| 730 | debug(99, "link: %s", link); |
---|
| 731 | debug(99, "path: %s", path); |
---|
| 732 | |
---|
| 733 | streamurl = ostrcat(link, " swfVfy=1 playpath=mp4:", 0, 0); |
---|
| 734 | streamurl = ostrcat(streamurl, path, 1, 0); |
---|
| 735 | streamurl = ostrcat(streamurl, " app=", 1, 0); |
---|
| 736 | streamurl = ostrcat(streamurl, name, 1, 0); |
---|
| 737 | streamurl = ostrcat(streamurl, "/_definst_ pageUrl=", 1, 0); |
---|
| 738 | streamurl = ostrcat(streamurl, url, 1, 0); |
---|
| 739 | streamurl = ostrcat(streamurl, "/p/ tcUrl=", 1, 0); |
---|
| 740 | streamurl = ostrcat(streamurl, link, 1, 0); |
---|
| 741 | streamurl = ostrcat(streamurl, " swfUrl=", 1, 0); |
---|
| 742 | streamurl = ostrcat(streamurl, url, 1, 0); |
---|
| 743 | streamurl = ostrcat(streamurl, "/includes/vodplayer.swf", 1, 0); |
---|
| 744 | |
---|
| 745 | if(link != NULL) |
---|
| 746 | free(link), link = NULL; |
---|
| 747 | |
---|
| 748 | if(path != NULL) |
---|
| 749 | free(path), path = NULL; |
---|
[14097] | 750 | } |
---|
[15299] | 751 | free(tmpstr); tmpstr = NULL; |
---|
[14486] | 752 | debug(99, "streamurl: %s", streamurl); |
---|
[14097] | 753 | } |
---|
| 754 | return streamurl; |
---|
| 755 | } |
---|
| 756 | |
---|
[13931] | 757 | #endif |
---|