Add URL-based deck import from popular deck sites#10247
Add URL-based deck import from popular deck sites#10247RafaelHGOliveira wants to merge 10 commits intoCard-Forge:masterfrom
Conversation
Add support for importing decks directly from URLs in the deck import dialog. Supported sites: Moxfield, Archidekt, EDHREC, TappedOut, and MTGGoldfish. Each site has a dedicated fetcher that converts the response to a text format compatible with DeckRecognizer. The URL field is added to the top of the existing import dialog with async fetching via SwingWorker to keep the UI responsive.
EDHREC: Rewrite parser to correctly extract card names from nested cardlists/cardviews JSON structure. Previously only found the commander. Moxfield: Add unicode unescape for card names with apostrophes (e.g. Herald\u0027s Horn -> Herald's Horn). Archidekt: Improve error message when API returns error for newer deck IDs that aren't supported by the legacy API endpoint.
The extractStringValue method had a 500-char search limit that was too small for Archidekt's JSON where the "name" field is ~758 chars after "oracleCard" due to many intermediate fields (legalities, faces, etc). Increased limit to 2000 chars.
- Extract deck name from API responses (Moxfield, Archidekt, EDHREC, TappedOut) and include as Name: line in imported text - Remove unnecessary trailing " |" from commander card lines in multi-commander decks - Commanders now listed on separate lines without pipe separator
Moxfield and EDHREC APIs return commanders in both the commander section and the mainboard, causing Commander decks to import with extra cards (e.g. 104 instead of 100 with partner commanders). Deduplicate by collecting commander/companion names before parsing mainboard and skipping any card already placed in the command zone.
|
I think it would be better if we have different sites as different classes that would be more clean |
|
your class isn't even connected to anything...? :/ imo it's way too much work to try and keep this updated whenever their api changes, that's why they have Export functions in the first place 🤷♂️ |
|
I think some of these approaches are fine, others raise concerns.
|
|
Thanks for the feedback everyone! @Hanmac — Good point. I'll refactor into separate fetcher classes per site. @tool4ever — The integration commit was missing from the PR, my bad. Regarding maintenance: the goal is to reduce friction for multiplayer — copy-pasting export text still requires multiple steps. But I understand the concern about API stability. @Jetz72 — Really appreciate the thorough analysis.
I'll update the PR with the refactored classes and address the API concerns. Thanks! |
Split the monolithic DeckUrlFetcher into individual fetcher classes for each supported site (Moxfield, Archidekt, EDHREC, TappedOut, MTGGoldfish). DeckUrlFetcher now acts as a thin dispatcher and DeckSiteFetcher provides shared HTTP/JSON utilities as a base class.
Summary
Adds the ability to import decks directly from a URL in the deck editor. Supported sites:
Motivation
I started using Forge to play Commander with friends online, and one of the biggest friction points was getting our decks into the game. We all build decks on different websites, so having to manually export and convert was tedious. This feature lets you just paste a URL and go.
What it does
DeckUrlFetcherclass that detects the site from the URL and fetches/parses the deck via each site's API or page scrapingDeckRecognizerpipeline — fetched text is passed straight throughCommits
All commits by Rafael Oliveira.
Test plan