jhj0517 commited on
Commit
3048545
1 Parent(s): b554e58

patch file name

Browse files
Files changed (1) hide show
  1. modules/subtitle_manager.py +10 -1
modules/subtitle_manager.py CHANGED
@@ -120,4 +120,13 @@ def get_serialized_vtt(dicts):
120
 
121
  def safe_filename(name):
122
  INVALID_FILENAME_CHARS = r'[<>:"/\\|?*\x00-\x1f]'
123
- return re.sub(INVALID_FILENAME_CHARS, '_', name)
 
 
 
 
 
 
 
 
 
 
120
 
121
  def safe_filename(name):
122
  INVALID_FILENAME_CHARS = r'[<>:"/\\|?*\x00-\x1f]'
123
+ safe_name = re.sub(INVALID_FILENAME_CHARS, '_', name)
124
+ # Truncate the filename if it exceeds the max_length (20)
125
+ if len(safe_name) > 20:
126
+ file_extension = safe_name.split('.')[-1]
127
+ if len(file_extension) + 1 < 20:
128
+ truncated_name = safe_name[:20 - len(file_extension) - 1]
129
+ safe_name = truncated_name + '.' + file_extension
130
+ else:
131
+ safe_name = safe_name[:20]
132
+ return safe_name