Beispiel #1
0
bool Engine::ValidateEpisodeNumber(anime::Episode& episode,
                                   const anime::Item& anime_item,
                                   const MatchOptions& match_options,
                                   bool redirect) const {
    if (episode.elements().empty(anitomy::kElementEpisodeNumber)) {
        if (anime_item.GetEpisodeCount() == 1)
            return true;  // Single-episode anime can do without an episode number
        if (episode.file_extension().empty())
            return true;  // It's a batch release
    }

    auto range = episode.episode_number_range();

    if (range.second > 0 &&  // We need this to be able to redirect episode 0
            range.second <= anime_item.GetEpisodeCount()) {
        return true;  // Episode number is within range
    }

    if (match_options.allow_sequels) {
        int destination_id = anime::ID_UNKNOWN;
        std::pair<int, int> destination_range;
        if (SearchEpisodeRedirection(anime_item.GetId(), range,
                                     destination_id, destination_range)) {
            if (redirect) {
                LOG(LevelDebug, L"Redirection: " +
                    ToWstr(anime_item.GetId()) + L":" +
                    anime::GetEpisodeRange(episode) + L" -> " +
                    ToWstr(destination_id) + L":" +
                    anime::GetEpisodeRange(destination_range));
                episode.anime_id = destination_id;
                episode.set_episode_number_range(destination_range);
            }
            return true;  // Redirection available
        }
    }

    if (!anime::IsValidEpisodeCount(anime_item.GetEpisodeCount()))
        return true;  // Episode count is unknown, so anything goes

    return false;  // Episode number is out of range
}
Beispiel #2
0
static void ChangeAnimeFolder(anime::Item& anime_item,
                              const std::wstring& path) {
  anime_item.SetFolder(path);
  Settings.Save();

  LOG(LevelDebug, L"Anime folder changed: " + anime_item.GetTitle() + L"\n"
                  L"Path: " + anime_item.GetFolder());

  if (path.empty()) {
    for (int i = 1; i <= anime_item.GetAvailableEpisodeCount(); ++i) {
      anime_item.SetEpisodeAvailability(i, false, path);
    }
  }

  ScanAvailableEpisodesQuick(anime_item.GetId());
}
Beispiel #3
0
std::wstring GetAnimePage(const anime::Item& anime_item) {
  return L"http://myanimelist.net/anime/" +
         anime_item.GetId(sync::kMyAnimeList) + L"/";
}