mirror of
https://github.com/karl0ss/GoGoDownloader.git
synced 2025-04-26 19:49:23 +01:00
Added a feature that will print if the desired quality is not found then use a default quality.
This commit is contained in:
parent
7b23113f8b
commit
6b59251753
@ -3,8 +3,10 @@ import requests as req
|
|||||||
import shutil
|
import shutil
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
|
import colorama
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
from colorama import Fore
|
||||||
|
|
||||||
|
|
||||||
@dataclass(init=True)
|
@dataclass(init=True)
|
||||||
@ -15,6 +17,7 @@ class Download:
|
|||||||
all_episodes: int
|
all_episodes: int
|
||||||
episode_start: int
|
episode_start: int
|
||||||
episode_end: int
|
episode_end: int
|
||||||
|
printed: bool = False
|
||||||
|
|
||||||
def get_links(self, source=None) -> list[str]:
|
def get_links(self, source=None) -> list[str]:
|
||||||
if source is not None:
|
if source is not None:
|
||||||
@ -64,8 +67,15 @@ class Download:
|
|||||||
link = soup.find("div", {"class": "mirror_link"}).find(
|
link = soup.find("div", {"class": "mirror_link"}).find(
|
||||||
"div", {"class": "dowload"}
|
"div", {"class": "dowload"}
|
||||||
)
|
)
|
||||||
# episode_name: int, episode_link: str
|
if not self.printed:
|
||||||
return [download_link.split("+")[-1], link.a.get("href")]
|
CustomMessage(None, self.episode_quality).qual_not_found()
|
||||||
|
self.episode_quality = link.text.split()[1][1:]
|
||||||
|
CustomMessage(None, self.episode_quality).use_default_qual()
|
||||||
|
self.printed = True
|
||||||
|
return [
|
||||||
|
download_link.split("+")[-1],
|
||||||
|
link.a.get("href"),
|
||||||
|
] # episode_name: str, episode_link: str
|
||||||
|
|
||||||
def download_episodes(self, url) -> object:
|
def download_episodes(self, url) -> object:
|
||||||
header = {
|
header = {
|
||||||
@ -83,10 +93,21 @@ class Download:
|
|||||||
|
|
||||||
|
|
||||||
@dataclass(init=True)
|
@dataclass(init=True)
|
||||||
class CustomError(Exception):
|
class CustomMessage(Exception):
|
||||||
"""Custom exception that will accept message as a parameter and it will print it on the console."""
|
"""Custom message that will accept message as a parameter and it will print it on the console."""
|
||||||
|
|
||||||
message: str
|
message: str = None
|
||||||
|
episode_quality: str = None
|
||||||
|
|
||||||
def print_error(self) -> str:
|
def print_error(self) -> str:
|
||||||
print(self.message)
|
print(self.message)
|
||||||
|
|
||||||
|
def qual_not_found(self) -> str:
|
||||||
|
print(
|
||||||
|
f"[{Fore.RED}-{Fore.RESET}] {Fore.LIGHTCYAN_EX}{self.episode_quality}{Fore.RESET} quality not found."
|
||||||
|
)
|
||||||
|
|
||||||
|
def use_default_qual(self) -> str:
|
||||||
|
print(
|
||||||
|
f"[{Fore.GREEN}+{Fore.RESET}] Using {Fore.LIGHTCYAN_EX}{self.episode_quality}{Fore.RESET} as a default quality."
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user