jhj0517 commited on
Commit
582adb3
1 Parent(s): f02937a

fix long file name truncation

Browse files
Files changed (2) hide show
  1. app.py +1 -0
  2. modules/subtitle_manager.py +3 -0
app.py CHANGED
@@ -203,6 +203,7 @@ parser.add_argument('--server_port', type=int, default=None, help='Gradio server
203
  parser.add_argument('--username', type=str, default=None, help='Gradio authentication username')
204
  parser.add_argument('--password', type=str, default=None, help='Gradio authentication password')
205
  parser.add_argument('--theme', type=str, default=None, help='Gradio Blocks theme')
 
206
  _args = parser.parse_args()
207
 
208
  if __name__ == "__main__":
 
203
  parser.add_argument('--username', type=str, default=None, help='Gradio authentication username')
204
  parser.add_argument('--password', type=str, default=None, help='Gradio authentication password')
205
  parser.add_argument('--theme', type=str, default=None, help='Gradio Blocks theme')
206
+ parser.add_argument('--colab', type=bool, default=False, nargs='?', const=True, help='Is colab user or not')
207
  _args = parser.parse_args()
208
 
209
  if __name__ == "__main__":
modules/subtitle_manager.py CHANGED
@@ -119,8 +119,11 @@ def get_serialized_vtt(dicts):
119
 
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]
 
119
 
120
 
121
  def safe_filename(name):
122
+ from app import _args
123
  INVALID_FILENAME_CHARS = r'[<>:"/\\|?*\x00-\x1f]'
124
  safe_name = re.sub(INVALID_FILENAME_CHARS, '_', name)
125
+ if _args.colab:
126
+ return safe_name
127
  # Truncate the filename if it exceeds the max_length (20)
128
  if len(safe_name) > 20:
129
  file_extension = safe_name.split('.')[-1]