async def al(ctx): """SEARCH FOR ANIME WITH Anilist. EX: s.al School Rumble""" try: new_msg = ctx.message.content[4:] search = An.search.anime(new_msg) episodes = search['data']['Page']['media'][0]['episodes'] episodes_dumps = json.dumps(episodes) if episodes_dumps == "null": episodes = "Currently airing or unknown" else: episodes = episodes name = search['data']['Page']['media'][0]['title']['romaji'] rank = search['data']['Page']['media'][0]['popularity'] score = search['data']['Page']['media'][0]['averageScore'] img = search['data']['Page']['media'][0]['coverImage']['large'] season = search['data']['Page']['media'][0]['season'] an = Pymoe.Anilist() ide = search['data']['Page']['media'][0]['id'] a = an.get.anime(ide) b = json.dumps(a) c = json.loads(b) d = c['data']['Media']['description'] e = d.replace("<br><br>", "") await bot.say( "Anime Name: {}\nEpisodes: {}\nRank: {}\nAverage Score: {}%\nSeason: {}\nSummary: {}\n{}" .format(name, episodes, rank, score, season, e, img)) except IndexError: print("") finally: #if anime is not found output not found not_found = json.dumps(search) not_json = json.loads(not_found) if not_json['data']['Page']['pageInfo']['lastPage'] == 0: await bot.say("Anime {} is not found.".format(new_msg))
def test_kitsuUser(self): kitsu = Pymoe.Kitsu( "dd031b32d2f56c990b1425efe6c42ad847e7fe3ab46bf1299f05ecd856bdb7dd", "54d7307928f63414defd96399fc31ba847961ceaecef3a5fd93144e960c0e151") test_search = kitsu.user.search("CCubed") self.assertIsInstance(test_search, SearchWrapper) self.assertEqual("119864", test_search[0]['id']) self.assertEqual(1, len(test_search)) self.assertEqual("CCubed", test_search[0]['attributes']['name']) del test_search test_search = kitsu.user.get(119864) self.assertIsInstance(test_search, dict) self.assertEqual("119864", test_search['id']) self.assertEqual("CCubed", test_search['attributes']['name']) del test_search tokens = kitsu.auth.authenticate("*****@*****.**", os.environ['KITSU_PW']) update_dict = { "about": "A Computer Programmer, Coder and Future Teacher." } self.assertTrue(kitsu.user.update(119864, update_dict, tokens[0])) del update_dict
def test_Mal(self): mal = Pymoe.Mal("TeshiKO", os.environ['MAL_PW']) test_search = mal.anime.search("Bleach") self.assertIsInstance(test_search, NT_SEARCH_ANIME) self.assertEqual(test_search.finished[0].title, "Bleach") self.assertEqual(test_search.finished[0].id, "269") test_anime = test_search.finished[0] del test_search test_search = mal.manga.search("King") self.assertIsInstance(test_search, NT_SEARCH_MANGA) self.assertEqual(test_search.finished[0].title, "Kareshi Kanojo no Jijou") self.assertEqual(test_search.finished[0].id, "17") test_manga = test_search.finished[0] del test_search test_anime.status.user = "******" test_anime.episodes.current = 1 self.assertTrue(mal.anime.add(test_anime)) test_anime.episodes.current = 2 self.assertTrue(mal.anime.update(test_anime)) self.assertTrue(mal.anime.delete(test_anime)) del test_anime test_manga.status.user = "******" test_manga.chapters.current = 1 test_manga.volumes.current = 1 self.assertTrue(mal.manga.add(test_manga)) test_manga.chapters.current = 2 self.assertTrue(mal.manga.update(test_manga)) self.assertTrue(mal.manga.delete(test_manga))
def test_kitsuAuth(self): kitsu = Pymoe.Kitsu( "dd031b32d2f56c990b1425efe6c42ad847e7fe3ab46bf1299f05ecd856bdb7dd", "54d7307928f63414defd96399fc31ba847961ceaecef3a5fd93144e960c0e151") kitsu.auth.set_remember(True) tokens = kitsu.auth.authenticate("*****@*****.**", os.environ['KITSU_PW']) self.assertIsInstance(tokens, tuple) self.assertEqual(tokens[0], kitsu.auth.get("*****@*****.**"))
def test_baka(self): baka = Pymoe.Bakatsuki() self.assertIsInstance(baka.active(), list) self.assertIsInstance(baka.light_novels(), list) self.assertIsInstance(baka.teaser(), list) self.assertIsInstance(baka.web_novels(), list) test_novel = baka.active()[0] self.assertIsInstance(baka.chapters(test_novel[0]), OrderedDict) self.assertIsInstance(baka.cover(test_novel[1]), str) self.assertIsInstance(baka.get_text(test_novel[0]), str) del test_novel
def test_kitsuManga(self): kitsu = Pymoe.Kitsu( "dd031b32d2f56c990b1425efe6c42ad847e7fe3ab46bf1299f05ecd856bdb7dd", "54d7307928f63414defd96399fc31ba847961ceaecef3a5fd93144e960c0e151") test_search = kitsu.manga.get(20463) self.assertIsInstance(test_search, dict) self.assertIsInstance( test_search['data']['attributes']['canonicalTitle'], str) del test_search test_search = kitsu.manga.search("King") self.assertIsInstance(test_search, SearchWrapper) self.assertIsInstance(test_search[0]['attributes']['canonicalTitle'], str) del test_search
def test_kitsuLibrary(self): kitsu = Pymoe.Kitsu( "dd031b32d2f56c990b1425efe6c42ad847e7fe3ab46bf1299f05ecd856bdb7dd", "54d7307928f63414defd96399fc31ba847961ceaecef3a5fd93144e960c0e151") test_search = kitsu.library.get(119864) self.assertIsInstance(test_search, SearchWrapper) del test_search tokens = kitsu.auth.authenticate("*****@*****.**", os.environ['KITSU_PW']) new_entry = {"status": "current", "progress": 4} lib_entry_id = kitsu.library.create(119864, 244, "anime", tokens[0], new_entry) self.assertTrue( kitsu.library.update(lib_entry_id, {"progress": 5}, tokens[0])) self.assertTrue(kitsu.library.delete(lib_entry_id, tokens[0]))
def test_Anilist(self): alist = Pymoe.Anilist(os.environ['ANILIST_CID'], os.environ['ANILIST_CSECRET']) # Search self.assertIsInstance(alist.search.character("Cecil"), list) self.assertIsInstance(alist.search.anime("Bleach"), list) self.assertIsInstance(alist.search.manga("Bleach"), list) self.assertIsInstance(alist.search.staff("Miyuki"), list) self.assertIsInstance(alist.search.studio("go"), list) # Get self.assertIsInstance(alist.get.anime(49), dict) self.assertIsInstance(alist.get.manga(30014), dict) self.assertIsInstance(alist.get.staff(95004), dict) self.assertIsInstance(alist.get.studio(2), dict) self.assertIsInstance(alist.get.character(11), dict) # Get reviews self.assertIsInstance(alist.get.reviews(21049, "anime", False, 2174), dict) self.assertIsInstance(alist.get.reviews(21049, "anime", True), list) self.assertIsInstance(alist.get.reviews("Remiak", "user"), dict)
import json import aiohttp from io import BytesIO from PIL import Image, ImageDraw, ImageOps, ImageFont from oauth2client.service_account import ServiceAccountCredentials from bs4 import BeautifulSoup #GETTING API KEYS FROM HEROKU #api = os.environ["RIOT_KEY"] #wu_key = os.environ['WU_API'] #owm = os.environ['open_weather'] #img_api = os.environ['img_api'] #apiai_token = os.environ['api_ai'] bot_token = os.environ['BOT_TOKEN'] token = os.environ['TOKEN'] An = Pymoe.Anilist() bot = commands.Bot(command_prefix='dd!') epoch = datetime.datetime.utcfromtimestamp(0) def __init__(self, bot): self.session = aiohttp.ClientSession(loop=bot.loop) @bot.event async def on_ready(): print('Logged in as') print(bot.user.name) print(bot.user.id) print('------')
def test_VNDB(self): vndb = Pymoe.VNDB() self.assertIsInstance(vndb.dbstats(), dict)
def __init__(self): super().__init__(command_prefix=self.get_prefix, case_insensitive=True, help_command=None, guild_subscriptions=False) builtins.__dict__["_"] = self.translate signal.signal(signal.SIGTERM, self.shutdown) self.db_connector, self.db_cursor, self.app_info, self.gspread, self.config = None, None, None, None, {} self.sentry, self.lavalink, self.dbl, self.statposter, self.anilist = sentry_sdk, None, None, None, Pymoe.Anilist( )