diff --git a/README.md b/README.md index 6d42f91..fd691b0 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ ## Prerequisites - Python 3.7 or higher installed on your system. -- Required Python packages (`aiohttp`, `beautifulsoup4`, `requests`, `validators`, `questionary`, `nest_asyncio`, `tqdm`, `termcolor`) which can be installed via pip. +- Required Python packages (`aiohttp`, `beautifulsoup4`, `validators`, `questionary`, `nest_asyncio`, `tqdm`, `termcolor`) which can be installed via pip. ## Installation diff --git a/anime_downloader/id_grab.py b/anime_downloader/id_grab.py index a4fb2fb..7c82a00 100644 --- a/anime_downloader/id_grab.py +++ b/anime_downloader/id_grab.py @@ -1,10 +1,12 @@ -import requests from bs4 import BeautifulSoup +import aiohttp - -def grab_id(url): - response = requests.get(url) - soup = BeautifulSoup(response.content, "html.parser") - anime_id = soup.find("input", {"id": "movie_id"})["value"] - - return (anime_id) \ No newline at end of file +async def grab_id(url): + """Grab the anime ID from the anime details page asynchronously.""" + async with aiohttp.ClientSession() as session: + async with session.get(url) as response: + response_content = await response.text() + soup = BeautifulSoup(response_content, "html.parser") + anime_id = soup.find("input", {"id": "movie_id"})["value"] + + return anime_id \ No newline at end of file diff --git a/anime_downloader/link_download.py b/anime_downloader/link_download.py index 90f8f71..f76e90b 100644 --- a/anime_downloader/link_download.py +++ b/anime_downloader/link_download.py @@ -176,7 +176,7 @@ async def display_anime_details(selected_link): if download_choice: start = questionary.text("Download episode from (number): ").ask() end = questionary.text("To: ").ask() - code = grab_id(selected_link) + code = await grab_id(selected_link) anime_eps_url = fetch_ep_list_api.format(START_EP=start, END_EP=end, ANIME_ID=code) await fetch_episode_links(anime_eps_url, anime_info.get('title')) else: diff --git a/anime_downloader/search_download.py b/anime_downloader/search_download.py index 955635f..83e4490 100644 --- a/anime_downloader/search_download.py +++ b/anime_downloader/search_download.py @@ -151,7 +151,7 @@ async def display_anime_details(title, selected_link): async def fetch_episode_links(selected_link, title): """Fetch episode links for the selected anime and download them.""" - code = grab_id(selected_link) + code = await grab_id(selected_link) start = questionary.text("Download episode from (number): ").ask() end = questionary.text("To: ").ask() QUALITY = data["preferred_res"] diff --git a/requirements.txt b/requirements.txt index fb6ec77..08eeb0b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,5 @@ aiohttp beautifulsoup4 -requests nest_asyncio questionary validators