TV Series info using Episodate API with Python

Hello everyone, in this tutorial we are going to fetch information about TV shows using API in Python. We are going to use the Episodate API. This API provides us with tons of information regarding the shows.

Using this you can make your own website like IMDB.

Features of Episodate API

This API provides a ton of features like browsing for the most popular TV shows, searching for a specific TV show and getting details of that specific TV show.

You can find the documentation of the Episodate API here.

Top 10 popular TV shows using  Episodate API in Python

Let us start by importing the requests module.

import requests

info = []
base_url = ' https://www.episodate.com/api/most-popular'
response = requests.get(base_url)
x = response.json()
shows = x['tv_shows']
for i in range (10):
    print(str(i+1)+"."+shows[i]['name'])
    print("-"+shows[i]['network'])
    print()

Here we used the API request to find the most popular TV shows, we converted the response into JSON format and performed certain list and dictionary operations to filter our data from the JSON response.

OUTPUT:

1.The Flash
-The CW

2.Game of Thrones
-HBO

3.Arrow
-The CW

4.Lucifer
-Netflix

5.Supergirl
-The CW

6.DC's Legends of Tomorrow
-The CW

7.The Walking Dead
-AMC

8.Dragon Ball Super
-Fuji TV

9.Stranger Things
-Netflix

10.The 100
-The CW

Consider another example where we need details about a specific show:

We will do this by using another API call provided by Episodate to fetch the details of a TV show. The URL is ‘https://www.episodate.com/api/show-details?q={name}’.

Here we simply have to replace {name} with the permalink of the show(as there can be more than one shows with the same name).

To find the permalink of the TV show we can use this API call – ‘https://www.episodate.com/api/search?q={name}’

One of my favorite TV show is Lucifer, let us now make a script that fetches us details about the show.

import requests

info = []
base_url = 'https://www.episodate.com/api/show-details?q='
name = input("Enter the name of the TV show: ")
url = base_url+name #API URL
response = requests.get(url)
x = response.json()
shows = x['tvShow']
episodes = shows["episodes"]
 
#Filtering content from the JSON response 

print("\n\nTITLE: "+ shows['name'] )
print("       - "+ shows['network'])
print("\nDESCRIPTION: "+ shows['description'] )
print("\nRATING: "+ shows['rating'])
genre = shows['genres']
print("GENRE: " + str(shows['genres']))
for i in range (len(episodes)):
    print('Season '+ str(episodes[i]['season'])+' Episode '+ str(episodes[i]['episode'])+" - "+episodes[i]['name'])

After getting the response, I just performed list and dictionary operations to filter the data.

OUTPUT:

TITLE: Lucifer
- Netflix

DESCRIPTION: The Devil has come to Los Angeles….. (And so on, I am not adding all the lines)

RATING: 9.6777
GENRE: ['Crime', 'Drama', 'Supernatural']
Season 1 Episode 1 - Pilot
Season 1 Episode 2 - Lucifer, Stay. Good Devil.
Season 1 Episode 3 - The Would-Be Prince of Darkness
Season 1 Episode 4 - Manly Whatnots
Season 1 Episode 5 - Sweet Kicks
Season 1 Episode 6 - Favorite Son
Season 1 Episode 7 - Wingman
Season 1 Episode 8 - Et Tu, Doctor?
Season 1 Episode 9 - A Priest Walks Into a Bar
Season 1 Episode 10 - Pops
Season 1 Episode 11 - St. Lucifer
Season 1 Episode 12 - #TeamLucifer
Season 1 Episode 13 - Take Me Back to Hell
Season 1 Episode 14 - Episode 14
Season 2 Episode 1 - Everything's Coming Up Lucifer
Season 2 Episode 2 - Liar, Liar, Slutty Dress on Fire
Season 2 Episode 3 - Sin-Eater
Season 2 Episode 4 - Lady Parts
Season 2 Episode 5 - Weaponizer
Season 2 Episode 6 - Monster
Season 2 Episode 7 - My Little Monkey
Season 2 Episode 8 - Trip to Stabby Town
Season 2 Episode 9 - Homewrecker
Season 2 Episode 10 - Quid Pro Ho
Season 2 Episode 11 - Stewardess Interruptus
Season 2 Episode 12 - Love Handles
Season 2 Episode 13 - A Good Day to Die
Season 2 Episode 14 - Candy Morningstar
Season 2 Episode 15 - Deceptive Little Parasite
Season 2 Episode 16 - God Johnson
Season 2 Episode 17 - Sympathy for the Goddess
Season 2 Episode 18 - The Good, the Bad and the Crispy
Season 3 Episode 1 - They're Back, Aren't They?
Season 3 Episode 2 - The One with the Baby Carrot
Season 3 Episode 3 - Mr. and Mrs. Mazikeen Smith
Season 3 Episode 4 - What Would Lucifer Do?
Season 3 Episode 5 - Welcome Back, Charlotte Richards
Season 3 Episode 6 - Vegas with Some Radish
Season 3 Episode 7 - Off the Record
Season 3 Episode 8 - Chloe Does Lucifer
Season 3 Episode 9 - The Sinnerman
Season 3 Episode 10 - The Sin Bin
Season 3 Episode 11 - City of Angels?
Season 3 Episode 12 - All About Her
Season 3 Episode 13 - Til Death Do Us Part
Season 3 Episode 14 - My Brother's Keeper
Season 3 Episode 15 - High School Poppycock
Season 3 Episode 16 - Infernal Guinea Pig
Season 3 Episode 17 - Let Pinhead Sing!
Season 3 Episode 18 - The Last Heartbreak
Season 3 Episode 19 - Orange Is the New Maze
Season 3 Episode 20 - The Angel of San Bernardino
Season 3 Episode 21 - Anything Pierce Can Do I Can Do Better
Season 3 Episode 22 - All Hands on Decker
Season 3 Episode 23 - Quintessential Deckerstar
Season 3 Episode 24 - A Devil of My Word
Season 3 Episode 25 - Boo Normal
Season 3 Episode 26 - Once Upon a Time
Season 4 Episode 1 - Everything's Okay
Season 4 Episode 2 - Somebody's Been Reading Dante's Inferno
Season 4 Episode 3 - O, Ye of Little Faith, Father
Season 4 Episode 4 - All About Eve
Season 4 Episode 5 - Expire Erect
Season 4 Episode 6 - Orgy Pants to Work
Season 4 Episode 7 - Devil Is as Devil Does
Season 4 Episode 8 - Super Bad Boyfriend
Season 4 Episode 9 - Save Lucifer
Season 4 Episode 10 - Who's da New King of Hell?
Season 5 Episode 1 - Really Sad Devil Guy
Season 5 Episode 2 - Lucifer! Lucifer! Lucifer!
Season 5 Episode 3 - ¡Diablo!
Season 5 Episode 4 - It Never Ends Well for the Chicken
Season 5 Episode 5 - Detective Amenadiel
Season 5 Episode 6 - BluBallz
Season 5 Episode 7 - Our Mojo
Season 5 Episode 8 - Spoiler Alert

Also read: Using IMDbPY to search for movies : Python

Leave a Reply

Your email address will not be published. Required fields are marked *