diff options
| author | A Farzat <a@farzat.xyz> | 2025-10-04 09:57:01 +0300 |
|---|---|---|
| committer | A Farzat <a@farzat.xyz> | 2025-10-04 09:57:01 +0300 |
| commit | 354bdd39c2823964f61d75856b418c710b7a6997 (patch) | |
| tree | eeb69265810ad198442b5a361e660aed6e001658 | |
| parent | a61527e1593324d20c9992d95622c58dce303613 (diff) | |
| download | csca5028-354bdd39c2823964f61d75856b418c710b7a6997.tar.gz csca5028-354bdd39c2823964f61d75856b418c710b7a6997.zip | |
Add a component to interact with yt-dlp
| -rw-r--r-- | components/ytdlp/__init__.py | 9 |
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"]} |
