X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2FFileDownloader.py;h=c471cc16081d5ff40cd0898ba0149f346d6c574e;hb=c7214f9a6fd5fb86668b71cbd44187e1babd26a9;hp=9dc3523e0e492c774fbaf277d560ab3a7a8993a2;hpb=59ae15a507cbf93de13f8fda8444d2d9a251747a;p=youtube-dl diff --git a/youtube_dl/FileDownloader.py b/youtube_dl/FileDownloader.py index 9dc3523e0..c471cc160 100644 --- a/youtube_dl/FileDownloader.py +++ b/youtube_dl/FileDownloader.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +from __future__ import absolute_import + import math import os import re @@ -12,7 +14,7 @@ import time if os.name == 'nt': import ctypes -from utils import * +from .utils import * class FileDownloader(object): @@ -332,8 +334,11 @@ class FileDownloader(object): template_dict['epoch'] = int(time.time()) template_dict['autonumber'] = u'%05d' % self._num_downloads - template_dict = dict((key, u'NA' if val is None else val) for key, val in template_dict.items()) - template_dict = dict((k, sanitize_filename(compat_str(v), self.params.get('restrictfilenames'))) for k,v in template_dict.items()) + sanitize = lambda k,v: sanitize_filename( + u'NA' if v is None else compat_str(v), + restricted=self.params.get('restrictfilenames'), + is_id=(k==u'id')) + template_dict = dict((k, sanitize(k, v)) for k,v in template_dict.items()) filename = self.params['outtmpl'] % template_dict return filename @@ -461,7 +466,7 @@ class FileDownloader(object): try: success = self._do_download(filename, info_dict) except (OSError, IOError) as err: - raise UnavailableVideoError + raise UnavailableVideoError() except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err: self.trouble(u'ERROR: unable to download video data: %s' % str(err)) return