mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-07 12:05:35 +00:00
Update page.py
This commit is contained in:
parent
5466d71e57
commit
69b7095d32
@ -8,24 +8,16 @@ from Src.Util.console import console
|
|||||||
import requests, sys, json
|
import requests, sys, json
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
|
|
||||||
def domain_version():
|
def domain_version():
|
||||||
|
domain_req = requests.get("https://api.telegra.ph/getPage/Link-Aggiornato-StreamingCommunity-01-17")
|
||||||
|
domain = domain_req.json()['result']['description']
|
||||||
console.print("[green]Get rules ...")
|
console.print("[green]Get rules ...")
|
||||||
req_repo = None
|
req_repo = None
|
||||||
try:
|
|
||||||
with open('data.json', 'r') as file:
|
|
||||||
req_repo = json.load(file)
|
|
||||||
except FileNotFoundError:
|
|
||||||
req_repo = {"domain": ""}
|
|
||||||
domain = req_repo['domain']
|
|
||||||
|
|
||||||
while True:
|
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 = domain
|
||||||
try:
|
try:
|
||||||
site_request = requests.get(site_url, headers={'user-agent': get_headers()})
|
site_request = requests.get(site_url, headers={'user-agent': get_headers()})
|
||||||
soup = BeautifulSoup(site_request.text, "lxml")
|
soup = BeautifulSoup(site_request.text, "lxml")
|
||||||
@ -38,16 +30,18 @@ def domain_version():
|
|||||||
domain = None
|
domain = None
|
||||||
continue
|
continue
|
||||||
|
|
||||||
def search(title_search, domain):
|
|
||||||
|
|
||||||
req = requests.get(f"https://streamingcommunity.{domain}/api/search?q={title_search}", headers={'user-agent': get_headers()})
|
def search(title_search, domain):
|
||||||
|
req = requests.get(f"{domain}/api/search?q={title_search}", headers={'user-agent': get_headers()})
|
||||||
|
|
||||||
if req.ok:
|
if req.ok:
|
||||||
return [{'name': title['name'], 'type': title['type'], 'id': title['id'], 'slug': title['slug']} for title in req.json()['data']][0:21]
|
return [{'name': title['name'], 'type': title['type'], 'id': title['id'], 'slug': title['slug']} for title in
|
||||||
|
req.json()['data']][0:21]
|
||||||
else:
|
else:
|
||||||
console.log(f"[red]Error: {req.status_code}")
|
console.log(f"[red]Error: {req.status_code}")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
def display_search_results(db_title):
|
def display_search_results(db_title):
|
||||||
for i, title in enumerate(db_title):
|
for i, title in enumerate(db_title):
|
||||||
console.print(f"[yellow]{i} [white]-> [green]{title['name']} [white]- [cyan]{title['type']}")
|
console.print(f"[yellow]{i} [white]-> [green]{title['name']} [white]- [cyan]{title['type']}")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user