#pragma once // YuGiOhBandaiCardPreviewSource: Yugipedia pageimages + SMW ask for Bandai // Carddass previews and auto-detect (by English name or Bandai number). #include "ccm/ports/ICardPreviewSource.hpp" #include "ccm/ports/IHttpClient.hpp" #include #include #include namespace ccm { class YuGiOhBandaiCardPreviewSource final : public ICardPreviewSource { public: explicit YuGiOhBandaiCardPreviewSource(IHttpClient& http); [[nodiscard]] bool supportsAutoDetectPrint() const noexcept override { return true; } Result fetchImageUrl(std::string_view name, std::string_view setId, std::string_view setNo) override; Result detectFirstPrint(std::string_view name, std::string_view setId) override; Result> detectPrintVariants(std::string_view name, std::string_view setId) override; Result detectBySetNo(std::string_view setId, std::string_view setNo) override; Result> detectVariantsBySetNo( std::string_view setId, std::string_view setNo) override; // Prefer " (Bandai)" / English / Sealdass page depending on setId. static std::string preferredPageTitle(std::string_view name, std::string_view setId, std::string_view setNo); static std::string buildPageImagesUrl(std::string_view pageTitle); static std::string buildAskByNameUrl(std::string_view englishName); static std::string buildAskByNumberUrl(std::string_view setNo); // True for Jump/Toei promo codes (J1, TA2, …). Yugipedia's SMW // `Bandai number` property is numeric-only, so these must use the // promotional gallery instead of `action=ask`. [[nodiscard]] static bool isAlphanumericPromoNumber(std::string_view setNo); static Result> parsePromoGalleryResponse(const std::string& body, std::string_view wantedSetNo); static Result parsePageImagesResponse(const std::string& body); static Result> parseAskResponse(const std::string& body, std::string_view preferredSetId, std::string_view wantedSetNo = {}); static AutoDetectedPrint enrichPrint(AutoDetectedPrint print, std::string_view pageTitle); private: Result fetchPageImage(std::string_view pageTitle); Result> askByName(std::string_view name, std::string_view setId); Result> askByNumber(std::string_view setId, std::string_view setNo); IHttpClient& http_; }; } // namespace ccm