import os
import re
import sys
+import traceback
import zlib
import email.utils
import json
class ExtractorError(Exception):
"""Error during info extraction."""
def __init__(self, msg, tb=None):
- """ tb is the original traceback (so that it can be printed out) """
+ """ tb, if given, is the original traceback (so that it can be printed out). """
super(ExtractorError, self).__init__(msg)
- if tb is None:
- tb = sys.exc_info()[2]
self.traceback = tb
+ def format_traceback(self):
+ if self.traceback is None:
+ return None
+ return u''.join(traceback.format_tb(self.traceback))
+
class DownloadError(Exception):
"""Download Error exception.
This exception may be raised by PostProcessor's .run() method to
indicate an error in the postprocessing task.
"""
- pass
+ def __init__(self, msg):
+ self.msg = msg
class MaxDownloadsReached(Exception):
""" --max-downloads limit has been reached. """
if 'Accept-encoding' in req.headers:
del req.headers['Accept-encoding']
del req.headers['Youtubedl-no-compression']
+ if 'Youtubedl-user-agent' in req.headers:
+ if 'User-Agent' in req.headers:
+ del req.headers['User-Agent']
+ req.headers['User-Agent'] = req.headers['Youtubedl-user-agent']
+ del req.headers['Youtubedl-user-agent']
return req
def http_response(self, req, resp):