Check-in [7a1577bf74]
Overview
Comment: | Collect audio format form URL guessing into new class heuristic_funcs |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
7a1577bf74f0745148cba02ad1cd469d |
User & Date: | mario on 2017-02-26 21:44:13 |
Other Links: | manifest | tags |
Context
2017-02-26
| ||
21:45 | Reuse mime_guess+list_guess functions from action.heuristic_funcs check-in: c5e06b031a user: mario tags: trunk | |
21:44 | Collect audio format form URL guessing into new class heuristic_funcs check-in: 7a1577bf74 user: mario tags: trunk | |
21:43 | Enable search with post/json=1 and seperating token from other params{} check-in: 85f1271d4d user: mario tags: trunk | |
Changes
Modified action.py from [1923204c8e] to [77e25ddc1d].
1 2 3 4 5 6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | - + - + | # encoding: UTF-8 # api: streamtuner2 # type: functions # category: io # title: play/record actions # description: Starts audio applications, guesses MIME types for URLs |
︙ | |||
369 370 371 372 373 374 375 376 377 378 379 | 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 | + + + + + + + + + + + + + + + + + + + + + + + + + - + - + | return (mime, url) # Rejoin into string content = "\n".join(str.decode(errors='replace') for str in r.iter_lines()) return (mime, content) # A few guessing functions # class heuristic_funcs(object): # 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, default="x-audio-video/unknown"): audio = re.findall("\\b(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("\\b(mp4|flv|avi|mp2|theora|3gp|nsv|fli|ogv|webm|mng|mxu|wmv|mpv|mkv)", url) if audio: return "video/{}".format(*audio) return default # guess PLS/M3U from url def list_guess(self, url): ext = re.findall("|".join(playlist_fmt_prio), url) if ext: return ext[0] else: return "srv" # Extract URLs and meta infos (titles) from playlist formats # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # It's mostly regex-based at the moment, because that's more |
︙ | |||
602 603 604 605 606 607 608 | 627 628 629 630 631 632 633 634 635 636 637 638 639 640 | - - - - - - - - - - - - | "listformat": self.probe_ext(url) or "href", # or srv? "format": self.mime_guess(url), "genre": "copy", } comb.update(row) return comb |
︙ |