From 79f0c1e248195bf935d7e272a30e03daa2ea0ec6 Mon Sep 17 00:00:00 2001 From: "karl.hudgell" Date: Thu, 20 Jan 2022 14:47:07 +0000 Subject: [PATCH 1/2] rename main to GoGoDownloader --- main.py => GoGoDownloader.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) rename main.py => GoGoDownloader.py (95%) diff --git a/main.py b/GoGoDownloader.py similarity index 95% rename from main.py rename to GoGoDownloader.py index 6f95741..a0e3a42 100644 --- a/main.py +++ b/GoGoDownloader.py @@ -1,7 +1,7 @@ import requests import ctypes import os -from backend import Download, CustomMessage, config_check +from backend import gogoanime, CustomMessage, config_check from bs4 import BeautifulSoup from colorama import Fore @@ -125,7 +125,7 @@ def gogodownloader(config): else: episode_end = all_episodes - download = Download( + gogo = gogoanime( config, name, episode_quality, @@ -145,12 +145,12 @@ def gogodownloader(config): source = None dl_links = [] - episode_links = download.get_links(source) + episode_links = gogo.get_links(source) for link in episode_links: - dl_links.append(download.get_download_link(link)) + dl_links.append(gogo.get_download_link(link)) - download.file_downloader(dl_links) + gogo.file_downloader(dl_links) use_again = input(f"{IN}Do you want to use the app again? (y|n) > ").lower() if use_again == "y": From 1852b8fe2edfac4bfc43c3a3a4a2eba1163fba93 Mon Sep 17 00:00:00 2001 From: "karl.hudgell" Date: Thu, 20 Jan 2022 14:47:21 +0000 Subject: [PATCH 2/2] move to user/pass not token --- README.md | 23 +++++++++++------------ backend.py | 44 ++++++++++++++++++++++++++++++++++++++------ config.json.default | 3 ++- 3 files changed, 51 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index cb9a90a..7428149 100644 --- a/README.md +++ b/README.md @@ -17,24 +17,24 @@ GoGo Downloader is based on the now broken **BitAnime**. I have had to rework quite a bit of the code to get it working again, and have ideas for some other improvements, I don't want to mess with the original codebase too much, hence **GoGo Downloader**. - **GoGo Downloader** gets its content from [gogoanime](https://gogoanime.film/). If you get a **404** error, please look up the correct anime name on [gogoanime](https://gogoanime.film/). The application will let you download all the episodes, or you can choose how many episodes you want to download. +**GoGo Downloader** gets its content from [gogoanime](https://gogoanime.film/). If you get a **404** error, please look up the correct anime name on [gogoanime](https://gogoanime.film/). The application will let you download all the episodes, or you can choose how many episodes you want to download. GoGo Anime has changed the way they show download links, and this no longer works via BS4, as the recaptcha blocks the links, but if you are logged in, there are other routes to get to download links, I have taken one of these routes to restore the application. ## Features - - Download all qualities options from GoGoAnime - - Update the current GoGoAnime domain via config file (as they keep changing it) - - Specify the number of concurrent downloads via config file (Max is 6) - - Set file overwrite via config file (0 = Skip / 1 = Overwrite) +- Download all qualities options from GoGoAnime +- Update the current GoGoAnime domain via config file (as they keep changing it) +- Specify the number of concurrent downloads via config file (Max is 6) +- Set file overwrite via config file (0 = Skip / 1 = Overwrite) ## Installation - - ```git clone https://github.com/karl0ss/GoGoDownloader.git``` - - ```pip install -r requirements.txt``` - - Create config.json from config.json.default - - Add your GoGoAnime auth token from the ```auth``` cookie in your browser to the config.json - - Run the app with ```python main.py``` +- `git clone https://github.com/karl0ss/GoGoDownloader.git` +- `pip install -r requirements.txt` +- Create config.json from config.json.default +- Add your GoGoAnime username and password to config.json (Can't be a Google account) +- Run the app with `python main.py` ## Screenshot @@ -47,7 +47,6 @@ GoGo Anime has changed the way they show download links, and this no longer work **GoGo Downloader** is highly reliant on the python modules `requests`, `colorama`, `parfive`, and `BeautifulSoup`. - ## Usage The anime name is separated by "-". You can either type it manually, or go to [gogoanime.film](https://gogoanime.film/) and search for the anime you want to download and copy the name from the URL. @@ -62,4 +61,4 @@ The anime name is separated by "-". You can either type it manually, or go to [g ##### Multiple word title - https://gogoanime.film/category/shadows-house >> shadows-house -- https://gogoanime.film/category/kono-subarashii-sekai-ni-shukufuku-wo- >> kono-subarashii-sekai-ni-shukufuku-wo- \ No newline at end of file +- https://gogoanime.film/category/kono-subarashii-sekai-ni-shukufuku-wo- >> kono-subarashii-sekai-ni-shukufuku-wo- diff --git a/backend.py b/backend.py index 19728ec..cf71814 100644 --- a/backend.py +++ b/backend.py @@ -26,11 +26,18 @@ def config_check(): if os.path.exists("./config.json"): with open("./config.json", "r") as f: CONFIG = json.load(f) - if not "GoGoAnimeAuthKey" in CONFIG or len(CONFIG["GoGoAnimeAuthKey"]) == 0: - print("GoGoAnimeAuthKey not set in config.json") + if not "GoGoAnime_Username" in CONFIG or len(CONFIG["GoGoAnime_Username"]) == 0: + print("GoGoAnime_Username not set in config.json") exit(0) else: - return CONFIG + if ( + not "GoGoAnime_Password" in CONFIG + or len(CONFIG["GoGoAnime_Password"]) == 0 + ): + print("GoGoAnime_Password not set in config.json") + exit(0) + else: + return CONFIG else: print("config.json file not found") exit(0) @@ -55,7 +62,7 @@ CURRENT_DOMAIN = "film" @dataclass(init=True) -class Download: +class gogoanime: config: object name: str episode_quality: str @@ -66,6 +73,32 @@ class Download: title: str printed: bool = False + def get_gogoanime_auth_cookie(self): + session = requests.session() + page = session.get( + f"https://gogoanime.{self.config['CurrentGoGoAnimeDomain']}/login.html" + ) + soup = BeautifulSoup(page.content, "html.parser") + meta_path = soup.select('meta[name="csrf-token"]') + csrf_token = meta_path[0].attrs["content"] + + url = f"https://gogoanime.{self.config['CurrentGoGoAnimeDomain']}/login.html" + payload = f"email={self.config['GoGoAnime_Username']}&password={self.config['GoGoAnime_Password']}&_csrf={csrf_token}" + headers = { + "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']}/", + "content-type": "application/x-www-form-urlencoded", + } + session.headers = headers + + r = session.post(url, data=payload, headers=headers) + + if r.status_code == 200: + return session.cookies.get_dict().get("auth") + else: + print("ldldl") + def get_links(self, source=None): if source is not None: source_ep = f"https://gogoanime.{self.config['CurrentGoGoAnimeDomain']}/{self.name}-episode-" @@ -83,10 +116,9 @@ class Download: return episode_links def get_download_link(self, url): - page = requests.get( url, - cookies=dict(auth=self.config["GoGoAnimeAuthKey"]), + cookies=dict(auth=gogoanime.get_gogoanime_auth_cookie(self)), ) soup = BeautifulSoup(page.content, "html.parser") diff --git a/config.json.default b/config.json.default index 576812d..d633ba1 100644 --- a/config.json.default +++ b/config.json.default @@ -1,5 +1,6 @@ { - "GoGoAnimeAuthKey": "", + "GoGoAnime_Username":"", + "GoGoAnime_Password":"", "MaxConcurrentDownloads": 4, "CurrentGoGoAnimeDomain": "film", "OverwriteDownloads": 0