From b18bc002d99f4afda9ebdadbadb928d00e8209cb Mon Sep 17 00:00:00 2001 From: tooomm Date: Sat, 24 Jul 2021 11:34:04 +0200 Subject: [PATCH 01/19] Rework README a bit (#280) --- README.md | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 12762415..6632c72a 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ # Magic-Spoiler [![Discord](https://img.shields.io/discord/314987288398659595?label=Discord&logo=discord&logoColor=white)](https://discord.gg/3Z9yzmA) [![Gitter Chat](https://img.shields.io/gitter/room/Cockatrice/Magic-Spoiler)](https://gitter.im/Cockatrice/Magic-Spoiler) # -Magic-Spoiler is a Python script to scrape [Scryfall](https://scryfall.com) to compile XML files (Cockatrice formatted) and application-ready JSON files (MTGJSON formatted) with information about spoiled cards from upcoming sets. +Magic-Spoiler is a Python script to query the [Scryfall](https://scryfall.com) API to compile XML files (Cockatrice formatted) and application-ready JSON files (MTGJSON formatted) with information about spoiled cards from upcoming sets. -## Output [![Build Status](https://github.com/Cockatrice/Magic-Spoiler/workflows/Deploy/badge.svg?branch=master&event=schedule)](https://github.com/Cockatrice/Magic-Spoiler/actions?query=workflow%3ADeploy+event%3Aschedule+branch%3Amaster) ## +## Output [![Build Status](https://github.com/Cockatrice/Magic-Spoiler/workflows/Deploy/badge.svg?branch=master)](https://github.com/Cockatrice/Magic-Spoiler/actions?query=workflow%3ADeploy+event%3Aworkflow_dispatch+event%3Aschedule+branch%3Amaster) ## >**Enable "Download Spoilers Automatically" in `Cockatrice → Settings → Card Sources → Spoilers` to get updates automatically pushed to your client!**
You can also [add the desired .xml file(s) to your customsets folder manually](https://github.com/Cockatrice/Cockatrice/wiki/Custom-Cards-&-Sets#to-add-custom-sets-follow-these-steps) to make Cockatrice use it. @@ -17,8 +17,10 @@ Just looking for XML or JSON files? [They are in our `files` branch!](https://g When run by our CI, the script automatically updates the files and uploads new versions to this branch. ([History of changes](https://github.com/Cockatrice/Magic-Spoiler/commits/files))
GitHub Actions are scheduled to autoamtically run on a daily basis. -## Errors ## -Noticed an error in the card data? Check out our [Contributing file](https://github.com/Cockatrice/Magic-Spoiler/blob/master/.github/CONTRIBUTING.md) for information on how to help! +## Contributing ## +Noticed an error in the card data? Check out our [Contributing file](https://github.com/Cockatrice/Magic-Spoiler/blob/master/.github/CONTRIBUTING.md) for information on how to help fixing it! + +We do happily accept PR's that improve our script as well! ## Running ## @@ -36,8 +38,11 @@ pip install -r requirements.txt $> python -m magic_spoiler ``` -Outputs the following files to `out/` directory:
-`spoiler.xml`, `spoiler.json`
-`{SET_CODE}.xml`, `{SET_CODE}.json` -> **spoiler** → files contain all currently available spoilers from different sets
-> **{SETCODE}** → files contain just the spoiler available for this single set
+### Output ### + +All XML and JSON spoiler files are written to the `out/` directory: + +| File Name | Content | +|:--|:--| +| `spoiler.xml`, `spoiler.json` | files contain **all** currently available spoilers from different **sets** | +| `{SET_CODE}.xml`, `{SET_CODE}.json` | files contain just the spoiler available for this **single set** | From 4791c9e2d200333272113f09b2458f2d9a1634df Mon Sep 17 00:00:00 2001 From: tooomm Date: Tue, 27 Jul 2021 18:46:06 +0200 Subject: [PATCH 02/19] CI: Add link to deploy commit (#279) --- .github/workflows/deploy.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f6720fe5..869a12c3 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -73,3 +73,5 @@ jobs: git add -A . git commit -m "Deploy: $GITHUB_SHA" git push + deploy_commit=`git rev-parse HEAD` + echo "See deployment: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/commit/$deploy_commit" From 6fd325b176c87231f63b6816b2978e88a12e528d Mon Sep 17 00:00:00 2001 From: tooomm Date: Mon, 24 Jan 2022 14:29:33 +0100 Subject: [PATCH 03/19] tweaks --- .github/workflows/deploy.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 869a12c3..254b5c50 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -21,6 +21,7 @@ jobs: # Do not run the scheduled workflow on forks if: github.event != 'schedule' || github.repository_owner == 'Cockatrice' + name: Check for new spoiler runs-on: ubuntu-latest env: @@ -74,4 +75,4 @@ jobs: git commit -m "Deploy: $GITHUB_SHA" git push deploy_commit=`git rev-parse HEAD` - echo "See deployment: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/commit/$deploy_commit" + echo ::notice::"See deployment: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/commit/$deploy_commit" From 764ff7203c4f12e6c0a3fd811a41f56c15cd1a6d Mon Sep 17 00:00:00 2001 From: tooomm Date: Mon, 24 Jan 2022 14:44:42 +0100 Subject: [PATCH 04/19] Update __main__.py --- magic_spoiler/__main__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/magic_spoiler/__main__.py b/magic_spoiler/__main__.py index 9c2474a3..b8ed8c19 100644 --- a/magic_spoiler/__main__.py +++ b/magic_spoiler/__main__.py @@ -648,6 +648,7 @@ def main() -> None: print("::set-output name=deploy::true") else: print("::set-output name=deploy::false") + print("::notice:: No new spoilers found") if __name__ == "__main__": From 47c3b439634a806ab96f8b0a9bae40837b6e5bd9 Mon Sep 17 00:00:00 2001 From: tooomm Date: Mon, 24 Jan 2022 14:48:05 +0100 Subject: [PATCH 05/19] Update __main__.py --- magic_spoiler/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/magic_spoiler/__main__.py b/magic_spoiler/__main__.py index b8ed8c19..75636a50 100644 --- a/magic_spoiler/__main__.py +++ b/magic_spoiler/__main__.py @@ -412,7 +412,7 @@ def write_spoilers_xml(trice_dicts: Dict[str, List[Dict[str, Any]]]) -> bool: return False # Move new version to old location - print("Changes detected, replacing spoiler.xml with updated version") + print("::notice::Changes detected, replacing spoiler.xml with updated version") shutil.move(card_xml_file.name, old_xml_location) return True From bcfb1038c771c13a269aa2c9b32ca4df0b45e4b5 Mon Sep 17 00:00:00 2001 From: tooomm Date: Mon, 24 Jan 2022 15:00:05 +0100 Subject: [PATCH 06/19] Update __main__.py --- magic_spoiler/__main__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/magic_spoiler/__main__.py b/magic_spoiler/__main__.py index 75636a50..0ab27bae 100644 --- a/magic_spoiler/__main__.py +++ b/magic_spoiler/__main__.py @@ -408,7 +408,7 @@ def write_spoilers_xml(trice_dicts: Dict[str, List[Dict[str, Any]]]) -> bool: old_xml_location = str(OUTPUT_DIR.joinpath(output_file_name)) if compare_xml_content(card_xml_file.name, old_xml_location): - print("No new data in spoiler.xml, skipping replacement") + print("::notice::No new data in spoiler.xml, skipping replacement") return False # Move new version to old location @@ -646,9 +646,10 @@ def main() -> None: # Set output to deploy if changed: print("::set-output name=deploy::true") + print("::notice title=Updates available::New spoiler files will be uploaded") else: print("::set-output name=deploy::false") - print("::notice:: No new spoilers found") + print("::notice title=No updates available::There are no new spoiler cards") if __name__ == "__main__": From 8bceceae6e6de87759eb74816be8b746e8217281 Mon Sep 17 00:00:00 2001 From: tooomm Date: Mon, 24 Jan 2022 15:09:11 +0100 Subject: [PATCH 07/19] Update __main__.py --- magic_spoiler/__main__.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/magic_spoiler/__main__.py b/magic_spoiler/__main__.py index 0ab27bae..243f7bf3 100644 --- a/magic_spoiler/__main__.py +++ b/magic_spoiler/__main__.py @@ -408,11 +408,11 @@ def write_spoilers_xml(trice_dicts: Dict[str, List[Dict[str, Any]]]) -> bool: old_xml_location = str(OUTPUT_DIR.joinpath(output_file_name)) if compare_xml_content(card_xml_file.name, old_xml_location): - print("::notice::No new data in spoiler.xml, skipping replacement") + print("No new data in spoiler.xml, skipping replacement") return False # Move new version to old location - print("::notice::Changes detected, replacing spoiler.xml with updated version") + print("Changes detected, replacing spoiler.xml with updated version") shutil.move(card_xml_file.name, old_xml_location) return True @@ -644,13 +644,13 @@ def main() -> None: changed |= delete_old_files() # Set output to deploy - if changed: - print("::set-output name=deploy::true") - print("::notice title=Updates available::New spoiler files will be uploaded") - else: - print("::set-output name=deploy::false") - print("::notice title=No updates available::There are no new spoiler cards") - + if CI == true: + if changed: + print("::set-output name=deploy::true") + print("::notice title=Updates available::New spoiler files will be uploaded") + else: + print("::set-output name=deploy::false") + print("::notice title=No updates available::There are no new spoiler cards") if __name__ == "__main__": main() From 929a04c9151f026bfb7fe0b70afb189eef0191c2 Mon Sep 17 00:00:00 2001 From: tooomm Date: Mon, 24 Jan 2022 15:14:30 +0100 Subject: [PATCH 08/19] Update __main__.py --- magic_spoiler/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/magic_spoiler/__main__.py b/magic_spoiler/__main__.py index 243f7bf3..d4862afb 100644 --- a/magic_spoiler/__main__.py +++ b/magic_spoiler/__main__.py @@ -644,7 +644,7 @@ def main() -> None: changed |= delete_old_files() # Set output to deploy - if CI == true: + if os.getenv('CI'): if changed: print("::set-output name=deploy::true") print("::notice title=Updates available::New spoiler files will be uploaded") From ef0ced8d690f05a2101c4be1042647f5cc2ee845 Mon Sep 17 00:00:00 2001 From: tooomm Date: Mon, 24 Jan 2022 15:27:22 +0100 Subject: [PATCH 09/19] Update __main__.py --- magic_spoiler/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/magic_spoiler/__main__.py b/magic_spoiler/__main__.py index d4862afb..4f35eea0 100644 --- a/magic_spoiler/__main__.py +++ b/magic_spoiler/__main__.py @@ -644,7 +644,7 @@ def main() -> None: changed |= delete_old_files() # Set output to deploy - if os.getenv('CI'): + if os.environ('CI'): if changed: print("::set-output name=deploy::true") print("::notice title=Updates available::New spoiler files will be uploaded") From 1adfed5fc6237e814f0a4f6066a855faed98fa29 Mon Sep 17 00:00:00 2001 From: tooomm Date: Mon, 24 Jan 2022 15:35:56 +0100 Subject: [PATCH 10/19] Update __main__.py --- magic_spoiler/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/magic_spoiler/__main__.py b/magic_spoiler/__main__.py index 4f35eea0..243f7bf3 100644 --- a/magic_spoiler/__main__.py +++ b/magic_spoiler/__main__.py @@ -644,7 +644,7 @@ def main() -> None: changed |= delete_old_files() # Set output to deploy - if os.environ('CI'): + if CI == true: if changed: print("::set-output name=deploy::true") print("::notice title=Updates available::New spoiler files will be uploaded") From d54f4127930b24848a46d7096c36962c3e8f44fd Mon Sep 17 00:00:00 2001 From: tooomm Date: Mon, 24 Jan 2022 15:38:34 +0100 Subject: [PATCH 11/19] Update __main__.py --- magic_spoiler/__main__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/magic_spoiler/__main__.py b/magic_spoiler/__main__.py index 243f7bf3..5da6985f 100644 --- a/magic_spoiler/__main__.py +++ b/magic_spoiler/__main__.py @@ -5,6 +5,7 @@ import contextvars import datetime import hashlib import json +import os import pathlib import shutil import time @@ -644,7 +645,7 @@ def main() -> None: changed |= delete_old_files() # Set output to deploy - if CI == true: + if os.environ('CI'): if changed: print("::set-output name=deploy::true") print("::notice title=Updates available::New spoiler files will be uploaded") From 8afb4cee34f6c7e966995f5892cb5ed6ff022172 Mon Sep 17 00:00:00 2001 From: tooomm Date: Mon, 24 Jan 2022 15:43:55 +0100 Subject: [PATCH 12/19] Update __main__.py --- magic_spoiler/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/magic_spoiler/__main__.py b/magic_spoiler/__main__.py index 5da6985f..76153c58 100644 --- a/magic_spoiler/__main__.py +++ b/magic_spoiler/__main__.py @@ -645,7 +645,7 @@ def main() -> None: changed |= delete_old_files() # Set output to deploy - if os.environ('CI'): + if os.environ['CI']: if changed: print("::set-output name=deploy::true") print("::notice title=Updates available::New spoiler files will be uploaded") From 0610f60c9f196f8b43a2b26e823eccdfab7a2441 Mon Sep 17 00:00:00 2001 From: tooomm Date: Mon, 24 Jan 2022 17:31:24 +0100 Subject: [PATCH 13/19] fix quote --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 254b5c50..eefbc8d5 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -75,4 +75,4 @@ jobs: git commit -m "Deploy: $GITHUB_SHA" git push deploy_commit=`git rev-parse HEAD` - echo ::notice::"See deployment: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/commit/$deploy_commit" + echo "::notice::See deployment: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/commit/$deploy_commit" From bf02be35c87dd486196ddcd4c7a3ca99c8b018db Mon Sep 17 00:00:00 2001 From: tooomm Date: Mon, 31 Jan 2022 14:27:06 +0100 Subject: [PATCH 14/19] fix if condition --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index eefbc8d5..d2146812 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -19,7 +19,7 @@ on: jobs: deploy: # Do not run the scheduled workflow on forks - if: github.event != 'schedule' || github.repository_owner == 'Cockatrice' + if: github.event_name != 'schedule' || github.repository_owner == 'Cockatrice' name: Check for new spoiler runs-on: ubuntu-latest From b6b518b1d94cd4f4d24575fb248946f92319c34e Mon Sep 17 00:00:00 2001 From: tooomm Date: Fri, 4 Feb 2022 15:09:17 +0100 Subject: [PATCH 15/19] title --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 254b5c50..e6adb40e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -75,4 +75,4 @@ jobs: git commit -m "Deploy: $GITHUB_SHA" git push deploy_commit=`git rev-parse HEAD` - echo ::notice::"See deployment: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/commit/$deploy_commit" + echo ::notice title=New data uploaded::"See deployment: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/commit/$deploy_commit" From 13023af7802d0e65210abbaf3b6c1e91b8ecfc18 Mon Sep 17 00:00:00 2001 From: tooomm Date: Fri, 4 Feb 2022 15:17:32 +0100 Subject: [PATCH 16/19] wording --- magic_spoiler/__main__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/magic_spoiler/__main__.py b/magic_spoiler/__main__.py index 76153c58..c4f9fe31 100644 --- a/magic_spoiler/__main__.py +++ b/magic_spoiler/__main__.py @@ -648,10 +648,9 @@ def main() -> None: if os.environ['CI']: if changed: print("::set-output name=deploy::true") - print("::notice title=Updates available::New spoiler files will be uploaded") else: print("::set-output name=deploy::false") - print("::notice title=No updates available::There are no new spoiler cards") + print("::notice title=No updates available::No new spoiler cards found for deployment") if __name__ == "__main__": main() From d234a9ccef7e2add17997471d0421264829d777f Mon Sep 17 00:00:00 2001 From: tooomm Date: Fri, 4 Feb 2022 15:19:15 +0100 Subject: [PATCH 17/19] Update __main__.py --- magic_spoiler/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/magic_spoiler/__main__.py b/magic_spoiler/__main__.py index c4f9fe31..923d4427 100644 --- a/magic_spoiler/__main__.py +++ b/magic_spoiler/__main__.py @@ -644,7 +644,7 @@ def main() -> None: # Cleanup outdated stuff that's not necessary changed |= delete_old_files() - # Set output to deploy + # Only when run in CI, enable deployment on changes if os.environ['CI']: if changed: print("::set-output name=deploy::true") From a33e90021b949012e0823e9d196176122fe250fb Mon Sep 17 00:00:00 2001 From: tooomm Date: Fri, 4 Feb 2022 16:54:35 +0100 Subject: [PATCH 18/19] cleanup --- magic_spoiler/__main__.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/magic_spoiler/__main__.py b/magic_spoiler/__main__.py index 923d4427..50de81ac 100644 --- a/magic_spoiler/__main__.py +++ b/magic_spoiler/__main__.py @@ -5,7 +5,6 @@ import contextvars import datetime import hashlib import json -import os import pathlib import shutil import time @@ -644,13 +643,12 @@ def main() -> None: # Cleanup outdated stuff that's not necessary changed |= delete_old_files() - # Only when run in CI, enable deployment on changes - if os.environ['CI']: - if changed: - print("::set-output name=deploy::true") - else: - print("::set-output name=deploy::false") - print("::notice title=No updates available::No new spoiler cards found for deployment") + # Enable deployment on changes (used in CI) + if changed: + print("::set-output name=deploy::true") + else: + print("::set-output name=deploy::false") + print("::notice title=No updates available::No new spoiler cards found for deployment") if __name__ == "__main__": main() From 5e6d9ad5f77a5288aac00977d25c4d27c7bbdf58 Mon Sep 17 00:00:00 2001 From: ebbit1q Date: Fri, 4 Feb 2022 23:56:11 +0100 Subject: [PATCH 19/19] Update magic_spoiler/__main__.py --- magic_spoiler/__main__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/magic_spoiler/__main__.py b/magic_spoiler/__main__.py index 50de81ac..ff32a358 100644 --- a/magic_spoiler/__main__.py +++ b/magic_spoiler/__main__.py @@ -650,5 +650,6 @@ def main() -> None: print("::set-output name=deploy::false") print("::notice title=No updates available::No new spoiler cards found for deployment") + if __name__ == "__main__": main()