about summary refs log blame commit diff stats
path: root/src/main.cpp
blob: 6f3ce188156a40e328c0b0cd0fb023a0daf5e920 (plain) (tree)
1
2
3
4
5
6
7
8
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 "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 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") cout << k.key() << ": " << k.value() << endl;
        }
    }
}

void parseSysArgs(int argc, char **argv) {

    for (int i{0}; i < argc; ++i) {
        cout << *(argv + i) << endl;
    }
}

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

    parseSysArgs(argc, argv);
    

    validateStructConversions();
    
    // YtdlpWrapper yt;
    // Video::video vid = yt.getVideoByUrl("https://youtu.be/jy5x7bDYd4o?list=OLAK5uy_kSLxuOA_vBO8SsXaI6PjJbqvsIBnBReGM");
    // cout << vid.id << ", " << vid.url << endl;
    // yt.~YtdlpWrapper();

    // vector<Video::video> response = yt.searchVideos("factorio");
    // for (Video::video i: response) {

    //     cout << i.id << ", " << i.url << ", " << endl; 
    // }

    // nlohmann::json j = yt.getJsonSearch("the very thought of you");
    // cout << j << endl;

    // SqliteInterface data;

    // vector<string> instances = getInstances();
    // for (auto i: instances) {
    //     cout << i << " ";
    // }
    // cout << endl;

    string searchTerm;
    int searchingFor{-1};

    Tui ux;
    ux.renderSearchBar(searchTerm, searchingFor);
    cout << searchTerm << searchingFor << endl;
}