예제 #1
0
파일: list.cpp 프로젝트: Hydro8182/taiga
int SortListByTitle(const anime::Item& item1, const anime::Item& item2) {
  if (Settings.GetBool(taiga::kApp_List_DisplayEnglishTitles)) {
    return CompareStrings(item1.GetEnglishTitle(true),
                          item2.GetEnglishTitle(true));
  } else {
    return CompareStrings(item1.GetTitle(), item2.GetTitle());
  }
}
예제 #2
0
파일: list.cpp 프로젝트: Hydro8182/taiga
int SortListByPopularity(const anime::Item& item1, const anime::Item& item2) {
  int val1 = item1.GetPopularity();
  int val2 = item2.GetPopularity();

  if (val1 != val2)
    if (val1 == 0 || val2 == 0)
      return val2 == 0 ? base::kLessThan : base::kGreaterThan;

  return CompareValues<int>(val1, val2);
}
예제 #3
0
파일: list.cpp 프로젝트: Hydro8182/taiga
int SortListBySeason(const anime::Item& item1, const anime::Item& item2,
                     int order) {
  anime::Season season1(item1.GetDateStart());
  anime::Season season2(item2.GetDateStart());

  if (season1 != season2)
    return CompareValues<anime::Season>(season1, season2);

  if (item1.GetAiringStatus() != item2.GetAiringStatus())
    return SortListByAiringStatus(item1, item2);

  return SortListByTitle(item1, item2) * order;
}
예제 #4
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
}
예제 #5
0
파일: list.cpp 프로젝트: Hydro8182/taiga
int SortListByDateStart(const anime::Item& item1, const anime::Item& item2) {
  Date date1 = item1.GetDateStart();
  Date date2 = item2.GetDateStart();

  if (date1 != date2) {
    if (!date1.year)
      date1.year = static_cast<unsigned short>(-1);  // Hello.
    if (!date2.year)
      date2.year = static_cast<unsigned short>(-1);  // We come from the future.
    if (!date1.month)
      date1.month = 12;
    if (!date2.month)
      date2.month = 12;
    if (!date1.day)
      date1.day = 31;
    if (!date2.day)
      date2.day = 31;
  }

  return CompareValues<Date>(date1, date2);
}
예제 #6
0
void Service::ParseAnimeObject(Json::Value& value, anime::Item& anime_item) {
  anime_item.SetSlug(StrToWstr(value["slug"].asString()));
  anime_item.SetAiringStatus(TranslateSeriesStatusFrom(StrToWstr(value["status"].asString())));
  anime_item.SetTitle(StrToWstr(value["title"].asString()));
  anime_item.SetSynonyms(StrToWstr(value["alternate_title"].asString()));
  anime_item.SetEpisodeCount(value["episode_count"].asInt());
  anime_item.SetImageUrl(StrToWstr(value["cover_image"].asString()));
  anime_item.SetSynopsis(StrToWstr(value["synopsis"].asString()));
  anime_item.SetType(TranslateSeriesTypeFrom(StrToWstr(value["show_type"].asString())));

  std::vector<std::wstring> genres;
  auto& genres_value = value["genres"];
  for (size_t i = 0; i < genres_value.size(); i++)
    genres.push_back(StrToWstr(genres_value[i]["name"].asString()));

  if (!genres.empty())
    anime_item.SetGenres(genres);
}
예제 #7
0
파일: monitor.cpp 프로젝트: Hydro8182/taiga
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());
}
예제 #8
0
void Service::ParseAnimeObjectV2(Json::Value& value, anime::Item& anime_item) {
  anime_item.SetSlug(StrToWstr(value["slug"].asString()));
  anime_item.SetTitle(StrToWstr(value["canonical_title"].asString()));
  anime_item.SetEnglishTitle(StrToWstr(value["english_title"].asString()));
  anime_item.SetSynonyms(StrToWstr(value["romaji_title"].asString()));
  anime_item.SetSynopsis(StrToWstr(value["synopsis"].asString()));
  anime_item.SetImageUrl(StrToWstr(value["poster_image"].asString()));
  anime_item.SetType(TranslateSeriesTypeFrom(StrToWstr(value["type"].asString())));
  anime_item.SetDateStart(StrToWstr(value["started_airing"].asString()));
  anime_item.SetDateEnd(StrToWstr(value["finished_airing"].asString()));
  anime_item.SetScore(TranslateSeriesRatingFrom(value["community_rating"].asFloat()));
  anime_item.SetAgeRating(TranslateAgeRatingFrom(StrToWstr(value["age_rating"].asString())));
  anime_item.SetEpisodeCount(value["episode_count"].asInt());
  anime_item.SetEpisodeLength(value["episode_length"].asInt());

  std::vector<std::wstring> genres;
  auto& genres_value = value["genres"];
  for (size_t i = 0; i < genres_value.size(); i++)
    genres.push_back(StrToWstr(genres_value[i].asString()));

  if (!genres.empty())
    anime_item.SetGenres(genres);
}
예제 #9
0
std::wstring GetAnimePage(const anime::Item& anime_item) {
  return L"http://myanimelist.net/anime/" +
         anime_item.GetId(sync::kMyAnimeList) + L"/";
}
예제 #10
0
파일: list.cpp 프로젝트: Hydro8182/taiga
int SortListByScore(const anime::Item& item1, const anime::Item& item2) {
  return CompareValues<double>(item1.GetScore(), item2.GetScore());
}
예제 #11
0
파일: list.cpp 프로젝트: Hydro8182/taiga
int SortListByLastUpdated(const anime::Item& item1, const anime::Item& item2) {
  return CompareValues<time_t>(_wtoi64(item1.GetMyLastUpdated().c_str()),
                               _wtoi64(item2.GetMyLastUpdated().c_str()));
}
예제 #12
0
파일: list.cpp 프로젝트: Hydro8182/taiga
int SortListByEpisodeCount(const anime::Item& item1, const anime::Item& item2) {
  return CompareValues<int>(item1.GetEpisodeCount(), item2.GetEpisodeCount());
}
예제 #13
0
파일: list.cpp 프로젝트: Hydro8182/taiga
int SortListByAiringStatus(const anime::Item& item1, const anime::Item& item2) {
  return CompareValues<int>(item1.GetAiringStatus(), item2.GetAiringStatus());
}
예제 #14
0
std::wstring GetAnimePage(const anime::Item& anime_item) {
  return L"http://hummingbird.me/anime/" + anime_item.GetSlug();
}