mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-02-04 16:47:32 +01:00
Allow --trim-filenames=0 and update tests
This commit is contained in:
parent
fa6e2f83aa
commit
1e82fe3bfe
@ -717,7 +717,7 @@ class TestYoutubeDL(unittest.TestCase):
|
||||
ydl._num_downloads = 1
|
||||
self.assertEqual(ydl.validate_outtmpl(tmpl), None)
|
||||
|
||||
out = ydl.evaluate_outtmpl(tmpl, info or self.outtmpl_info)
|
||||
out = ydl.evaluate_outtmpl_for_filename(tmpl, info or self.outtmpl_info)
|
||||
fname = ydl.prepare_filename(info or self.outtmpl_info)
|
||||
|
||||
if not isinstance(expected, (list, tuple)):
|
||||
@ -791,7 +791,7 @@ class TestYoutubeDL(unittest.TestCase):
|
||||
self.assertEqual(got_dict.get(info_field), expected, info_field)
|
||||
return True
|
||||
|
||||
test('%()j', (expect_same_infodict, None))
|
||||
test('%()j', (expect_same_infodict, None), trim_file_name=0)
|
||||
|
||||
# NA placeholder
|
||||
NA_TEST_OUTTMPL = '%(uploader_date)s-%(width)d-%(x|def)s-%(id)s.%(ext)s'
|
||||
|
@ -1458,10 +1458,16 @@ class YoutubeDL:
|
||||
else:
|
||||
raise ValueError("--trim-filenames must end with 'b' or 'c'")
|
||||
|
||||
max_file_name = self.params.get('trim_file_name') or DEFAULT_MAX_FILE_NAME
|
||||
max_file_name = self.params.get('trim_file_name')
|
||||
if max_file_name is None:
|
||||
max_file_name = DEFAULT_MAX_FILE_NAME
|
||||
mode, max_file_name = parse_max_file_name(max_file_name)
|
||||
if max_file_name < 1:
|
||||
if max_file_name < 0:
|
||||
raise ValueError('Invalid --trim-filenames specified')
|
||||
if max_file_name == 0:
|
||||
# no maximum
|
||||
return filename + suffix
|
||||
|
||||
encoding = self.params.get('filesystem_encoding') or sys.getfilesystemencoding()
|
||||
|
||||
def trim_filename(name: str, length: int):
|
||||
|
Loading…
x
Reference in New Issue
Block a user