about summary refs log tree commit diff stats
path: root/src/YtdlpWrapper.hpp
blob: b1633ca9705d6f52a68a05003e8cc93b5a92dea4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef YTDLPWRAPPER_H
#define YTDLPWRAPPER_H
#include <string>
#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;
        int preference;
        int id;
        std::optional<std::string> resolution;
    };

    struct video {

        std::string id;
        std::string title;
        std::string url;
        std::string channel;
        std::optional<int> duration;
        std::optional<int> viewcount;
        std::optional<std::string> description;
        std::vector<format> formats;
        std::vector<thumbnail> thumbnails;
    };
}

class YtdlpWrapper {

    public:
        nlohmann::json getJsonSearch(const std::string& searchTerm, int limit = 1);
    private:
        pybind11::object get_ytdl();
        pybind11::object ytdl = pybind11::none();
        pybind11::scoped_interpreter guard{};
};


#endif