Skip to content

Commit

Permalink
artist now gets properly set when using music option, and can also be…
Browse files Browse the repository at this point in the history
… pre-set
  • Loading branch information
SenpaiSimon committed Oct 14, 2024
1 parent 3c0b83d commit 81d8402
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 9 deletions.
2 changes: 1 addition & 1 deletion include/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#define JELLY_VIDEO_PLAYLIST_PATH_PATTERN "/%(uploader)s [%(uploader_id)s]/%(playlist_title)s"
#define DEFAULT_VIDEO_PLAYLIST_FILE_NAME(id) "/%(title)s - S" + id + "E%(playlist_index)s [%(id)s].%(ext)s"

#define DEFAULT_MUSIC_PLAYLIST_PATH_PATTERN "/%(uploader)s/%(playlist_title)s"
#define DEFAULT_MUSIC_PLAYLIST_PATH_PATTERN(artist) "/" + artist + "/%(playlist_title)s"
#define DEFAULT_MUSIC_PLAYLIST_FILE_NAME "/%(title)s.%(ext)s"

#define DEFAULT_RSS_PLAYLIST_PATH_PATTERN "/%(playlist_title)s"
Expand Down
12 changes: 12 additions & 0 deletions src/argumentParser/argumentParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ settings argumentParser::parse() {
this->setting.jellyfin = true;
continue;
}

// if(string(this->argValues[i]) == "--albumOverwrite" || string(this->argValues[i]) == "-alo") {
// this->setting.album = this->argValues[i + 1];
// i++;
// continue;
// }

if(string(this->argValues[i]) == "--artistOverwrite" || string(this->argValues[i]) == "-aro") {
this->setting.artist = this->argValues[i + 1];
i++;
continue;
}

tools::printLine();
cout << "==" << endl;
Expand Down
25 changes: 18 additions & 7 deletions src/downloader/downloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ void downloader::setNewDlUrl(string url) {
void downloader::preStart() {
fs::create_directories(conf["videoPath"]);
fs::create_directories(conf["musicPath"]);
fs::create_directories(conf["rssPath"]);
fs::create_directories("temp");
}

Expand All @@ -28,7 +29,6 @@ void downloader::start() {
string outputPath = "";
string tempOutFile = "";
string tempPath = "";
string rssArtistName = "";

// TODO check for missing artist or album and prompt user
if(setting.mediaType == "video") { // single video
Expand Down Expand Up @@ -62,13 +62,22 @@ void downloader::start() {
}
tempOutFile = tempPath + DEFAULT_VIDEO_PLAYLIST_FILE_NAME(to_string(setting.idOverwrite));
} else if (setting.mediaType == "musicPlaylist") { // whole music playlist
if(setting.artist.empty()) {
cout << "==" << endl;
cout << "== Enter " << colors::cyan("Artist Name") << ": ";
getline(cin, setting.artist);
}

outputPath = conf["musicPath"];
tempPath = string(conf["tempPath"]) + DEFAULT_MUSIC_PLAYLIST_PATH_PATTERN;
tempPath = string(conf["tempPath"]) + DEFAULT_MUSIC_PLAYLIST_PATH_PATTERN(setting.artist);
tempOutFile = tempPath + DEFAULT_MUSIC_PLAYLIST_FILE_NAME;
} else if (setting.mediaType == "rss") { // single rss feed
cout << "==" << endl;
cout << "== Enter " << colors::cyan("Artist Name") << ": ";
getline(cin, rssArtistName);
if(setting.artist.empty()) {
cout << "==" << endl;
cout << "== Enter " << colors::cyan("Artist Name") << ": ";
getline(cin, setting.artist);
}

outputPath = conf["rssPath"];
tempPath = string(conf["tempPath"]) + DEFAULT_RSS_PLAYLIST_PATH_PATTERN;
tempOutFile = tempPath + DEFAULT_RSS_PLAYLIST_FILE_NAME;
Expand Down Expand Up @@ -110,14 +119,16 @@ void downloader::start() {
downloadCommand += " --embed-thumbnail --embed-metadata";
downloadCommand += " --parse-metadata \"playlist_autonumber:%(track_number)s\"";
downloadCommand += " --parse-metadata \"playlist_title:%(album)s\"";
downloadCommand += " --parse-metadata \"playlist_autonumber:%(artist)s\""; // hacky workaround to get it to replace stuff
downloadCommand += " --replace-in-metadata \"artist\" \"\\d+\" \"" + setting.artist +"\"";
downloadCommand += " --add-metadata --embed-chapters";
downloadCommand += " -f \"bestaudio[ext=m4a]/bestaudio[ext=aac]/bestaudio[ext=mp3]\" -o \"" + tempOutFile + "\"";
} else if (setting.mediaType == "rss") {
downloadCommand += " --embed-thumbnail --embed-metadata";
downloadCommand += " --parse-metadata \"playlist_autonumber:%(track_number)s\"";
downloadCommand += " --parse-metadata \"playlist_title:%(album)s\"";
downloadCommand += " --parse-metadata \"playlist_autonumber:%(artist)s\"";
downloadCommand += " --replace-in-metadata \"artist\" \"\\d+\" \"" + rssArtistName +"\"";
downloadCommand += " --parse-metadata \"playlist_autonumber:%(artist)s\""; // hacky workaround to get it to replace stuff
downloadCommand += " --replace-in-metadata \"artist\" \"\\d+\" \"" + setting.artist +"\"";
downloadCommand += " --add-metadata --embed-chapters";
downloadCommand += " -f \"bestaudio[ext=m4a]/bestaudio[ext=aac]/bestaudio[ext=mp3]\" -o \"" + tempOutFile + "\"";
}
Expand Down
2 changes: 1 addition & 1 deletion src/idExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void idExtractor::extractData() {
if(setting->mediaType == "musicPlaylist") {
// this path is without a ending slash /
playlistPath = string(conf["musicPath"]) + \
tools::executeCommand(YT_DLP_PARSE_PATH(DEFAULT_MUSIC_PLAYLIST_PATH_PATTERN, setting->dlUrl));
tools::executeCommand(YT_DLP_PARSE_PATH(DEFAULT_MUSIC_PLAYLIST_PATH_PATTERN(setting->artist), setting->dlUrl));
// also without a ending slash /
channelPath = playlistPath;
channelPath = channelPath.erase(channelPath.find_last_of("/"));
Expand Down
3 changes: 3 additions & 0 deletions src/misc/tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ void tools::printHelp() {
cout << "== -ido, --idOverwrite [num] -- optional" << endl;
cout << "==\tOverwrite the auto ID" << endl;
cout << "==" << endl;
cout << "== -aro, --artistOverwrite [album name] -- optional" << endl;
cout << "==\tPre-Set the Album to set for music and rss" << endl;
cout << "==" << endl;
tools::printLine();
}

Expand Down

0 comments on commit 81d8402

Please sign in to comment.