|
| 1 | +export const metadata = { |
| 2 | + title: 'Library', |
| 3 | + description: |
| 4 | + "On this page, we'll dive into how to manage the instance's library and sources.", |
| 5 | +} |
| 6 | + |
| 7 | +# Library |
| 8 | + |
| 9 | +Drop supports having more than one library 'source' enabled at a time. This allows users to use multiple folders on their server, and merge all the separate libraries into one. |
| 10 | + |
| 11 | +Each library source has a specific type, which defines how it connects to games: |
| 12 | + |
| 13 | +- Drop-style (internally `Filesystem`). The default and recommended type, it supports the versioned folders that Drop was built for. |
| 14 | +- Compatibility (internally `FlatFilesystem`). Implemented for compatibility with GameVault and similar libraries, doesn't use versioned folders. |
| 15 | + |
| 16 | +You can read more about the user's side of things on the docs: [Library Sources](https://docs.droposs.org/docs/library). |
| 17 | + |
| 18 | +<Note> |
| 19 | + We plan to add network-based library sources in the future, so keep this in |
| 20 | + mind when using the endpoints. They may take longer to return values in the |
| 21 | + future. |
| 22 | +</Note> |
| 23 | + |
| 24 | +--- |
| 25 | + |
| 26 | +## The game model |
| 27 | + |
| 28 | +The game model stores most of the metadata attached to the game, and is used to render store pages and display in clients. |
| 29 | + |
| 30 | +### Properties |
| 31 | + |
| 32 | +<Properties> |
| 33 | + #### Internal IDs and metadata |
| 34 | + <Property name="id" type="string"> |
| 35 | + UUID of the game. Used internally to refer to this game. |
| 36 | + </Property> |
| 37 | + <Property name="metadataSource" type="string"> |
| 38 | + ID of the metadata sourced originally used to import this game. |
| 39 | + </Property> |
| 40 | + <Property name="metadataId" type="string"> |
| 41 | + Internal metadata source's ID for the original import. |
| 42 | + </Property> |
| 43 | + <Property name="created" type="timestamp"> |
| 44 | + Timestamp of when this game was originally created. |
| 45 | + </Property> |
| 46 | + <Property name="libraryId" type="string"> |
| 47 | + ID of library source this game is linked to. |
| 48 | + </Property> |
| 49 | + <Property name="libraryPath" type="string"> |
| 50 | + Path within the library source this game is linked to. |
| 51 | + </Property> |
| 52 | + |
| 53 | +#### Admin-provided metadata |
| 54 | + |
| 55 | +<Property name="mName" type="string"> |
| 56 | + The name of this game. |
| 57 | +</Property> |
| 58 | +<Property name="mShortDescription" type="string"> |
| 59 | + A short description of this game, without requiring formatting. |
| 60 | +</Property> |
| 61 | +<Property name="mDescription" type="markdown"> |
| 62 | + A markdown representation of the long-form description of this game. |
| 63 | +</Property> |
| 64 | +<Property name="mReleased" type="timestamp"> |
| 65 | + When this game was released. |
| 66 | +</Property> |
| 67 | + |
| 68 | +<Property name="mIconObjectId" type="string"> |
| 69 | + Object ID of icon. |
| 70 | +</Property> |
| 71 | +<Property name="mBannerObjectId" type="string"> |
| 72 | + Object ID of background banner. Usually a wide, high-resolution image. |
| 73 | +</Property> |
| 74 | +<Property name="mCoverObjectId" type="string"> |
| 75 | + Object ID of cover. Usually a tall image with the title of the game. |
| 76 | +</Property> |
| 77 | +<Property name="mImageCarouselObjectIds" type="string[]"> |
| 78 | + Array of object IDs shown on the store's carousel. |
| 79 | +</Property> |
| 80 | +<Property name="mImageLibraryObjectIds" type="string[]"> |
| 81 | + An array of all object IDs linked to this game. |
| 82 | +</Property> |
| 83 | + |
| 84 | +#### Metadata flags |
| 85 | + |
| 86 | + <Property name="featured" type="boolean"> |
| 87 | + Whether or not this game is featured for the carousel. |
| 88 | + </Property> |
| 89 | +</Properties> |
| 90 | + |
| 91 | +--- |
| 92 | + |
| 93 | +## Fetch library {{ tag: 'GET', label: '/api/v1/admin/library', apilevel: "system", acl: "library:read" }} |
| 94 | + |
| 95 | +<Row> |
| 96 | + <Col> |
| 97 | + |
| 98 | + This endpoint fetches all unimported and imported games. |
| 99 | + |
| 100 | + ### Response values |
| 101 | + <Properties> |
| 102 | + |
| 103 | + <Property name="unimportedGames" type="object"> |
| 104 | + An object of library ID to paths that are yet to be imported. |
| 105 | + </Property> |
| 106 | + <Property name="games" type="array"> |
| 107 | + An array of game objects with attached status. |
| 108 | + |
| 109 | + <Properties> |
| 110 | + |
| 111 | + <Property name="game" type="object"> |
| 112 | + A metadata game object. Refer to [the game model](#the-game-model). |
| 113 | + </Property> |
| 114 | + <Property name="status" type="string | object"> |
| 115 | + A field indicating the status of this game. |
| 116 | + |
| 117 | + If it is a string, it'll be "offline", which means that the library source this game is connected to isn't working right now. |
| 118 | + |
| 119 | + If it's an object, it'll look like: |
| 120 | + |
| 121 | + ```json |
| 122 | + { |
| 123 | + "noVersions": false, |
| 124 | + "unimportedVersions": [] |
| 125 | + } |
| 126 | + ``` |
| 127 | + |
| 128 | + </Property> |
| 129 | +</Properties> |
| 130 | + </Property> |
| 131 | +</Properties> |
| 132 | + |
| 133 | + </Col> |
| 134 | + <Col sticky> |
| 135 | + |
| 136 | + <CodeGroup title="Request" tag="GET" label="/api/v1/admin/library"> |
| 137 | + |
| 138 | + ```bash {{ title: 'cURL' }} |
| 139 | + curl -G http://localhost:3000/api/v1/admin/library \ |
| 140 | + -H "Authorization: Bearer {token}" |
| 141 | + ``` |
| 142 | + |
| 143 | + ```js |
| 144 | + const response = await fetch("http://localhost:3000/api/v1/admin/library", { |
| 145 | + headers: { |
| 146 | + Authorization: "Bearer {token}" |
| 147 | + }, |
| 148 | + }); |
| 149 | + |
| 150 | + const results = await response.json(); |
| 151 | + |
| 152 | + ``` |
| 153 | + |
| 154 | + </CodeGroup> |
| 155 | + |
| 156 | + ```json {{ title: 'Response' }} |
| 157 | + { |
| 158 | + "unimportedGames": { |
| 159 | + "myLibraryId": [ // These are paths on disk |
| 160 | + "My Game", |
| 161 | + "My Other Game", |
| 162 | + "Horizon Zero Dawn" |
| 163 | + ], |
| 164 | + "myOtherLibraryId": [] |
| 165 | + }, |
| 166 | + "games": [ |
| 167 | + { |
| 168 | + "game": { ... }, |
| 169 | + "status": { |
| 170 | + "noVersions": false, |
| 171 | + "unimportedVersions": [] |
| 172 | + } |
| 173 | + }, |
| 174 | + { |
| 175 | + "game": { ... }, |
| 176 | + "status": "offline" |
| 177 | + } |
| 178 | + ] |
| 179 | + } |
| 180 | + ``` |
| 181 | + |
| 182 | + </Col> |
| 183 | +</Row> |
| 184 | + |
| 185 | +--- |
0 commit comments