mirror of
				https://github.com/karl0ss/GoGoDownloader.git
				synced 2025-11-04 00:21:13 +00:00 
			
		
		
		
	quick check for logged in user and some logs
This commit is contained in:
		
							parent
							
								
									0b48cca908
								
							
						
					
					
						commit
						bbec182b38
					
				@ -4,6 +4,7 @@ import os
 | 
			
		||||
from backend import gogoanime, CustomMessage, config_check
 | 
			
		||||
from bs4 import BeautifulSoup
 | 
			
		||||
from colorama import Fore
 | 
			
		||||
import logging
 | 
			
		||||
 | 
			
		||||
OK = f"{Fore.RESET}[{Fore.GREEN}+{Fore.RESET}] "
 | 
			
		||||
ERR = f"{Fore.RESET}[{Fore.RED}-{Fore.RESET}] "
 | 
			
		||||
@ -39,6 +40,7 @@ def gogodownloader(config):
 | 
			
		||||
        )
 | 
			
		||||
        while True:
 | 
			
		||||
            name = input(f"{IN}Enter anime name > ").lower()
 | 
			
		||||
            logging.info("episode searched for " + name)
 | 
			
		||||
            if "-" in name:
 | 
			
		||||
                title = name.replace("-", " ").title().strip()
 | 
			
		||||
            else:
 | 
			
		||||
@ -70,6 +72,7 @@ def gogodownloader(config):
 | 
			
		||||
                break
 | 
			
		||||
            else:
 | 
			
		||||
                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}Episode/s: {Fore.LIGHTCYAN_EX}{all_episodes}")
 | 
			
		||||
        print(f"{OK}Quality: {Fore.LIGHTCYAN_EX}{episode_quality}")
 | 
			
		||||
@ -135,7 +138,7 @@ def gogodownloader(config):
 | 
			
		||||
            episode_end,
 | 
			
		||||
            title,
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
        gogo.user_logged_in_check()
 | 
			
		||||
        source = f"https://gogoanime.{CURRENT_DOMAIN}/{name}"
 | 
			
		||||
        with requests.get(source) as res:
 | 
			
		||||
            soup = BeautifulSoup(res.content, "html.parser")
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										31
									
								
								backend.py
									
									
									
									
									
								
							
							
						
						
									
										31
									
								
								backend.py
									
									
									
									
									
								
							@ -7,6 +7,14 @@ from dataclasses import dataclass
 | 
			
		||||
from colorama import Fore
 | 
			
		||||
from parfive import Downloader
 | 
			
		||||
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}] "
 | 
			
		||||
@ -25,9 +33,11 @@ def config_check():
 | 
			
		||||
        [object]: Config object
 | 
			
		||||
    """
 | 
			
		||||
    if os.path.exists("./config.json"):
 | 
			
		||||
        logging.info("Config.json loaded")
 | 
			
		||||
        with open("./config.json", "r") as f:
 | 
			
		||||
            CONFIG = json.load(f)
 | 
			
		||||
        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")
 | 
			
		||||
            exit(0)
 | 
			
		||||
        else:
 | 
			
		||||
@ -35,11 +45,18 @@ def config_check():
 | 
			
		||||
                not "GoGoAnime_Password" in CONFIG
 | 
			
		||||
                or len(CONFIG["GoGoAnime_Password"]) == 0
 | 
			
		||||
            ):
 | 
			
		||||
                logging.error("GoGoAnime_Password not set in config.json")
 | 
			
		||||
                print("GoGoAnime_Password not set in config.json")
 | 
			
		||||
                exit(0)
 | 
			
		||||
            else:
 | 
			
		||||
                logging.info(
 | 
			
		||||
                    "Config loaded and "
 | 
			
		||||
                    + CONFIG["GoGoAnime_Username"]
 | 
			
		||||
                    + " username found"
 | 
			
		||||
                )
 | 
			
		||||
                return CONFIG
 | 
			
		||||
    else:
 | 
			
		||||
        logging.error("config.json not found")
 | 
			
		||||
        print("config.json file not found")
 | 
			
		||||
        exit(0)
 | 
			
		||||
 | 
			
		||||
@ -100,6 +117,20 @@ class gogoanime:
 | 
			
		||||
        else:
 | 
			
		||||
            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):
 | 
			
		||||
        if source is not None:
 | 
			
		||||
            source_ep = f"https://gogoanime.{self.config['CurrentGoGoAnimeDomain']}/{self.name}-episode-"
 | 
			
		||||
 | 
			
		||||
@ -1 +1 @@
 | 
			
		||||
3.0.0
 | 
			
		||||
3.1.0
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user