-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.py
61 lines (51 loc) · 1.63 KB
/
search.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
52
53
54
55
56
57
58
59
60
61
import argparse
from imdb import IMDb, IMDbError
# or import imdb
# ia = imdb.IMDb()
ia = IMDb()
# Simple movie search
def getMovies(movie):
myMovie = ia.search_movie(movie)
try:
for film in myMovie:
return film
except IMDbError as e:
print(e)
# Simple people search
def getPeople(folks):
stars = ia.search_person(folks)
try:
for star in stars:
return star
except IMDbError as e:
print(e)
# Simple keyword search
def findKeywords(word):
_find = ia.search_keyword(word)
try:
for words in _find:
return words
except IMDbError as e:
print(e)
parser = argparse.ArgumentParser(description='Search imdb for movies, people, or keywords')
parser.add_argument('-m', '--movie', help='search for a movie or movies', type=str, metavar='film')
parser.add_argument('-p', '--people', help='search for a people', type=str, metavar='folks')
parser.add_argument('-k', '--keyword', help='search using keywords', type=str, metavar='word')
# parser.add_argument('yourMovie', help='Search for a movie or movies', type=str)
# yourMovie = input('What movie are you looking for?\n ')
args = parser.parse_args()
if args.movie:
print()
print(getMovies(args.movie))
elif args.people:
print()
print(getPeople(args.people))
elif args.keyword:
print()
print(findKeywords(args.keyword))
else:
print('Search IMDB for Movies, People, or Keywords')
print()
print('USAGE: Use "-m MOVIE" to search for a movie or movies')
print(' Use "-p PEOPLE" to search for a person')
print(' Or use "-k KEYWORD" to search by keyword')