Update app.py
Browse files
app.py
CHANGED
@@ -96,13 +96,28 @@ def transcribe_audio_chunks(chunks):
|
|
96 |
return ' '.join(transcriptions)
|
97 |
|
98 |
def download_file(url):
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
|
107 |
def get_file_info(file_path):
|
108 |
try:
|
|
|
96 |
return ' '.join(transcriptions)
|
97 |
|
98 |
def download_file(url):
|
99 |
+
with requests.Session() as session:
|
100 |
+
response = session.get(url, stream=True, allow_redirects=True)
|
101 |
+
response.raise_for_status()
|
102 |
+
|
103 |
+
# Check if we can get the filename from Content-Disposition header
|
104 |
+
content_disposition = response.headers.get('Content-Disposition')
|
105 |
+
if content_disposition:
|
106 |
+
filename = re.findall("filename=(.+)", content_disposition)[0].strip('"')
|
107 |
+
else:
|
108 |
+
# If not, use a default name with .mp4 extension
|
109 |
+
filename = 'downloaded_video.mp4'
|
110 |
+
|
111 |
+
# Save the content to a temporary file with .mp4 extension
|
112 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix='.mp4') as temp_file:
|
113 |
+
for chunk in response.iter_content(chunk_size=8192):
|
114 |
+
if chunk:
|
115 |
+
temp_file.write(chunk)
|
116 |
+
temp_file_path = temp_file.name
|
117 |
+
|
118 |
+
logger.info(f"File downloaded and saved as: {temp_file_path}")
|
119 |
+
return temp_file_path
|
120 |
+
|
121 |
|
122 |
def get_file_info(file_path):
|
123 |
try:
|