Scryfall
FUNCTIONS THAT INTERACT WITH SCRYFALL
MTGJSON_SET_DATA_EXTRA = ['sealedProduct', 'booster', 'cards']
module-attribute
ERROR HANDLING
card_scan(img_url)
Downloads scryfall art from URL @param img_url: Scryfall URI for image. @return: Filename of the saved image, None if unsuccessful.
Source code in src/utils/scryfall.py
340 341 342 343 344 345 346 347 348 349 350 |
|
check_playable_card(card_json)
Checks if this card object is a playable game piece. @param card_json: Scryfall data for this card. @return: Valid scryfall data if check passed, else None.
Source code in src/utils/scryfall.py
405 406 407 408 409 410 411 412 413 414 415 |
|
get_basic_land(card_name, name_normalized, set_code)
cached
Generate fake Scryfall data from basic land. @param card_name: Name of the basic land card. @param name_normalized: Normalized version of the name string. @param set_code: Desired set code for the basic land. @return: Fake scryfall data.
Source code in src/utils/scryfall.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
get_card_data(card_name, card_set=None, card_number=None)
Fetch card data from Scryfall API. @param card_name: Name of the card. @param card_set: Set code of the card. @param card_number: Collector number of the card. @return: Scryfall dict or Exception.
Source code in src/utils/scryfall.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
|
get_card_search(card_name, card_set=None, lang='en', extras=False)
Get card using /cards/search Scryfall API endpoint. @note: https://scryfall.com/docs/api/cards/search @param card_name: Name of the card, ex: Damnation @param card_set: Set code to look for, ex: MH2 @param lang: Lang code to look for, ex: en @param extras: Forces include_extras if True, otherwise use setting. @return: Card dict or ScryfallError
Source code in src/utils/scryfall.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
|
get_card_unique(card_set, card_number, lang='en')
Get card using /cards/:code/:number(/:lang) Scryfall API endpoint. @note: https://scryfall.com/docs/api/cards/collector @param card_set: Set code of the card, ex: MH2 @param card_number: Collector number of the card @param lang: Lang code to look for, ex: en @return: Card dict or ScryfallError
Source code in src/utils/scryfall.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
|
get_cards_oracle(oracle_id, all_pages=False, **kwargs)
Grab paginated card list from a Scryfall API endpoint using the Oracle ID of the card. @param oracle_id: Scryfall Oracle ID of the card. @param all_pages: Whether to return all additional pages, or just the first. @param kwargs: Optional parameters to pass to API endpoint.
Source code in src/utils/scryfall.py
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
|
get_cards_paged(url=SCRY_API_CARDS_SEARCH, all_pages=True, **kwargs)
Grab paginated card list from a Scryfall API endpoint. @param url: Scryfall API URL endpoint to access. @param all_pages: Whether to return all additional pages, or just the first. @param kwargs: Optional parameters to pass to API endpoint.
Source code in src/utils/scryfall.py
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
|
get_set_data(card_set)
Grab available set data. @param card_set: The set to look for, ex: MH2 @return: MTG set dict or empty dict.
Source code in src/utils/scryfall.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
|
get_set_mtgjson(card_set)
Grab available set data from MTG Json. @param card_set: The set to look for, ex: MH2 @return: MTGJson set dict or empty dict.
Source code in src/utils/scryfall.py
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
|
get_set_scryfall(card_set)
Grab available set data from MTG Json. @param card_set: The set to look for, ex: MH2 @return: Scryfall set dict or empty dict.
Source code in src/utils/scryfall.py
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
|
handle_final_exception(fail_response)
Decorator to handle any exception and return appropriate failure value. @param fail_response: Return value if Exception occurs. @return: Return value of the function, or fail_response.
Source code in src/utils/scryfall.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
|
handle_request_failure(fail_response='error')
Decorator to handle all Scryfall request failure cases, and return appropriate failure value. @param fail_response: The value to return if request failed entirely. By default, it tries to return a ScryfallError formatting proper failure message. @return: Requested data if successful, fail_response if not.
Source code in src/utils/scryfall.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
|
parse_card_info(file_path)
Retrieve card name from the input file, and optional tags (artist, set, number). @param file_path: Path to the image file. @return: Dict of card details.
Source code in src/utils/scryfall.py
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 |
|
process_scryfall_data(data)
Process any additional required data before sending it to the layout object. @param data: Unprocessed scryfall data. @return: Processed scryfall data.
Source code in src/utils/scryfall.py
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 |
|