1
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp synced 2025-01-19 07:13:05 +01:00

Remove --filesystem-encoding option

This commit is contained in:
7x11x13 2025-01-08 15:00:02 -05:00
parent ac69f9474b
commit 8063b142d9
3 changed files with 12 additions and 15 deletions

View file

@ -2,6 +2,7 @@
# Allow direct execution # Allow direct execution
import os import os
import platform
import sys import sys
import unittest import unittest
from unittest.mock import patch from unittest.mock import patch
@ -930,11 +931,15 @@ class TestYoutubeDL(unittest.TestCase):
# --trim-filenames # --trim-filenames
test('%(title6)s.%(ext)s', '' * 10 + '.mp4') 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='3c')
test('%(title6)s.%(ext)s', '' * 3 + '.mp4', trim_file_name='9b', filesystem_encoding='utf-8') if sys.getfilesystemencoding() == 'utf-8' and platform.system() != 'Windows':
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='9b')
test('%(title6)s.%(ext)s', '' * 3 + '.mp4', trim_file_name='11b', filesystem_encoding='utf-8') test('%(title6)s.%(ext)s', '' * 3 + '.mp4', trim_file_name='10b')
test('%(title6)s.%(ext)s', '' * 4 + '.mp4', trim_file_name='12b', filesystem_encoding='utf-8') test('%(title6)s.%(ext)s', '' * 3 + '.mp4', trim_file_name='11b')
test('%(title6)s.%(ext)s', '' * 6 + '.mp4', trim_file_name='12b', filesystem_encoding='utf-16le') 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') test('folder/%(title6)s.%(ext)s', f'fol{os.path.sep}あああ.mp4', trim_file_name='3c')
def test_format_note(self): def test_format_note(self):

View file

@ -13,6 +13,7 @@ import locale
import operator import operator
import os import os
from pathlib import Path from pathlib import Path
import platform
import random import random
import re import re
import shutil import shutil
@ -267,7 +268,6 @@ class YoutubeDL:
outtmpl_na_placeholder: Placeholder for unavailable meta fields. outtmpl_na_placeholder: Placeholder for unavailable meta fields.
restrictfilenames: Do not allow "&" and spaces in file names restrictfilenames: Do not allow "&" and spaces in file names
trim_file_name: Limit length of filename (extension excluded) 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 windowsfilenames: True: Force filenames to be Windows compatible
False: Sanitize filenames only minimally False: Sanitize filenames only minimally
This option has no effect when running on Windows This option has no effect when running on Windows
@ -1449,7 +1449,7 @@ class YoutubeDL:
# no maximum # no maximum
return filename + suffix 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): def trim_filename(name: str):
if mode == 'b': if mode == 'b':

View file

@ -1,4 +1,3 @@
import codecs
import sys import sys
if sys.version_info < (3, 9): if sys.version_info < (3, 9):
@ -432,12 +431,6 @@ def validate_options(opts):
# Other options # Other options
validate_regex('trim filenames', opts.trim_file_name, r'(?:\d+[bc]?|notrim)') 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: if opts.playlist_items is not None:
try: try:
tuple(PlaylistEntries.parse_playlist_items(opts.playlist_items)) tuple(PlaylistEntries.parse_playlist_items(opts.playlist_items))
@ -895,7 +888,6 @@ def parse_options(argv=None):
'max_downloads': opts.max_downloads, 'max_downloads': opts.max_downloads,
'prefer_free_formats': opts.prefer_free_formats, 'prefer_free_formats': opts.prefer_free_formats,
'trim_file_name': opts.trim_file_name, 'trim_file_name': opts.trim_file_name,
'filesystem_encoding': opts.filesystem_encoding,
'verbose': opts.verbose, 'verbose': opts.verbose,
'dump_intermediate_pages': opts.dump_intermediate_pages, 'dump_intermediate_pages': opts.dump_intermediate_pages,
'write_pages': opts.write_pages, 'write_pages': opts.write_pages,