YoutubeDLHandler,
)
from .extractor import get_info_extractor, gen_extractors
-from .FileDownloader import FileDownloader
+from .downloader import get_suitable_downloader
from .version import __version__
u'Set the LC_ALL environment variable to fix this.')
self.params['restrictfilenames'] = True
- self.fd = FileDownloader(self, self.params)
-
if '%(stitle)s' in self.params.get('outtmpl', ''):
self.report_warning(u'%(stitle)s is deprecated. Use the %(title)s and the --restrict-filenames flag(which also secures %(uploader)s et al) instead.')
self._pps.append(pp)
pp.set_downloader(self)
+ def add_progress_hook(self, ph):
+ """Add the progress hook (currently only for the file downloader)"""
+ self._progress_hooks.append(ph)
+
def _bidi_workaround(self, message):
if not hasattr(self, '_output_channel'):
return message
ext_ord)
formats = sorted(formats, key=_free_formats_key)
- info_dict['formats'] = formats
+ if formats[0] is not info_dict:
+ # only set the 'formats' fields if the original info_dict list them
+ # otherwise we end up with a circular reference, the first (and unique)
+ # element in the 'formats' field in info_dict is info_dict itself,
+ # wich can't be exported to json
+ info_dict['formats'] = formats
if self.params.get('listformats', None):
self.list_formats(info_dict)
return
success = True
else:
try:
- success = self.fd._do_download(filename, info_dict)
+ fd = get_suitable_downloader(info_dict)(self, self.params)
+ for ph in self._progress_hooks:
+ fd.add_progress_hook(ph)
+ success = fd.download(filename, info_dict)
except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self.report_error(u'unable to download video data: %s' % str(err))
return