#ifndef YTDLPWRAPPER_H #define YTDLPWRAPPER_H #include #include #include namespace Video { struct format { std::string format; std::string url; std::string vcodec; std::string acodec; std::string ext; std::optional quality; std::optional resolution; std::optional height; std::optional width; }; struct thumbnail { std::string url; int preference; int id; std::optional resolution; std::optional height; std::optional width; }; struct video { std::string id; std::string title; std::string url; std::string channelId; std::string channelUrl; std::vector formats; std::vector thumbnails; std::optional uploader; std::optional uploaderId; std::optional uploaderUrl; std::optional duration; std::optional viewcount; std::optional description; }; void to_json(nlohmann::json& j, const format& f); void to_json(nlohmann::json& j, const thumbnail& t); void to_json(nlohmann::json& j, const video& v); void from_json(const nlohmann::json& j, format& f); void from_json(const nlohmann::json& j, thumbnail& t); void from_json(const nlohmann::json& j, video& v); }; class YtdlpWrapper { public: nlohmann::json getJsonSearch(const std::string& searchTerm, int limit = 1); Video::video getVideoByUrl(const std::string& url); std::vector searchVideos(const std::string& searchterm, int limit = 1); private: pybind11::object get_ytdl(); pybind11::object ytdl = pybind11::none(); pybind11::scoped_interpreter guard{}; }; #endif