diff options
| -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"]} |
