1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-12-23 15:07:54 +01:00

[extractor/common] Encode the url when calculating the md5 with —write-pages option

This doesn’t cause any problem in python 2.*, but on python 3 the `md5` function only accepts bytes.
This commit is contained in:
Jaime Marquínez Ferrándiz 2014-01-25 15:31:58 +01:00
parent f945612bd0
commit 944d65c762

View File

@ -240,7 +240,7 @@ class InfoExtractor(object):
except AttributeError: except AttributeError:
url = url_or_request url = url_or_request
if len(url) > 200: if len(url) > 200:
h = u'___' + hashlib.md5(url).hexdigest() h = u'___' + hashlib.md5(url.encode('utf-8')).hexdigest()
url = url[:200 - len(h)] + h url = url[:200 - len(h)] + h
raw_filename = ('%s_%s.dump' % (video_id, url)) raw_filename = ('%s_%s.dump' % (video_id, url))
filename = sanitize_filename(raw_filename, restricted=True) filename = sanitize_filename(raw_filename, restricted=True)