diff options
author | bashonly <88596187+bashonly@users.noreply.github.com> | 2025-02-18 20:23:42 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-19 02:23:42 +0000 |
commit | be69468752ff598cacee57bb80533deab2367a5d (patch) | |
tree | 337d2d5b996dd1d6ab898d7be22c3b7d0fdecb41 /yt_dlp/utils/_utils.py | |
parent | 5271ef48c6f61c145e03e18e960995d2e651d205 (diff) |
[fd/hls] Support `--write-pages` for m3u8 media playlists (#12333)
Authored by: bashonly
Diffstat (limited to 'yt_dlp/utils/_utils.py')
-rw-r--r-- | yt_dlp/utils/_utils.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/yt_dlp/utils/_utils.py b/yt_dlp/utils/_utils.py index a71a381e5..c6a90a0dd 100644 --- a/yt_dlp/utils/_utils.py +++ b/yt_dlp/utils/_utils.py @@ -5631,6 +5631,24 @@ def filesize_from_tbr(tbr, duration): return int(duration * tbr * (1000 / 8)) +def _request_dump_filename(url, video_id, data=None, trim_length=None): + if data is not None: + data = hashlib.md5(data).hexdigest() + basen = join_nonempty(video_id, data, url, delim='_') + trim_length = trim_length or 240 + if len(basen) > trim_length: + h = '___' + hashlib.md5(basen.encode()).hexdigest() + basen = basen[:trim_length - len(h)] + h + filename = sanitize_filename(f'{basen}.dump', restricted=True) + # Working around MAX_PATH limitation on Windows (see + # http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx) + if os.name == 'nt': + absfilepath = os.path.abspath(filename) + if len(absfilepath) > 259: + filename = fR'\\?\{absfilepath}' + return filename + + # XXX: Temporary class _YDLLogger: def __init__(self, ydl=None): |