New input system

This commit is contained in:
2026-08-20 11:53:20 -06:00
parent 280c84ac6e
commit 070e583bd2
5 changed files with 41 additions and 6 deletions
+23 -6
View File
@@ -1,19 +1,36 @@
#include <filesystem>
#include <iostream>
#include <string>
#include "config.hpp"
#include "utils.hpp"
auto main(int argc, char* argv[]) -> int {
auto musicDir = "/home/ethanscharlie/Downloads/tmp";
std::vector<std::string> urls;
std::vector<std::string> urls = {
"https://music.youtube.com/playlist?list=OLAK5uy_kwG9Ln_fS_R-Oa8F-JIgs8PPBoRgDe8ok",
"https://www.youtube.com/watch?v=WpmOb-Xanlg",
"https://music.youtube.com/playlist?list=OLAK5uy_kfXTUdgy8U4_-Gg4fUYSy-8RPPvgnSuek&si=7VPceO4X9GEYCb28"};
printf(
"Welcome to YTMusicDL26! You can use playlists or video from youtube or youtube music (youtube music is "
"better).\n");
printf("Type \"end\" when your finished.\n");
int index = 0;
while (true) {
std::string input;
printf("%d: ", index);
std::cin >> input;
if (input == "end") {
break;
}
urls.push_back(input);
index++;
}
printf("Starting rips...\n");
std::string musicDir = musicFolder();
std::filesystem::create_directories(TMP_DOWNLOAD_FOLDER);
for (const std::string& url : urls) {
autoDetermineRip(musicDir, url);
}
+12
View File
@@ -149,3 +149,15 @@ auto autoDetermineRip(const std::string& musicFolder, const std::string& url) ->
return false;
}
auto musicFolder() -> std::string {
#ifdef _WIN32
const char* userProfile = std::getenv("USERPROFILE");
if (userProfile) return std::filesystem::path(userProfile) / "Music";
#else
const char* home = std::getenv("HOME");
if (home) return std::filesystem::path(home) / "Music";
#endif
return "";
}
+2
View File
@@ -18,3 +18,5 @@ auto moveAndSortTmpFilesToFolder(const std::string& folder, const std::string& a
-> bool;
auto autoDetermineRip(const std::string& musicFolder, const std::string& url) -> bool;
auto musicFolder() -> std::string;