diff options
author | Philipp Hagemeister <phihag@phihag.de> | 2013-10-28 10:44:02 +0100 |
---|---|---|
committer | Philipp Hagemeister <phihag@phihag.de> | 2013-10-28 10:44:02 +0100 |
commit | d41e6efc852c34da582790a54ecc4f5e9dbbedda (patch) | |
tree | 0676ffe25b9e5d747ef5c1b0cfeec11486fa58c1 /youtube_dl/extractor/common.py | |
parent | c19f7764a5499b0f1e1914dd5101619b8d57d7cf (diff) |
New debug option --write-pages
Diffstat (limited to 'youtube_dl/extractor/common.py')
-rw-r--r-- | youtube_dl/extractor/common.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/youtube_dl/extractor/common.py b/youtube_dl/extractor/common.py index aaa5c24c8..458635f1e 100644 --- a/youtube_dl/extractor/common.py +++ b/youtube_dl/extractor/common.py @@ -15,6 +15,7 @@ from ..utils import ( compiled_regex_type, ExtractorError, RegexNotFoundError, + sanitize_filename, unescapeHTML, ) @@ -182,6 +183,17 @@ class InfoExtractor(object): self.to_screen(u'Dumping request to ' + url) dump = base64.b64encode(webpage_bytes).decode('ascii') self._downloader.to_screen(dump) + if self._downloader.params.get('write_pages', False): + try: + url = url_or_request.get_full_url() + except AttributeError: + url = url_or_request + raw_filename = ('%s_%s.dump' % (video_id, url)) + filename = sanitize_filename(raw_filename, restricted=True) + self.to_screen(u'Saving request to ' + filename) + with open(filename, 'wb') as outf: + outf.write(webpage_bytes) + content = webpage_bytes.decode(encoding, 'replace') return (content, urlh) |