jpjp9292 commited on
Commit
1b61d80
Β·
verified Β·
1 Parent(s): d579a03

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -28
app.py CHANGED
@@ -63,42 +63,17 @@ def convert_mp4_to_mp3(video_file_path, output_dir):
63
  video.close()
64
  return output_path
65
 
66
- # def mp4_to_mp3_converter(video_file):
67
- # # μ—…λ‘œλ“œ μ‹œκ°„ ν‘œμ‹œ
68
- # upload_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
69
- # print(f"File uploaded at: {upload_time}")
70
-
71
- # # λΉ„λ””μ˜€ 파일이 없을 λ•Œ 처리
72
- # if video_file is None:
73
- # return "Error: No video file was uploaded."
74
-
75
- # # μ €μž₯ 경둜 μ„€μ •
76
- # modeltarget = "mp4_to_mp3_conversion"
77
- # save_path = os.path.join("/home/user/app", modeltarget)
78
- # os.makedirs(save_path, exist_ok=True)
79
-
80
- # # μ‚¬μš©μžμ—κ²Œ μ—…λ‘œλ“œ 쀑 λ©”μ‹œμ§€ λ°˜ν™˜
81
- # upload_message = "μ™„λ£Œλ˜μ—ˆμŠ΅λ‹ˆλ‹€. λ‹€μš΄λ°›μ•„μ„œ ν™•μΈν•΄μ£Όμ„Έμš”."
82
-
83
- # # MP3 λ³€ν™˜ ν›„ 파일 경둜 λ°˜ν™˜
84
- # try:
85
- # time.sleep(1) # μž μ‹œ λŒ€κΈ°
86
- # mp3_file_path = convert_mp4_to_mp3(video_file.name, save_path)
87
- # return upload_message, mp3_file_path # λ‹€μš΄λ‘œλ“œλ₯Ό μœ„ν•œ 파일 경둜 λ°˜ν™˜
88
- # except Exception as e:
89
- # return f"Error occurred during conversion: {str(e)}"
90
-
91
  def mp4_to_mp3_converter(video_file):
92
  # λΉ„λ””μ˜€ 파일이 없을 λ•Œ 처리
93
  if video_file is None:
94
- return "Error: No video file was uploaded."
95
 
96
  # 파일 ν™•μž₯자 체크
97
  allowed_extensions = ['mp4', 'webm', 'avi', 'mov', 'mkv']
98
  file_extension = os.path.splitext(video_file.name)[1][1:].lower()
99
 
100
  if file_extension not in allowed_extensions:
101
- return f"Error: Unsupported file format. Please upload a file with one of the following extensions: {', '.join(allowed_extensions)}"
102
 
103
  # μ €μž₯ 경둜 μ„€μ •
104
  modeltarget = "mp4_to_mp3_conversion"
@@ -110,7 +85,7 @@ def mp4_to_mp3_converter(video_file):
110
  mp3_file_path = convert_mp4_to_mp3(video_file.name, save_path)
111
  return mp3_file_path # λ‹€μš΄λ‘œλ“œλ₯Ό μœ„ν•œ 파일 경둜 λ°˜ν™˜
112
  except Exception as e:
113
- return f"Error occurred during conversion: {str(e)}"
114
 
115
 
116
 
 
63
  video.close()
64
  return output_path
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  def mp4_to_mp3_converter(video_file):
67
  # λΉ„λ””μ˜€ 파일이 없을 λ•Œ 처리
68
  if video_file is None:
69
+ return "였λ₯˜: μ—…λ‘œλ“œλœ λΉ„λ””μ˜€ 파일이 μ—†μŠ΅λ‹ˆλ‹€."
70
 
71
  # 파일 ν™•μž₯자 체크
72
  allowed_extensions = ['mp4', 'webm', 'avi', 'mov', 'mkv']
73
  file_extension = os.path.splitext(video_file.name)[1][1:].lower()
74
 
75
  if file_extension not in allowed_extensions:
76
+ return f"였λ₯˜: μ§€μ›λ˜μ§€ μ•ŠλŠ” 파일 ν˜•μ‹μž…λ‹ˆλ‹€. λ‹€μŒ ν™•μž₯자 쀑 ν•˜λ‚˜μ˜ νŒŒμΌμ„ μ—…λ‘œλ“œν•˜μ„Έμš”: {', '.join(allowed_extensions)}"
77
 
78
  # μ €μž₯ 경둜 μ„€μ •
79
  modeltarget = "mp4_to_mp3_conversion"
 
85
  mp3_file_path = convert_mp4_to_mp3(video_file.name, save_path)
86
  return mp3_file_path # λ‹€μš΄λ‘œλ“œλ₯Ό μœ„ν•œ 파일 경둜 λ°˜ν™˜
87
  except Exception as e:
88
+ return f"λ³€ν™˜ 쀑 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€: {str(e)}"
89
 
90
 
91