diff options
author | ComradeCrow <comradecrow@vivaldi.net> | 2023-04-27 00:52:55 -0700 |
---|---|---|
committer | ComradeCrow <comradecrow@vivaldi.net> | 2023-04-27 00:52:55 -0700 |
commit | f72e036610d5174ba95fe7c11793ccf02c96ee6d (patch) | |
tree | 096f21caf47bf931809ef36181c55a3f2897b169 /src/main.cpp | |
parent | 304f8dcd8d1e217dce56ccebb9be6f95d558ab31 (diff) | |
download | ytcpp-f72e036610d5174ba95fe7c11793ccf02c96ee6d.tar.gz |
json conversions
json conversions are working, ytdlpwrapper crashes on destruction
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/src/main.cpp b/src/main.cpp index 69309c0..8153a75 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,24 +21,45 @@ using json = nlohmann::json; namespace fs = std::filesystem; void validateStructConversions() { - fs::path here("raycharles.json"); + fs::path here("info.json"); cout << fs::absolute(here) << endl; ifstream ifs; ifs.open(fs::absolute(here).c_str(), ifstream::in); json info = json::parse(ifs); + info = info["entries"][0]; - Video::video v = info["entries"][0].get<Video::video>(); + Video::video v = info.get<Video::video>(); json j = v; - cout << j << endl; + + for (auto& i: j.items()) { + + if (i.key() != "formats") { + + assert(j.at(i.key()) == info.at(i.key())); + cout << i.key() << ": " << i.value() << endl; + } + } + + for (auto i: j["formats"]) { + + for (auto& k: i.items()) { + + if (k.key() == "quality" || k.key() == "resolution") cout << k.key() << ": " << k.value() << endl; + } + } } int main(int argc, char **argv) { - validateStructConversions(); + // validateStructConversions(); - // YtdlpWrapper yt; + YtdlpWrapper yt; + Video::video vid = yt.getVideoByUrl("https://youtu.be/jy5x7bDYd4o?list=OLAK5uy_kSLxuOA_vBO8SsXaI6PjJbqvsIBnBReGM"); + cout << vid.id << ", " << vid.url << endl; + yt.~YtdlpWrapper(); + // vector<Video::video> response = yt.searchVideos("factorio"); // for (Video::video i: response) { @@ -48,9 +69,9 @@ int main(int argc, char **argv) { // nlohmann::json j = yt.getJsonSearch("the very thought of you"); // cout << j << endl; - // cout << VERSION << endl; + cout << VERSION << endl; - // SqliteInterface data; + SqliteInterface data; // vector<string> instances = getInstances(); // for (auto i: instances) { |