Skip to content

Instantly share code, notes, and snippets.

@SergioSV96
Created May 15, 2020 12:47
Show Gist options
  • Save SergioSV96/cec03e3e2bef1536d0b2a5e1d09c90ef to your computer and use it in GitHub Desktop.
Save SergioSV96/cec03e3e2bef1536d0b2a5e1d09c90ef to your computer and use it in GitHub Desktop.
Next TV Show episode
import json
import requests
def get_show_id(title: str):
response = requests.get(f"https://www.episodate.com/api/search?q={title}&page=1")
json_data = json.loads(response.text)
if len(json_data["tv_shows"]) == 0:
exit("Not found")
elif json_data["tv_shows"][0]["status"] != "Running":
exit("Ended")
else:
return json_data["tv_shows"][0]["id"]
def get_latest_episode(id: int):
response = requests.get(f"https://www.episodate.com/api/show-details?q={id}")
json_data = json.loads(response.text)
if json_data["tvShow"]["countdown"]:
return json_data["tvShow"]["countdown"]["air_date"]
else:
exit("Not announced yet")
if __name__ == "__main__":
show_name = input()
show_name = show_name.replace(" ", "%20")
show_id = get_show_id(show_name)
print(get_latest_episode(show_id))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment