diff options
Diffstat (limited to 'youtube_dl/utils.py')
| -rw-r--r-- | youtube_dl/utils.py | 33 | 
1 files changed, 19 insertions, 14 deletions
| diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index 52f0dd09a..edeee1853 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -312,17 +312,17 @@ def sanitize_path(s):      """Sanitizes and normalizes path on Windows"""      if sys.platform != 'win32':          return s -    drive, _ = os.path.splitdrive(s) -    unc, _ = os.path.splitunc(s) -    unc_or_drive = unc or drive -    norm_path = os.path.normpath(remove_start(s, unc_or_drive)).split(os.path.sep) -    if unc_or_drive: +    drive_or_unc, _ = os.path.splitdrive(s) +    if sys.version_info < (2, 7) and not drive_or_unc: +        drive_or_unc, _ = os.path.splitunc(s) +    norm_path = os.path.normpath(remove_start(s, drive_or_unc)).split(os.path.sep) +    if drive_or_unc:          norm_path.pop(0)      sanitized_path = [          path_part if path_part in ['.', '..'] else re.sub('(?:[/<>:"\\|\\\\?\\*]|\.$)', '#', path_part)          for path_part in norm_path] -    if unc_or_drive: -        sanitized_path.insert(0, unc_or_drive + os.path.sep) +    if drive_or_unc: +        sanitized_path.insert(0, drive_or_unc + os.path.sep)      return os.path.join(*sanitized_path) @@ -452,6 +452,17 @@ def make_HTTPS_handler(params, **kwargs):          return YoutubeDLHTTPSHandler(params, context=context, **kwargs) +def bug_reports_message(): +    if ytdl_is_updateable(): +        update_cmd = 'type  youtube-dl -U  to update' +    else: +        update_cmd = 'see  https://yt-dl.org/update  on how to update' +    msg = '; please report this issue on https://yt-dl.org/bug .' +    msg += ' Make sure you are using the latest version; %s.' % update_cmd +    msg += ' Be sure to call youtube-dl with the --verbose flag and include its complete output.' +    return msg + +  class ExtractorError(Exception):      """Error during info extraction.""" @@ -467,13 +478,7 @@ class ExtractorError(Exception):          if cause:              msg += ' (caused by %r)' % cause          if not expected: -            if ytdl_is_updateable(): -                update_cmd = 'type  youtube-dl -U  to update' -            else: -                update_cmd = 'see  https://yt-dl.org/update  on how to update' -            msg += '; please report this issue on https://yt-dl.org/bug .' -            msg += ' Make sure you are using the latest version; %s.' % update_cmd -            msg += ' Be sure to call youtube-dl with the --verbose flag and include its complete output.' +            msg += bug_reports_message()          super(ExtractorError, self).__init__(msg)          self.traceback = tb | 
