aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/LocalAnime.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/LocalAnime.cpp')
-rw-r--r--src/plugins/LocalAnime.cpp55
1 files changed, 36 insertions, 19 deletions
diff --git a/src/plugins/LocalAnime.cpp b/src/plugins/LocalAnime.cpp
index c906b9b..59e52ad 100644
--- a/src/plugins/LocalAnime.cpp
+++ b/src/plugins/LocalAnime.cpp
@@ -190,7 +190,7 @@ namespace QuickMedia {
static std::vector<LocalAnimeItem> get_episodes_in_directory(const Path &directory) {
std::vector<LocalAnimeItem> episodes;
- for_files_in_dir_sort_name(directory, [&episodes](const Path &filepath, FileType file_type) -> bool {
+ for_files_in_dir_sort_name(directory, [&episodes](const Path &filepath, FileType file_type, time_t) -> bool {
if(file_type != FileType::REGULAR || !is_video_ext(filepath.ext()))
return true;
@@ -206,21 +206,28 @@ namespace QuickMedia {
static std::vector<LocalAnimeItem> get_episodes_or_seasons_in_directory(const Path &directory) {
std::vector<LocalAnimeItem> anime_items;
- auto callback = [&](const Path &filepath, FileType file_type) -> bool {
- time_t modified_time_seconds;
- if(!file_get_last_modified_time_seconds(filepath.data.c_str(), &modified_time_seconds))
- return true;
-
+ auto callback = [&](const Path &filepath, FileType file_type, time_t last_modified_seconds) -> bool {
if(file_type == FileType::REGULAR) {
- if(is_video_ext(filepath.ext()))
- anime_items.push_back(LocalAnimeEpisode{ filepath, modified_time_seconds });
+ if(is_video_ext(filepath.ext())) {
+ if(last_modified_seconds == 0) {
+ if(!file_get_last_modified_time_seconds(filepath.data.c_str(), &last_modified_seconds))
+ return true;
+ }
+
+ anime_items.push_back(LocalAnimeEpisode{ filepath, last_modified_seconds });
+ }
return true;
}
+ if(last_modified_seconds == 0) {
+ if(!file_get_last_modified_time_seconds(filepath.data.c_str(), &last_modified_seconds))
+ return true;
+ }
+
LocalAnimeSeason season;
season.name = filepath.filename();
season.episodes = get_episodes_in_directory(filepath);
- season.modified_time_seconds = modified_time_seconds;
+ season.modified_time_seconds = last_modified_seconds;
if(season.episodes.empty())
return true;
@@ -236,23 +243,33 @@ namespace QuickMedia {
return anime_items;
}
- std::vector<LocalAnimeItem> get_anime_in_directory(const Path &directory) {
+ std::vector<LocalAnimeItem> get_anime_in_directory(const Path &directory, bool recursive) {
std::vector<LocalAnimeItem> anime_items;
- auto callback = [&anime_items](const Path &filepath, FileType file_type) -> bool {
- time_t modified_time_seconds;
- if(!file_get_last_modified_time_seconds(filepath.data.c_str(), &modified_time_seconds))
- return true;
-
+ auto callback = [&anime_items, recursive](const Path &filepath, FileType file_type, time_t last_modified_seconds) -> bool {
if(file_type == FileType::REGULAR) {
- if(is_video_ext(filepath.ext()))
- anime_items.push_back(LocalAnimeEpisode{ filepath, modified_time_seconds });
+ if(is_video_ext(filepath.ext())) {
+ if(last_modified_seconds == 0) {
+ if(!file_get_last_modified_time_seconds(filepath.data.c_str(), &last_modified_seconds))
+ return true;
+ }
+
+ anime_items.push_back(LocalAnimeEpisode{ filepath, last_modified_seconds });
+ }
return true;
}
+
+ if(!recursive)
+ return true;
+ if(last_modified_seconds == 0) {
+ if(!file_get_last_modified_time_seconds(filepath.data.c_str(), &last_modified_seconds))
+ return true;
+ }
+
LocalAnime anime;
anime.name = filepath.filename();
anime.items = get_episodes_or_seasons_in_directory(filepath);
- anime.modified_time_seconds = modified_time_seconds;
+ anime.modified_time_seconds = last_modified_seconds;
if(anime.items.empty())
return true;
@@ -352,7 +369,7 @@ namespace QuickMedia {
PluginResult LocalAnimeSearchPage::lazy_fetch(BodyItems &result_items) {
if(fetch_home_page) {
fetch_home_page = false;
- anime_items = get_anime_in_directory(get_config().local_anime.directory);
+ anime_items = get_anime_in_directory(get_config().local_anime.directory, get_config().local_anime.recursive);
}
std::unordered_map<std::string, WatchProgress> watch_progress = get_watch_progress_for_plugin("local-anime");