diff options
author | dec05eba <dec05eba@protonmail.com> | 2023-01-21 00:49:37 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2023-01-21 00:49:37 +0100 |
commit | 62ba1032657a0bf3878a5fe77018633adab8767d (patch) | |
tree | aea387d6a293428b20b402ccb579a49441ec12bd /src/plugins/utils | |
parent | 760d903fe7c7c56a6408accff0daa47c2e743eed (diff) |
NyaaSi: exclude episode number from track name, add extension
Diffstat (limited to 'src/plugins/utils')
-rw-r--r-- | src/plugins/utils/EpisodeNameParser.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/plugins/utils/EpisodeNameParser.cpp b/src/plugins/utils/EpisodeNameParser.cpp index a381cca..e314953 100644 --- a/src/plugins/utils/EpisodeNameParser.cpp +++ b/src/plugins/utils/EpisodeNameParser.cpp @@ -90,6 +90,10 @@ namespace QuickMedia { episode_name.remove_prefix(i + 1); return episode; } + + static bool ends_with(std::string_view str, std::string_view substr) { + return str.size() >= substr.size() && str.substr(str.size() - substr.size()) == substr; + } std::optional<EpisodeNameParts> episode_name_extract_parts(std::string_view episode_name) { EpisodeNameParts name_parts; @@ -122,6 +126,27 @@ namespace QuickMedia { else if(episode_name.find("3840x2160") != std::string_view::npos) name_parts.resolution = "3840x2160"; + if(ends_with(episode_name, ".mkv")) + name_parts.file_ext = ".mkv"; + else if(ends_with(episode_name, ".mp4")) + name_parts.file_ext = ".mp4"; + else if(ends_with(episode_name, ".avi")) + name_parts.file_ext = ".avi"; + else if(ends_with(episode_name, ".webm")) + name_parts.file_ext = ".webm"; + else if(ends_with(episode_name, ".wmv")) + name_parts.file_ext = ".wmv"; + else if(ends_with(episode_name, ".mp3")) + name_parts.file_ext = ".mp3"; + else if(ends_with(episode_name, ".flac")) + name_parts.file_ext = ".flac"; + else if(ends_with(episode_name, ".opus")) + name_parts.file_ext = ".opus"; + else if(ends_with(episode_name, ".wav")) + name_parts.file_ext = ".wav"; + else if(ends_with(episode_name, ".ogg")) + name_parts.file_ext = ".ogg"; + return name_parts; } }
\ No newline at end of file |