Skip to content

Instantly share code, notes, and snippets.

@sloev
Created July 10, 2020 15:03
Show Gist options
  • Select an option

  • Save sloev/fd61182079ece55abbb895c5e0d964c4 to your computer and use it in GitHub Desktop.

Select an option

Save sloev/fd61182079ece55abbb895c5e0d964c4 to your computer and use it in GitHub Desktop.

pip install -r requirements.txt

requests
mac-say
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