aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorComradeCrow <comradecrow@vivaldi.net>2023-05-06 13:01:33 -0700
committerComradeCrow <comradecrow@vivaldi.net>2023-05-06 13:01:33 -0700
commit3212791b7ac63f01da8bb115e68c43a36c3b67a7 (patch)
tree0fac11019a89f12671ee2a13dfb1e9ab235bc892
parent9b0c5473222010c5de405713fdbdad258cc268f3 (diff)
downloadytcpp-3212791b7ac63f01da8bb115e68c43a36c3b67a7.tar.gz
unix spawn is working
-rw-r--r--src/main.cpp60
1 files changed, 36 insertions, 24 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 6f3ce18..3ee071a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -9,6 +9,15 @@
#include <fstream>
#include <filesystem>
#include <stdlib.h>
+#ifdef __unix
+#include <unistd.h>
+#include <spawn.h>
+#elif __posix
+#include <unistd.h>
+#include <spawn.h>
+#elif _WIN32
+#include <windows.h>
+#endif
#include "tui.hpp"
#include "video.hpp"
@@ -60,39 +69,42 @@ void parseSysArgs(int argc, char **argv) {
}
}
+
+
int main(int argc, char **argv) {
parseSysArgs(argc, argv);
-
+ #ifdef _WIN32
+ start mpv
+ bool CreateProcessA()
+ #elif __unix
+ extern char **environ;
- validateStructConversions();
-
- // YtdlpWrapper yt;
- // Video::video vid = yt.getVideoByUrl("https://youtu.be/jy5x7bDYd4o?list=OLAK5uy_kSLxuOA_vBO8SsXaI6PjJbqvsIBnBReGM");
- // cout << vid.id << ", " << vid.url << endl;
- // yt.~YtdlpWrapper();
+ int i{0};
+ while ((environ[i]) != nullptr) {
- // vector<Video::video> response = yt.searchVideos("factorio");
- // for (Video::video i: response) {
+ cout << environ[i++] << endl;
+ }
+ pid_t pid{0};
+ fs::path vidFile("It's Time to Celebrate [K3qjudqERKU].webm");
+ char *const mpvArgs[] = {strdup("mpv"), strdup(fs::absolute(vidFile).c_str()), nullptr};
+
+ i = 0;
+ while ((mpvArgs[i]) != nullptr) {
- // cout << i.id << ", " << i.url << ", " << endl;
- // }
+ cout << mpvArgs[i++] << " ";
+ }
+ cout << endl;
- // nlohmann::json j = yt.getJsonSearch("the very thought of you");
- // cout << j << endl;
+ int result = posix_spawnp(&pid, mpvArgs[0], NULL, NULL, mpvArgs, environ);
+ if (result != 0) {
- // SqliteInterface data;
+ cout << "ERROR RUNNING " << mpvArgs[0] << "! Error code " << result << ": " << strerror(result) << endl;
+ } else {
- // vector<string> instances = getInstances();
- // for (auto i: instances) {
- // cout << i << " ";
- // }
- // cout << endl;
+ cout << "pid: " << pid << endl;
+ }
- string searchTerm;
- int searchingFor{-1};
+ #endif
- Tui ux;
- ux.renderSearchBar(searchTerm, searchingFor);
- cout << searchTerm << searchingFor << endl;
} \ No newline at end of file