mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-07 20:15:24 +00:00
Refactor domain function to store domain in a JSON file
This commit is contained in:
parent
f866d9b42c
commit
594aa1840e
@ -9,30 +9,34 @@ import requests, sys, json
|
|||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
def domain_version():
|
def domain_version():
|
||||||
|
|
||||||
console.print("[green]Get rules ...")
|
console.print("[green]Get rules ...")
|
||||||
req_repo = requests.get("https://raw.githubusercontent.com/Ghost6446/Streaming_comunity_data/main/data.json", headers={'user-agent': get_headers()}, timeout=5)
|
req_repo = None
|
||||||
domain = req_repo.json()['domain']
|
try:
|
||||||
|
with open('data.json', 'r') as file:
|
||||||
|
req_repo = json.load(file)
|
||||||
|
except FileNotFoundError:
|
||||||
|
req_repo = {"domain": ""}
|
||||||
|
domain = req_repo['domain']
|
||||||
|
|
||||||
if req_repo.ok:
|
while True:
|
||||||
|
if not domain:
|
||||||
|
domain = input("Insert domain (streamingcommunity.?): ")
|
||||||
|
req_repo['domain'] = domain
|
||||||
|
with open('data.json', 'w') as file:
|
||||||
|
json.dump(req_repo, file)
|
||||||
console.print(f"[blue]Test domain [white]=> [red]{domain}")
|
console.print(f"[blue]Test domain [white]=> [red]{domain}")
|
||||||
site_url = f"https://streamingcommunity.{domain}"
|
site_url = f"https://streamingcommunity.{domain}"
|
||||||
site_request = requests.get(site_url, headers={'user-agent': get_headers()})
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
site_request = requests.get(site_url, headers={'user-agent': get_headers()})
|
||||||
soup = BeautifulSoup(site_request.text, "lxml")
|
soup = BeautifulSoup(site_request.text, "lxml")
|
||||||
version = json.loads(soup.find("div", {"id": "app"}).get("data-page"))['version']
|
version = json.loads(soup.find("div", {"id": "app"}).get("data-page"))['version']
|
||||||
console.print(f"[blue]Rules [white]=> [red].{domain}")
|
console.print(f"[blue]Rules [white]=> [red].{domain}")
|
||||||
|
|
||||||
return domain, version
|
return domain, version
|
||||||
|
|
||||||
except:
|
except Exception as e:
|
||||||
console.log("[red]Cant get version, problem with domain")
|
console.log("[red]Cant get version, problem with domain. Try again.")
|
||||||
sys.exit(0)
|
domain = None
|
||||||
|
continue
|
||||||
else:
|
|
||||||
console.log(f"[red]Error: {req_repo.status_code}")
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
def search(title_search, domain):
|
def search(title_search, domain):
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user