summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorA Farzat <a@farzat.xyz>2025-10-04 09:57:01 +0300
committerA Farzat <a@farzat.xyz>2025-10-04 09:57:01 +0300
commit354bdd39c2823964f61d75856b418c710b7a6997 (patch)
treeeeb69265810ad198442b5a361e660aed6e001658 /components
parenta61527e1593324d20c9992d95622c58dce303613 (diff)
downloadcsca5028-354bdd39c2823964f61d75856b418c710b7a6997.tar.gz
csca5028-354bdd39c2823964f61d75856b418c710b7a6997.zip
Add a component to interact with yt-dlp
Diffstat (limited to 'components')
-rw-r--r--components/ytdlp/__init__.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/components/ytdlp/__init__.py b/components/ytdlp/__init__.py
new file mode 100644
index 0000000..c4bd4d0
--- /dev/null
+++ b/components/ytdlp/__init__.py
@@ -0,0 +1,9 @@
+from typing import Any, Dict
+from json import dumps
+from yt_dlp import YoutubeDL # type: ignore
+
+def obtain_vid_info(url: str) -> Dict[str, Any]:
+ ydl_opts = { "check_formats": False, }
+ with YoutubeDL(ydl_opts) as ydl:
+ info = ydl.extract_info(url, download=False)
+ return {"duration": info["duration"]}