[extractor/common] Protect against long video IDs and URLs
authorPhilipp Hagemeister <phihag@phihag.de>
Mon, 12 May 2014 19:56:10 +0000 (21:56 +0200)
committerPhilipp Hagemeister <phihag@phihag.de>
Mon, 12 May 2014 19:58:23 +0000 (21:58 +0200)
youtube_dl/extractor/common.py

index 10b0cbe695a68b6a3c3928a6c89125020a2fff3d..cef8c523ce9864c6b6f3127ed298c5f473908aa4 100644 (file)
@@ -242,10 +242,11 @@ class InfoExtractor(object):
                 url = url_or_request.get_full_url()
             except AttributeError:
                 url = url_or_request
-            if len(url) > 200:
-                h = u'___' + hashlib.md5(url.encode('utf-8')).hexdigest()
-                url = url[:200 - len(h)] + h
-            raw_filename = ('%s_%s.dump' % (video_id, url))
+            basen = video_id + '_' + url
+            if len(basen) > 240:
+                h = u'___' + hashlib.md5(basen.encode('utf-8')).hexdigest()
+                basen = basen[:240 - len(h)] + h
+            raw_filename = basen + '.dump'
             filename = sanitize_filename(raw_filename, restricted=True)
             self.to_screen(u'Saving request to ' + filename)
             with open(filename, 'wb') as outf: