about summary refs log tree commit diff stats
path: root/src/invapi.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/invapi.cpp')
-rw-r--r--src/invapi.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/invapi.cpp b/src/invapi.cpp
index 3fd6632..59e91bf 100644
--- a/src/invapi.cpp
+++ b/src/invapi.cpp
@@ -15,13 +15,15 @@ using json = nlohmann::json;
 InvidiousApi::InvidiousApi(const string& url) {
 
     instanceUrl = url;
+    
 }
 
 vector<string> InvidiousApi::getInstances() {
 
     vector<string> result;
     cpr::Response r = cpr::Get(cpr::Url{"https://api.invidious.io/instances.json"}, 
-        cpr::Parameters{{"sort_by", "health"}, {"fields", "uri,api"}});
+        cpr::Parameters{{"sort_by", "health"}, {"fields", "uri,api"}},
+        cpr::Timeout{5000});
 
     if (r.status_code > 299) {
         
@@ -42,7 +44,8 @@ vector<string> InvidiousApi::getInstances() {
 void InvidiousApi::saveInstancesToDb(SqliteInterface& sqldb) {
 
     cpr::Response r = cpr::Get(cpr::Url{"https://api.invidious.io/instances.json"}, 
-        cpr::Parameters{{"sort_by", "health"}, {"fields", "uri,api,health,location"}});
+        cpr::Parameters{{"sort_by", "health"}, {"fields", "uri,api,health,location"}}, 
+        cpr::Timeout{5000});
 
     if (r.status_code > 299) {
         
@@ -59,6 +62,16 @@ void InvidiousApi::saveInstancesToDb(SqliteInterface& sqldb) {
     }    
 }
 
+void InvidiousApi::test() {
+
+    session.SetUrl(cpr::Url{instanceUrl});
+    session.SetParameters(cpr::Parameters{{"hello", "world"}});
+    cpr::Response new_r = session.Get();
+
+    cout << new_r.url << endl;
+    cout << new_r.text << endl;
+}
+
 std::string InvidiousApi::getInstance() {
 
     return instanceUrl;