Bin constant

This commit is contained in:
2026-08-20 12:14:39 -06:00
parent 96276d7639
commit 4fc7457052
3 changed files with 16 additions and 9 deletions
+6
View File
@@ -2,3 +2,9 @@
#define TMP_DOWNLOAD_FOLDER "tmp/download" #define TMP_DOWNLOAD_FOLDER "tmp/download"
#define MAX_THREADS 4 #define MAX_THREADS 4
#ifdef _WIN32
#define BIN_FOLDER "bin/windows"
#else
#define BIN_FOLDER "bin/linux"
#endif
+2 -2
View File
@@ -130,12 +130,12 @@ auto Playlist::urlsFromPlaylist(const std::string& url) -> std::vector<std::stri
std::filesystem::remove(urlsFileLocation); std::filesystem::remove(urlsFileLocation);
ytdlp( ytdlp(
std::format("--js-runtimes \"deno:bin/linux/deno\" " std::format("--js-runtimes \"deno:{}/deno\" "
"--quiet " "--quiet "
"--flat-playlist " "--flat-playlist "
"--print-to-file \"%(webpage_url)s\" " "--print-to-file \"%(webpage_url)s\" "
"{} \"{}\"", "{} \"{}\"",
urlsFileLocation, url)); BIN_FOLDER, urlsFileLocation, url));
std::ifstream f(urlsFileLocation); std::ifstream f(urlsFileLocation);
if (!f.is_open()) { if (!f.is_open()) {
+8 -7
View File
@@ -19,7 +19,7 @@ using json = nlohmann::json;
// This runs in shell, if put through a website interface it would allow for injection // This runs in shell, if put through a website interface it would allow for injection
auto ytdlp(const std::string& args) -> bool { auto ytdlp(const std::string& args) -> bool {
system(std::format("bin/linux/yt-dlp {}", args).c_str()); system(std::format("{}/yt-dlp {}", BIN_FOLDER, args).c_str());
return true; 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(); std::string name = std::filesystem::path(file).filename().string();
name = std::regex_replace(name, std::regex(".mp3"), ""); name = std::regex_replace(name, std::regex(".mp3"), "");
system(std::format("bin/linux/ffmpeg " system(std::format("{}/ffmpeg "
"-hide_banner -loglevel error " "-hide_banner -loglevel error "
"-i \"{}\" " "-i \"{}\" "
"-i \"{}/cover.jpg\" " "-i \"{}/cover.jpg\" "
@@ -40,7 +40,8 @@ auto metadata(const std::string& file, const std::string& artist, const std::str
"-metadata album=\"{}\" " "-metadata album=\"{}\" "
"-metadata track=\"{}\" " "-metadata track=\"{}\" "
"\"{}/{}_{}.mp3\"", "\"{}/{}_{}.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()); .c_str());
} }
@@ -91,13 +92,13 @@ auto downloadVideo(const std::string& url) -> bool {
} }
ytdlp( ytdlp(
std::format("--js-runtimes \"deno:bin/linux/deno\" " std::format("--js-runtimes \"deno:{}/deno\" "
"--quiet " "--quiet "
"-f \"bestaudio/best\" " "-f \"bestaudio/best\" "
"-x --audio-format mp3 " "-x --audio-format mp3 "
"-o \"{}/%(title)s.%(ext)s\" " "-o \"{}/%(title)s.%(ext)s\" "
"{}", "{}",
TMP_DOWNLOAD_FOLDER, url)); BIN_FOLDER, TMP_DOWNLOAD_FOLDER, url));
printf("Finished downloading video %s.\n", url.c_str()); printf("Finished downloading video %s.\n", url.c_str());
return true; return true;
@@ -106,11 +107,11 @@ auto downloadVideo(const std::string& url) -> bool {
auto writeAndReturnDataJson(const std::string& url) -> json { auto writeAndReturnDataJson(const std::string& url) -> json {
std::filesystem::remove("tmp/data.json"); std::filesystem::remove("tmp/data.json");
ytdlp( ytdlp(
std::format("--js-runtimes \"deno:bin/linux/deno\" " std::format("--js-runtimes \"deno:{}/deno\" "
"--dump-single-json " "--dump-single-json "
"\"{}\" " "\"{}\" "
"> tmp/data.json", "> tmp/data.json",
url)); BIN_FOLDER, url));
std::ifstream f("tmp/data.json"); std::ifstream f("tmp/data.json");
if (!f) { if (!f) {