[extractor/common] Encode the url when calculating the md5 with `—write-pages` option
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Sat, 25 Jan 2014 14:31:58 +0000 (15:31 +0100)
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Sat, 25 Jan 2014 14:32:56 +0000 (15:32 +0100)
This doesn’t cause any problem in python 2.*, but on python 3 the `md5` function only accepts bytes.

youtube_dl/extractor/common.py

index aa48bd4e6b663fe490c3ad65295a52a856f28036..3cf742a3b6f49751ee4827a7d1f5cde3a59a884c 100644 (file)
@@ -240,7 +240,7 @@ class InfoExtractor(object):
             except AttributeError:
                 url = url_or_request
             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
             raw_filename = ('%s_%s.dump' % (video_id, url))
             filename = sanitize_filename(raw_filename, restricted=True)