Mercurial > minori
changeset 413:192da585a0a8 default tip
*: fix formatting
the clang-format file was broken andjust using LLVM defaults.
now it's fixed and is more in line with what I actually prefer my
code to look like -- esp. with regards to tabulators
| author | Paper <paper@tflc.us> |
|---|---|
| date | Sat, 25 Jul 2026 14:54:32 -0400 |
| parents | 05aed03e0111 |
| children | |
| files | .clang-format include/core/anime.h include/core/anime_season.h include/core/endian.h include/core/filesystem.h include/core/http.h include/core/session.h include/core/torrent.h src/core/anime_db.cc src/core/config.cc src/core/date.cc src/core/filesystem.cc src/core/http.cc src/core/strings.cc src/core/time.cc src/gui/window.cc src/library/library.cc src/main.cc src/services/anilist.cc src/services/kitsu.cc src/services/services.cc |
| diffstat | 21 files changed, 317 insertions(+), 287 deletions(-) [+] |
line wrap: on
line diff
--- a/.clang-format Sat Jul 25 14:33:03 2026 -0400 +++ b/.clang-format Sat Jul 25 14:54:32 2026 -0400 @@ -1,6 +1,8 @@ --- +Language: Cpp +Standard: c++17 BasedOnStyle: LLVM -UseTab: ForIndentation +UseTab: ForContinuationAndIndentation PointerAlignment: Right ColumnLimit: 120 IndentWidth: 4 @@ -21,7 +23,9 @@ SpaceAfterTemplateKeyword: false -AlignAfterOpenBracket: Align +AlignAfterOpenBracket: false +ContinuationIndentWidth: 4 + AlignArrayOfStructures: Left AlignEscapedNewlines: DontAlign AlignConsecutiveMacros: true @@ -33,7 +37,3 @@ AllowShortCaseLabelsOnASingleLine: false Cpp11BracedListStyle: true - ---- -Language: Cpp -Standard: c++17
--- a/include/core/anime.h Sat Jul 25 14:33:03 2026 -0400 +++ b/include/core/anime.h Sat Jul 25 14:54:32 2026 -0400 @@ -21,7 +21,11 @@ }; constexpr std::array<ListStatus, 5> ListStatuses{ - ListStatus::Current, ListStatus::Completed, ListStatus::Paused, ListStatus::Dropped, ListStatus::Planning, + ListStatus::Current, + ListStatus::Completed, + ListStatus::Paused, + ListStatus::Dropped, + ListStatus::Planning, }; enum class SeriesStatus { @@ -34,8 +38,12 @@ }; constexpr std::array<SeriesStatus, 6> SeriesStatuses{ - SeriesStatus::Unknown, SeriesStatus::Finished, SeriesStatus::Releasing, - SeriesStatus::NotYetReleased, SeriesStatus::Cancelled, SeriesStatus::Hiatus, + SeriesStatus::Unknown, + SeriesStatus::Finished, + SeriesStatus::Releasing, + SeriesStatus::NotYetReleased, + SeriesStatus::Cancelled, + SeriesStatus::Hiatus, }; enum class SeriesFormat { @@ -50,8 +58,14 @@ }; constexpr std::array<SeriesFormat, 8> SeriesFormats{ - SeriesFormat::Unknown, SeriesFormat::Tv, SeriesFormat::TvShort, SeriesFormat::Movie, - SeriesFormat::Special, SeriesFormat::Ova, SeriesFormat::Ona, SeriesFormat::Music, + SeriesFormat::Unknown, + SeriesFormat::Tv, + SeriesFormat::TvShort, + SeriesFormat::Movie, + SeriesFormat::Special, + SeriesFormat::Ova, + SeriesFormat::Ona, + SeriesFormat::Music, }; enum class TitleLanguage { @@ -61,9 +75,9 @@ }; constexpr std::array<TitleLanguage, 3> TitleLanguages{ - TitleLanguage::Romaji, - TitleLanguage::Native, - TitleLanguage::English, + TitleLanguage::Romaji, + TitleLanguage::Native, + TitleLanguage::English, }; enum class Service { @@ -76,9 +90,9 @@ /* this doesn't include MAL and Kitsu because they aren't really * "valid" services yet. */ constexpr std::array<Service, 3> Services{ - Service::AniList, - Service::MyAnimeList, - Service::Kitsu, + Service::AniList, + Service::MyAnimeList, + Service::Kitsu, }; enum class ScoreFormat { @@ -90,7 +104,11 @@ }; constexpr std::array<ScoreFormat, 5> ScoreFormats{ - ScoreFormat::Point100, ScoreFormat::Point10Decimal, ScoreFormat::Point10, ScoreFormat::Point5, ScoreFormat::Point3, + ScoreFormat::Point100, + ScoreFormat::Point10Decimal, + ScoreFormat::Point10, + ScoreFormat::Point5, + ScoreFormat::Point3, }; struct ListInformation {
--- a/include/core/anime_season.h Sat Jul 25 14:33:03 2026 -0400 +++ b/include/core/anime_season.h Sat Jul 25 14:54:32 2026 -0400 @@ -18,10 +18,10 @@ }; static constexpr std::array<Name, 4> Names{ - Name::Winter, - Name::Spring, - Name::Summer, - Name::Autumn, + Name::Winter, + Name::Spring, + Name::Summer, + Name::Autumn, }; Season() = default;
--- a/include/core/endian.h Sat Jul 25 14:33:03 2026 -0400 +++ b/include/core/endian.h Sat Jul 25 14:54:32 2026 -0400 @@ -38,7 +38,7 @@ return COMPILER_BUILTIN_BSWAP32(x); #else return (((x & UINT32_C(0x000000FF)) << 24) | ((x & UINT32_C(0x0000FF00)) << 8) | - ((x & UINT32_C(0x00FF0000)) >> 8) | ((x & UINT32_C(0xFF000000)) >> 24)); + ((x & UINT32_C(0x00FF0000)) >> 8) | ((x & UINT32_C(0xFF000000)) >> 24)); #endif } @@ -48,9 +48,9 @@ return COMPILER_BUILTIN_BSWAP64(x); #else return (((x & UINT64_C(0x00000000000000FF)) << 56) | ((x & UINT64_C(0x000000000000FF00)) << 40) | - ((x & UINT64_C(0x0000000000FF0000)) << 24) | ((x & UINT64_C(0x00000000FF000000)) << 8) | - ((x & UINT64_C(0x000000FF00000000)) >> 8) | ((x & UINT64_C(0x0000FF0000000000)) >> 24) | - ((x & UINT64_C(0x00FF000000000000)) >> 40) | ((x & UINT64_C(0xFF00000000000000)) >> 56)); + ((x & UINT64_C(0x0000000000FF0000)) << 24) | ((x & UINT64_C(0x00000000FF000000)) << 8) | + ((x & UINT64_C(0x000000FF00000000)) >> 8) | ((x & UINT64_C(0x0000FF0000000000)) >> 24) | + ((x & UINT64_C(0x00FF000000000000)) >> 40) | ((x & UINT64_C(0xFF00000000000000)) >> 56)); #endif }
--- a/include/core/filesystem.h Sat Jul 25 14:33:03 2026 -0400 +++ b/include/core/filesystem.h Sat Jul 25 14:54:32 2026 -0400 @@ -15,9 +15,7 @@ std::filesystem::path GetAnimePostersPath(); // (dotpath)/anime/posters/ struct PathHash { - auto operator()(const std::filesystem::path &p) const noexcept { - return std::filesystem::hash_value(p); - } + auto operator()(const std::filesystem::path &p) const noexcept { return std::filesystem::hash_value(p); } }; template<typename T> @@ -42,8 +40,8 @@ }; /* Constructor functions. Yes, I'm doing this the C way :) */ -IWatcher *GetRecursiveFilesystemWatcher(void *opaque, const std::filesystem::path &path, - IWatcher::EventHandler handler); +IWatcher *GetRecursiveFilesystemWatcher( + void *opaque, const std::filesystem::path &path, IWatcher::EventHandler handler); IWatcher *GetFilesystemWatcher(void *opaque, const std::filesystem::path &path, IWatcher::EventHandler handler); } // namespace Filesystem
--- a/include/core/http.h Sat Jul 25 14:33:03 2026 -0400 +++ b/include/core/http.h Sat Jul 25 14:54:32 2026 -0400 @@ -35,7 +35,7 @@ }; QByteArray Request(const std::string &url, const std::vector<std::string> &headers = {}, const std::string &data = "", - Type type = Type::Get); + Type type = Type::Get); class RequestThread final : public QThread { Q_OBJECT @@ -43,7 +43,7 @@ public: RequestThread(Type type = Type::Get, QObject *parent = nullptr); RequestThread(const std::string &url, const std::vector<std::string> &headers = {}, const std::string &data = "", - Type type = Type::Get, QObject *parent = nullptr); + Type type = Type::Get, QObject *parent = nullptr); ~RequestThread(); void SetUrl(const std::string &url);
--- a/include/core/session.h Sat Jul 25 14:33:03 2026 -0400 +++ b/include/core/session.h Sat Jul 25 14:54:32 2026 -0400 @@ -37,9 +37,9 @@ std::mt19937 gen; static constexpr semver::version version{ - MINORI_VERSION_MAJOR, - MINORI_VERSION_MINOR, - MINORI_VERSION_PATCH, + MINORI_VERSION_MAJOR, + MINORI_VERSION_MINOR, + MINORI_VERSION_PATCH, }; signals:
--- a/include/core/torrent.h Sat Jul 25 14:33:03 2026 -0400 +++ b/include/core/torrent.h Sat Jul 25 14:54:32 2026 -0400 @@ -48,7 +48,7 @@ std::string _group; size_t _size = 0; std::string _resolution; /* technically should be an int, - but std::string is more useful */ + but std::string is more useful */ int _seeders = 0; int _leechers = 0; int _downloads = 0;
--- a/src/core/anime_db.cc Sat Jul 25 14:33:03 2026 -0400 +++ b/src/core/anime_db.cc Sat Jul 25 14:54:32 2026 -0400 @@ -64,7 +64,7 @@ for (const auto &[id, anime] : items) if (anime.IsInUserList()) total += anime.GetDuration() * anime.GetUserProgress() + - anime.GetEpisodes() * anime.GetDuration() * anime.GetUserRewatchedTimes(); + anime.GetEpisodes() * anime.GetDuration() * anime.GetUserRewatchedTimes(); return total; } @@ -277,7 +277,7 @@ anime.SetTitleSynonyms(JSON::GetArray<std::vector<std::string>>(json, "/synonyms"_json_pointer, {})); anime.SetEpisodes(JSON::GetNumber(json, "/episodes"_json_pointer, 0)); anime.SetAiringStatus( - Translate::ToSeriesStatus(JSON::GetString<std::string>(json, "/airing_status"_json_pointer, ""))); + Translate::ToSeriesStatus(JSON::GetString<std::string>(json, "/airing_status"_json_pointer, ""))); anime.SetStartedDate(Date(JSON::GetValue(json, "/started_date"_json_pointer))); anime.SetCompletedDate(Date(JSON::GetValue(json, "/completed_date"_json_pointer))); anime.SetGenres(JSON::GetArray<std::vector<std::string>>(json, "/genres"_json_pointer, {}));
--- a/src/core/config.cc Sat Jul 25 14:33:03 2026 -0400 +++ b/src/core/config.cc Sat Jul 25 14:54:32 2026 -0400 @@ -50,24 +50,24 @@ anime_list.language = Translate::ToLanguage(toml::find_or(data, "Anime List", "Title language", "Romaji")); anime_list.display_aired_episodes = toml::find_or(data, "Anime List", "Display only aired episodes", true); anime_list.display_available_episodes = - toml::find_or(data, "Anime List", "Display only available episodes in library", true); + toml::find_or(data, "Anime List", "Display only available episodes in library", true); anime_list.highlight_anime_if_available = toml::find_or(data, "Anime List", "Highlight anime if available", true); anime_list.highlighted_anime_above_others = - (anime_list.highlight_anime_if_available) - ? toml::find_or(data, "Anime List", "Display highlighted anime above others", false) - : false; + (anime_list.highlight_anime_if_available) + ? toml::find_or(data, "Anime List", "Display highlighted anime above others", false) + : false; auth.anilist.auth_token = toml::find_or(data, "Authentication/AniList", "Auth Token", ""); auth.anilist.user_id = toml::find_or(data, "Authentication/AniList", "User ID", 0); auth.kitsu.access_token = toml::find_or(data, "Authentication/Kitsu", "Access Token", ""); auth.kitsu.access_token_expiration = - toml::find_or(data, "Authentication/Kitsu", "Access Token Expiration", static_cast<Time::Timestamp>(0)); + toml::find_or(data, "Authentication/Kitsu", "Access Token Expiration", static_cast<Time::Timestamp>(0)); auth.kitsu.refresh_token = toml::find_or(data, "Authentication/Kitsu", "Refresh Token", ""); auth.kitsu.user_id = toml::find_or(data, "Authentication/Kitsu", "User ID", ""); torrents.feed_link = - toml::find_or(data, "Torrents", "RSS feed", "https://www.tokyotosho.info/rss.php?filter=1,11&zwnj=0"); + toml::find_or(data, "Torrents", "RSS feed", "https://www.tokyotosho.info/rss.php?filter=1,11&zwnj=0"); recognition.detect_media_players = toml::find_or(data, "Recognition", "Detect media players", true); @@ -132,7 +132,7 @@ for (const auto &[enabled, player] : recognition.players) { const std::string section = - (player.type == animone::PlayerType::WebBrowser) ? "Recognition/Players" : "Recognition/Browsers"; + (player.type == animone::PlayerType::WebBrowser) ? "Recognition/Players" : "Recognition/Browsers"; data[section][player.name] = enabled; }
--- a/src/core/date.cc Sat Jul 25 14:33:03 2026 -0400 +++ b/src/core/date.cc Sat Jul 25 14:54:32 2026 -0400 @@ -6,8 +6,8 @@ #include <QDebug> #include <algorithm> +#include <cstdio> #include <sstream> -#include <cstdio> /* An implementation of AniList's "fuzzy date" */ @@ -139,7 +139,7 @@ nlohmann::json Date::GetAsAniListJson() const { nlohmann::json json = { - {"year", nullptr}, + {"year", nullptr}, {"month", nullptr}, {"day", nullptr} };
--- a/src/core/filesystem.cc Sat Jul 25 14:33:03 2026 -0400 +++ b/src/core/filesystem.cc Sat Jul 25 14:54:32 2026 -0400 @@ -12,8 +12,8 @@ #elif defined(HAVE_INOTIFY) /* ehhhh */ # include <fcntl.h> +# include <sys/inotify.h> # include <unistd.h> -# include <sys/inotify.h> #elif defined(__MACH__) && defined(__APPLE__) # include <CoreFoundation/CoreFoundation.h> # include <CoreServices/CoreServices.h> @@ -80,7 +80,7 @@ class Watcher : public IWatcher { public: Watcher(void *opaque, const std::filesystem::path &path, EventHandler handler) - : path_(path), handler_(handler), opaque_(opaque) + : path_(path), handler_(handler), opaque_(opaque) { } @@ -107,7 +107,7 @@ resort to old-fashioned recursion. --paper */ static void IterateDirectory(const std::filesystem::path &path, bool recursive, - const std::function<void(const std::filesystem::path &path)> &func) + const std::function<void(const std::filesystem::path &path)> &func) { std::error_code ec; static const std::filesystem::directory_iterator end; @@ -130,7 +130,7 @@ class StdFilesystemWatcher : public Watcher { public: StdFilesystemWatcher(void *opaque, const std::filesystem::path &path, EventHandler handler, bool recursive) - : Watcher(opaque, path, handler), recursive_(recursive) + : Watcher(opaque, path, handler), recursive_(recursive) { } @@ -205,7 +205,7 @@ class Win32Watcher : public StdFilesystemWatcher { public: Win32Watcher(void *opaque, const std::filesystem::path &path, IWatcher::EventHandler handler, bool recursive) - : StdFilesystemWatcher(opaque, path, handler, recursive), dirwatcher_(INVALID_HANDLE_VALUE), first_(true) + : StdFilesystemWatcher(opaque, path, handler, recursive), dirwatcher_(INVALID_HANDLE_VALUE), first_(true) { } @@ -239,8 +239,8 @@ protected: bool TryCreateDirWatcher() { - dirwatcher_ = FindFirstChangeNotificationW(Watcher::path_.wstring().c_str(), recursive_, - FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME); + dirwatcher_ = FindFirstChangeNotificationW( + Watcher::path_.wstring().c_str(), recursive_, FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME); return (dirwatcher_ != INVALID_HANDLE_VALUE); } @@ -258,7 +258,7 @@ class Win32WatcherVista : public Win32Watcher { public: Win32WatcherVista(void *opaque, const std::filesystem::path &path, IWatcher::EventHandler handler, bool recursive) - : Win32Watcher(opaque, path, handler, recursive), dirhandle_(INVALID_HANDLE_VALUE) + : Win32Watcher(opaque, path, handler, recursive), dirhandle_(INVALID_HANDLE_VALUE) { ZeroMemory(&overlapped_, sizeof(overlapped_)); overlapped_.hEvent = nullptr; @@ -285,7 +285,7 @@ * directory tree into memory. Instead, iterate through the directory * ourselves. */ IterateDirectory(path_, recursive_, - [this](const std::filesystem::path &p) { handler_(opaque_, p, Event::Created); }); + [this](const std::filesystem::path &p) { handler_(opaque_, p, Event::Created); }); } else { /* Uh oh; we might have to fall back to Win32Watcher. Call into it to * load the tree into memory. */ @@ -353,8 +353,8 @@ if (dirhandle_ == INVALID_HANDLE_VALUE) { dirhandle_ = - CreateFileW(Watcher::path_.wstring().c_str(), FILE_LIST_DIRECTORY, FILE_SHARE_READ | FILE_SHARE_WRITE, - nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, nullptr); + CreateFileW(Watcher::path_.wstring().c_str(), FILE_LIST_DIRECTORY, FILE_SHARE_READ | FILE_SHARE_WRITE, + nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, nullptr); if (dirhandle_ == INVALID_HANDLE_VALUE) return false; } @@ -366,8 +366,7 @@ bool QueueDirectoryRead() { return ReadDirectoryChangesW(dirhandle_, change_buf_, sizeof(change_buf_), TRUE, - FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME, nullptr, &overlapped_, - nullptr); + FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME, nullptr, &overlapped_, nullptr); } HANDLE dirhandle_; @@ -381,11 +380,8 @@ class InotifyWatcher : public StdFilesystemWatcher { public: InotifyWatcher(void *opaque, const std::filesystem::path &path, IWatcher::EventHandler handler, bool recursive) - : StdFilesystemWatcher(opaque, path, handler, recursive) - , first_(true) - , giveup_(false) - , ev_(nullptr) - , ev_size_(0) + : StdFilesystemWatcher(opaque, path, handler, recursive), first_(true), giveup_(false), ev_(nullptr), + ev_size_(0) { } @@ -467,14 +463,14 @@ continue; } - if (ev->mask & (IN_MOVE|IN_CREATE|IN_DELETE)) { + if (ev->mask & (IN_MOVE | IN_CREATE | IN_DELETE)) { std::filesystem::path p = wds_[ev->wd] / ev->name; - if (ev->mask & (IN_MOVED_TO|IN_CREATE)) { + if (ev->mask & (IN_MOVED_TO | IN_CREATE)) { if (std::filesystem::is_directory(p)) AddWatchDescriptor(p); handler_(opaque_, p, Event::Created); - } else if (ev->mask & (IN_MOVED_FROM|IN_DELETE)) { + } else if (ev->mask & (IN_MOVED_FROM | IN_DELETE)) { handler_(opaque_, wds_[ev->wd] / ev->name, Event::Deleted); } @@ -490,7 +486,7 @@ * but has a function for toggling non-blocking */ struct FileDescriptor { public: - FileDescriptor() : fd_(-1) { } + FileDescriptor() : fd_(-1) {} ~FileDescriptor() { reset(); } int get() { return fd_; } @@ -536,19 +532,19 @@ return false; if (!fd_) { -#ifdef HAVE_INOTIFY_INIT1 +# ifdef HAVE_INOTIFY_INIT1 fd_.reset(inotify_init1(IN_NONBLOCK)); -#else +# else fd_.reset(inotify_init()); -#endif +# endif if (!fd_) return false; -#ifndef HAVE_INOTIFY_INIT1 +# ifndef HAVE_INOTIFY_INIT1 /* Very old linux */ if (!fd_.SetNonBlocking(true)) return false; -#endif +# endif } return !!fd_; @@ -559,7 +555,8 @@ if (!fd_ || giveup_) return false; - int wd = inotify_add_watch(fd_.get(), p.string().c_str(), IN_CREATE | IN_DELETE | IN_MOVED_FROM | IN_MOVED_TO | IN_DELETE_SELF); + int wd = inotify_add_watch( + fd_.get(), p.string().c_str(), IN_CREATE | IN_DELETE | IN_MOVED_FROM | IN_MOVED_TO | IN_DELETE_SELF); if (wd < 0) { /* Don't even try to watch any more */ giveup_ = true; @@ -596,8 +593,7 @@ class FSEventsWatcher : public StdFilesystemWatcher { public: FSEventsWatcher(void *opaque, const std::filesystem::path &path, IWatcher::EventHandler handler, bool recursive) - : StdFilesystemWatcher(opaque, path, handler, recursive) - , first_(true) + : StdFilesystemWatcher(opaque, path, handler, recursive), first_(true) { FSEventStreamContext ctx; @@ -608,9 +604,11 @@ ctx.version = 0; CFStringRef str = Strings::ToCFString(path.u8string()); - CFArrayRef arr = CFArrayCreate(kCFAllocatorDefault, reinterpret_cast<const void **>(&str), 1, &kCFTypeArrayCallBacks); + CFArrayRef arr = + CFArrayCreate(kCFAllocatorDefault, reinterpret_cast<const void **>(&str), 1, &kCFTypeArrayCallBacks); - stream_ = FSEventStreamCreate(kCFAllocatorDefault, callback_static, &ctx, arr, kFSEventStreamEventIdSinceNow, 0.5, 0); + stream_ = + FSEventStreamCreate(kCFAllocatorDefault, callback_static, &ctx, arr, kFSEventStreamEventIdSinceNow, 0.5, 0); // kill these off now CFRelease(str); @@ -652,11 +650,12 @@ } private: - void callback(ConstFSEventStreamRef streamRef, std::size_t numEvents, void *eventPaths, const FSEventStreamEventFlags *eventFlags, const FSEventStreamEventId *eventIds) + void callback(ConstFSEventStreamRef streamRef, std::size_t numEvents, void *eventPaths, + const FSEventStreamEventFlags *eventFlags, const FSEventStreamEventId *eventIds) { // assert(streamRef == stream_); -#if 0 +# if 0 for (std::size_t i = 0; i < numEvents; i++) { if ((eventFlags[i] == 0) || (eventFlags[i] & (kFSEventStreamEventFlagItemCreated|kFSEventStreamEventFlagItemRemoved|kFSEventStreamEventFlagMustScanSubDirs))) { EventInfo ev; @@ -679,16 +678,18 @@ } } } -#else +# else /* I only evr get eventFlags[i] == 0 so I think this is * probably the best way ??? */ rescan_.push_back(Watcher::path_); -#endif +# endif } - static void callback_static(ConstFSEventStreamRef streamRef, void *clientCallBackInfo, std::size_t numEvents, void *eventPaths, const FSEventStreamEventFlags *eventFlags, const FSEventStreamEventId *eventIds) + static void callback_static(ConstFSEventStreamRef streamRef, void *clientCallBackInfo, std::size_t numEvents, + void *eventPaths, const FSEventStreamEventFlags *eventFlags, const FSEventStreamEventId *eventIds) { - reinterpret_cast<FSEventsWatcher *>(clientCallBackInfo)->callback(streamRef, numEvents, eventPaths, eventFlags, eventIds); + reinterpret_cast<FSEventsWatcher *>(clientCallBackInfo) + ->callback(streamRef, numEvents, eventPaths, eventFlags, eventIds); } void runloop_thread() @@ -707,10 +708,7 @@ // will handle everything from here } - static void runloop_thread_static(FSEventsWatcher *e) - { - e->runloop_thread(); - } + static void runloop_thread_static(FSEventsWatcher *e) { e->runloop_thread(); } struct EventInfo { enum Event type;
--- a/src/core/http.cc Sat Jul 25 14:33:03 2026 -0400 +++ b/src/core/http.cc Sat Jul 25 14:54:32 2026 -0400 @@ -1,11 +1,11 @@ #include "core/http.h" #include "core/session.h" #include <QByteArray> +#include <cstring> #include <curl/curl.h> #include <iostream> #include <string> #include <vector> -#include <cstring> namespace HTTP { @@ -95,7 +95,7 @@ } } else { res.insert(res.end(), ptr, ptr + len); - //not needed: ptr += len; + // not needed: ptr += len; len = 0; } } @@ -118,8 +118,8 @@ return base; } -static void SetCurlOpts(CURL *curl, const std::string &url, const std::vector<std::string> &headers, - const std::string &data, Type type) +static void SetCurlOpts( + CURL *curl, const std::string &url, const std::vector<std::string> &headers, const std::string &data, Type type) { struct curl_slist *list; @@ -192,8 +192,8 @@ } RequestThread::RequestThread(const std::string &url, const std::vector<std::string> &headers, const std::string &data, - Type type, QObject *parent) - : QThread(parent) + Type type, QObject *parent) + : QThread(parent) { SetUrl(url); SetData(data);
--- a/src/core/strings.cc Sat Jul 25 14:33:03 2026 -0400 +++ b/src/core/strings.cc Sat Jul 25 14:54:32 2026 -0400 @@ -74,15 +74,15 @@ void ConvertRomanNumerals(std::string &string) { static const std::vector<std::pair<std::string_view, std::string_view>> vec = { - {"2", "II" }, + {"2", "II" }, {"3", "III" }, {"4", "IV" }, {"5", "V" }, {"6", "VI" }, {"7", "VII" }, - {"8", "VIII"}, + {"8", "VIII"}, {"9", "IX" }, - {"11", "XI" }, + {"11", "XI" }, {"12", "XII" }, {"13", "XIII"} }; @@ -95,14 +95,14 @@ void NormalizeUnicode(std::string &string) { static constexpr utf8proc_option_t options = static_cast<utf8proc_option_t>( - UTF8PROC_COMPAT | UTF8PROC_COMPOSE | UTF8PROC_STABLE | UTF8PROC_IGNORE | UTF8PROC_STRIPCC | UTF8PROC_STRIPMARK | - UTF8PROC_LUMP | UTF8PROC_CASEFOLD | UTF8PROC_NLF2LS); + UTF8PROC_COMPAT | UTF8PROC_COMPOSE | UTF8PROC_STABLE | UTF8PROC_IGNORE | UTF8PROC_STRIPCC | UTF8PROC_STRIPMARK | + UTF8PROC_LUMP | UTF8PROC_CASEFOLD | UTF8PROC_NLF2LS); /* ack */ utf8proc_uint8_t *buf = nullptr; const utf8proc_ssize_t size = - utf8proc_map(reinterpret_cast<const utf8proc_uint8_t *>(string.data()), string.size(), &buf, options); + utf8proc_map(reinterpret_cast<const utf8proc_uint8_t *>(string.data()), string.size(), &buf, options); if (buf) { if (size) @@ -216,7 +216,8 @@ #if defined(__APPLE__) && defined(__MACH__) CFStringRef ToCFString(const std::string &string) { - return CFStringCreateWithBytes(kCFAllocatorDefault, reinterpret_cast<const UInt8 *>(string.data()), string.size(), kCFStringEncodingUTF8, false); + return CFStringCreateWithBytes(kCFAllocatorDefault, reinterpret_cast<const UInt8 *>(string.data()), string.size(), + kCFStringEncodingUTF8, false); } std::string ToUtf8String(CFStringRef str) { @@ -230,7 +231,8 @@ range.length = len; range.location = 0; CFIndex used; - CFStringGetBytes(str, range, kCFStringEncodingUTF8, 0, false, reinterpret_cast<UInt8 *>(buf.data()), buf.size(), &used); + CFStringGetBytes( + str, range, kCFStringEncodingUTF8, 0, false, reinterpret_cast<UInt8 *>(buf.data()), buf.size(), &used); buf.resize(used); return buf; } @@ -253,15 +255,15 @@ uint64_t HumanReadableSizeToBytes(const std::string &str) { static const std::unordered_map<std::string, uint64_t> bytes_map = { - {"KB", 1e3 }, + {"KB", 1e3 }, {"MB", 1e6 }, {"GB", 1e9 }, {"TB", 1e12 }, - {"PB", 1e15 }, + {"PB", 1e15 }, {"KiB", 1ull << 10}, {"MiB", 1ull << 20}, - {"GiB", 1ull << 30}, - {"TiB", 1ull << 40}, + {"GiB", 1ull << 30}, + {"TiB", 1ull << 40}, {"PiB", 1ull << 50} /* surely we won't need more than this */ }; @@ -286,7 +288,7 @@ return Strings::ToUtf8String(session.config.locale.GetLocale().formattedDataSize(bytes, precision)); #else static const std::unordered_map<uint64_t, std::string> map = { - {1ull << 10, "KiB"}, + {1ull << 10, "KiB"}, {1ull << 20, "MiB"}, {1ull << 30, "GiB"}, {1ull << 40, "TiB"}, @@ -339,17 +341,17 @@ * * XXX probably better to use case folding here */ static constexpr std::array<std::string_view, 3> suffixes = { - "-dark", /* Adwaita-dark */ - "-Dark", /* Arc-Dark */ - "-Darker", /* Arc-Darker */ + "-dark", /* Adwaita-dark */ + "-Dark", /* Arc-Dark */ + "-Darker", /* Arc-Darker */ }; for (const auto &suffix : suffixes) { if (str.size() < suffix.size()) continue; - if (std::equal(str.data() + str.size() - suffix.length(), str.data() + str.size(), suffix.begin(), - suffix.end())) + if (std::equal( + str.data() + str.size() - suffix.length(), str.data() + str.size(), suffix.begin(), suffix.end())) return true; }
--- a/src/core/time.cc Sat Jul 25 14:33:03 2026 -0400 +++ b/src/core/time.cc Sat Jul 25 14:54:32 2026 -0400 @@ -75,7 +75,7 @@ const int seconds = std::fmod(amount, minutes_conv) / seconds_conv; const auto add_time_segment = [](std::ostringstream &str, int64_t amount, const std::string_view &singular, - const std::string_view &plural, bool always = false) { + const std::string_view &plural, bool always = false) { if (amount > 0 || always) str << amount << ((amount == 1) ? singular : plural); };
--- a/src/gui/window.cc Sat Jul 25 14:33:03 2026 -0400 +++ b/src/gui/window.cc Sat Jul 25 14:54:32 2026 -0400 @@ -56,9 +56,9 @@ emit Done(files); } -MainWindowAsyncSynchronizeThread::MainWindowAsyncSynchronizeThread(QAction *action, AnimeListPage *page, - QObject *parent) - : QThread(parent) +MainWindowAsyncSynchronizeThread::MainWindowAsyncSynchronizeThread( + QAction *action, AnimeListPage *page, QObject *parent) + : QThread(parent) { SetAction(action); SetPage(page); @@ -226,7 +226,7 @@ sync_action = menu->addAction(tr("Synchronize &list")); connect(sync_action, &QAction::triggered, this, - [this, sync_action] { AsyncSynchronize(sync_action, &stack_); }); + [this, sync_action] { AsyncSynchronize(sync_action, &stack_); }); sync_action->setIcon(QIcon(":/icons/24x24/arrow-circle-double-135.png")); sync_action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_S)); @@ -437,13 +437,13 @@ menu->addAction("MALgraph", [] { QDesktopServices::openUrl(QUrl("https://graph.anime.plus/")); }); menu->addSeparator(); menu->addAction("AniChart", [] { QDesktopServices::openUrl(QUrl("https://anichart.net/airing")); }); - menu->addAction("Monthly.moe", - [] { QDesktopServices::openUrl(QUrl("https://www.monthly.moe/weekly")); }); + menu->addAction( + "Monthly.moe", [] { QDesktopServices::openUrl(QUrl("https://www.monthly.moe/weekly")); }); menu->addAction("Senpai Anime Charts", - [] { QDesktopServices::openUrl(QUrl("https://www.senpai.moe/?mode=calendar")); }); + [] { QDesktopServices::openUrl(QUrl("https://www.senpai.moe/?mode=calendar")); }); menu->addSeparator(); - menu->addAction("Anime Streaming Search Engine", - [] { QDesktopServices::openUrl(QUrl("https://because.moe/")); }); + menu->addAction( + "Anime Streaming Search Engine", [] { QDesktopServices::openUrl(QUrl("https://because.moe/")); }); menu->addAction("The Fansub Database", [] { QDesktopServices::openUrl(QUrl("https://fansubdb.com")); }); button->setMenu(menu); @@ -477,7 +477,7 @@ for (const auto &path : session.config.library.paths) { const QString folder = Strings::ToQString(path); QAction *action = - folder_menu->addAction(folder, [folder] { QDesktopServices::openUrl(QUrl::fromLocalFile(folder)); }); + folder_menu->addAction(folder, [folder] { QDesktopServices::openUrl(QUrl::fromLocalFile(folder)); }); if (i < 9) { /* Qt::Key_1 is equivalent to 1 in ASCII, so we can use the same @@ -495,9 +495,8 @@ { folder_menu->addAction(tr("&Add new folder..."), [this] { - const QString dir = - QFileDialog::getExistingDirectory(this, tr("Open Directory"), QDir::homePath(), - QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + const QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), QDir::homePath(), + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); if (dir.isEmpty()) return; session.config.library.paths.insert(Strings::ToUtf8String(dir));
--- a/src/library/library.cc Sat Jul 25 14:33:03 2026 -0400 +++ b/src/library/library.cc Sat Jul 25 14:54:32 2026 -0400 @@ -40,7 +40,7 @@ continue; watchers_[p].reset( - Filesystem::GetRecursiveFilesystemWatcher(reinterpret_cast<void *>(this), p, Database::StaticEventHandler)); + Filesystem::GetRecursiveFilesystemWatcher(reinterpret_cast<void *>(this), p, Database::StaticEventHandler)); } }
--- a/src/main.cc Sat Jul 25 14:33:03 2026 -0400 +++ b/src/main.cc Sat Jul 25 14:54:32 2026 -0400 @@ -1,8 +1,8 @@ #include "core/anime.h" #include "core/anime_db.h" #include "core/date.h" +#include "core/http.h" #include "core/session.h" -#include "core/http.h" #include "core/strings.h" #include "gui/window.h" #include "services/anilist.h"
--- a/src/services/anilist.cc Sat Jul 25 14:33:03 2026 -0400 +++ b/src/services/anilist.cc Sat Jul 25 14:54:32 2026 -0400 @@ -73,15 +73,15 @@ static std::optional<nlohmann::json> SendJSONRequest(const nlohmann::json &data) { std::vector<std::string> headers = { - "Accept: application/json", - "Content-Type: application/json", + "Accept: application/json", + "Content-Type: application/json", }; if (!session.config.auth.anilist.auth_token.empty()) headers.push_back("Authorization: Bearer " + session.config.auth.anilist.auth_token); const std::string response = - Strings::ToUtf8String(HTTP::Request("https://graphql.anilist.co", headers, data.dump(), HTTP::Type::Post)); + Strings::ToUtf8String(HTTP::Request("https://graphql.anilist.co", headers, data.dump(), HTTP::Type::Post)); if (response.empty()) { session.SetStatusBar(Strings::Translate("AniList: JSON request returned an empty result!")); return std::nullopt; @@ -93,14 +93,14 @@ out = nlohmann::json::parse(response); } catch (const std::exception &ex) { session.SetStatusBar( - fmt::format(Strings::Translate("AniList: Failed to parse request JSON with error \"{}\"!"), ex.what())); + fmt::format(Strings::Translate("AniList: Failed to parse request JSON with error \"{}\"!"), ex.what())); return std::nullopt; } if (out.contains("/errors"_json_pointer) && out.at("/errors"_json_pointer).is_array()) { for (const auto &error : out.at("/errors"_json_pointer)) std::cerr << "AniList: Received an error in response: " - << JSON::GetString<std::string>(error, "/message"_json_pointer, "") << std::endl; + << JSON::GetString<std::string>(error, "/message"_json_pointer, "") << std::endl; session.SetStatusBar(Strings::Translate("AniList: Received an error in response!")); return std::nullopt; @@ -112,11 +112,11 @@ static void ParseListStatus(std::string status, Anime::Anime &anime) { static const std::unordered_map<std::string, Anime::ListStatus> map = { - {"CURRENT", Anime::ListStatus::Current }, - {"PLANNING", Anime::ListStatus::Planning }, - {"COMPLETED", Anime::ListStatus::Completed}, - {"DROPPED", Anime::ListStatus::Dropped }, - {"PAUSED", Anime::ListStatus::Paused } + {"CURRENT", Anime::ListStatus::Current }, + {"PLANNING", Anime::ListStatus::Planning }, + {"COMPLETED", Anime::ListStatus::Completed}, + {"DROPPED", Anime::ListStatus::Dropped }, + {"PAUSED", Anime::ListStatus::Paused } }; if (status == "REPEATING") { @@ -156,9 +156,9 @@ static void ParseTitle(const nlohmann::json &json, Anime::Anime &anime) { static const std::unordered_map<Anime::TitleLanguage, nlohmann::json::json_pointer> map = { - {Anime::TitleLanguage::Native, "/native"_json_pointer }, - {Anime::TitleLanguage::English, "/english"_json_pointer}, - {Anime::TitleLanguage::Romaji, "/romaji"_json_pointer }, + {Anime::TitleLanguage::Native, "/native"_json_pointer }, + {Anime::TitleLanguage::English, "/english"_json_pointer}, + {Anime::TitleLanguage::Romaji, "/romaji"_json_pointer }, }; for (const auto &[language, ptr] : map) @@ -194,14 +194,14 @@ anime.SetFormat(Translate::AniList::ToSeriesFormat(JSON::GetString<std::string>(json, "/format"_json_pointer, ""))); anime.SetAiringStatus( - Translate::AniList::ToSeriesStatus(JSON::GetString<std::string>(json, "/status"_json_pointer, ""))); + Translate::AniList::ToSeriesStatus(JSON::GetString<std::string>(json, "/status"_json_pointer, ""))); if (json.contains("/startDate"_json_pointer) && json["/startDate"_json_pointer].is_object()) anime.SetStartedDate(Date(json["/startDate"_json_pointer])); anime.SetCompletedDate(json.contains("/endDate"_json_pointer) && json["/endDate"_json_pointer].is_object() - ? Date(json["/endDate"_json_pointer]) - : anime.GetStartedDate()); + ? Date(json["/endDate"_json_pointer]) + : anime.GetStartedDate()); anime.SetPosterUrl(JSON::GetString<std::string>(json, "/coverImage/large"_json_pointer, "")); @@ -270,30 +270,30 @@ auto &auth = session.config.auth.anilist; static constexpr std::string_view query = "query ($id: Int) {\n" - " MediaListCollection (userId: $id, type: ANIME) {\n" - " lists {\n" - " name\n" - " entries {\n" - " score\n" - " notes\n" - " status\n" - " progress\n" - " startedAt {\n" - " year\n" - " month\n" - " day\n" - " }\n" - " completedAt {\n" - " year\n" - " month\n" - " day\n" - " }\n" - " updatedAt\n" - " media {\n" MEDIA_FIELDS " }\n" - " }\n" - " }\n" - " }\n" - "}\n"; + " MediaListCollection (userId: $id, type: ANIME) {\n" + " lists {\n" + " name\n" + " entries {\n" + " score\n" + " notes\n" + " status\n" + " progress\n" + " startedAt {\n" + " year\n" + " month\n" + " day\n" + " }\n" + " completedAt {\n" + " year\n" + " month\n" + " day\n" + " }\n" + " updatedAt\n" + " media {\n" MEDIA_FIELDS " }\n" + " }\n" + " }\n" + " }\n" + "}\n"; // clang-format off nlohmann::json request = { @@ -330,10 +330,10 @@ std::vector<int> Search(const std::string &search) { static constexpr std::string_view query = "query ($search: String) {\n" - " Page (page: 1, perPage: 50) {\n" - " media (search: $search, type: ANIME) {\n" MEDIA_FIELDS " }\n" - " }\n" - "}\n"; + " Page (page: 1, perPage: 50) {\n" + " media (search: $search, type: ANIME) {\n" MEDIA_FIELDS " }\n" + " }\n" + "}\n"; // clang-format off nlohmann::json json = { @@ -363,31 +363,31 @@ bool GetSeason(Anime::Season season) { static constexpr std::string_view query = - "query ($season: MediaSeason!, $season_year: Int!, $page: Int) {\n" - " Page(page: $page) {\n" - " media(season: $season, seasonYear: $season_year, type: ANIME, sort: START_DATE) {\n" MEDIA_FIELDS " }\n" - " pageInfo {\n" - " total\n" - " perPage\n" - " currentPage\n" - " lastPage\n" - " hasNextPage\n" - " }\n" - " }\n" - "}\n"; + "query ($season: MediaSeason!, $season_year: Int!, $page: Int) {\n" + " Page(page: $page) {\n" + " media(season: $season, seasonYear: $season_year, type: ANIME, sort: START_DATE) {\n" MEDIA_FIELDS " }\n" + " pageInfo {\n" + " total\n" + " perPage\n" + " currentPage\n" + " lastPage\n" + " hasNextPage\n" + " }\n" + " }\n" + "}\n"; int page = 0; bool has_next_page = true; while (has_next_page) { nlohmann::json json = { - {"query", query}, - {"variables", - { - {"season", Translate::AniList::ToString(season.season)}, - {"season_year", Strings::ToUtf8String(season.year)}, - {"page", page}, - } }, + {"query", query}, + {"variables", + { + {"season", Translate::AniList::ToString(season.season)}, + {"season_year", Strings::ToUtf8String(season.year)}, + {"page", page}, + } }, }; const std::optional<nlohmann::json> res = SendJSONRequest(json); @@ -418,13 +418,13 @@ return 0; static constexpr std::string_view query = - "mutation ($media_id: Int, $progress: Int, $status: MediaListStatus, $score: Int, $notes: String," - " $start: FuzzyDateInput, $comp: FuzzyDateInput, $repeat: Int) {\n" - " SaveMediaListEntry (mediaId: $media_id, progress: $progress, status: $status, scoreRaw: $score," - " notes: $notes, startedAt: $start, completedAt: $comp, repeat: $repeat) {\n" - " id\n" - " }\n" - "}\n"; + "mutation ($media_id: Int, $progress: Int, $status: MediaListStatus, $score: Int, $notes: String," + " $start: FuzzyDateInput, $comp: FuzzyDateInput, $repeat: Int) {\n" + " SaveMediaListEntry (mediaId: $media_id, progress: $progress, status: $status, scoreRaw: $score," + " notes: $notes, startedAt: $start, completedAt: $comp, repeat: $repeat) {\n" + " id\n" + " }\n" + "}\n"; // clang-format off nlohmann::json json = { {"query", query}, @@ -465,12 +465,11 @@ /* Prompt for PIN */ QDesktopServices::openUrl(QUrl(Strings::ToQString( - "https://anilist.co/api/v2/oauth/authorize?client_id=" + std::string(CLIENT_ID) + "&response_type=token"))); + "https://anilist.co/api/v2/oauth/authorize?client_id=" + std::string(CLIENT_ID) + "&response_type=token"))); bool ok; - QString token = QInputDialog::getText( - 0, "Credentials needed!", "Please enter the code given to you after logging in to AniList:", QLineEdit::Normal, - "", &ok); + QString token = QInputDialog::getText(0, "Credentials needed!", + "Please enter the code given to you after logging in to AniList:", QLineEdit::Normal, "", &ok); if (!ok || token.isEmpty()) return false; @@ -480,13 +479,13 @@ session.SetStatusBar(Strings::Translate("AniList: Requesting user ID...")); static constexpr std::string_view query = "query {\n" - " Viewer {\n" - " id\n" - " }\n" - "}\n"; + " Viewer {\n" + " id\n" + " }\n" + "}\n"; nlohmann::json json = { - {"query", query} + {"query", query} }; /* SendJSONRequest handles status errors */
--- a/src/services/kitsu.cc Sat Jul 25 14:33:03 2026 -0400 +++ b/src/services/kitsu.cc Sat Jul 25 14:54:32 2026 -0400 @@ -40,7 +40,7 @@ static const std::vector<std::string> headers = {{"Content-Type: application/json"}}; const std::string ret = - Strings::ToUtf8String(HTTP::Request(std::string(OAUTH_PATH), headers, data.dump(), HTTP::Type::Post)); + Strings::ToUtf8String(HTTP::Request(std::string(OAUTH_PATH), headers, data.dump(), HTTP::Type::Post)); if (ret.empty()) { session.SetStatusBar(Strings::Translate("Kitsu: Request returned empty data!")); return false; @@ -51,19 +51,19 @@ result = nlohmann::json::parse(ret, nullptr, false); } catch (const std::exception &ex) { session.SetStatusBar( - fmt::format(Strings::Translate("Kitsu: Failed to parse authorization data with error \"{}\""), ex.what())); + fmt::format(Strings::Translate("Kitsu: Failed to parse authorization data with error \"{}\""), ex.what())); return false; } if (result.contains("/error"_json_pointer)) { - session.SetStatusBar(fmt::format(Strings::Translate("Kitsu: Failed with error \"{}\"!"), - result["/error"_json_pointer].get<std::string>())); + session.SetStatusBar(fmt::format( + Strings::Translate("Kitsu: Failed with error \"{}\"!"), result["/error"_json_pointer].get<std::string>())); return false; } - const std::vector<nlohmann::json::json_pointer> required = { - "/access_token"_json_pointer, "/created_at"_json_pointer, "/expires_in"_json_pointer, - "/refresh_token"_json_pointer, "/scope"_json_pointer, "/token_type"_json_pointer}; + const std::vector<nlohmann::json::json_pointer> required = {"/access_token"_json_pointer, + "/created_at"_json_pointer, "/expires_in"_json_pointer, "/refresh_token"_json_pointer, "/scope"_json_pointer, + "/token_type"_json_pointer}; for (const auto &ptr : required) { if (!result.contains(ptr)) { @@ -74,7 +74,7 @@ session.config.auth.kitsu.access_token = result["/access_token"_json_pointer].get<std::string>(); session.config.auth.kitsu.access_token_expiration = result["/created_at"_json_pointer].get<Time::Timestamp>() + - result["/expires_in"_json_pointer].get<Time::Timestamp>(); + result["/expires_in"_json_pointer].get<Time::Timestamp>(); session.config.auth.kitsu.refresh_token = result["/refresh_token"_json_pointer].get<std::string>(); /* the next two are not that important */ @@ -85,8 +85,8 @@ static bool RefreshAccessToken(void) { const nlohmann::json request = { - {"grant_type", "refresh_token" }, - {"refresh_token", session.config.auth.kitsu.refresh_token}, + {"grant_type", "refresh_token" }, + {"refresh_token", session.config.auth.kitsu.refresh_token}, }; if (!SendAuthRequest(request)) @@ -113,9 +113,18 @@ static void AddAnimeFilters(std::map<std::string, std::string> &map) { static const std::vector<std::string> fields = { - "abbreviatedTitles", "averageRating", "episodeCount", "episodeLength", "posterImage", - "startDate", "status", "subtype", "titles", "categories", - "synopsis", "animeProductions", + "abbreviatedTitles", + "averageRating", + "episodeCount", + "episodeLength", + "posterImage", + "startDate", + "status", + "subtype", + "titles", + "categories", + "synopsis", + "animeProductions", }; static const std::string imploded = Strings::Implode(fields, ","); @@ -128,8 +137,16 @@ static void AddLibraryEntryFilters(std::map<std::string, std::string> &map) { static const std::vector<std::string> fields = { - "anime", "startedAt", "finishedAt", "notes", "progress", - "ratingTwenty", "reconsumeCount", "reconsuming", "status", "updatedAt", + "anime", + "startedAt", + "finishedAt", + "notes", + "progress", + "ratingTwenty", + "reconsumeCount", + "reconsuming", + "status", + "updatedAt", }; static const std::string imploded = Strings::Implode(fields, ","); @@ -139,16 +156,15 @@ /* ----------------------------------------------------------------------------- */ static std::optional<nlohmann::json> SendJSONAPIRequest(const std::string &path, - const std::map<std::string, std::string> ¶ms = {}, - const std::string &data = "", HTTP::Type type = HTTP::Type::Get) + const std::map<std::string, std::string> ¶ms = {}, const std::string &data = "", + HTTP::Type type = HTTP::Type::Get) { std::optional<std::string> token = AccountAccessToken(); if (!token) return std::nullopt; const std::vector<std::string> headers = {"Accept: application/vnd.api+json", - "Authorization: Bearer " + token.value(), - "Content-Type: application/vnd.api+json"}; + "Authorization: Bearer " + token.value(), "Content-Type: application/vnd.api+json"}; const std::string url = HTTP::EncodeParamsList(std::string(BASE_API_PATH) + path, params); @@ -161,7 +177,7 @@ json = nlohmann::json::parse(response); } catch (const std::exception &ex) { session.SetStatusBar( - fmt::format(Strings::Translate("Kitsu: Failed to parse response with error \"{}\""), ex.what())); + fmt::format(Strings::Translate("Kitsu: Failed to parse response with error \"{}\""), ex.what())); return std::nullopt; } @@ -183,9 +199,9 @@ static void ParseTitleJson(Anime::Anime &anime, const nlohmann::json &json) { static const std::map<std::string, Anime::TitleLanguage> lookup = { - {"en", Anime::TitleLanguage::English}, - {"en_jp", Anime::TitleLanguage::Romaji }, - {"ja_jp", Anime::TitleLanguage::Native } + {"en", Anime::TitleLanguage::English}, + {"en_jp", Anime::TitleLanguage::Romaji }, + {"ja_jp", Anime::TitleLanguage::Native } }; for (const auto &[string, title] : lookup) @@ -196,12 +212,12 @@ static void ParseSubtype(Anime::Anime &anime, const std::string &str) { static const std::map<std::string, Anime::SeriesFormat> lookup = { - {"ONA", Anime::SeriesFormat::Ona }, + {"ONA", Anime::SeriesFormat::Ona }, {"OVA", Anime::SeriesFormat::Ova }, - {"TV", Anime::SeriesFormat::Tv }, - {"movie", Anime::SeriesFormat::Movie }, - {"music", Anime::SeriesFormat::Music }, - {"special", Anime::SeriesFormat::Special} + {"TV", Anime::SeriesFormat::Tv }, + {"movie", Anime::SeriesFormat::Movie }, + {"music", Anime::SeriesFormat::Music }, + {"special", Anime::SeriesFormat::Special} }; if (lookup.find(str) == lookup.end()) @@ -213,11 +229,11 @@ static void ParseListStatus(Anime::Anime &anime, const std::string &str) { static const std::map<std::string, Anime::ListStatus> lookup = { - {"completed", Anime::ListStatus::Completed}, - {"current", Anime::ListStatus::Current }, - {"dropped", Anime::ListStatus::Dropped }, - {"on_hold", Anime::ListStatus::Paused }, - {"planned", Anime::ListStatus::Planning } + {"completed", Anime::ListStatus::Completed}, + {"current", Anime::ListStatus::Current }, + {"dropped", Anime::ListStatus::Dropped }, + {"on_hold", Anime::ListStatus::Paused }, + {"planned", Anime::ListStatus::Planning } }; if (lookup.find(str) == lookup.end()) @@ -229,11 +245,11 @@ static void ParseSeriesStatus(Anime::Anime &anime, const std::string &str) { static const std::map<std::string, Anime::SeriesStatus> lookup = { - {"current", Anime::SeriesStatus::Releasing }, - {"finished", Anime::SeriesStatus::Finished }, - {"tba", Anime::SeriesStatus::Hiatus }, // is this right? - {"unreleased", Anime::SeriesStatus::Cancelled }, - {"upcoming", Anime::SeriesStatus::NotYetReleased}, + {"current", Anime::SeriesStatus::Releasing }, + {"finished", Anime::SeriesStatus::Finished }, + {"tba", Anime::SeriesStatus::Hiatus }, // is this right? + {"unreleased", Anime::SeriesStatus::Cancelled }, + {"upcoming", Anime::SeriesStatus::NotYetReleased}, }; if (lookup.find(str) == lookup.end()) @@ -273,7 +289,7 @@ ParseTitleJson(anime, attributes["/titles"_json_pointer]); if (attributes.contains("/abbreviatedTitles"_json_pointer) && - attributes["/abbreviatedTitles"_json_pointer].is_array()) + attributes["/abbreviatedTitles"_json_pointer].is_array()) for (const auto &title : attributes["/abbreviatedTitles"_json_pointer]) anime.AddTitleSynonym(title.get<std::string>()); @@ -283,10 +299,10 @@ if (attributes.contains("/startDate"_json_pointer) && attributes["/startDate"_json_pointer].is_string()) anime.SetStartedDate(attributes["/startDate"_json_pointer].get<std::string>()); - anime.SetCompletedDate(attributes.contains("/endDate"_json_pointer) && - attributes["/endDate"_json_pointer].is_string() - ? attributes["/endDate"_json_pointer].get<std::string>() - : anime.GetStartedDate()); + anime.SetCompletedDate( + attributes.contains("/endDate"_json_pointer) && attributes["/endDate"_json_pointer].is_string() + ? attributes["/endDate"_json_pointer].get<std::string>() + : anime.GetStartedDate()); if (attributes.contains("/subtype"_json_pointer) && attributes["/subtype"_json_pointer].is_string()) ParseSubtype(anime, attributes["/subtype"_json_pointer].get<std::string>()); @@ -295,7 +311,7 @@ ParseSeriesStatus(anime, attributes["/status"_json_pointer].get<std::string>()); if (attributes.contains("/posterImage/original"_json_pointer) && - attributes["/posterImage/original"_json_pointer].is_string()) + attributes["/posterImage/original"_json_pointer].is_string()) anime.SetPosterUrl(attributes["/posterImage/original"_json_pointer].get<std::string>()); if (attributes.contains("/episodeCount"_json_pointer) && attributes["/episodeCount"_json_pointer].is_number()) @@ -310,15 +326,15 @@ static int ParseLibraryJson(const nlohmann::json &json) { static const std::vector<nlohmann::json::json_pointer> required = { - "/id"_json_pointer, - "/relationships/anime/data/id"_json_pointer, - "/attributes"_json_pointer, + "/id"_json_pointer, + "/relationships/anime/data/id"_json_pointer, + "/attributes"_json_pointer, }; for (const auto &ptr : required) { if (!json.contains(ptr)) { - session.SetStatusBar(fmt::format(Strings::Translate("Kitsu: Failed to parse library object! (missing {})"), - ptr.to_string())); + session.SetStatusBar(fmt::format( + Strings::Translate("Kitsu: Failed to parse library object! (missing {})"), ptr.to_string())); return 0; } } @@ -346,11 +362,11 @@ if (attributes.contains("/startedAt"_json_pointer) && attributes["/startedAt"_json_pointer].is_string()) anime.SetUserDateStarted( - Date(Time::ParseISO8601Time(attributes["/startedAt"_json_pointer].get<std::string>()))); + Date(Time::ParseISO8601Time(attributes["/startedAt"_json_pointer].get<std::string>()))); if (attributes.contains("/finishedAt"_json_pointer) && attributes["/finishedAt"_json_pointer].is_string()) anime.SetUserDateCompleted( - Date(Time::ParseISO8601Time(attributes["/finishedAt"_json_pointer].get<std::string>()))); + Date(Time::ParseISO8601Time(attributes["/finishedAt"_json_pointer].get<std::string>()))); if (attributes.contains("/notes"_json_pointer) && attributes["/notes"_json_pointer].is_string()) anime.SetUserNotes(attributes["/notes"_json_pointer].get<std::string>()); @@ -422,7 +438,7 @@ static const nlohmann::json::json_pointer required = "/type"_json_pointer; if (!json.contains(required) && !json[required].is_string()) { session.SetStatusBar( - fmt::format(Strings::Translate("Kitsu: Failed to generic object! (missing {})"), required.to_string())); + fmt::format(Strings::Translate("Kitsu: Failed to generic object! (missing {})"), required.to_string())); return 0; } @@ -456,11 +472,11 @@ bool have_next_page = true; std::map<std::string, std::string> params = { - {"filter[user_id]", auth.user_id }, - {"filter[kind]", "anime" }, - {"include", "anime" }, - {"page[offset]", Strings::ToUtf8String(page) }, - {"page[limit]", Strings::ToUtf8String(LIBRARY_MAX_SIZE)} + {"filter[user_id]", auth.user_id }, + {"filter[kind]", "anime" }, + {"include", "anime" }, + {"page[offset]", Strings::ToUtf8String(page) }, + {"page[limit]", Strings::ToUtf8String(LIBRARY_MAX_SIZE)} }; AddAnimeFilters(params); AddLibraryEntryFilters(params); @@ -502,12 +518,12 @@ /* :) */ static const std::map<std::string, std::string> anime_params = { - {"include", Strings::Implode( - { - "categories", - "animeProductions", - "animeProductions.producer", - }, ",")} + {"include", Strings::Implode( + { + "categories", + "animeProductions", + "animeProductions.producer", + }, ",")} }; bool RetrieveAnimeMetadata(int id) @@ -531,7 +547,7 @@ if (!json.contains("/included"_json_pointer) || !json["/included"_json_pointer].is_array()) { session.SetStatusBar( - Strings::Translate("Kitsu: Server returned bad data when trying to retrieve anime metadata!")); + Strings::Translate("Kitsu: Server returned bad data when trying to retrieve anime metadata!")); return false; } @@ -560,7 +576,7 @@ if (!json.contains("/data"_json_pointer) || !json["/data"_json_pointer].is_array()) { session.SetStatusBar( - Strings::Translate("Kitsu: Server returned bad data when trying to retrieve search results!")); + Strings::Translate("Kitsu: Server returned bad data when trying to retrieve search results!")); return {}; } @@ -580,10 +596,10 @@ bool GetSeason(Anime::Season season) { static const std::map<Anime::Season::Name, std::string> map = { - {Anime::Season::Name::Winter, "winter"}, - {Anime::Season::Name::Spring, "spring"}, - {Anime::Season::Name::Summer, "summer"}, - {Anime::Season::Name::Autumn, "fall" }, + {Anime::Season::Name::Winter, "winter"}, + {Anime::Season::Name::Spring, "spring"}, + {Anime::Season::Name::Summer, "summer"}, + {Anime::Season::Name::Autumn, "fall" }, }; session.SetStatusBar(Strings::Translate("Kitsu: Retrieving season data...")); @@ -602,7 +618,7 @@ if (!json.contains("/data"_json_pointer) || !json["/data"_json_pointer].is_array()) { session.SetStatusBar( - Strings::Translate("Kitsu: Server returned bad data when trying to retrieve search results!")); + Strings::Translate("Kitsu: Server returned bad data when trying to retrieve search results!")); return false; } @@ -709,7 +725,7 @@ bool AuthorizeUser(const std::string &email, const std::string &password) { const nlohmann::json body = { - {"grant_type", "password" }, + {"grant_type", "password" }, {"username", email }, {"password", HTTP::UrlEncode(password)} }; @@ -718,7 +734,7 @@ return false; static const std::map<std::string, std::string> params = { - {"filter[self]", "true"} + {"filter[self]", "true"} }; std::optional<nlohmann::json> response = SendJSONAPIRequest("/users", params);
--- a/src/services/services.cc Sat Jul 25 14:33:03 2026 -0400 +++ b/src/services/services.cc Sat Jul 25 14:54:32 2026 -0400 @@ -12,7 +12,7 @@ void Synchronize() { session.SetStatusBar( - fmt::format(Strings::Translate("{}: Retrieving anime list..."), Translate::ToString(session.config.service))); + fmt::format(Strings::Translate("{}: Retrieving anime list..."), Translate::ToString(session.config.service))); switch (session.config.service) { case Anime::Service::AniList: @@ -45,7 +45,7 @@ std::vector<int> Search(const std::string &search) { session.SetStatusBar( - fmt::format(Strings::Translate("{}: Requesting search query..."), Translate::ToString(session.config.service))); + fmt::format(Strings::Translate("{}: Requesting search query..."), Translate::ToString(session.config.service))); switch (session.config.service) { case Anime::Service::AniList: @@ -59,8 +59,8 @@ bool GetSeason(Anime::Season season) { - session.SetStatusBar(fmt::format(Strings::Translate("{}: Retrieving anime season data..."), - Translate::ToString(session.config.service))); + session.SetStatusBar(fmt::format( + Strings::Translate("{}: Retrieving anime season data..."), Translate::ToString(session.config.service))); switch (session.config.service) { case Anime::Service::AniList: @@ -74,8 +74,8 @@ void UpdateAnimeEntry(int id) { - session.SetStatusBar(fmt::format(Strings::Translate("{}: Updating remote anime entry..."), - Translate::ToString(session.config.service))); + session.SetStatusBar(fmt::format( + Strings::Translate("{}: Updating remote anime entry..."), Translate::ToString(session.config.service))); switch (session.config.service) { case Anime::Service::AniList:
