diff options
author | felix <felix.von.s@posteo.de> | 2021-05-23 18:34:49 +0200 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-06-13 20:36:40 +0530 |
commit | cdb19aa4c254a1e4dea942f51d22790b7c99021c (patch) | |
tree | e30bdec6cec21fa0b78e93d0c97ffbb860bba837 /yt_dlp/utils.py | |
parent | 4d85fbbdbba79aed7b73ea54b1bdc20d078961d4 (diff) | |
download | hypervideo-pre-cdb19aa4c254a1e4dea942f51d22790b7c99021c.tar.lz hypervideo-pre-cdb19aa4c254a1e4dea942f51d22790b7c99021c.tar.xz hypervideo-pre-cdb19aa4c254a1e4dea942f51d22790b7c99021c.zip |
[downloader/mhtml] Add new downloader (#343)
This downloader is intended to be used for streams that consist of a
timed sequence of stand-alone images, such as slideshows or thumbnail
streams
This can be used for implementing:
https://github.com/ytdl-org/youtube-dl/issues/4974#issue-58006762
https://github.com/ytdl-org/youtube-dl/issues/4540#issuecomment-69574231
https://github.com/ytdl-org/youtube-dl/pull/11185#issuecomment-335554239
https://github.com/ytdl-org/youtube-dl/issues/9868
https://github.com/ytdl-org/youtube-dl/pull/14951
Authored by: fstirlitz
Diffstat (limited to 'yt_dlp/utils.py')
-rw-r--r-- | yt_dlp/utils.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py index 3cb79b657..59445a1da 100644 --- a/yt_dlp/utils.py +++ b/yt_dlp/utils.py @@ -2244,6 +2244,17 @@ def unescapeHTML(s): r'&([^&;]+;)', lambda m: _htmlentity_transform(m.group(1)), s) +def escapeHTML(text): + return ( + text + .replace('&', '&') + .replace('<', '<') + .replace('>', '>') + .replace('"', '"') + .replace("'", ''') + ) + + def process_communicate_or_kill(p, *args, **kwargs): try: return p.communicate(*args, **kwargs) @@ -2323,13 +2334,14 @@ def decodeOption(optval): return optval -def formatSeconds(secs, delim=':'): +def formatSeconds(secs, delim=':', msec=False): if secs > 3600: - return '%d%s%02d%s%02d' % (secs // 3600, delim, (secs % 3600) // 60, delim, secs % 60) + ret = '%d%s%02d%s%02d' % (secs // 3600, delim, (secs % 3600) // 60, delim, secs % 60) elif secs > 60: - return '%d%s%02d' % (secs // 60, delim, secs % 60) + ret = '%d%s%02d' % (secs // 60, delim, secs % 60) else: - return '%d' % secs + ret = '%d' % secs + return '%s.%03d' % (ret, secs % 1) if msec else ret def make_HTTPS_handler(params, **kwargs): |