async def animeinfo(client, message): pablo = await edit_or_reply(message, "`Searching For Anime.....`") anime = get_text(message) if not anime: await pablo.edit("`Please Give Me A Valid Input. You Can Check Help Menu To Know More!`") return search = AnimeSearch(anime) ID = search.results[0].mal_id anime = Anime(ID) jp = "" for x in anime.genres: jp += x + "; " link = anime.image_url if link is None: link = search.results[0].image_url By = f"""<u><b>Anime Information Gathered</b></u> <b>tlele:- {search.results[0].title} Mal ID:- {search.results[0].mal_id} Url:- {search.results[0].url} Type:- {search.results[0].type} Episodes:- {search.results[0].episodes} Score:- {search.results[0].score} Synopsis:- {search.results[0].synopsis} Status:- {anime.status} Genres:- {jp} Duration:- {anime.duration} Popularity:- {anime.popularity} Rank:- {anime.rank} favorites:- {anime.favorites}</b> """ await pablo.edit(By, parse_mode="html")
def animeInf(animeTit): animesearch = AnimeSearch(animeTit) anime = animesearch.results[0] animeId = Anime(anime.mal_id) short = animeId.synopsis.split(".", 2) info = f"**Anime title**: {anime.title}\n**Anime score**: {anime.score}\n**Anime synoposis**: {short[0]}. {short[1]}.\n{animeId.image_url}" return info
async def random_anime_def(message): while 1 : try : number_anime = randint(0, 25000) anime = Anime(number_anime) await message.channel.send("Si tu sais pas quoi faire, tu peux regarder :\nhttps://myanimelist.net/anime/" + str(number_anime)) break except : print(number_anime, "error anime") continue
async def get_anime(self, ctx, *args): logger.info(Constants.FUN_QUERY_SENT, Constants.ANIME, " ".join(args)) try: anime_search = AnimeSearch(" ".join(args)) anime = Anime((anime_search.results[0]).mal_id) await ctx.send( Constants.MSG_FUN_RESPONSE.format(anime.title, anime.synopsis, anime.image_url)) except Exception: logger.error(Constants.FUN_QUERY_ERR, Constants.ANIME, ' '.join(args)) await ctx.send( Constants.MSG_FUN_ERR.format(Constants.ANIME, ' '.join(args)))
async def anime(self, interaction: discord.Interaction, params: str): print( f'{interaction.user}({interaction.user.id}) executed Anime command.' ) await interaction.response.send_message(embed=discord.Embed( title='Fetching Data...Please Wait.', color=self.client.guilds[0].get_member(self.client.user.id).color)) search = AnimeSearch(params) if len(search.results) > 0: anime_data = search.results[0] anime_data_2 = Anime(anime_data.mal_id) print(anime_data_2.title) embed = discord.Embed(title=anime_data.title, description=anime_data_2.title_japanese, color=self.client.guilds[0].get_member( self.client.user.id).color, url=anime_data.url) embed.set_image(url=anime_data.image_url) embed.add_field(name='Synopsis', value=anime_data.synopsis, inline=False) embed.add_field(name='Episodes', value=str(anime_data_2.episodes), inline=True) embed.add_field(name='Status', value=str(anime_data_2.status), inline=True) embed.add_field(name='Score', value=str(anime_data.score), inline=True) embed.set_footer(text=f'Aired: {anime_data_2.aired}') button = Button(label='View on site', style=discord.ButtonStyle.url, url=anime_data_2.url) view = View() view.add_item(button) await interaction.edit_original_message(embed=embed, view=view) else: await interaction.edit_original_message( embed=await helpers.embed_helper.create_error_embed( f'Could not find any anime similar to {params}'))
async def anime(self, ctx, *,name=""): if name == "": await ctx.send(f"{ctx.author.mention} you need to provide a name to search.") else: async with ctx.typing(): search = AnimeSearch(name) anime = Anime(search.results[0].mal_id) result = discord.Embed(title=anime.title, description=f"Description\n{anime.synopsis}", color=ctx.author.color) result.set_author(name=ctx.author.name, icon_url=ctx.author.avatar_url) result.add_field(name="Information",value=f"**English Title:** {anime.title_english}\n**Japanese Title:** {anime.title_japanese}\n**Total Episode:** {anime.episodes}\n**Type:** {anime.type}\n**Status:** {anime.status}\n**Genres:** {anime.genres}\n**Duration:** {anime.duration}\n**Rating:** {anime.rating}\n**Rank:** {anime.rank}",inline=False) result.set_thumbnail(url=client.user.avatar_url) result.set_image(url=anime.image_url) result.timestamp = datetime.datetime.now() await ctx.send(embed=result)
def animerec(): p = numpy.random.randint(16000, size=1) id = int(p[0]) # for i in range(id,16000): try: anime = Anime(id) title = str(anime.title) titlef = title.replace(' ', '_') titlef = titlef.replace(':', '_') url = 'https://myanimelist.net/anime/' + str( id) + '/' + titlef + '?q=cow&cat=anime' get = requests.get(url) site = get.text soup = BeautifulSoup(site, 'html.parser') #animeimage img_tags = soup.find("div", attrs={'style': 'text-align: center;'}) x = img_tags.find('a') y = x.findAll('img') count = 1 fin = [] for i in y: if count <= 1: link = i['data-src'] count += 1 else: pass #animesynopsis syn_tags = soup.find('p', attrs={'itemprop': 'description'}).text fin.append(link) fin.append(title) fin.append(syn_tags) return fin except ValueError: animerec()
async def _(event): if event.fwd_from: return input_str = event.pattern_match.group(1) Zp = await edit_or_reply(event, "Please Wait....🚶♂️🚶♂️🚶♂️") search = AnimeSearch(input_str) ID = search.results[0].mal_id anime = Anime(ID) jp = "" for x in anime.genres: jp += x + "; " link = anime.image_url if link == None: link = search.results[0].image_url By = f"""<u><b>Anime Information Gathered</b></u> <b>tlele:- {search.results[0].title} Mal ID:- {search.results[0].mal_id} Url:- {search.results[0].url} Type:- {search.results[0].type} Episodes:- {search.results[0].episodes} Score:- {search.results[0].score} Synopsis:- {search.results[0].synopsis} Status:- {anime.status} Genres:- {jp} Duration:- {anime.duration} Popularity:- {anime.popularity} Rank:- {anime.rank} favorites:- {anime.favorites}</b> """ await borg.send_message( event.chat_id, By, parse_mode="HTML", file=link, force_document=False, silent=True, ) await Zp.delete()
def AJAX_getDataFromMal(request, animeId): Anime_object = get_object_or_404(AnimeTitle, pk=animeId) mal_id = Anime_object.mal_anime_link.split('/') try: for l in mal_id: if l.isnumeric(): mal_id = l break mal_Anime = Anime(int(mal_id)) score = mal_Anime.score scoreForPie = int((float(score) / 10) * 360) scoreForPieALT = 360 - scoreForPie if float(score) > 7.2: score_color = ' 54 ,256 , 54' else: score_color = '256 ,256 , 256' popularity = mal_Anime.popularity status = mal_Anime.status rating = mal_Anime.rating studios = mal_Anime.studios rank = mal_Anime.rank print("###########\n", score, popularity, status, mal_Anime) context = { 'score': score, 'popularity': popularity, 'status': status, 'rating': rating, 'studios': studios, 'scoreForPie': scoreForPie, 'scoreForPieALT': scoreForPieALT, 'score_color': score_color, 'rank': rank, } except Exception: pass return JsonResponse(context)
# coding: utf-8 import parse from mal import Anime import sqlite3 from random import randint from time import sleep import sys conn = sqlite3.connect('anisong.db') c = conn.cursor() anime = Anime(6702) if anime.ending_themes is not None: for song1 in anime.ending_themes: song1 = song1.lstrip() ans = parse.parse( '"{title_en} ({title_jp})" by {artist} (eps {start_ep}-{end_ep})', song1) if ans is None: ans = parse.parse( '"{title_en}" by {artist} (eps {start_ep}-{end_ep})', song1) if ans is None: ans = parse.parse( '"{title_en} ({title_jp})" by {artist} (ep {start_ep})', song1) if ans is None: ans = parse.parse('"{title_en}" by {artist} (ep {start_ep})', song1) if ans is not None: ans = ans.named print(ans)
def setUpClass(cls): cls.anime = Anime(1)
async def aboutanime(self, ctx: commands.Context, mal_id: int): """Displays about the anime using the MAL ANIME ID. get it by using animesearch command.""" await ctx.send(":mag: Searching...", delete_after=5) anime = Anime(int(mal_id)) embeds = [] e = Embed( title=anime.title, description=anime.synopsis[:4096], timestamp=ctx.message.created_at, ) if anime.title_japanese: e.add_field( name=":japanese_castle: **Title in Japanese**", value=f"{anime.title_japanese}", ) if anime.title_synonyms: e.add_field(name="**Title Synonyms**", value=" ,".join(anime.title_synonyms)) if anime.score: e.add_field(name=":star: **Score**", value=f"{anime.score} :star:") if anime.type: e.add_field(name=":dividers: **Type**", value=anime.type) if anime.url: e.add_field(name=":link: **MAL Url**", value=f"[CLICK HERE]({anime.url})") if anime.mal_id: e.add_field(name=":id: **MAL ID**", value=anime.mal_id) if anime.status: e.add_field(name=":hourglass_flowing_sand: **Status**", value=anime.status) if anime.genres: e.add_field(name=":arrow_right: **Genre**", value=" ,".join(anime.genres)) if anime.rank: e.add_field(name=":trophy: **Rank**", value=anime.rank) if anime.popularity: e.add_field(name="**Popularity**", value=f"#{anime.popularity}") if anime.episodes: e.add_field(name=":minidisc: **No. of Episodes**", value=anime.episodes) if anime.premiered: e.add_field(name="**Premire(d)**", value=anime.premiered) if anime.aired: e.add_field(name=":calendar_spiral: **Air(ed/ing)**", value=anime.aired) if anime.broadcast: e.add_field(name="**Broadcast**", value=anime.broadcast) if anime.producers: e.add_field(name="**Producers**", value=" ,".join(anime.producers)) if anime.licensors: e.add_field(name="**Licensors**", value=" ,".join(anime.licensors)) if anime.studios: e.add_field(name=":microphone2: **Studios**", value=" ,".join(anime.studios)) if anime.source: e.add_field(name=":information_source: **Source**", value=anime.source) if anime.duration: e.add_field(name=":stopwatch: **Duration**", value=anime.duration) if anime.rating: e.add_field(name="**Rating**", value=anime.rating) if (anime.related_anime and len(format_related_anime_manga(anime.related_anime)) < 1024): e.add_field( name="**Related Anime**", value=format_related_anime_manga(anime.related_anime), ) else: if anime.related_anime: e1 = Embed( title="Related Anime", description=format_related_anime_manga( anime.related_anime)[:4096], ) e1.set_footer( text= f"{anime.title_japanese} | {anime.mal_id} | {anime.score} stars", icon_url=anime.image_url, ) embeds.append(e1) if anime.opening_themes and len(" ,".join( anime.opening_themes)) <= 1000: e.add_field( name=":play_pause: **Opening Theme(s)**", value="・\n".join(anime.opening_themes), ) else: if anime.opening_themes: e1 = Embed( title=":play_pause: Opening Theme(s)", description="・\n".join(anime.opening_themes)[:4096], ) e1.set_footer( text= f"{anime.title_japanese} | {anime.mal_id} | {anime.score} stars", icon_url=anime.image_url, ) embeds.append(e1) if anime.ending_themes and len(" ,".join(anime.ending_themes)) <= 1000: e.add_field( name=":stop_button: **Ending Theme(s)**", value="・\n".join(anime.ending_themes), ) else: if anime.ending_themes: e1 = Embed( title=":stop_button: Ending Theme(s)", description="・\n".join(anime.ending_themes)[:4096], ) e1.set_footer( text= f"{anime.title_japanese} | {anime.mal_id} | {anime.score} stars", icon_url=anime.image_url, ) embeds.append(e1) if anime.staff and len(format_staff(anime.staff)) <= 700: e.add_field(name=":factory_worker: Staff", value=format_staff(anime.staff)) else: if anime.staff: e1 = Embed( title=":factory_worker: Staff", description=format_staff(anime.staff)[:4096], ) e1.set_footer( text= f"{anime.title_japanese} | {anime.mal_id} | {anime.score} stars", icon_url=anime.image_url, ) embeds.append(e1) if anime.characters and len(format_characters( anime.characters)) <= 600: e.add_field(name="**Characters**", value=format_characters(anime.characters)) else: if anime.characters: e1 = Embed( title="Characters", description=format_characters(anime.characters)[:4096], ) e1.set_footer( text= f"{anime.title_japanese} | {anime.mal_id} | {anime.score} stars", icon_url=anime.image_url, ) embeds.append(e1) if anime.image_url: e.set_image(url=anime.image_url) e.set_footer( text= f"{anime.title_japanese} | {anime.mal_id} | {anime.score} stars", icon_url=anime.image_url, ) paginator = EmbedPaginator(entries=[e] + embeds, ctx=ctx) await paginator.start()
def get_duration(amime_id: int) -> Optional[str]: return Anime(amime_id).duration