Mercurial > minori
diff src/core/anime_db.cpp @ 64:fe719c109dbc
*: update
1. add media tracking ability, and it displays info on the `now playing` page
2. the `now playing` page now actually shows something
3. renamed every page class to be more accurate to what it is
4. ...
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Sun, 01 Oct 2023 23:15:43 -0400 |
parents | fc1bf97c528b |
children |
line wrap: on
line diff
--- a/src/core/anime_db.cpp Sun Oct 01 06:39:47 2023 -0400 +++ b/src/core/anime_db.cpp Sun Oct 01 23:15:43 2023 -0400 @@ -1,5 +1,7 @@ #include "core/anime_db.h" #include "core/anime.h" +#include "core/strings.h" +#include <QDebug> namespace Anime { @@ -79,13 +81,28 @@ int amt = 0; for (const auto& a : items) { if (a.second.IsInUserList() && a.second.GetUserScore()) { - squares_sum += std::pow((double)a.second.GetUserScore() - avg, 2); + squares_sum += std::pow(static_cast<double>(a.second.GetUserScore()) - avg, 2); amt++; } } return (amt > 0) ? std::sqrt(squares_sum / amt) : 0; } +int Database::GetAnimeFromTitle(std::string title) { + if (title.empty()) + return 0; + for (const auto& a : items) { + if (a.second.GetUserPreferredTitle().find(title) != std::string::npos) + return a.second.GetId(); + for (const auto& t : a.second.GetTitleSynonyms()) { + if (t.find(title) != std::string::npos) { + return a.second.GetId(); + } + } + } + return 0; +} + Database db; } // namespace Anime \ No newline at end of file