Skip to content

Commit

Permalink
Merge pull request #476 from niwa2/youtube_file_name_length
Browse files Browse the repository at this point in the history
increase possible file name length for youtube transcriptions
  • Loading branch information
jhj0517 authored Jan 24, 2025
2 parents 0721cc0 + 0da5b40 commit 44c0681
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions modules/utils/subtitle_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,13 +444,14 @@ def generate_file(

def safe_filename(name):
INVALID_FILENAME_CHARS = r'[<>:"/\\|?*\x00-\x1f]'
MAX_FILENAME_LENGTH = 200
safe_name = re.sub(INVALID_FILENAME_CHARS, '_', name)
# Truncate the filename if it exceeds the max_length (20)
if len(safe_name) > 20:
# Truncate the filename if it exceeds the max_length (MAX_FILENAME_LENGTH)
if len(safe_name) > MAX_FILENAME_LENGTH:
file_extension = safe_name.split('.')[-1]
if len(file_extension) + 1 < 20:
truncated_name = safe_name[:20 - len(file_extension) - 1]
if len(file_extension) + 1 < MAX_FILENAME_LENGTH:
truncated_name = safe_name[:MAX_FILENAME_LENGTH - len(file_extension) - 1]
safe_name = truncated_name + '.' + file_extension
else:
safe_name = safe_name[:20]
safe_name = safe_name[:MAX_FILENAME_LENGTH]
return safe_name

0 comments on commit 44c0681

Please sign in to comment.