Dotfiles for my tiling window manager + terminal workflow.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.1 KiB

  1. #!/usr/bin/env python
  2. import requests
  3. def get_tier_value(num):
  4. url = f"https://www.glhfers.com/api/rom-metadata/{num}"
  5. try:
  6. response = requests.get(url)
  7. response.raise_for_status() # Raise an error for bad status codes
  8. data = response.json()
  9. # Find the Tier trait value
  10. for attribute in data.get("attributes", []):
  11. if attribute.get("trait_type") == "Tier":
  12. return attribute.get("value")
  13. # value = attribute.get("value")
  14. return "Tier not found"
  15. except requests.exceptions.RequestException as e:
  16. return f"Error fetching data: {e}"
  17. def main():
  18. while True:
  19. try:
  20. num = input("Enter a number: ")
  21. if num.lower() == 'exit':
  22. break
  23. num = int(num) # Convert input to integer
  24. tier_value = get_tier_value(num)
  25. print(f"{tier_value}")
  26. except ValueError:
  27. print("Invalid input. Please enter a number or 'exit' to quit.")
  28. if __name__ == "__main__":
  29. main()