mirror of
https://github.com/karl0ss/GoGoDownloader.git
synced 2025-04-27 03:59:22 +01:00
changed some code in the bitanime and backend file to add a dynamic episode quality feature
This commit is contained in:
parent
228323c491
commit
c4a265d168
@ -40,26 +40,70 @@ def get_download_links(episode_link):
|
|||||||
link = soup.find("li", {"class": "dowloads"})
|
link = soup.find("li", {"class": "dowloads"})
|
||||||
return link.a.get("href")
|
return link.a.get("href")
|
||||||
else:
|
else:
|
||||||
pass
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_download_urls(download_link):
|
def get_download_urls(download_link):
|
||||||
link = requests.get(download_link)
|
link = requests.get(download_link[1])
|
||||||
soup = BeautifulSoup(link.content, "html.parser")
|
soup = BeautifulSoup(link.content, "html.parser")
|
||||||
link = soup.find_all("div", {"class": "dowload"})
|
link = soup.find("div", {"class": "mirror_link"}).find_all(
|
||||||
return link[0].a.get("href")
|
"div", {"class": "dowload"}
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
if len(link) > 5:
|
||||||
|
return [
|
||||||
|
download_link[1].split("+")[-1],
|
||||||
|
link[int(download_link[0]) + 1].a.get("href"),
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
return [
|
||||||
|
download_link[1].split("+")[-1],
|
||||||
|
link[int(download_link[0])].a.get("href"),
|
||||||
|
]
|
||||||
|
except IndexError:
|
||||||
|
return [download_link[1].split("+")[-1], link[0].a.get("href")]
|
||||||
|
|
||||||
|
|
||||||
def download_episodes(url):
|
def download_episodes(url):
|
||||||
header = {
|
if "cdn" in url[1]:
|
||||||
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0",
|
header = {
|
||||||
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
|
"Host": "gogo-cdn.com",
|
||||||
"Accept-Language": "en-US,en;q=0.5",
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0",
|
||||||
"Accept-Encoding": "gzip, deflate",
|
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
|
||||||
"Connection": "close",
|
"Accept-Language": "en-US,en;q=0.5",
|
||||||
}
|
"Accept-Encoding": "gzip, deflate",
|
||||||
url_resp = requests.get(url, headers=header, stream=True)
|
"Referer": "https://streamani.io/",
|
||||||
episode_name = f"{url.split('-')[-2]}.mp4"
|
"Upgrade-Insecure-Requests": "1",
|
||||||
file_name = os.path.join(folder_path, episode_name)
|
"Sec-Fetch-Dest": "document",
|
||||||
with open(file_name, "wb") as file:
|
"Sec-Fetch-Mode": "navigate",
|
||||||
shutil.copyfileobj(url_resp.raw, file)
|
"Sec-Fetch-Site": "cross-site",
|
||||||
|
"Sec-Fetch-User": "?1",
|
||||||
|
"Te": "trailers",
|
||||||
|
"Connection": "close",
|
||||||
|
}
|
||||||
|
url_resp = requests.get(url[1], headers=header, stream=True)
|
||||||
|
episode_name = f"{url[0]}.mp4"
|
||||||
|
file_name = os.path.join(folder_path, episode_name)
|
||||||
|
with open(file_name, "wb") as file:
|
||||||
|
shutil.copyfileobj(url_resp.raw, file)
|
||||||
|
else:
|
||||||
|
header = {
|
||||||
|
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0",
|
||||||
|
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
|
||||||
|
"Accept-Language": "en-US,en;q=0.5",
|
||||||
|
"Accept-Encoding": "gzip, deflate",
|
||||||
|
"Connection": "close",
|
||||||
|
}
|
||||||
|
url_resp = requests.get(url, headers=header, stream=True)
|
||||||
|
episode_name = f"{url[0]}.mp4"
|
||||||
|
file_name = os.path.join(folder_path, episode_name)
|
||||||
|
with open(file_name, "wb") as file:
|
||||||
|
shutil.copyfileobj(url_resp.raw, file)
|
||||||
|
# url_resp = requests.get(url, headers=header, stream=True)
|
||||||
|
# try:
|
||||||
|
# episode_name = f"{url.split('/')[-1].split('-')[-2]}.mp4"
|
||||||
|
# except IndexError:
|
||||||
|
# episode_name = f"{url_resp.url.split('/')[-1].split('.')[-3]}.mp4"
|
||||||
|
# file_name = os.path.join(folder_path, episode_name)
|
||||||
|
# with open(file_name, "wb") as file:
|
||||||
|
# shutil.copyfileobj(url_resp.raw, file)
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
# Dependencies
|
# Dependencies
|
||||||
|
|
||||||
|
# DYNAMIC EPISODE QUALITY - WIP
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import ctypes
|
import ctypes
|
||||||
import os
|
import os
|
||||||
@ -37,7 +39,7 @@ def bitanime():
|
|||||||
"""
|
"""
|
||||||
check = True
|
check = True
|
||||||
while check:
|
while check:
|
||||||
name = input(f"Enter anime name >> ").lower()
|
name = input("Enter anime name >> ").lower()
|
||||||
if "-" in name:
|
if "-" in name:
|
||||||
title = name.replace("-", " ").title().strip()
|
title = name.replace("-", " ").title().strip()
|
||||||
else:
|
else:
|
||||||
@ -45,13 +47,35 @@ def bitanime():
|
|||||||
source = f"https://gogoanime.pe/category/{name}"
|
source = f"https://gogoanime.pe/category/{name}"
|
||||||
resp = requests.get(source)
|
resp = requests.get(source)
|
||||||
if resp.status_code == 200:
|
if resp.status_code == 200:
|
||||||
print(f"{Fore.LIGHTGREEN_EX}===========================================")
|
print(
|
||||||
|
f"{Fore.LIGHTGREEN_EX}==========================================="
|
||||||
|
)
|
||||||
check = False
|
check = False
|
||||||
else:
|
else:
|
||||||
print(
|
print(
|
||||||
f"{Fore.LIGHTRED_EX}Error 404: Anime not found. Please try again."
|
f"{Fore.LIGHTRED_EX}Error 404: Anime not found. Please try again."
|
||||||
)
|
)
|
||||||
check = True
|
check = True
|
||||||
|
check = True
|
||||||
|
while check:
|
||||||
|
quality = input("Enter episode quality >> ")
|
||||||
|
episode_quality = ""
|
||||||
|
if quality == "1" or quality == "":
|
||||||
|
episode_quality = "360P"
|
||||||
|
quality = "1"
|
||||||
|
check = False
|
||||||
|
elif quality == "2":
|
||||||
|
episode_quality = "480P"
|
||||||
|
check = False
|
||||||
|
elif quality == "3":
|
||||||
|
episode_quality = "720P"
|
||||||
|
check = False
|
||||||
|
elif quality == "4":
|
||||||
|
episode_quality = "1080P"
|
||||||
|
check = False
|
||||||
|
else:
|
||||||
|
print(f"{Fore.LIGHTRED_EX}Invalid input. Please try again.")
|
||||||
|
check = True
|
||||||
"""
|
"""
|
||||||
Get how many episode/s the anime has
|
Get how many episode/s the anime has
|
||||||
"""
|
"""
|
||||||
@ -63,6 +87,7 @@ def bitanime():
|
|||||||
"""
|
"""
|
||||||
print(f"Title: {Fore.LIGHTCYAN_EX}{title}")
|
print(f"Title: {Fore.LIGHTCYAN_EX}{title}")
|
||||||
print(f"Episode/s: {Fore.LIGHTCYAN_EX}{episode_number}")
|
print(f"Episode/s: {Fore.LIGHTCYAN_EX}{episode_number}")
|
||||||
|
print(f"Quality: {Fore.LIGHTCYAN_EX}{episode_quality}")
|
||||||
print(f"Link: {Fore.LIGHTCYAN_EX}{source}")
|
print(f"Link: {Fore.LIGHTCYAN_EX}{source}")
|
||||||
print(f"{Fore.LIGHTGREEN_EX}===========================================")
|
print(f"{Fore.LIGHTGREEN_EX}===========================================")
|
||||||
"""
|
"""
|
||||||
@ -83,8 +108,14 @@ def bitanime():
|
|||||||
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))
|
||||||
filtered_download_links = [download_link for download_link in download_links if download_link]
|
filtered_download_links = [
|
||||||
download_urls = list(exec.map(bd.get_download_urls, filtered_download_links))
|
[quality, download_link]
|
||||||
|
for download_link in download_links
|
||||||
|
if download_link
|
||||||
|
]
|
||||||
|
download_urls = list(
|
||||||
|
exec.map(bd.get_download_urls, filtered_download_links)
|
||||||
|
)
|
||||||
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}===========================================")
|
||||||
bd.get_path(folder)
|
bd.get_path(folder)
|
||||||
@ -104,8 +135,14 @@ def bitanime():
|
|||||||
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))
|
||||||
filtered_download_links = [download_link for download_link in download_links if download_link]
|
filtered_download_links = [
|
||||||
download_urls = list(exec.map(bd.get_download_urls, filtered_download_links))
|
[quality, download_link]
|
||||||
|
for download_link in download_links
|
||||||
|
if download_link
|
||||||
|
]
|
||||||
|
download_urls = list(
|
||||||
|
exec.map(bd.get_download_urls, filtered_download_links)
|
||||||
|
)
|
||||||
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}===========================================")
|
||||||
bd.get_path(folder)
|
bd.get_path(folder)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user