New feature: Adding a new server [StreamSB] (WIP)

This commit is contained in:
sh1nobu 2021-10-01 20:17:53 +08:00
parent d1c222ff91
commit b362cdc0d1
3 changed files with 95 additions and 1 deletions

View File

@ -91,6 +91,42 @@ class Download:
shutil.copyfileobj(res.raw, file, 8192)
class Status:
url = "https://goload.one/download?id=MTcxNjIz&typesub=Gogoanime-SUB&title=Sonny+Boy+Episode+12"
streamsb = "StreamSB"
gogo = "SDP"
def check_status(self):
with req.get(self.url) as res:
soup = BeautifulSoup(res.content, "html.parser")
self.streamsb = soup.find_all("div", {"class": "mirror_link"})[1].find(
"div",
text=re.compile(fr"\b{self.streamsb}\b"),
attrs={"class": "dowload"},
)
self.gogo = soup.find_all("div", {"class": "mirror_link"})[0].find(
"div",
text=re.compile(fr"\b{self.gogo}\b"),
attrs={"class": "dowload"},
)
self.print_server_status()
def print_server_status(self):
streamsb_status = (
f"[{Fore.RED}-{Fore.RESET}] 1. StreamSB ({Fore.RED}Unavailable{Fore.RESET})"
if self.streamsb is None
else f"[{Fore.GREEN}+{Fore.RESET}] 1. StreamSB ({Fore.GREEN}Available{Fore.RESET})"
)
gogo_status = (
f"[{Fore.RED}-{Fore.RESET}] 2. Gogo Sever ({Fore.RED}Unavailable{Fore.RESET})"
if self.gogo is None
else f"[{Fore.GREEN}+{Fore.RESET}] 2. Gogo Server ({Fore.GREEN}Available{Fore.RESET})"
)
print(f"[{Fore.GREEN}+{Fore.RESET}] Available Servers")
print(streamsb_status)
print(gogo_status)
@dataclass(init=True)
class CustomMessage(Exception):
"""Custom message that will accept message as a parameter and it will print it on the console."""

View File

@ -47,6 +47,12 @@ def bitanime():
break
else:
print(f"{ERR}Error 404: Anime not found. Please try again.")
while True:
server = input(f"{IN}Choose a server > ")
if server:
break
while True:
quality = input(
f"{IN}Enter episode quality (1.SD/360P|2.HD/720P|3.FULLHD/1080P) > "
@ -62,11 +68,12 @@ def bitanime():
break
else:
print(f"{ERR}Invalid input. Please try again.")
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}")
print(f"{OK}Link: {Fore.LIGHTCYAN_EX}{source}")
folder = os.path.join(os.getcwd(), title)
if not os.path.exists(folder):
os.mkdir(folder)

51
src/test.py Normal file
View File

@ -0,0 +1,51 @@
# Dependencies
import requests as req
import shutil
import re
import os
from bs4 import BeautifulSoup
from dataclasses import dataclass
from colorama import Fore
class Status:
url = "https://goload.one/download?id=MTcxNjIz&typesub=Gogoanime-SUB&title=Sonny+Boy+Episode+12"
streamsb = "StreamSB"
gogo = "SDP"
def check_status(self):
with req.get(self.url) as res:
soup = BeautifulSoup(res.content, "html.parser")
print(self.streamsb)
self.streamsb = soup.find_all("div", {"class": "mirror_link"})[1].find(
"div",
text=re.compile(fr"\b{self.streamsb}\b"),
attrs={"class": "dowload"},
)
print(self.streamsb)
print(self.gogo)
self.gogo = soup.find("div", {"class": "mirror_link"}).find(
"div",
text=re.compile(fr"\b{self.gogo}\b"),
attrs={"class": "dowload"},
)
print(self.gogo)
self.print_server_status()
def print_server_status(self):
streamsb_status = (
f"[{Fore.RED}-{Fore.RESET}] 1. StreamSB ({Fore.RED}Unavailable{Fore.RESET})"
if self.streamsb is None
else f"[{Fore.GREEN}+{Fore.RESET}] 1. StreamSB ({Fore.GREEN}Available{Fore.RESET})"
)
gogo_status = (
f"[{Fore.RED}-{Fore.RESET}] 2. Gogo Sever ({Fore.RED}Unavailable{Fore.RESET})"
if self.gogo is None
else f"[{Fore.GREEN}+{Fore.RESET}] 2. Gogo Server ({Fore.GREEN}Available{Fore.RESET})"
)
print(f"[{Fore.GREEN}+{Fore.RESET}] Available Servers")
print(streamsb_status)
print(gogo_status)
Status().check_status()