X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fdownloader%2Fcommon.py;h=8e0e386bf185803e07b89bea3ee46c5ffb62e527;hb=0aed8df2bf12c9e41f1cae7545f1e8379763cbf9;hp=e9c9b4473a16ed47ebe3eb74274c9ce952193358;hpb=3bc2ddccc8622379ec11e802dff30a635285a9c8;p=youtube-dl diff --git a/youtube_dl/downloader/common.py b/youtube_dl/downloader/common.py index e9c9b4473..8e0e386bf 100644 --- a/youtube_dl/downloader/common.py +++ b/youtube_dl/downloader/common.py @@ -1,14 +1,13 @@ -import math import os import re -import subprocess import sys import time from ..utils import ( + compat_str, encodeFilename, - timeconvert, format_bytes, + timeconvert, ) @@ -175,7 +174,7 @@ class FileDownloader(object): return os.rename(encodeFilename(old_filename), encodeFilename(new_filename)) except (IOError, OSError) as err: - self.report_error(u'unable to rename file') + self.report_error(u'unable to rename file: %s' % compat_str(err)) def try_utime(self, filename, last_modified_hdr): """Try to set the last-modified time of the given file.""" @@ -279,8 +278,9 @@ class FileDownloader(object): """Download to a filename using the info from info_dict Return True on success and False otherwise """ - url = info_dict['url'] - + sleep_interval = self.params.get('sleepinterval', 0) + self.to_screen(u'[download] Sleeping %d seconds...' %sleep_interval) + time.sleep(sleep_interval) # Check file already present if self.params.get('continuedl', False) and os.path.isfile(encodeFilename(filename)) and not self.params.get('nopart', False): self.report_file_already_downloaded(filename) @@ -290,8 +290,8 @@ class FileDownloader(object): 'total_bytes': os.path.getsize(encodeFilename(filename)), }) return True - else: - return self.real_download(filename, info_dict) + + return self.real_download(filename, info_dict) def real_download(self, filename, info_dict): """Real download process. Redefine in subclasses.""" @@ -318,4 +318,3 @@ class FileDownloader(object): if the download is successful. """ self._progress_hooks.append(ph) -