mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-01-10 20:45:51 +01:00
Remove --filesystem-encoding option
This commit is contained in:
parent
ac69f9474b
commit
8063b142d9
@ -2,6 +2,7 @@
|
||||
|
||||
# Allow direct execution
|
||||
import os
|
||||
import platform
|
||||
import sys
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
@ -930,11 +931,15 @@ def gen():
|
||||
# --trim-filenames
|
||||
test('%(title6)s.%(ext)s', 'あ' * 10 + '.mp4')
|
||||
test('%(title6)s.%(ext)s', 'あ' * 3 + '.mp4', trim_file_name='3c')
|
||||
test('%(title6)s.%(ext)s', 'あ' * 3 + '.mp4', trim_file_name='9b', filesystem_encoding='utf-8')
|
||||
test('%(title6)s.%(ext)s', 'あ' * 3 + '.mp4', trim_file_name='10b', filesystem_encoding='utf-8')
|
||||
test('%(title6)s.%(ext)s', 'あ' * 3 + '.mp4', trim_file_name='11b', filesystem_encoding='utf-8')
|
||||
test('%(title6)s.%(ext)s', 'あ' * 4 + '.mp4', trim_file_name='12b', filesystem_encoding='utf-8')
|
||||
test('%(title6)s.%(ext)s', 'あ' * 6 + '.mp4', trim_file_name='12b', filesystem_encoding='utf-16le')
|
||||
if sys.getfilesystemencoding() == 'utf-8' and platform.system() != 'Windows':
|
||||
test('%(title6)s.%(ext)s', 'あ' * 3 + '.mp4', trim_file_name='9b')
|
||||
test('%(title6)s.%(ext)s', 'あ' * 3 + '.mp4', trim_file_name='10b')
|
||||
test('%(title6)s.%(ext)s', 'あ' * 3 + '.mp4', trim_file_name='11b')
|
||||
test('%(title6)s.%(ext)s', 'あ' * 4 + '.mp4', trim_file_name='12b')
|
||||
elif platform.system() == 'Windows':
|
||||
test('%(title6)s.%(ext)s', 'あ' * 4 + '.mp4', trim_file_name='8b')
|
||||
test('%(title6)s.%(ext)s', 'あ' * 4 + '.mp4', trim_file_name='9b')
|
||||
test('%(title6)s.%(ext)s', 'あ' * 5 + '.mp4', trim_file_name='10b')
|
||||
test('folder/%(title6)s.%(ext)s', f'fol{os.path.sep}あああ.mp4', trim_file_name='3c')
|
||||
|
||||
def test_format_note(self):
|
||||
|
@ -13,6 +13,7 @@
|
||||
import operator
|
||||
import os
|
||||
from pathlib import Path
|
||||
import platform
|
||||
import random
|
||||
import re
|
||||
import shutil
|
||||
@ -267,7 +268,6 @@ class YoutubeDL:
|
||||
outtmpl_na_placeholder: Placeholder for unavailable meta fields.
|
||||
restrictfilenames: Do not allow "&" and spaces in file names
|
||||
trim_file_name: Limit length of filename (extension excluded)
|
||||
filesystem_encoding: Encoding to use when calculating filename length in bytes
|
||||
windowsfilenames: True: Force filenames to be Windows compatible
|
||||
False: Sanitize filenames only minimally
|
||||
This option has no effect when running on Windows
|
||||
@ -1449,7 +1449,7 @@ def parse_trim_file_name(trim_file_name):
|
||||
# no maximum
|
||||
return filename + suffix
|
||||
|
||||
encoding = self.params.get('filesystem_encoding') or sys.getfilesystemencoding()
|
||||
encoding = sys.getfilesystemencoding() if platform.system() != 'Windows' else 'utf-16-le'
|
||||
|
||||
def trim_filename(name: str):
|
||||
if mode == 'b':
|
||||
|
@ -1,4 +1,3 @@
|
||||
import codecs
|
||||
import sys
|
||||
|
||||
if sys.version_info < (3, 9):
|
||||
@ -432,12 +431,6 @@ def metadataparser_actions(f):
|
||||
# Other options
|
||||
validate_regex('trim filenames', opts.trim_file_name, r'(?:\d+[bc]?|notrim)')
|
||||
|
||||
if opts.filesystem_encoding is not None:
|
||||
try:
|
||||
codecs.lookup(opts.filesystem_encoding)
|
||||
except LookupError:
|
||||
raise ValueError(f'Invalid filesystem encoding: {opts.filesystem_encoding}')
|
||||
|
||||
if opts.playlist_items is not None:
|
||||
try:
|
||||
tuple(PlaylistEntries.parse_playlist_items(opts.playlist_items))
|
||||
@ -895,7 +888,6 @@ def parse_options(argv=None):
|
||||
'max_downloads': opts.max_downloads,
|
||||
'prefer_free_formats': opts.prefer_free_formats,
|
||||
'trim_file_name': opts.trim_file_name,
|
||||
'filesystem_encoding': opts.filesystem_encoding,
|
||||
'verbose': opts.verbose,
|
||||
'dump_intermediate_pages': opts.dump_intermediate_pages,
|
||||
'write_pages': opts.write_pages,
|
||||
|
Loading…
Reference in New Issue
Block a user