diff options
-rw-r--r-- | plugins/utils/EpisodeNameParser.hpp | 1 | ||||
-rw-r--r-- | src/plugins/NyaaSi.cpp | 2 | ||||
-rw-r--r-- | src/plugins/utils/EpisodeNameParser.cpp | 25 |
3 files changed, 27 insertions, 1 deletions
diff --git a/plugins/utils/EpisodeNameParser.hpp b/plugins/utils/EpisodeNameParser.hpp index 7976cdc..dfb843d 100644 --- a/plugins/utils/EpisodeNameParser.hpp +++ b/plugins/utils/EpisodeNameParser.hpp @@ -10,6 +10,7 @@ namespace QuickMedia { std::string_view season; // optional std::string_view episode; // required std::string_view resolution; // optional + std::string_view file_ext; // optional }; std::optional<EpisodeNameParts> episode_name_extract_parts(std::string_view episode_name); diff --git a/src/plugins/NyaaSi.cpp b/src/plugins/NyaaSi.cpp index d0bc616..38e3c21 100644 --- a/src/plugins/NyaaSi.cpp +++ b/src/plugins/NyaaSi.cpp @@ -30,7 +30,7 @@ namespace QuickMedia { return TrackResult::ERR; } - const std::string track_name = combine_strings({ episode_parts->group, episode_parts->anime, episode_parts->episode, episode_parts->season, episode_parts->resolution }, ' '); + const std::string track_name = combine_strings({ episode_parts->group, episode_parts->anime, episode_parts->season, episode_parts->resolution, episode_parts->file_ext }, ' '); std::string url = "https://nyaa.si/?page=rss&q=" + url_param_encode(track_name) + "&c=0_0&f=0"; if(!episode_parts->group.empty()) 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 |