From ec0fafbb1915b830035f621f4660c7e46b1a53ed Mon Sep 17 00:00:00 2001 From: Anisse Astier Date: Mon, 7 Apr 2014 23:09:53 +0200 Subject: [PATCH] [extractor/common] fallback on utf-8 when charset is not found fixes #2721 --- youtube_dl/extractor/common.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/common.py b/youtube_dl/extractor/common.py index da4193734..9653d44eb 100644 --- a/youtube_dl/extractor/common.py +++ b/youtube_dl/extractor/common.py @@ -251,7 +251,10 @@ def _download_webpage_handle(self, url_or_request, video_id, note=None, errnote= with open(filename, 'wb') as outf: outf.write(webpage_bytes) - content = webpage_bytes.decode(encoding, 'replace') + try: + content = webpage_bytes.decode(encoding, 'replace') + except LookupError: + content = webpage_bytes.decode('utf-8', 'replace') if (u'Access to this site is blocked' in content and u'Websense' in content[:512]):