about summary refs log tree commit diff stats
path: root/src/main.cpp
diff options
context:
space:
mode:
authorComradeCrow <comradecrow@vivaldi.net>2023-08-30 19:12:22 -0700
committerComradeCrow <comradecrow@vivaldi.net>2023-08-30 19:12:22 -0700
commit12df82c1a90208a822ebdf3d5f4994d55ef7cbea (patch)
treef4e55f053778a637803dd492ae1ac0dcd21ec309 /src/main.cpp
parentfd350c39ce8dab1ebb6bca94abf25e2e782086b3 (diff)
downloadytcpp-12df82c1a90208a822ebdf3d5f4994d55ef7cbea.tar.gz
update
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp94
1 files changed, 8 insertions, 86 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 178575b..42ad541 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,23 +1,9 @@
-// #include <cpr/cpr.h>
-#include <nlohmann/json.hpp>
-// #include <pybind11/embed.h>
-// #include <sqlite3.h>
-// #include <string>
 #include <iostream>
-// #include <exception>
-// #include <vector>
-#include <fstream>
-#include <filesystem>
 #include <stdlib.h>
 #include <cstring>
-#ifdef _WIN32
-#include <windows.h>
-#elif (__unix || __posix)
-#include <unistd.h>
-#include <spawn.h>
-#include <sys/wait.h>
-#endif
+#include <map>
 
+#include <ytcpp.hpp>
 #include <tui.hpp>
 #include <video.hpp>
 #include <invapi.hpp>
@@ -30,77 +16,13 @@ using namespace std;
 using json = nlohmann::json;
 namespace fs = std::filesystem;
 
-void validateStructConversions() {
-    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.get<Video::video>();
-    json j = v;
-    
-    for (auto& i: j.items()) {
-        
-        if (i.key() != "formats") {
-            
-            assert(i.value() == 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" || k.key() == "url") cout << k.key() << ": " << k.value() << endl;
-        }
-    }
-}
-
-void spawn(const char* url, bool wait) {
-
-    #ifdef _WIN32
-
-        start mpv
-        bool CreateProcessA()
-    #elif (__unix || __posix)
-
-        extern char **environ;
-        pid_t pid{0};
-        char *const mpvArgs[] = {strdup("mpv"), strdup(url), nullptr};
 
-        int result = posix_spawnp(&pid, mpvArgs[0], NULL, NULL, mpvArgs, environ);
-        if (result != 0) { 
-
-            cout << "ERROR RUNNING " << mpvArgs[0] << "! Error code " << result << ": " << strerror(result) << endl;
-        } else {
-
-            cout << "pid: " << pid << endl;
-            if (wait) {
-
-                do {
-                    if (waitpid(pid, &result, 0) != -1) {
-
-                        cout << "Child status: " << WEXITSTATUS(result) << endl;
-                    } else {
-
-                        perror("waitpid");
-                        exit(1);
-                    }
-                } while (!WIFEXITED(result) && !WIFSIGNALED(result));
-            }
-        }
-    #endif
-}
 
 void parseSysArgs(int argc, char **argv) {
-
+    multimap <string, string> args;
     string currentArg; 
     for (int i{0}; i < argc; ++i) {
+
         if (strncmp(argv[i], "-", 1) == 0) {
 
             if (strcmp(argv[i], "--version") == 0) {
@@ -141,9 +63,9 @@ int main(int argc, char **argv) {
     // InvidiousApi invapi("https://httpbin.org/get");
     // invapi.test();
     // InvidiousApi::saveInstancesToDb(sqldb);
-    // vector<string> instances = InvidiousApi::getInstances();
-    // for (string i: instances) {
+    vector<InvidiousApi::instance> instances = InvidiousApi::getInstances();
+    for (InvidiousApi::instance i: instances) {
 
-    //     cout << i << endl;
-    // }
+        cout << i.url << " " << i.health << " " << i.location << endl;
+    }
 }
\ No newline at end of file