Example #1
0
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
Example #2
0
def heading():
    driverpth = "C:\\Program Files (x86)\\chromedriver.exe"
    options = Options()
    options.add_argument("--log-level=3")
    options.add_argument("--silent")
    options.add_argument("--no-sandbox")
    options.add_argument("--disable-logging")
    options.add_argument("--mute-audio")
    options.add_argument(
        '--user-agent=Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1'
    )
    driver = webdriver.Chrome(executable_path=driverpth, options=options)
    driver.get('https://www.randomanime.org/custom-list/')

    time.sleep(2)
    driver.find_element_by_xpath(
        "/html/body/main/section/footer/button[1]").click()
    time.sleep(5)
    title = driver.find_elements_by_xpath(
        "/html/body/main/div/div/header/div[1]/div[2]/h3/span[1]")
    for post in title:
        name = post.text
    driver.close()
    search = AnimeSearch("" + name)
    description = search.results[0].synopsis
    z = []
    z.append(name)
    z.append(description)

    return z
Example #3
0
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 search_anime(self, query):
        try:
            search = AnimeSearch(query, timeout=self.timeout)

            return [x.__dict__ for x in search.results]
        except Exception as e:
            logging.warning(e, exc_info=True)
            return None
Example #5
0
 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)))
Example #6
0
    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}'))
Example #7
0
	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)
Example #8
0
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()
    async def animesearch(self, ctx: commands.Context, *, anime_name: str):
        """Searches Anime from MAL and displays the first 10 search result."""
        search = AnimeSearch(str(anime_name).strip(" ").lower())
        search_results = search.results[:10]
        description = ""
        for i, k in enumerate(search_results):
            description += f"{i+1}. **{k.title}**\n"
        e1 = Embed(
            title=f"Anime search results for {str(anime_name).capitalize()}",
            description=description[:4096],
            timestamp=ctx.message.created_at,
        )
        e1.set_footer(
            text=
            f"Showing 10 results out of {len(search.results)} | Use the reactions of this message to paginate",
            icon_url=LinksAndVars.mal_logo.value,
        )
        embeds = [e1]
        for i in search_results:
            e = Embed(title=i.title,
                      description=i.synopsis,
                      timestamp=ctx.message.created_at)
            if i.score:
                e.add_field(name="**Score**", value=f"{i.score} :star:")
            if i.type:
                e.add_field(name="**Anime Type**", value=i.type)
            if i.url:
                e.add_field(name="**MAL Url**", value=f"[CLICK HERE]({i.url})")
            if i.mal_id:
                e.add_field(name="**MAL ID**", value=i.mal_id)
            # if i.image_url:
            #     e.set_image(url=i.image_url) #later it the comment will be removed
            e.set_footer(text=f"{i.title} | {i.mal_id} | {i.score} stars",
                         icon_url=i.image_url)
            embeds.append(e)

        paginator = EmbedPaginator(entries=embeds, ctx=ctx)
        await paginator.start()
