aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Garcia <sarbalap+freshmeat@gmail.com>2010-04-03 09:54:36 +0200
committerRicardo Garcia <sarbalap+freshmeat@gmail.com>2010-10-31 11:26:53 +0100
commit7d8d06122d2e768f3ecce3ceb2e01d1f3a5ef050 (patch)
treed2558639e787b994b4ea633d506fce4d6ccb0d83
parent9177ce4d8ce93a7de0c75bdfdfd36bca5d6086f9 (diff)
downloadyoutube-dl-7d8d06122d2e768f3ecce3ceb2e01d1f3a5ef050.tar.xz
Add the "ord" template parameter (fixes issue #101)
-rwxr-xr-xyoutube-dl4
1 files changed, 4 insertions, 0 deletions
diff --git a/youtube-dl b/youtube-dl
index 09f1441a4..4cb958336 100755
--- a/youtube-dl
+++ b/youtube-dl
@@ -201,12 +201,14 @@ class FileDownloader(object):
_ies = []
_pps = []
_download_retcode = None
+ _num_downloads = None
def __init__(self, params):
"""Create a FileDownloader object with the given options."""
self._ies = []
self._pps = []
self._download_retcode = 0
+ self._num_downloads = 0
self.params = params
@staticmethod
@@ -402,6 +404,7 @@ class FileDownloader(object):
try:
template_dict = dict(info_dict)
template_dict['epoch'] = unicode(long(time.time()))
+ template_dict['ord'] = unicode('%05d' % self._num_downloads)
filename = self.params['outtmpl'] % template_dict
except (ValueError, KeyError), err:
self.trouble('ERROR: invalid output template or system charset: %s' % str(err))
@@ -555,6 +558,7 @@ class FileDownloader(object):
try:
(stream, filename) = sanitize_open(filename, open_mode)
self.report_destination(filename)
+ self._num_downloads += 1
except (OSError, IOError), err:
self.trouble('ERROR: unable to open for writing: %s' % str(err))
return False