Update app.py
Browse files
app.py
CHANGED
|
@@ -14,6 +14,8 @@ def download_video():
|
|
| 14 |
if not video_id:
|
| 15 |
return jsonify({'error': 'Missing video ID'}), 400
|
| 16 |
|
|
|
|
|
|
|
| 17 |
try:
|
| 18 |
# YouTube URLを作成
|
| 19 |
youtube_url = f'https://www.youtube.com/watch?v={video_id}'
|
|
@@ -55,9 +57,9 @@ def download_video():
|
|
| 55 |
|
| 56 |
finally:
|
| 57 |
# クリーンアップ: 使用後にファイルを削除
|
| 58 |
-
if os.path.exists(file_path):
|
| 59 |
os.remove(file_path)
|
| 60 |
|
| 61 |
|
| 62 |
if __name__ == '__main__':
|
| 63 |
-
app.run(debug=True, host='0.0.0.0'
|
|
|
|
| 14 |
if not video_id:
|
| 15 |
return jsonify({'error': 'Missing video ID'}), 400
|
| 16 |
|
| 17 |
+
file_path = None # file_path を事前に初期化
|
| 18 |
+
|
| 19 |
try:
|
| 20 |
# YouTube URLを作成
|
| 21 |
youtube_url = f'https://www.youtube.com/watch?v={video_id}'
|
|
|
|
| 57 |
|
| 58 |
finally:
|
| 59 |
# クリーンアップ: 使用後にファイルを削除
|
| 60 |
+
if file_path and os.path.exists(file_path):
|
| 61 |
os.remove(file_path)
|
| 62 |
|
| 63 |
|
| 64 |
if __name__ == '__main__':
|
| 65 |
+
app.run(debug=True, host='0.0.0.0')
|