aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2015-12-20 05:27:38 +0600
committerSergey M․ <dstftw@gmail.com>2015-12-20 05:27:38 +0600
commit7f8b271465df75bb1f83cb181dc45fee5fe02cf9 (patch)
treea17694aae937027a453b6d279dff3be5530e73e9 /youtube_dl/extractor
parentfdae2358581be6f80ac5fd20b1062e87a8797f46 (diff)
Properly convert errors to strings
Diffstat (limited to 'youtube_dl/extractor')
-rw-r--r--youtube_dl/extractor/common.py12
-rw-r--r--youtube_dl/extractor/dailymotion.py6
-rw-r--r--youtube_dl/extractor/facebook.py4
-rw-r--r--youtube_dl/extractor/youtube.py3
4 files changed, 11 insertions, 14 deletions
diff --git a/youtube_dl/extractor/common.py b/youtube_dl/extractor/common.py
index 3ab72ff76..5659e40c8 100644
--- a/youtube_dl/extractor/common.py
+++ b/youtube_dl/extractor/common.py
@@ -30,11 +30,11 @@ from ..utils import (
clean_html,
compiled_regex_type,
determine_ext,
+ error_to_str,
ExtractorError,
fix_xml_ampersands,
float_or_none,
int_or_none,
- preferredencoding,
RegexNotFoundError,
sanitize_filename,
sanitized_Request,
@@ -333,12 +333,8 @@ class InfoExtractor(object):
return False
if errnote is None:
errnote = 'Unable to download webpage'
- err_str = str(err)
- # On python 2 error byte string must be decoded with proper
- # encoding rather than ascii
- if sys.version_info[0] < 3:
- err_str = err_str.decode(preferredencoding())
- errmsg = '%s: %s' % (errnote, err_str)
+
+ errmsg = '%s: %s' % (errnote, error_to_str(err))
if fatal:
raise ExtractorError(errmsg, sys.exc_info()[2], cause=err)
else:
@@ -628,7 +624,7 @@ class InfoExtractor(object):
else:
raise netrc.NetrcParseError('No authenticators for %s' % self._NETRC_MACHINE)
except (IOError, netrc.NetrcParseError) as err:
- self._downloader.report_warning('parsing .netrc: %s' % compat_str(err))
+ self._downloader.report_warning('parsing .netrc: %s' % error_to_str(err))
return (username, password)
diff --git a/youtube_dl/extractor/dailymotion.py b/youtube_dl/extractor/dailymotion.py
index 428556213..7d66baf96 100644
--- a/youtube_dl/extractor/dailymotion.py
+++ b/youtube_dl/extractor/dailymotion.py
@@ -7,10 +7,10 @@ import itertools
from .common import InfoExtractor
-from ..compat import compat_str
from ..utils import (
- ExtractorError,
determine_ext,
+ error_to_str,
+ ExtractorError,
int_or_none,
parse_iso8601,
sanitized_Request,
@@ -278,7 +278,7 @@ class DailymotionIE(DailymotionBaseInfoExtractor):
'https://api.dailymotion.com/video/%s/subtitles?fields=id,language,url' % video_id,
video_id, note=False)
except ExtractorError as err:
- self._downloader.report_warning('unable to download video subtitles: %s' % compat_str(err))
+ self._downloader.report_warning('unable to download video subtitles: %s' % error_to_str(err))
return {}
info = json.loads(sub_list)
if (info['total'] > 0):
diff --git a/youtube_dl/extractor/facebook.py b/youtube_dl/extractor/facebook.py
index 321eec59e..296d3dd77 100644
--- a/youtube_dl/extractor/facebook.py
+++ b/youtube_dl/extractor/facebook.py
@@ -7,11 +7,11 @@ import socket
from .common import InfoExtractor
from ..compat import (
compat_http_client,
- compat_str,
compat_urllib_error,
compat_urllib_parse_unquote,
)
from ..utils import (
+ error_to_str,
ExtractorError,
limit_length,
sanitized_Request,
@@ -116,7 +116,7 @@ class FacebookIE(InfoExtractor):
if re.search(r'id="checkpointSubmitButton"', check_response) is not None:
self._downloader.report_warning('Unable to confirm login, you have to login in your brower and authorize the login.')
except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
- self._downloader.report_warning('unable to log in: %s' % compat_str(err))
+ self._downloader.report_warning('unable to log in: %s' % error_to_str(err))
return
def _real_initialize(self):
diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py
index 4556a16fb..d63aa5f4e 100644
--- a/youtube_dl/extractor/youtube.py
+++ b/youtube_dl/extractor/youtube.py
@@ -26,6 +26,7 @@ from ..compat import (
from ..utils import (
clean_html,
encode_dict,
+ error_to_str,
ExtractorError,
float_or_none,
get_element_by_attribute,
@@ -903,7 +904,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
'https://video.google.com/timedtext?hl=en&type=list&v=%s' % video_id,
video_id, note=False)
except ExtractorError as err:
- self._downloader.report_warning('unable to download video subtitles: %s' % compat_str(err))
+ self._downloader.report_warning('unable to download video subtitles: %s' % error_to_str(err))
return {}
sub_lang_list = {}