pip install -r requirements.txt
Created
July 10, 2020 15:03
-
-
Save sloev/fd61182079ece55abbb895c5e0d964c4 to your computer and use it in GitHub Desktop.
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
| requests | |
| mac-say |
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
| import requests | |
| import json | |
| import time | |
| import mac_say | |
| url = "https://gateway.gofundme.com/web-gateway/v1/feed/support-loppen/donations?limit=2&offset=0&sort=recent" | |
| totals_url = "https://gateway.gofundme.com/web-gateway/v1/feed/support-loppen/counts" | |
| spoken = set() | |
| def play_status(): | |
| resp = requests.get(totals_url) | |
| data = resp.json() | |
| counts = data.get("references", {}).get("counts") | |
| mac_say.say(["-v","Sara",f"""{counts['total_donations']}, har nu tilsammen doneret, {int(counts['amount_raised_unattributed'])}, kroner"""]) | |
| while True: | |
| new = False | |
| resp = requests.get(url) | |
| data = resp.json() | |
| donations = data.get("references", {}).get("donations") | |
| for donation in donations: | |
| if donation['donation_id'] not in spoken: | |
| new = True | |
| spoken.add(donation['donation_id']) | |
| mac_say.say(["-v","Sara", f"{', '.join(donation['name'].split())}, har lige nu doneret, {int(donation['amount'])}, kroner"]) | |
| time.sleep(2) | |
| print(donation['donation_id']) | |
| if new: | |
| play_status() | |
| time.sleep(2) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment