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
+1
View File
@@ -28,6 +28,7 @@ target_link_libraries(YTMusicDL26 PUBLIC
) )
file(COPY ${CMAKE_SOURCE_DIR}/bin DESTINATION ${CMAKE_BINARY_DIR}) file(COPY ${CMAKE_SOURCE_DIR}/bin DESTINATION ${CMAKE_BINARY_DIR})
file(COPY ${CMAKE_SOURCE_DIR}/config DESTINATION ${CMAKE_BINARY_DIR})
if (WIN32) if (WIN32)
target_link_options(YTMusicDL26 PRIVATE target_link_options(YTMusicDL26 PRIVATE
+3
View File
@@ -0,0 +1,3 @@
{
}
+23 -6
View File
@@ -1,19 +1,36 @@
#include <filesystem> #include <filesystem>
#include <iostream>
#include <string> #include <string>
#include "config.hpp" #include "config.hpp"
#include "utils.hpp" #include "utils.hpp"
auto main(int argc, char* argv[]) -> int { auto main(int argc, char* argv[]) -> int {
auto musicDir = "/home/ethanscharlie/Downloads/tmp"; std::vector<std::string> urls;
std::vector<std::string> urls = { printf(
"https://music.youtube.com/playlist?list=OLAK5uy_kwG9Ln_fS_R-Oa8F-JIgs8PPBoRgDe8ok", "Welcome to YTMusicDL26! You can use playlists or video from youtube or youtube music (youtube music is "
"https://www.youtube.com/watch?v=WpmOb-Xanlg", "better).\n");
"https://music.youtube.com/playlist?list=OLAK5uy_kfXTUdgy8U4_-Gg4fUYSy-8RPPvgnSuek&si=7VPceO4X9GEYCb28"}; 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); std::filesystem::create_directories(TMP_DOWNLOAD_FOLDER);
for (const std::string& url : urls) { for (const std::string& url : urls) {
autoDetermineRip(musicDir, url); autoDetermineRip(musicDir, url);
} }
+12
View File
@@ -149,3 +149,15 @@ auto autoDetermineRip(const std::string& musicFolder, const std::string& url) ->
return false; 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; -> bool;
auto autoDetermineRip(const std::string& musicFolder, const std::string& url) -> bool; auto autoDetermineRip(const std::string& musicFolder, const std::string& url) -> bool;
auto musicFolder() -> std::string;