|
@@ -33,26 +33,60 @@ db::video getVideoByYTID(std::string yt_id) {
|
|
|
return output;
|
|
|
}
|
|
|
|
|
|
-int main(int argc, char **argv) {
|
|
|
- if (argc == 1) {
|
|
|
- std::cout << "Программа не принимает 0 аргументов";
|
|
|
- exit(1);
|
|
|
+int main(int argc, char** argv) {
|
|
|
+ // ==Инициализация==
|
|
|
+ // --Язык--
|
|
|
+ std::locale::global(std::locale(""));
|
|
|
+
|
|
|
+ // --Аргументы приложения--
|
|
|
+ Glib::ustring config_path;
|
|
|
+ Glib::OptionEntry opt_config_path = Glib::OptionEntry();
|
|
|
+ opt_config_path.set_long_name("config");
|
|
|
+ opt_config_path.set_short_name('c');
|
|
|
+ opt_config_path.set_flags(Glib::OptionEntry::Flags::NONE);
|
|
|
+ opt_config_path.set_description("Path to JSON configuration file");
|
|
|
+ opt_config_path.set_arg_description("<path to config>");
|
|
|
+
|
|
|
+ Glib::OptionContext option_context = Glib::OptionContext(
|
|
|
+ "- launcher for mpv to watch youtube videos"
|
|
|
+ );
|
|
|
+ Glib::OptionGroup main_group = Glib::OptionGroup(
|
|
|
+ "Main option group",
|
|
|
+ "main option description",
|
|
|
+ "no help."
|
|
|
+ );
|
|
|
+ main_group.add_entry(opt_config_path, config_path);
|
|
|
+ option_context.set_main_group(main_group);
|
|
|
+
|
|
|
+ try {
|
|
|
+ option_context.parse(argc, argv);
|
|
|
+ } catch (Glib::OptionError* e) {
|
|
|
+ std::cout << e->what();
|
|
|
+ return 1;
|
|
|
}
|
|
|
|
|
|
- // --Инициализация--
|
|
|
- std::locale::global(std::locale(""));
|
|
|
+ // --Получение данных из файла настроек--
|
|
|
+ // TODO
|
|
|
+ std::string db_path = ":memory:";
|
|
|
+ std::string api_key = "key";
|
|
|
+
|
|
|
+ // --Общая инициализация--
|
|
|
curl_global_init(CURL_GLOBAL_ALL);
|
|
|
- db::databaseInit(argv[1]);
|
|
|
+ db::databaseInit(db_path);
|
|
|
db::createTables();
|
|
|
- ytapi::youtubeInit(argv[2]);
|
|
|
+ ytapi::youtubeInit(api_key);
|
|
|
|
|
|
- db::video found;
|
|
|
- std::vector<std::string> video_ids = ytapi::getVideoIDsByQuery(argv[3]);
|
|
|
- for (auto id : video_ids) {
|
|
|
- found = getVideoByYTID(id);
|
|
|
+ // ==Запуск приложения==
|
|
|
+ auto app = Gtk::Application::create("com.github.aquadim.YTMPV");
|
|
|
+ return app->make_window_and_run<components::MainWindow>(argc, argv);
|
|
|
|
|
|
- std::cout << found.title << ":" << found.author_obj.name << std::endl;
|
|
|
- }
|
|
|
+ //~ db::video found;
|
|
|
+ //~ std::vector<std::string> video_ids = ytapi::getVideoIDsByQuery(argv[3]);
|
|
|
+ //~ for (auto id : video_ids) {
|
|
|
+ //~ found = getVideoByYTID(id);
|
|
|
+
|
|
|
+ //~ std::cout << found.title << ":" << found.author_obj.name << std::endl;
|
|
|
+ //~ }
|
|
|
|
|
|
//~ std::ifstream ifs("example.json");
|
|
|
//~ std::string content(
|