diff --git a/CMakeLists.txt b/CMakeLists.txt index 3de3781..345117c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ target_link_libraries(YTMusicDL26 PUBLIC ) file(COPY ${CMAKE_SOURCE_DIR}/bin DESTINATION ${CMAKE_BINARY_DIR}) +file(COPY ${CMAKE_SOURCE_DIR}/config DESTINATION ${CMAKE_BINARY_DIR}) if (WIN32) target_link_options(YTMusicDL26 PRIVATE diff --git a/config/config.json b/config/config.json new file mode 100644 index 0000000..1797133 --- /dev/null +++ b/config/config.json @@ -0,0 +1,3 @@ +{ + +} diff --git a/src/main.cpp b/src/main.cpp index 148cf40..458c906 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,19 +1,36 @@ #include +#include #include #include "config.hpp" #include "utils.hpp" auto main(int argc, char* argv[]) -> int { - auto musicDir = "/home/ethanscharlie/Downloads/tmp"; + std::vector urls; - std::vector 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); } diff --git a/src/utils.cpp b/src/utils.cpp index 921561b..4d479be 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -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 ""; +} diff --git a/src/utils.hpp b/src/utils.hpp index 55d23cb..86ada8c 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -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;