Repository navigation
api: add card lookup endpoint - #891
Merged
Merged
Conversation
Contributor
Author
Now included, command-line override will now returns correspond default filename card0 or card1. Changes are squashed and fixup. All requested changes are applied. |
Add card.get_cards() to return the effective card ID and source for each reader supported by the current game. Identify each source as file or override, include the basename only for file-backed cards, and expose -card0 and -card1 overrides without treating them as files. Only allow the function when an API password is configured because card IDs should not be exposed to unauthenticated network clients. This lets static frontends such as spice.nimabe.net import existing cards without requiring users to open files on the game machine and copy IDs manually.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to GitHub Issue or related Pull Request, if one exists
N/A
Description of change
I am developing spice.nimabe.net, a static frontend for SpiceAPI. It already supports generating and inserting new card IDs, but SpiceAPI does not provide a way to discover cards already configured on the game machine.
This makes the frontend inconvenient for existing users who generated and saved their card IDs locally. They currently have to open each card file on the game machine and manually copy its ID into the frontend.
This change adds a
card.get_cardsAPI function that enumerates the current cards for readers supported by the running game. Each entry contains:source, set tofileoroverridefile_namefor file-backed cardsFile-backed cards expose only the save-file basename. Active
-card0and-card1values are returned withsource: "override"and nofile_name, instead of representing an override as a file. spicefe derives the useful default import namescard0andcard1from the reader index. Reader enumeration useseamuse_get_game_keypads()so games with only one reader do not expose a second card.This allows spicefe and other API clients to offer one-click import for existing cards, without requiring users to manually find and copy their card IDs.
Because card IDs are sensitive,
card.get_cardscan only be used when the operator has configured an API password. No full filesystem path is exposed. Missing, unreadable, and invalid cards are omitted.The existing
card.insertfunction remains unchanged. To avoid requiring a password for the whole card module, this change adds support for password requirements on individual API functions while preserving existing module-wide password behavior.Access to configured card paths and runtime card overrides is synchronized because API requests may read them concurrently with configuration updates.
The Python and Dart API wrappers and README documentation have been updated for the new function and source metadata.
Testing
src/spice2x/build_docker.shbuild successfully.git diff --checkpasses.This implementation was prepared with assistance from OpenAI Codex.