Skip to content

Commit

Permalink
added functionality for jellyfin using -j
Browse files Browse the repository at this point in the history
  • Loading branch information
SenpaiSimon committed Aug 14, 2024
1 parent d4906ae commit 9439642
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 7 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
Easy to use binary wrapper for using [yt-dlp](https://github.com/yt-dlp/yt-dlp).

# What it does
* This creates the Folder-Structures and also the File-Names exactly like it's needed for using in a Plex-Library.
* This creates the Folder-Structures and also the File-Names exactly like it's needed for using in a Plex/Jellyfin Library.

* For Plex you have to use the [YouTube-Agent](https://github.com/ZeroQI/YouTube-Agent.bundle) alongside with the [Absolute-Series-Scanner](https://github.com/ZeroQI/Absolute-Series-Scanner) for your library to look beautiful.
* For Jellyfin you have to use the [YouTube Plugin](https://github.com/ankenyr/jellyfin-youtube-metadata-plugin)

# Features
* Embeds Video metadata into the video itself
Expand All @@ -16,6 +17,7 @@ Easy to use binary wrapper for using [yt-dlp](https://github.com/yt-dlp/yt-dlp).
* Downloads metadata as info.json for plex
* Downloads and embeds english and german subtitles if available
* This can also download RSS-Feeds -- use "rss" option for that
* Also supports naming schemes for Jellyfin

# Requirements

Expand Down Expand Up @@ -81,6 +83,9 @@ This will print something like:
== -r, --reverse
== Reverse the order of the given playlist or rss feed
==
== -j, --jellyfin
== Apply naming scheme for jellyfin instead of plex
==
== -io, --indexOverwrite [num] -- optional
== Overwrite the playlist index
==
Expand Down
1 change: 1 addition & 0 deletions include/argumentParser/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ class settings

string cwd;

bool jellyfin;
settings();
};
2 changes: 2 additions & 0 deletions include/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
#define DEFAULT_MUSIC_FILE_NAME "/%(title)s [%(id)s].%(ext)s"

#define DEFAULT_VIDEO_PATH_PATTERN(folder) "/%(uploader)s/" + folder
#define JELLY_VIDEO_PATH_PATTERN(folder) "/%(uploader)s [%(uploader_id)s]/" + folder
#define DEFAULT_VIDEO_FILE_NAME "/%(title)s [%(id)s].%(ext)s"

#define DEFAULT_VIDEO_PLAYLIST_PATH_PATTERN "/%(uploader)s/%(playlist_title)s [youtube-%(playlist_id)s]"
#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"
Expand Down
5 changes: 5 additions & 0 deletions src/argumentParser/argumentParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ settings argumentParser::parse() {
this->setting.reverse = true;
continue;
}

if(string(this->argValues[i]) == "--jellyfin" || string(this->argValues[i]) == "-j") {
this->setting.jellyfin = true;
continue;
}

tools::printLine();
cout << "==" << endl;
Expand Down
1 change: 1 addition & 0 deletions src/argumentParser/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ settings::settings() {
this->reverse = false;
this->album = "";
this->artist = "";
this->jellyfin = false;

char cCurrentPath[FILENAME_MAX];
if (GetCurrentDir(cCurrentPath, sizeof(cCurrentPath))) {
Expand Down
12 changes: 10 additions & 2 deletions src/downloader/downloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ void downloader::start() {
getline(cin, this->customFolder);
}
outputPath = conf["videoPath"];
tempPath = string(conf["tempPath"]) + DEFAULT_VIDEO_PATH_PATTERN(this->customFolder);
if(setting.jellyfin) {
tempPath = string(conf["tempPath"]) + JELLY_VIDEO_PATH_PATTERN(this->customFolder);
} else {
tempPath = string(conf["tempPath"]) + DEFAULT_VIDEO_PATH_PATTERN(this->customFolder);
}
tempOutFile = tempPath + DEFAULT_VIDEO_FILE_NAME;
} else if (setting.mediaType == "music") { // single music file
cout << "==" << endl;
Expand All @@ -46,7 +50,11 @@ void downloader::start() {
tempOutFile = tempPath + DEFAULT_MUSIC_FILE_NAME;
} else if (setting.mediaType == "videoPlaylist") { // whole video playlist
outputPath = conf["videoPath"];
tempPath = string(conf["tempPath"]) + DEFAULT_VIDEO_PLAYLIST_PATH_PATTERN;
if(setting.jellyfin) {
tempPath = string(conf["tempPath"]) + JELLY_VIDEO_PLAYLIST_PATH_PATTERN;
} else {
tempPath = string(conf["tempPath"]) + DEFAULT_VIDEO_PLAYLIST_PATH_PATTERN;
}
tempOutFile = tempPath + DEFAULT_VIDEO_PLAYLIST_FILE_NAME(to_string(setting.idOverwrite));
} else if (setting.mediaType == "musicPlaylist") { // whole music playlist
outputPath = conf["musicPath"];
Expand Down
14 changes: 11 additions & 3 deletions src/idExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,31 @@ void idExtractor::extractData() {
// setup paths and names -- todo fill in artist and album
if(setting->mediaType == "videoPlaylist") {
// this path is without a ending slash /
playlistPath = string(conf["videoPath"]) + tools::executeCommand(YT_DLP_PARSE_PATH(DEFAULT_VIDEO_PLAYLIST_PATH_PATTERN, setting->dlUrl));
if(setting->jellyfin) {
playlistPath = string(conf["videoPath"]) + \
tools::executeCommand(YT_DLP_PARSE_PATH(JELLY_VIDEO_PLAYLIST_PATH_PATTERN, setting->dlUrl));
} else {
playlistPath = string(conf["videoPath"]) + \
tools::executeCommand(YT_DLP_PARSE_PATH(DEFAULT_VIDEO_PLAYLIST_PATH_PATTERN, setting->dlUrl));
}
// also without a ending slash /
channelPath = playlistPath;
channelPath = channelPath.erase(channelPath.find_last_of("/"));
}

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));
playlistPath = string(conf["musicPath"]) + \
tools::executeCommand(YT_DLP_PARSE_PATH(DEFAULT_MUSIC_PLAYLIST_PATH_PATTERN, setting->dlUrl));
// also without a ending slash /
channelPath = playlistPath;
channelPath = channelPath.erase(channelPath.find_last_of("/"));
}

if(setting->mediaType == "rss") {
// this path is without a ending slash /
playlistPath = string(conf["rssPath"]) + tools::executeCommand(YT_DLP_PARSE_PATH(DEFAULT_RSS_PLAYLIST_PATH_PATTERN, setting->dlUrl));
playlistPath = string(conf["rssPath"]) + \
tools::executeCommand(YT_DLP_PARSE_PATH(DEFAULT_RSS_PLAYLIST_PATH_PATTERN, setting->dlUrl));
playlistCount = tools::executeCommand(YT_DLP_PARSE_PATH("%(playlist_count)s", setting->dlUrl));
}

Expand Down
3 changes: 3 additions & 0 deletions src/misc/tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ void tools::printHelp() {
cout << "== -r, --reverse" << endl;
cout << "==\tReverse the order of the given playlist or rss feed" << endl;
cout << "==" << endl;
cout << "== -j, --jellyfin" << endl;
cout << "==\tApply naming scheme for jellyfin instead of plex" << endl;
cout << "==" << endl;
cout << "== -io, --indexOverwrite [num] -- optional" << endl;
cout << "==\tOverwrite the playlist index" << endl;
cout << "==" << endl;
Expand Down

0 comments on commit 9439642

Please sign in to comment.