Fully functional
This commit is contained in:
+8
-16
@@ -1,28 +1,20 @@
|
|||||||
#include <curl/curl.h>
|
|
||||||
#include <curl/easy.h>
|
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <nlohmann/json.hpp>
|
|
||||||
#include <regex>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "playlist.hpp"
|
|
||||||
#include "utils.hpp"
|
#include "utils.hpp"
|
||||||
#include "video.hpp"
|
|
||||||
|
|
||||||
auto main(int argc, char* argv[]) -> int {
|
auto main(int argc, char* argv[]) -> int {
|
||||||
auto musicDir = "/home/ethanscharlie/Downloads/tmp";
|
auto musicDir = "/home/ethanscharlie/Downloads/tmp";
|
||||||
std::string url = "https://music.youtube.com/playlist?list=OLAK5uy_kwG9Ln_fS_R-Oa8F-JIgs8PPBoRgDe8ok";
|
|
||||||
std::string videoUrl = "https://www.youtube.com/watch?v=WpmOb-Xanlg";
|
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"};
|
||||||
|
|
||||||
std::filesystem::create_directories(TMP_DOWNLOAD_FOLDER);
|
std::filesystem::create_directories(TMP_DOWNLOAD_FOLDER);
|
||||||
|
|
||||||
// url = std::regex_replace(url, std::regex("music.youtube"), "www.youtube");
|
for (const std::string& url : urls) {
|
||||||
// auto playlist = Playlist(url);
|
autoDetermineRip(musicDir, url);
|
||||||
// playlist.rip(musicDir);
|
}
|
||||||
|
|
||||||
videoUrl = std::regex_replace(videoUrl, std::regex("music.youtube"), "www.youtube");
|
|
||||||
auto video = Video(videoUrl);
|
|
||||||
video.rip(musicDir);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
|
#include "playlist.hpp"
|
||||||
|
#include "video.hpp"
|
||||||
|
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
@@ -135,3 +137,15 @@ auto moveAndSortTmpFilesToFolder(const std::string& folder, const std::string& a
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto autoDetermineRip(const std::string& musicFolder, const std::string& url) -> bool {
|
||||||
|
if (std::regex_search(url, std::regex("youtube.com/playlist"))) {
|
||||||
|
return Playlist(url).rip(musicFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (std::regex_search(url, std::regex("youtube.com/watch"))) {
|
||||||
|
return Video(url).rip(musicFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,3 +16,5 @@ auto writeAndReturnDataJson(const std::string& url) -> nlohmann::json;
|
|||||||
|
|
||||||
auto moveAndSortTmpFilesToFolder(const std::string& folder, const std::string& artist, const std::string& album)
|
auto moveAndSortTmpFilesToFolder(const std::string& folder, const std::string& artist, const std::string& album)
|
||||||
-> bool;
|
-> bool;
|
||||||
|
|
||||||
|
auto autoDetermineRip(const std::string& musicFolder, const std::string& url) -> bool;
|
||||||
|
|||||||
Reference in New Issue
Block a user