Example #10
0
    async def __call__(self):

        UserCancel = KeyboardInterrupt

        def search_pages(result_) -> discord.Embed:
            return discord.Embed(
                title=f"Titles matching '{self.query}'",
                description="\n".join([
                    f"[{index_}]: {value.title}"
                    for index_, value in enumerate(result_)
                ]),
            )

        try:
            errorMessage = None
            search = AnimeSearch(self.query)

            while 1:
                result = [
                    [anime for anime in search.results][x:x + 10]
                    for x in range(0, len([anime
                                           for anime in search.results]), 10)
                ]
                embeds = list(map(search_pages, result))
                cur_page = 0

                for index, item in enumerate(embeds):
                    item.set_footer(
                        text=
                        f"Please choose option or cancel\nPage {index+1}/{len(embeds)}"
                    )

                if len(embeds) > 1:
                    emojis = ["๐Ÿ—‘๏ธ", "โ—€๏ธ", "โ–ถ๏ธ"]
                else:
                    emojis = ["๐Ÿ—‘๏ธ"]

                await self.message.edit(content='',
                                        embed=embeds[cur_page % len(embeds)],
                                        components=[[
                                            Button(style=ButtonStyle.blue,
                                                   label=e,
                                                   custom_id=e) for e in emojis
                                        ]])

                while 1:
                    try:
                        emojitask = asyncio.create_task(
                            self.bot.wait_for(
                                "button_click",
                                check=lambda b_ctx: Sudo.pageTurnCheck(
                                    bot=self.bot,
                                    ctx=self.ctx,
                                    button_ctx=b_ctx,
                                    message=self.message),
                                timeout=60,
                            ))

                        responsetask = asyncio.create_task(
                            self.bot.wait_for(
                                "message",
                                check=lambda m: m.author == self.ctx.author,
                                timeout=30,
                            ))

                        waiting = [emojitask, responsetask]
                        done, waiting = await asyncio.wait(
                            waiting, return_when=asyncio.FIRST_COMPLETED
                        )  # 30 seconds wait either reply or react

                        if emojitask in done:
                            emojitask = emojitask.result()

                            if str(emojitask.custom_id) == "๐Ÿ—‘๏ธ":
                                await self.message.delete()
                                return
                            elif str(emojitask.custom_id) == "โ—€๏ธ":
                                cur_page -= 1
                            elif str(emojitask.custom_id) == "โ–ถ๏ธ":
                                cur_page += 1

                            await emojitask.respond(type=7,
                                                    content='',
                                                    embed=embeds[cur_page %
                                                                 len(embeds)])

                        elif responsetask in done:
                            try:
                                emojitask.cancel()
                                input = responsetask.result()
                                await input.delete()
                                if input.content.lower() == "cancel":
                                    raise UserCancel
                                input = int(input.content)
                                anime_item = result[cur_page][input]

                                if errorMessage is not None:
                                    await errorMessage.delete()

                                embed = discord.Embed(
                                    title=f"{anime_item.title}",
                                    description=anime_item.synopsis,
                                    url=anime_item.url,
                                )  # Myanimelist data

                                embed.add_field(
                                    name="MyAnimeListID",
                                    value=str(anime_item.mal_id),
                                    inline=True,
                                )
                                embed.add_field(
                                    name="Rating",
                                    value=str(anime_item.score),
                                    inline=True,
                                )
                                embed.add_field(
                                    name="Episodes",
                                    value=str(anime_item.episodes),
                                    inline=True,
                                )

                                embed.set_thumbnail(url=anime_item.image_url)
                                embed.set_footer(
                                    text=f"Requested by {self.ctx.author}")

                                Log.append_to_log(
                                    self.ctx, f"{self.ctx.command} result",
                                    anime_item.title)
                                await self.message.edit(
                                    embed=embed,
                                    components=[
                                        Button(style=ButtonStyle.blue,
                                               label="๐Ÿ—‘๏ธ",
                                               custom_id="๐Ÿ—‘๏ธ")
                                    ])
                                await self.bot.wait_for(
                                    "button_click",
                                    check=lambda button_ctx: Sudo.
                                    pageTurnCheck(bot=self.bot,
                                                  ctx=self.ctx,
                                                  button_ctx=button_ctx,
                                                  message=self.message),
                                    timeout=60,
                                )
                                return

                            except (ValueError, IndexError):
                                errorMessage = await self.ctx.send(
                                    content=
                                    "Invalid choice. Please choose a number between 0-9 or cancel"
                                )
                                continue

                            except asyncio.TimeoutError:
                                await self.message.edit(components=[])
                                return

                    except UserCancel:
                        await self.message.delete()

                    except asyncio.TimeoutError:
                        await self.message.delete()

                    except (asyncio.CancelledError, discord.errors.NotFound):
                        pass

                    except Exception:
                        await self.message.delete()
                        raise

        except Exception as e:
            await error_handler(self.bot, self.ctx, e, self.query)
        finally:
            return
