Update app.py
Browse files
app.py
CHANGED
|
@@ -106,16 +106,23 @@ def downloadTubeUpload(query):
|
|
| 106 |
if not best_audio_format:
|
| 107 |
return None
|
| 108 |
|
| 109 |
-
# Step 4: Upload the video file to lalal.ai and return the ID of the uploaded file
|
| 110 |
upload_url = "https://lalal.ai/api/upload/"
|
| 111 |
headers = {
|
| 112 |
-
|
| 113 |
-
|
|
|
|
| 114 |
with requests.get(best_audio_format["url"], stream=True) as r:
|
| 115 |
r.raise_for_status()
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
def split_file(file_id):
|
| 120 |
url_for_split = "https://www.lalal.ai/api/preview/"
|
| 121 |
|
|
|
|
| 106 |
if not best_audio_format:
|
| 107 |
return None
|
| 108 |
|
|
|
|
| 109 |
upload_url = "https://lalal.ai/api/upload/"
|
| 110 |
headers = {
|
| 111 |
+
"Content-Disposition": f"attachment; filename={video_id}.mp4"
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
with requests.get(best_audio_format["url"], stream=True) as r:
|
| 115 |
r.raise_for_status()
|
| 116 |
+
with open("temp.mp4", "wb") as f:
|
| 117 |
+
for chunk in r.iter_content(chunk_size=8192):
|
| 118 |
+
f.write(chunk)
|
| 119 |
+
|
| 120 |
+
with open("temp.mp4", "rb") as f:
|
| 121 |
+
files = {"file": ("temp.mp4", f, "multipart/form-data")}
|
| 122 |
+
response = requests.post(upload_url, headers=headers, files=files)
|
| 123 |
+
upload_response = response.json()
|
| 124 |
+
|
| 125 |
+
return upload_response.get("result", {}).get("id")
|
| 126 |
def split_file(file_id):
|
| 127 |
url_for_split = "https://www.lalal.ai/api/preview/"
|
| 128 |
|