From 1082974bf046a94b4a52df6e8b3b3649a5bb85d6 Mon Sep 17 00:00:00 2001 From: ComradeCrow Date: Sat, 1 Apr 2023 01:48:32 -0700 Subject: minor update --- CMakeLists.txt | 5 +++-- 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 #include +#include #include #include #include @@ -48,7 +49,7 @@ vector getInstances() { vector 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 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 getInstances() { int main() { - cout << renderSearchBar() << endl; + // cout << renderSearchBar() << endl; vector instances = getInstances(); for (auto i: instances) { cout << i << " "; -- cgit 1.4.1-2-gfad0