A number bug fixed

Now if you can have more than 10 videos that have same names.
This commit is contained in:
John128217 2018-02-21 21:55:28 -08:00 committed by GitHub
parent a22dce896c
commit c7290c7c2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -622,10 +622,13 @@ def url_save(
bar.done() bar.done()
if not force and auto_rename: if not force and auto_rename:
path, ext = os.path.basename(filepath).rsplit('.', 1) path, ext = os.path.basename(filepath).rsplit('.', 1)
if (re.compile(' \(\d\)').match(path[-4:]) is None): finder = re.compile(' \([1-9]\d*?\)$')
if (finder.search(path) is None):
thisfile = path + ' (1).' + ext thisfile = path + ' (1).' + ext
else: else:
thisfile = path[:-2] + str(int(path[-2]) + 1) + ').' + ext def numreturn(a):
return ' (' + str(int(a.group()[2:-1]) + 1) + ').'
thisfile = finder.sub(numreturn, path) + ext
filepath = os.path.join(os.path.dirname(filepath), thisfile) filepath = os.path.join(os.path.dirname(filepath), thisfile)
print('Changing name to %s' % tr(os.path.basename(filepath)), '...') print('Changing name to %s' % tr(os.path.basename(filepath)), '...')
continue_renameing = True continue_renameing = True