-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSampleOmdbAPI.py
39 lines (30 loc) · 1.02 KB
/
SampleOmdbAPI.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
#! /usr/bin/Python
# Import class to manage Omdb Api.
from OmdbApi import MoviesApi
# Import json parser.
import json
# Import sys library.
import sys
params = len (sys.argv)
# Usage python3 ./SampleOmdbApi.py Film_title
# Usage python3 ./SampleOmdbApi.py Bakuman
if (params == 1):
print ("We need at least one film title to start searching")
elif (params > 1):
movies = MoviesApi()
# It searchs into API every title we got at argument.
for title in range (1, params) :
# Title to search.
print ("Searching: " + sys.argv[title])
# First we need to do a query with the film title.
movies.findFilmByTitle (sys.argv[title])
# Second we get all movies returned by API.
moviesList = movies.getResults ()
# Check if there's a valid fims list.
if (moviesList != -1):
# Print all films/series found
for movie in moviesList:
print (movie['Title'])
print ("")
else:
print ("0 results. ")