mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-23 02:25:11 +00:00
Add --no-part option (closes #48)
This commit is contained in:
parent
d3975459d1
commit
3fb2c487c0
1 changed files with 14 additions and 10 deletions
20
youtube-dl
20
youtube-dl
|
@ -210,6 +210,7 @@ class FileDownloader(object):
|
||||||
playlistend: Playlist item to end at.
|
playlistend: Playlist item to end at.
|
||||||
logtostderr: Log messages to stderr instead of stdout.
|
logtostderr: Log messages to stderr instead of stdout.
|
||||||
consoletitle: Display progress in console window's titlebar.
|
consoletitle: Display progress in console window's titlebar.
|
||||||
|
nopart: Do not use temporary .part files.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
params = None
|
params = None
|
||||||
|
@ -238,13 +239,6 @@ class FileDownloader(object):
|
||||||
if not os.path.exists(dir):
|
if not os.path.exists(dir):
|
||||||
os.mkdir(dir)
|
os.mkdir(dir)
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def temp_name(filename):
|
|
||||||
"""Returns a temporary filename for the given filename."""
|
|
||||||
if filename == u'-' or (os.path.exists(filename) and not os.path.isfile(filename)):
|
|
||||||
return filename
|
|
||||||
return filename + u'.part'
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def format_bytes(bytes):
|
def format_bytes(bytes):
|
||||||
if bytes is None:
|
if bytes is None:
|
||||||
|
@ -375,6 +369,13 @@ class FileDownloader(object):
|
||||||
if speed > rate_limit:
|
if speed > rate_limit:
|
||||||
time.sleep((byte_counter - rate_limit * (now - start_time)) / rate_limit)
|
time.sleep((byte_counter - rate_limit * (now - start_time)) / rate_limit)
|
||||||
|
|
||||||
|
def temp_name(self, filename):
|
||||||
|
"""Returns a temporary filename for the given filename."""
|
||||||
|
if self.params.get('nopart', False) or filename == u'-' or \
|
||||||
|
(os.path.exists(filename) and not os.path.isfile(filename)):
|
||||||
|
return filename
|
||||||
|
return filename + u'.part'
|
||||||
|
|
||||||
def try_rename(self, old_filename, new_filename):
|
def try_rename(self, old_filename, new_filename):
|
||||||
try:
|
try:
|
||||||
if old_filename == new_filename:
|
if old_filename == new_filename:
|
||||||
|
@ -547,7 +548,7 @@ class FileDownloader(object):
|
||||||
|
|
||||||
def _do_download(self, filename, url, player_url):
|
def _do_download(self, filename, url, player_url):
|
||||||
# Check file already present
|
# Check file already present
|
||||||
if self.params.get('continuedl', False) and os.path.isfile(filename):
|
if self.params.get('continuedl', False) and os.path.isfile(filename) and not self.params.get('nopart', False):
|
||||||
self.report_file_already_downloaded(filename)
|
self.report_file_already_downloaded(filename)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -2329,6 +2330,8 @@ if __name__ == '__main__':
|
||||||
action='store_true', dest='continue_dl', help='resume partially downloaded files', default=False)
|
action='store_true', dest='continue_dl', help='resume partially downloaded files', default=False)
|
||||||
filesystem.add_option('--cookies',
|
filesystem.add_option('--cookies',
|
||||||
dest='cookiefile', metavar='FILE', help='file to dump cookie jar to')
|
dest='cookiefile', metavar='FILE', help='file to dump cookie jar to')
|
||||||
|
filesystem.add_option('--no-part',
|
||||||
|
action='store_true', dest='nopart', help='do not use .part files', default=False)
|
||||||
parser.add_option_group(filesystem)
|
parser.add_option_group(filesystem)
|
||||||
|
|
||||||
(opts, args) = parser.parse_args()
|
(opts, args) = parser.parse_args()
|
||||||
|
@ -2452,6 +2455,7 @@ if __name__ == '__main__':
|
||||||
'playlistend': opts.playlistend,
|
'playlistend': opts.playlistend,
|
||||||
'logtostderr': opts.outtmpl == '-',
|
'logtostderr': opts.outtmpl == '-',
|
||||||
'consoletitle': opts.consoletitle,
|
'consoletitle': opts.consoletitle,
|
||||||
|
'nopart': opts.nopart,
|
||||||
})
|
})
|
||||||
fd.add_info_extractor(youtube_search_ie)
|
fd.add_info_extractor(youtube_search_ie)
|
||||||
fd.add_info_extractor(youtube_pl_ie)
|
fd.add_info_extractor(youtube_pl_ie)
|
||||||
|
|
Loading…
Reference in a new issue