quick check for logged in user and some logs

This commit is contained in:
karl.hudgell 2022-02-22 16:35:18 +00:00
parent 0b48cca908
commit bbec182b38
3 changed files with 36 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import os
from backend import gogoanime, CustomMessage, config_check from backend import gogoanime, CustomMessage, config_check
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
from colorama import Fore from colorama import Fore
import logging
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}] "
@ -39,6 +40,7 @@ def gogodownloader(config):
) )
while True: while True:
name = input(f"{IN}Enter anime name > ").lower() name = input(f"{IN}Enter anime name > ").lower()
logging.info("episode searched for " + name)
if "-" in name: if "-" in name:
title = name.replace("-", " ").title().strip() title = name.replace("-", " ").title().strip()
else: else:
@ -70,6 +72,7 @@ def gogodownloader(config):
break break
else: else:
print(f"{ERR}Invalid input. Please try again.") print(f"{ERR}Invalid input. Please try again.")
logging.info("quality selected " + episode_quality)
print(f"{OK}Title: {Fore.LIGHTCYAN_EX}{title}") print(f"{OK}Title: {Fore.LIGHTCYAN_EX}{title}")
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}")
@ -135,7 +138,7 @@ def gogodownloader(config):
episode_end, episode_end,
title, title,
) )
gogo.user_logged_in_check()
source = f"https://gogoanime.{CURRENT_DOMAIN}/{name}" source = f"https://gogoanime.{CURRENT_DOMAIN}/{name}"
with requests.get(source) as res: with requests.get(source) as res:
soup = BeautifulSoup(res.content, "html.parser") soup = BeautifulSoup(res.content, "html.parser")

View File

@ -7,6 +7,14 @@ from dataclasses import dataclass
from colorama import Fore from colorama import Fore
from parfive import Downloader from parfive import Downloader
from threading import Semaphore from threading import Semaphore
import logging
logging.basicConfig(
level=logging.INFO,
filename="app.log",
filemode="w",
format="%(name)s - %(levelname)s - %(message)s",
)
OK = f"{Fore.RESET}[{Fore.GREEN}+{Fore.RESET}] " OK = f"{Fore.RESET}[{Fore.GREEN}+{Fore.RESET}] "
@ -25,9 +33,11 @@ def config_check():
[object]: Config object [object]: Config object
""" """
if os.path.exists("./config.json"): if os.path.exists("./config.json"):
logging.info("Config.json loaded")
with open("./config.json", "r") as f: with open("./config.json", "r") as f:
CONFIG = json.load(f) CONFIG = json.load(f)
if not "GoGoAnime_Username" in CONFIG or len(CONFIG["GoGoAnime_Username"]) == 0: if not "GoGoAnime_Username" in CONFIG or len(CONFIG["GoGoAnime_Username"]) == 0:
logging.error("GoGoAnime_Username not set in config.json")
print("GoGoAnime_Username not set in config.json") print("GoGoAnime_Username not set in config.json")
exit(0) exit(0)
else: else:
@ -35,11 +45,18 @@ def config_check():
not "GoGoAnime_Password" in CONFIG not "GoGoAnime_Password" in CONFIG
or len(CONFIG["GoGoAnime_Password"]) == 0 or len(CONFIG["GoGoAnime_Password"]) == 0
): ):
logging.error("GoGoAnime_Password not set in config.json")
print("GoGoAnime_Password not set in config.json") print("GoGoAnime_Password not set in config.json")
exit(0) exit(0)
else: else:
logging.info(
"Config loaded and "
+ CONFIG["GoGoAnime_Username"]
+ " username found"
)
return CONFIG return CONFIG
else: else:
logging.error("config.json not found")
print("config.json file not found") print("config.json file not found")
exit(0) exit(0)
@ -100,6 +117,20 @@ class gogoanime:
else: else:
print("ldldl") print("ldldl")
def user_logged_in_check(
self,
):
page = requests.get(
f"https://gogoanime.film/one-piece-episode-1",
cookies=dict(auth=gogoanime.get_gogoanime_auth_cookie(self)),
)
soup = BeautifulSoup(page.content, "html.parser")
loginCheck = soup(text=re.compile("Logout"))
if len(loginCheck) is 0:
raise Exception(
"User is not logged in, make sure account has been activated"
)
def get_links(self, source=None): def get_links(self, source=None):
if source is not None: if source is not None:
source_ep = f"https://gogoanime.{self.config['CurrentGoGoAnimeDomain']}/{self.name}-episode-" source_ep = f"https://gogoanime.{self.config['CurrentGoGoAnimeDomain']}/{self.name}-episode-"

View File

@ -1 +1 @@
3.0.0 3.1.0