Example #11
0
 def setUpClass(cls):
     cls.anime_search = AnimeSearch("cowboy bebop")
Example #12
0
def get_anime(query):
    search = AnimeSearch(query)
    result = search.results[0]
    if result:
        return f'**Title**: {result.title}  \n**Synopsis**: {result.synopsis}  \n**Score**: {result.score}  \n**Type**: {result.type}  \n**Episodes**: {result.episodes}  \n**Url**: {result.url}'
Example #13
0
from mal import AnimeSearch

print("+---------------------------------+")
print("|\tSelamat Datang di Info Anime\t |")
print("|\t\t\tBy Heriyanto\t\t\t |")
print("+---------------------------------+")

nama = input("Masukan Nama Anda : ")
pilihan = input("\nHi, " + nama +
                ". Apakah Anda ingin melihat info anime? (y/n) : ")

while pilihan == "y":
    print("Masukkan Judul Anime yang ingin Anda Cari")
    print("Contoh : Naruto Shippuden\n")

    search = AnimeSearch(input("Judul : "))
    print(search.results[0].title)
    print(search.results[0].score)
    print(search.results[0].mal_id)
    print(search.results[0].episodes)
    print(search.results[0].url)

    pilihan = input("\nHi, " + nama + ". Mau lihat info lagi? (y/n) : ")

    if pilihan == "y":
        print("+---------------------------------+")
        print("|\tSelamat Datang di Info Anime\t |")
        print("|\t\t\tBy Heriyanto\t\t\t |")
        print("+---------------------------------+")

    else:
Example #14
0
def id_animes():
    lista_id = []
    i = 0
    erros = 0
    count = 0
    # tenta entrar no json pra pegar os animes - nomes
    id = 1
    try:
        # abre o txt
        arquivo = open("animess.txt", "r", encoding='utf-8')
    # caso nao conseguir sai fora
    except:
        print(traceback.format_exc())
        print("verifica o arquivo ou nome ")
        # sair
        sys.exit()
    # linhs do txt
    linhas = arquivo.readlines()
    # for na lista  de animes do json
    for nomes_animes in linhas:
        # tenta pegar os nomes
        nomes_animes = nomes_animes.rstrip('\n')
        nomes_animes = nomes_animes.rstrip('\t')
        # pula linhas pares, os nome dos anime esta nas linhas impares
        if id % 2 == 1:
            print(nomes_animes)
            try:
                query = '''
                    query ($id: Int, $page: Int, $perPage: Int, $search: String) {
                        Page (page: $page, perPage: $perPage) {
                            media (id: $id, search: $search, type: ANIME, sort: POPULARITY_DESC) {
                                id
                                title {
                                    romaji
                                }
                            }
                        }
                    }
                    '''
                variables = {
                    'search': nomes_animes,
                    'page': 1,
                    'perPage': 1,
                    'MediaType': "ANIME"
                }
                url = 'https://graphql.anilist.co'
                response = requests.post(url,
                                         json={
                                             'query': query,
                                             'variables': variables
                                         })
                response = json.loads(response.text)
                # pega o id do response
                response_id = response['data']['Page']['media'][0]['id']
                lista_id.append(response_id)
                print(f"id: {count} = id:{lista_id[i]} ")
                i += 1
                count += 1
                id += 1
            # caso aconteรงa algum erro
            except:
                print("esse anime nao consegui achar o id: ", nomes_animes)
                try:
                    print("tentado com o My Anime List")
                    search = AnimeSearch(nomes_animes)
                    lista_id.append(search.results[0].mal_id)
                    print(f"id do My Anine List: {search.results[0].mal_id}")
                    print(f"id>: {count} = id:{lista_id[i]} ")
                    i += 1
                    count += 1
                except:
                    print("erro")
                    erros += 1
                    print("erros: ", erros)
        else:
            id += 1
    # tudo pronto
    return lista_id
Example #15
0
def search(anTitle):
    search = AnimeSearch(anTitle)
    return search.results[0].synopsis