mirror of
https://github.com/karl0ss/GoGoDownloader.git
synced 2025-04-26 19:49:23 +01:00
changed some codes that will let the script download all episodes
This commit is contained in:
parent
01c7a60133
commit
8657080d34
@ -25,9 +25,23 @@ def get_links(name, episode_number, source=None):
|
|||||||
def get_download_links(episode_link):
|
def get_download_links(episode_link):
|
||||||
episode_link_resp = requests.get(episode_link, stream=True)
|
episode_link_resp = requests.get(episode_link, stream=True)
|
||||||
soup = BeautifulSoup(episode_link_resp.content, "html.parser")
|
soup = BeautifulSoup(episode_link_resp.content, "html.parser")
|
||||||
link = soup.find("li", {"class": "dowloads"})
|
exist = soup.find("h1", {"class": "entry-title"})
|
||||||
return link.a.get("href")
|
if exist is None:
|
||||||
|
# 202
|
||||||
|
link = soup.find("li", {"class": "dowloads"})
|
||||||
|
return link.a.get("href")
|
||||||
|
else:
|
||||||
|
# 404
|
||||||
|
episode_link = f"{episode_link}-"
|
||||||
|
episode_link_resp = requests.get(episode_link, stream=True)
|
||||||
|
soup = BeautifulSoup(episode_link_resp.content, "html.parser")
|
||||||
|
exist = soup.find("h1", {"class": "entry-title"})
|
||||||
|
if exist is None:
|
||||||
|
link = soup.find("li", {"class": "dowloads"})
|
||||||
|
return link.a.get("href")
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def get_download_urls(download_link):
|
def get_download_urls(download_link):
|
||||||
link = requests.get(download_link, stream=True)
|
link = requests.get(download_link, stream=True)
|
||||||
@ -44,7 +58,8 @@ def download_episodes(url):
|
|||||||
"Accept-Encoding": "gzip, deflate",
|
"Accept-Encoding": "gzip, deflate",
|
||||||
"Connection": "close",
|
"Connection": "close",
|
||||||
}
|
}
|
||||||
url_resp = requests.get(url[1], headers=header, stream=True)
|
url_resp = requests.get(url, headers=header, stream=True)
|
||||||
file_name = os.path.join(folder_path, f"{url[0]}.mp4")
|
episode_name = f"{url.split('-')[-2]}.mp4"
|
||||||
|
file_name = os.path.join(folder_path, episode_name)
|
||||||
with open(file_name, "wb") as file:
|
with open(file_name, "wb") as file:
|
||||||
shutil.copyfileobj(url_resp.raw, file)
|
shutil.copyfileobj(url_resp.raw, file)
|
@ -81,55 +81,44 @@ def bitanime():
|
|||||||
if episode_zero is None:
|
if episode_zero is None:
|
||||||
# Episode 0 does exist
|
# Episode 0 does exist
|
||||||
exec = concurrent.futures.ThreadPoolExecutor()
|
exec = concurrent.futures.ThreadPoolExecutor()
|
||||||
episode_links = bd.get_links(name, episode_number, source)
|
episode_links = bd.get_links(name, episode_number)
|
||||||
download_links = list(exec.map(bd.get_download_links, episode_links))
|
download_links = list(exec.map(bd.get_download_links, episode_links))
|
||||||
download_urls = list(exec.map(bd.get_download_urls, download_links))
|
filtered_download_links = [download_link for download_link in download_links if download_link]
|
||||||
conv_download_urls = {
|
download_urls = list(exec.map(bd.get_download_urls, filtered_download_links))
|
||||||
episode_title: url for episode_title, url in enumerate(download_urls)
|
|
||||||
}
|
|
||||||
download_urls = sorted(set(conv_download_urls.items()))
|
|
||||||
print(f"Downloading {Fore.LIGHTCYAN_EX}{len(download_urls)} episode/s")
|
print(f"Downloading {Fore.LIGHTCYAN_EX}{len(download_urls)} episode/s")
|
||||||
print(f"{Fore.LIGHTGREEN_EX}====================================")
|
print(f"{Fore.LIGHTGREEN_EX}====================================")
|
||||||
print(download_urls)
|
bd.get_path(folder)
|
||||||
print(len(download_urls))
|
thread_map(
|
||||||
# bd.get_path(folder)
|
bd.download_episodes, download_urls, ncols=75, total=len(download_urls)
|
||||||
# thread_map(
|
)
|
||||||
# bd.download_episodes, download_urls, ncols=75, total=len(download_urls)
|
try:
|
||||||
# )
|
os.startfile(folder)
|
||||||
# try:
|
except (AttributeError):
|
||||||
# os.startfile(folder)
|
import sys, subprocess
|
||||||
# except (AttributeError):
|
|
||||||
# import sys, subprocess
|
|
||||||
|
|
||||||
# opener = "open" if sys.platform == "darwin" else "xdg-open"
|
opener = "open" if sys.platform == "darwin" else "xdg-open"
|
||||||
# subprocess.call([opener, folder])
|
subprocess.call([opener, folder])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Episode 0 does not exist
|
# Episode 0 does not exist
|
||||||
exec = concurrent.futures.ThreadPoolExecutor()
|
exec = concurrent.futures.ThreadPoolExecutor()
|
||||||
episode_links = bd.get_links(name, episode_number)
|
episode_links = bd.get_links(name, episode_number)
|
||||||
download_links = list(exec.map(bd.get_download_links, episode_links))
|
download_links = list(exec.map(bd.get_download_links, episode_links))
|
||||||
download_urls = list(exec.map(bd.get_download_urls, download_links))
|
filtered_download_links = [download_link for download_link in download_links if download_link]
|
||||||
conv_download_urls = {
|
download_urls = list(exec.map(bd.get_download_urls, filtered_download_links))
|
||||||
episode_title + 1: url
|
|
||||||
for episode_title, url in enumerate(download_urls)
|
|
||||||
}
|
|
||||||
download_urls = sorted(set(conv_download_urls.items()))
|
|
||||||
print(f"Downloading {Fore.LIGHTCYAN_EX}{len(download_urls)} episode/s")
|
print(f"Downloading {Fore.LIGHTCYAN_EX}{len(download_urls)} episode/s")
|
||||||
print(f"{Fore.LIGHTGREEN_EX}====================================")
|
print(f"{Fore.LIGHTGREEN_EX}====================================")
|
||||||
print(download_urls)
|
bd.get_path(folder)
|
||||||
print(len(download_urls))
|
thread_map(
|
||||||
# bd.get_path(folder)
|
bd.download_episodes, download_urls, ncols=75, total=len(download_urls)
|
||||||
# thread_map(
|
)
|
||||||
# bd.download_episodes, download_urls, ncols=75, total=len(download_urls)
|
try:
|
||||||
# )
|
os.startfile(folder)
|
||||||
# try:
|
except (AttributeError):
|
||||||
# os.startfile(folder)
|
import sys, subprocess
|
||||||
# except (AttributeError):
|
|
||||||
# import sys, subprocess
|
|
||||||
|
|
||||||
# opener = "open" if sys.platform == "darwin" else "xdg-open"
|
opener = "open" if sys.platform == "darwin" else "xdg-open"
|
||||||
# subprocess.call([opener, folder])
|
subprocess.call([opener, folder])
|
||||||
|
|
||||||
use_again = input("Do you want to download other anime? (y|n) >> ").lower()
|
use_again = input("Do you want to download other anime? (y|n) >> ").lower()
|
||||||
if use_again == "y":
|
if use_again == "y":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user