-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetch.py
51 lines (40 loc) · 1.25 KB
/
fetch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 1 18:34:54 2023
@author: User
"""
from imdb import IMDb
def get_movie_details(movie_title):
# Create an instance of the IMDb class
ia = IMDb()
# Search for movies with the given title
movies = ia.search_movie(movie_title)
if movies:
movie = movies[0]
ia.update(movie)
# Retrieve movie details
title = movie['title']
movie_url = ia.get_imdbURL(movie)
cast = [actor['name'] for actor in movie['cast'][:10]] # Get only the first 10 cast members
poster_url = movie['full-size cover url']
plot = movie['plot'][0]
year = movie['year']
country = movie['countries'][0]
genres = movie['genres']
return title, movie_url, cast, poster_url, plot, year, country, genres
else:
return None
def get_poster(movie_title):
# Create an instance of the IMDb class
ia = IMDb()
# Search for movies with the given title
movies = ia.search_movie(movie_title)
if movies:
movie = movies[0]
ia.update(movie)
# Retrieve movie details
title = movie['title']
poster_url = movie['full-size cover url']
return title, poster_url
else:
return None