-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.py
57 lines (39 loc) · 1.58 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
#!/bin/python
import sys
import inquirer
from jikanpy import Jikan
from termcolor import colored
jikan = Jikan()
# Searches anime name using Jikan
def anime_name(anime):
search = jikan.search('anime', anime)
return search
def anime_show(items):
items_crop = items['results'][:10]
for each in items_crop:
if each.get('type') == 'OVA' or each.get('type') == 'Special':
continue
else:
print(colored('Name:', 'green'), each['title'])
if each.get('type') == 'TV':
print(colored('Start Date:', 'green'), colored(each['start_date'][:4], 'red'))
if each.get('end_date') == None:
print(colored('End Date:', 'green'), colored('Not finished', 'red'))
else:
print(colored('End Date:', 'green'), colored(each['end_date'][:4], 'red'))
test = each['episodes']
if test == 0:
pass
else:
print(colored('Episodes:', 'green'), colored(each['episodes'], 'red'))
elif each.get('type') == 'Movie':
print(colored('Released on:', 'green'), colored(each['start_date'][:4], 'red'))
print(colored('Score:', 'green'), colored(each['score'], 'red'))
print(colored('MAL link:', 'green'), colored(each['url'], 'blue'))
print('')
print(colored('Description: ', 'green'), each['synopsis'])
print('')
print('-' * 80)
anime = sys.argv[1]
items = anime_name(anime)
anime_show(items)