diff --git a/src/config.hpp b/src/config.hpp index 5e50167..995f774 100644 --- a/src/config.hpp +++ b/src/config.hpp @@ -2,3 +2,9 @@ #define TMP_DOWNLOAD_FOLDER "tmp/download" #define MAX_THREADS 4 + +#ifdef _WIN32 +#define BIN_FOLDER "bin/windows" +#else +#define BIN_FOLDER "bin/linux" +#endif diff --git a/src/playlist.cpp b/src/playlist.cpp index accfe82..c10d8e0 100644 --- a/src/playlist.cpp +++ b/src/playlist.cpp @@ -130,12 +130,12 @@ auto Playlist::urlsFromPlaylist(const std::string& url) -> std::vector bool { - system(std::format("bin/linux/yt-dlp {}", args).c_str()); + system(std::format("{}/yt-dlp {}", BIN_FOLDER, args).c_str()); return true; } @@ -27,7 +27,7 @@ auto metadata(const std::string& file, const std::string& artist, const std::str std::string name = std::filesystem::path(file).filename().string(); name = std::regex_replace(name, std::regex(".mp3"), ""); - system(std::format("bin/linux/ffmpeg " + system(std::format("{}/ffmpeg " "-hide_banner -loglevel error " "-i \"{}\" " "-i \"{}/cover.jpg\" " @@ -40,7 +40,8 @@ auto metadata(const std::string& file, const std::string& artist, const std::str "-metadata album=\"{}\" " "-metadata track=\"{}\" " "\"{}/{}_{}.mp3\"", - file, TMP_DOWNLOAD_FOLDER, name, artist, album, index, TMP_DOWNLOAD_FOLDER, index, name) + BIN_FOLDER, file, TMP_DOWNLOAD_FOLDER, name, artist, album, index, TMP_DOWNLOAD_FOLDER, index, + name) .c_str()); } @@ -91,13 +92,13 @@ auto downloadVideo(const std::string& url) -> bool { } ytdlp( - std::format("--js-runtimes \"deno:bin/linux/deno\" " + std::format("--js-runtimes \"deno:{}/deno\" " "--quiet " "-f \"bestaudio/best\" " "-x --audio-format mp3 " "-o \"{}/%(title)s.%(ext)s\" " "{}", - TMP_DOWNLOAD_FOLDER, url)); + BIN_FOLDER, TMP_DOWNLOAD_FOLDER, url)); printf("Finished downloading video %s.\n", url.c_str()); return true; @@ -106,11 +107,11 @@ auto downloadVideo(const std::string& url) -> bool { auto writeAndReturnDataJson(const std::string& url) -> json { std::filesystem::remove("tmp/data.json"); ytdlp( - std::format("--js-runtimes \"deno:bin/linux/deno\" " + std::format("--js-runtimes \"deno:{}/deno\" " "--dump-single-json " "\"{}\" " "> tmp/data.json", - url)); + BIN_FOLDER, url)); std::ifstream f("tmp/data.json"); if (!f) {