From 354bdd39c2823964f61d75856b418c710b7a6997 Mon Sep 17 00:00:00 2001 From: A Farzat Date: Sat, 4 Oct 2025 09:57:01 +0300 Subject: Add a component to interact with yt-dlp --- components/ytdlp/__init__.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 components/ytdlp/__init__.py (limited to 'components/ytdlp/__init__.py') 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"]} -- cgit v1.2.3-70-g09d2