formatting and allowing the domain to be changed

This commit is contained in:
Karl Hudgell 2022-01-08 13:47:12 +00:00
parent 6fd7e6ee9e
commit 1fa2e28b70

View File

@ -12,6 +12,7 @@ import subprocess
OK = f"{Fore.RESET}[{Fore.GREEN}+{Fore.RESET}] " OK = f"{Fore.RESET}[{Fore.GREEN}+{Fore.RESET}] "
ERR = f"{Fore.RESET}[{Fore.RED}-{Fore.RESET}] " ERR = f"{Fore.RESET}[{Fore.RED}-{Fore.RESET}] "
IN = f"{Fore.RESET}[{Fore.LIGHTBLUE_EX}>{Fore.RESET}] " IN = f"{Fore.RESET}[{Fore.LIGHTBLUE_EX}>{Fore.RESET}] "
CURRENT_DOMAIN = "film"
try: try:
ctypes.windll.kernel32.SetConsoleTitleW("BitAnime") ctypes.windll.kernel32.SetConsoleTitleW("BitAnime")
except AttributeError: except AttributeError:
@ -39,7 +40,7 @@ def bitanime():
title = name.replace("-", " ").title().strip() title = name.replace("-", " ").title().strip()
else: else:
title = name.title().strip() title = name.title().strip()
source = f"https://gogoanime.wiki/category/{name}" source = f"https://gogoanime.{CURRENT_DOMAIN}/category/{name}"
with req.get(source) as res: with req.get(source) as res:
if res.status_code == 200: if res.status_code == 200:
soup = BeautifulSoup(res.content, "html.parser") soup = BeautifulSoup(res.content, "html.parser")
@ -70,7 +71,7 @@ def bitanime():
print(f"{OK}Episode/s: {Fore.LIGHTCYAN_EX}{all_episodes}") print(f"{OK}Episode/s: {Fore.LIGHTCYAN_EX}{all_episodes}")
print(f"{OK}Quality: {Fore.LIGHTCYAN_EX}{episode_quality}") print(f"{OK}Quality: {Fore.LIGHTCYAN_EX}{episode_quality}")
print(f"{OK}Link: {Fore.LIGHTCYAN_EX}{source}") print(f"{OK}Link: {Fore.LIGHTCYAN_EX}{source}")
folder = os.path.join(os.getcwd(), title) folder = os.path.join(os.getcwd(), title)
if not os.path.exists(folder): if not os.path.exists(folder):
os.mkdir(folder) os.mkdir(folder)
@ -125,7 +126,7 @@ def bitanime():
name, episode_quality, folder, all_episodes, episode_start, episode_end name, episode_quality, folder, all_episodes, episode_start, episode_end
) )
source = f"https://gogoanime.wiki/{name}" source = f"https://gogoanime.{CURRENT_DOMAIN}/{name}"
with req.get(source) as res: with req.get(source) as res:
soup = BeautifulSoup(res.content, "html.parser") soup = BeautifulSoup(res.content, "html.parser")
episode_zero = soup.find("h1", {"class": "entry-title"}) # value: 404 episode_zero = soup.find("h1", {"class": "entry-title"}) # value: 404
@ -136,7 +137,9 @@ def bitanime():
episode_links = download.get_links(source) episode_links = download.get_links(source)
with concurrent.futures.ThreadPoolExecutor() as executor: with concurrent.futures.ThreadPoolExecutor() as executor:
download_links = list(executor.map(get_download_links, episode_links)) download_links = list(executor.map(get_download_links, episode_links))
download_urls = list(executor.map(download.get_download_urls, download_links)) download_urls = list(
executor.map(download.get_download_urls, download_links)
)
print( print(
f"{OK}Downloading {Fore.LIGHTCYAN_EX}{len(download_urls)}{Fore.RESET} episode/s" f"{OK}Downloading {Fore.LIGHTCYAN_EX}{len(download_urls)}{Fore.RESET} episode/s"
) )
@ -144,7 +147,7 @@ def bitanime():
download.download_episodes, download.download_episodes,
download_urls, download_urls,
ncols=75, ncols=75,
total=len(download_urls) total=len(download_urls),
) )
try: try: