0
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-27 03:03:01 +00:00

dump files should obey --trim-filename (#1043)

Authored by: sulyi
This commit is contained in:
pukkandan 2021-09-22 05:25:17 +05:30
parent d9d8b85747
commit bd6f722de8
No known key found for this signature in database
GPG key ID: 0F00D95A001F4698

View file

@ -789,9 +789,10 @@ def _webpage_read_content(self, urlh, url_or_request, video_id, note=None, errno
self._downloader.to_screen(dump) self._downloader.to_screen(dump)
if self.get_param('write_pages', False): if self.get_param('write_pages', False):
basen = '%s_%s' % (video_id, urlh.geturl()) basen = '%s_%s' % (video_id, urlh.geturl())
if len(basen) > 240: trim_length = self.get_param('trim_file_name') or 240
if len(basen) > trim_length:
h = '___' + hashlib.md5(basen.encode('utf-8')).hexdigest() h = '___' + hashlib.md5(basen.encode('utf-8')).hexdigest()
basen = basen[:240 - len(h)] + h basen = basen[:trim_length - len(h)] + h
raw_filename = basen + '.dump' raw_filename = basen + '.dump'
filename = sanitize_filename(raw_filename, restricted=True) filename = sanitize_filename(raw_filename, restricted=True)
self.to_screen('Saving request to ' + filename) self.to_screen('Saving request to ' + filename)