mirror of
https://github.com/karl0ss/GoGoDownloader.git
synced 2025-04-26 11:39:22 +01:00
move everything to download class
This commit is contained in:
parent
90f041d1f6
commit
2df3c5ce1a
76
backend.py
76
backend.py
@ -36,13 +36,14 @@ CURRENT_DOMAIN = "film"
|
|||||||
|
|
||||||
@dataclass(init=True)
|
@dataclass(init=True)
|
||||||
class Download:
|
class Download:
|
||||||
|
config: object
|
||||||
name: str
|
name: str
|
||||||
episode_quality: str
|
episode_quality: str
|
||||||
folder: str
|
folder: str
|
||||||
all_episodes: int
|
all_episodes: int
|
||||||
episode_start: int
|
episode_start: int
|
||||||
episode_end: int
|
episode_end: int
|
||||||
config: object
|
title: str
|
||||||
printed: bool = False
|
printed: bool = False
|
||||||
|
|
||||||
def get_links(self, source=None):
|
def get_links(self, source=None):
|
||||||
@ -61,45 +62,46 @@ class Download:
|
|||||||
]
|
]
|
||||||
return episode_links
|
return episode_links
|
||||||
|
|
||||||
|
def get_download_link(self, url):
|
||||||
|
|
||||||
def get_download_link(config, url, episode_quality):
|
page = requests.get(
|
||||||
|
url,
|
||||||
page = requests.get(
|
cookies=dict(auth=self.config["GoGoAnimeAuthKey"]),
|
||||||
url,
|
|
||||||
cookies=dict(auth=config["GoGoAnimeAuthKey"]),
|
|
||||||
)
|
|
||||||
|
|
||||||
soup = BeautifulSoup(page.content, "html.parser")
|
|
||||||
|
|
||||||
for link in soup.find_all("a", href=True):
|
|
||||||
if episode_quality in link.text:
|
|
||||||
return link["href"]
|
|
||||||
|
|
||||||
|
|
||||||
def file_downloader(file_list: dict, title: str, config: object):
|
|
||||||
dl = Downloader(
|
|
||||||
max_conn=config["MaxConcurrentDownloads"],
|
|
||||||
overwrite=False,
|
|
||||||
headers=dict(
|
|
||||||
[
|
|
||||||
(
|
|
||||||
"User-Agent",
|
|
||||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36",
|
|
||||||
),
|
|
||||||
("authority", "gogo-cdn.com"),
|
|
||||||
("referer", f"https://gogoanime.{config['CurrentGoGoAnimeDomain']}/"),
|
|
||||||
]
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
for link in file_list:
|
|
||||||
dl.enqueue_file(
|
|
||||||
link,
|
|
||||||
path=f"./{title}",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
files = dl.download()
|
soup = BeautifulSoup(page.content, "html.parser")
|
||||||
return files
|
|
||||||
|
for link in soup.find_all("a", href=True):
|
||||||
|
if self.episode_quality in link.text:
|
||||||
|
return link["href"]
|
||||||
|
|
||||||
|
def file_downloader(self, file_list: dict):
|
||||||
|
dl = Downloader(
|
||||||
|
max_conn=self.config["MaxConcurrentDownloads"],
|
||||||
|
overwrite=self.config["OverwriteDownloads"],
|
||||||
|
headers=dict(
|
||||||
|
[
|
||||||
|
(
|
||||||
|
"User-Agent",
|
||||||
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36",
|
||||||
|
),
|
||||||
|
("authority", "gogo-cdn.com"),
|
||||||
|
(
|
||||||
|
"referer",
|
||||||
|
f"https://gogoanime.{self.config['CurrentGoGoAnimeDomain']}/",
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
for link in file_list:
|
||||||
|
dl.enqueue_file(
|
||||||
|
link,
|
||||||
|
path=f"./{self.title}",
|
||||||
|
)
|
||||||
|
|
||||||
|
files = dl.download()
|
||||||
|
return files
|
||||||
|
|
||||||
|
|
||||||
@dataclass(init=True)
|
@dataclass(init=True)
|
||||||
|
9
main.py
9
main.py
@ -1,7 +1,7 @@
|
|||||||
import requests
|
import requests
|
||||||
import ctypes
|
import ctypes
|
||||||
import os
|
import os
|
||||||
from backend import *
|
from backend import Download, CustomMessage, config_check
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from colorama import Fore
|
from colorama import Fore
|
||||||
|
|
||||||
@ -126,13 +126,14 @@ def gogodownloader(config):
|
|||||||
episode_end = all_episodes
|
episode_end = all_episodes
|
||||||
|
|
||||||
download = Download(
|
download = Download(
|
||||||
|
config,
|
||||||
name,
|
name,
|
||||||
episode_quality,
|
episode_quality,
|
||||||
folder,
|
folder,
|
||||||
all_episodes,
|
all_episodes,
|
||||||
episode_start,
|
episode_start,
|
||||||
episode_end,
|
episode_end,
|
||||||
config,
|
title,
|
||||||
)
|
)
|
||||||
|
|
||||||
source = f"https://gogoanime.{CURRENT_DOMAIN}/{name}"
|
source = f"https://gogoanime.{CURRENT_DOMAIN}/{name}"
|
||||||
@ -147,9 +148,9 @@ def gogodownloader(config):
|
|||||||
episode_links = download.get_links(source)
|
episode_links = download.get_links(source)
|
||||||
|
|
||||||
for link in episode_links:
|
for link in episode_links:
|
||||||
dl_links.append(get_download_link(config, link, episode_quality))
|
dl_links.append(download.get_download_link(link))
|
||||||
|
|
||||||
file_downloader(dl_links, title, config)
|
download.file_downloader(dl_links)
|
||||||
|
|
||||||
use_again = input(f"{IN}Do you want to use the app again? (y|n) > ").lower()
|
use_again = input(f"{IN}Do you want to use the app again? (y|n) > ").lower()
|
||||||
if use_again == "y":
|
if use_again == "y":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user