Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/python
- from jikanpy import Jikan
- from termcolor import colored
- import sys
- import inquirer
- import re
- jikan = Jikan()
- def anime_name(anime):
- anime = str(anime)
- search = jikan.search('anime', anime)
- return search
- def anime_download(items, anime):
- items_crop = items['results'][:10]
- my_anime_list = []
- for each in items_crop:
- if each.get('type') == 'OVA' or each.get('type') == 'Special' or each.get('type') == 'Movie':
- continue
- else:
- my_anime_list.append(each['title'])
- my_anime_list = [anime_name.lower() for anime_name in my_anime_list]
- final_list = []
- for item in my_anime_list:
- item = item.title()
- final_list.append(item)
- print(final_list)
- list_length = len(final_list)
- if list_length == 0:
- print("Not found")
- elif list_length > 1:
- which_anime = [
- inquirer.List('Anime',
- message="Which one you need to download? ",
- choices=final_list,
- ), ]
- answer = inquirer.prompt(which_anime)
- chosen_anime = answer['Anime']
- elif list_length == 1:
- chosen_anime = final_list[0]
- 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)
- try:
- if sys.argv[1] == "--search":
- try:
- anime = sys.argv[2]
- items = anime_name(anime)
- anime_show(items)
- except IndexError:
- print('ERR: No Anime Name Is Given To Search!')
- elif sys.argv[1] == "--download":
- try:
- anime = sys.argv[2]
- items = anime_name(anime)
- anime_download(items, anime)
- except IndexError:
- print('ERR: No Anime Name Is Given To Download!')
- except IndexError:
- print('Enter an option.\nOptions can be:\n --search\n --season\n --download\n --random')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement