Check-in [bf7e0f1bf3]
Overview
Comment: | A little more comments on playlist_export usage. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
bf7e0f1bf38d23181962304afe1a2c28 |
User & Date: | mario on 2015-04-30 21:21:29 |
Other Links: | manifest | tags |
Context
2015-04-30
| ||
23:57 | Test build -t arch Linux package as well. check-in: adb15be7f8 user: mario tags: trunk | |
21:21 | A little more comments on playlist_export usage. check-in: bf7e0f1bf3 user: mario tags: trunk | |
20:54 | Implement state: mapping (though no idea what 0-2 mean), and make default API key internally predefined again. check-in: cf32efcb61 user: mario tags: trunk | |
Changes
Modified action.py from [c4b64401d8] to [9f1cd78f49].
︙ | |||
17 18 19 20 21 22 23 | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | - - + + - - + + | # Some channels list raw "srv" addresses, while Youtube "href" # entries point to Flash videos. # # As fallback the playlist URL is retrieved and its MIME type # checked, then its content regexped to guess the list format. # Lastly a playlist format suitable for audio players recreated. # Which is somewhat of a security feature; playlists get cleaned |
︙ | |||
300 301 302 303 304 305 306 | 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | - + - - - + + + | # Rejoin into string content = "\n".join(str.decode(errors='replace') for str in r.iter_lines()) return (mime, content) |
︙ | |||
381 382 383 384 385 386 387 388 389 390 391 392 393 394 | 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | + | for i,val in enumerate(self.field(name, rules, self.src)): if len(rows) <= i: rows.append({"url":None}) rows[i][name] = val; log.DATA("pair-rx", rows) return self.uniq(rows) # Single field def field(self, name, rules, src_part): if name in rules: vals = re.findall(rules[name], src_part, re.X) #log.PLS_EXTR_FIELD(name, vals, src_part, rules[name]) return [self.decode(val, rules.get("unesc")) for val in vals] |
︙ | |||
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 | 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 | + - + - - + + + + - - + + + + + + + + + + + - + + | "homepage": "", "listformat": self.probe_ext(url) or "href", # or srv? "format": self.mime_guess(url), "genre": "copy", } comb.update(row) return comb # Probe url "extensions" for common media types # (only care about the common audio formats, don't need an exact match or pre-probing in practice) def mime_guess(self, url): audio = re.findall("(ogg|opus|spx|aacp|aac|mpeg|mp3|m4a|mp2|flac|midi|mod|kar|aiff|wma|ram|wav)", url) if audio: return "audio/{}".format(*audio) video = re.findall("(mp4|flv|avi|mp2|theora|3gp|nsv|fli|ogv|webm|mng|mxu|wmv|mpv|mkv)", url) if audio: return "video/{}".format(*audio) return "x-audio-video/unknown" |
︙ | |||
580 581 582 583 584 585 586 587 588 589 590 591 592 593 | 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 | + | rows = new_rows log.DATA("conversion to:", dest, " with rows=", rows) # call conversion schemes converter = getattr(self, dest) or self.pls return converter(rows) # save directly def file(self, rows, dest, fn): with open(fn, "w") as f: f.write(self.store(rows, dest)) |
︙ |