diff options
-rw-r--r-- | CMakeLists.txt | 5 | ||||
-rw-r--r-- | src/main.cpp | 12 |
2 files changed, 10 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 1702629..4500127 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,8 +17,6 @@ FetchContent_Declare(cpr GIT_REPOSITORY https://github.com/libcpr/cpr.git GIT_TAG c4713a704ca12237485ecbfec185f76c2a81bd09) FetchContent_MakeAvailable(cpr) -include(FetchContent) - FetchContent_Declare(ftxui GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui.git GIT_TAG v4.0.0 @@ -33,6 +31,8 @@ endif() FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.2/json.tar.xz) FetchContent_MakeAvailable(json) +find_package(SQLite3 REQUIRED) + add_executable(${PROJECT_NAME} src/main.cpp) target_include_directories(${PROJECT_NAME} PRIVATE src) @@ -42,4 +42,5 @@ target_link_libraries(${PROJECT_NAME} PRIVATE ftxui::dom PRIVATE ftxui::component PRIVATE nlohmann_json::nlohmann_json + PRIVATE SQLite::SQLite3 ) diff --git a/src/main.cpp b/src/main.cpp index 923f30f..fc5c887 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,6 @@ #include <cpr/cpr.h> #include <nlohmann/json.hpp> +#include <sqlite3.h> #include <string> #include <iostream> #include <exception> @@ -48,7 +49,7 @@ vector<string> getInstances() { vector<string> result; cpr::Response r = cpr::Get(cpr::Url{"https://api.invidious.io/instances.json"}, - cpr::Parameters{{"sort_by", "api"}}); + cpr::Parameters{{"sort_by", "health"}}); if (r.status_code > 299) { @@ -57,9 +58,10 @@ vector<string> getInstances() { } json j = json::parse(r.text); - for (json i: j) { - if (i[1]["api"]) { - result.push_back(i.front()); + for ( json i: j ) { + if ( i[1]["api"] != json::value_t::null && i[1]["api"]) { + + result.push_back( i[1]["uri"] ); } } return result; @@ -67,7 +69,7 @@ vector<string> getInstances() { int main() { - cout << renderSearchBar() << endl; + // cout << renderSearchBar() << endl; vector<string> instances = getInstances(); for (auto i: instances) { cout << i << " "; |