Skip to content

Commit

Permalink
commited
Browse files Browse the repository at this point in the history
  • Loading branch information
OTAKUWeBer committed Oct 6, 2024
1 parent 755a5e4 commit c09edf6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 10 additions & 8 deletions anime_downloader/id_grab.py
Original file line number Diff line number Diff line change
@@ -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)
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
2 changes: 1 addition & 1 deletion anime_downloader/link_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion anime_downloader/search_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
aiohttp
beautifulsoup4
requests
nest_asyncio
questionary
validators
Expand Down

0 comments on commit c09edf6

Please sign in to comment.