about summary refs log tree commit diff stats
path: root/src/main.cpp
blob: 42ad5415a15d14d446c88f18f82df5a78e408468 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <iostream>
#include <stdlib.h>
#include <cstring>
#include <map>

#include <ytcpp.hpp>
#include <tui.hpp>
#include <video.hpp>
#include <invapi.hpp>
#include <YtdlpWrapper.hpp>
#include <sqliteinterface.hpp>


// namespace py = pybind11;
using namespace std;
using json = nlohmann::json;
namespace fs = std::filesystem;



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) {

                cout << PROGRAM_NAME << " v" << VERSION << endl;
                currentArg = "";
            } else {

                currentArg = argv[i];
            }
        } 
        else {

            if (currentArg == "") {

                if (strncmp(argv[i], "http://", 7) == 0 || strncmp(argv[i], "https://", 8) == 0) {
                    
                    spawn(argv[i], true);
                }
            } else if (currentArg == "-S" || currentArg == "--search") {

                cout << "searching for: " << argv[i] << endl;
                currentArg = "";
            }
            // } else {

            //     cout << currentArg << ": " << argv[i] << endl;
            // }
        }
    }
}

int main(int argc, char **argv) {

    // validateStructConversions();
    parseSysArgs(argc, argv);
    SqliteInterface sqldb;
    // InvidiousApi invapi("https://httpbin.org/get");
    // invapi.test();
    // InvidiousApi::saveInstancesToDb(sqldb);
    vector<InvidiousApi::instance> instances = InvidiousApi::getInstances();
    for (InvidiousApi::instance i: instances) {

        cout << i.url << " " << i.health << " " << i.location << endl;
    }
}