diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/YtdlpWrapper.cpp | 2 | ||||
-rw-r--r-- | src/YtdlpWrapper.hpp | 35 | ||||
-rw-r--r-- | src/invapi.cpp | 1 | ||||
-rw-r--r-- | src/main.cpp | 13 | ||||
-rw-r--r-- | src/sqliteinterface.cpp | 2 | ||||
-rw-r--r-- | src/sqliteinterface.hpp | 8 |
6 files changed, 48 insertions, 13 deletions
diff --git a/src/YtdlpWrapper.cpp b/src/YtdlpWrapper.cpp index 2b87a62..9e27a1c 100644 --- a/src/YtdlpWrapper.cpp +++ b/src/YtdlpWrapper.cpp @@ -24,7 +24,7 @@ py::object YtdlpWrapper::get_ytdl() { return ytdl; } -json YtdlpWrapper::getJsonSearch(const string& searchTerm, int limit) { +json YtdlpWrapper::getJsonSearch(const std::string& searchTerm, int limit) { py::dict info = get_ytdl().attr("extract_info")("ytsearch"+std::to_string(limit)+":"+searchTerm, "download"_a=py::bool_(false)); return json::parse(pyDictToJsonString(info)); diff --git a/src/YtdlpWrapper.hpp b/src/YtdlpWrapper.hpp index f7cc256..9dbd3a2 100644 --- a/src/YtdlpWrapper.hpp +++ b/src/YtdlpWrapper.hpp @@ -4,12 +4,45 @@ #include <pybind11/embed.h> #include <nlohmann/json.hpp> +namespace Video { + + struct format { + + std::optional<float> quality; + std::string url; + std::string vcodec; + std::string acodec; + }; + + struct thumbnail { + + std::string url; + std::int preference; + std::int id; + std::optional<std::string> resolution; + } + + struct video { + + std::string id; + std::string title; + std::string url; + std::string channel; + std::int duration; + std::optional<int> viewcount; + std::optional<std::string> description; + + } +} + class YtdlpWrapper { + public: - nlohmann::json getJsonSearch(const string& searchTerm, int limit = 1); + nlohmann::json getJsonSearch(const std::string& searchTerm, int limit = 1); private: pybind11::object get_ytdl(); pybind11::object ytdl = pybind11::none(); + pybind11::scoped_interpreter guard{}; }; diff --git a/src/invapi.cpp b/src/invapi.cpp index 47a9575..b96d18b 100644 --- a/src/invapi.cpp +++ b/src/invapi.cpp @@ -1,5 +1,6 @@ #include <string> #include <vector> +#include <iostream> #include <cpr/cpr.h> #include <nlohmann/json.hpp> diff --git a/src/main.cpp b/src/main.cpp index f258c24..992761a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,24 +1,25 @@ #include <cpr/cpr.h> #include <nlohmann/json.hpp> +#include <pybind11/embed.h> #include <sqlite3.h> #include <string> #include <iostream> #include <exception> #include <vector> -#include "tui.cpp" -#include "invapi.cpp" -#include "YtdlpWrapper.cpp" +#include "tui.hpp" +#include "invapi.hpp" +#include "YtdlpWrapper.hpp" +namespace py = pybind11; using namespace std; int main() { - py::scoped_interpreter guard{}; YtdlpWrapper yt; - // nlohmann::json j = yt.getJsonSearch("All Quiet on the Western Front Ost"); - // cout << j << endl; + nlohmann::json j = yt.getJsonSearch("the very thought of you"); + cout << j << endl; // vector<string> instances = getInstances(); // for (auto i: instances) { diff --git a/src/sqliteinterface.cpp b/src/sqliteinterface.cpp index 1552063..6b244dc 100644 --- a/src/sqliteinterface.cpp +++ b/src/sqliteinterface.cpp @@ -1,3 +1,3 @@ #include <string> #include <sqlite3.h> - +#include "sqliteinterface.hpp" diff --git a/src/sqliteinterface.hpp b/src/sqliteinterface.hpp index a7f469e..6a38d2c 100644 --- a/src/sqliteinterface.hpp +++ b/src/sqliteinterface.hpp @@ -1,7 +1,7 @@ -#ifndef invapi -#define invapi -#include "sqliteinterface.cpp" - +#ifndef SQLITEINTERFACE_H +#define SQLITEINTERFACE_H +#include <string> +#include <sqlite3.h> #endif \ No newline at end of file |