Spaces:
Running
Running
Create social.py
Browse files- ingestion/social.py +21 -0
ingestion/social.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import tempfile
|
| 2 |
+
import yt_dlp
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def download_social(url):
|
| 6 |
+
|
| 7 |
+
output = tempfile.NamedTemporaryFile(
|
| 8 |
+
delete=False,
|
| 9 |
+
suffix=".mp4"
|
| 10 |
+
).name
|
| 11 |
+
|
| 12 |
+
ydl_opts = {
|
| 13 |
+
"outtmpl": output,
|
| 14 |
+
"format": "mp4",
|
| 15 |
+
"quiet": True
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
| 19 |
+
ydl.download([url])
|
| 20 |
+
|
| 21 |
+
return output
|