Add initial check script
This commit is contained in:
commit
ba9edfd14e
1 changed files with 32 additions and 0 deletions
32
check.py
Executable file
32
check.py
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
from urllib.parse import urljoin
|
||||
|
||||
INVIDIOUS_URL = "http://127.0.0.1:7529"
|
||||
|
||||
def check_landingpage():
|
||||
req = requests.get(INVIDIOUS_URL)
|
||||
return req.status_code == 200
|
||||
|
||||
def get_mc_videos():
|
||||
req = requests.get(urljoin(INVIDIOUS_URL, "search"), params={"q": "minecraft"})
|
||||
soup = BeautifulSoup(req.text, "html.parser")
|
||||
minecraft_videos = soup.find_all("a", {"title": "Watch on YouTube"})
|
||||
return minecraft_videos
|
||||
|
||||
def check_searchresults():
|
||||
return len(get_mc_videos()) > 0
|
||||
|
||||
def check_videoplayback():
|
||||
req = requests.get(get_mc_videos()[0].get("href"))
|
||||
return req.status_code == 200
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
result = check_landingpage() and check_searchresults() and check_videoplayback()
|
||||
sys.exit(0 if result else 1)
|
||||
except Exception:
|
||||
sys.exit(1)
|
||||
|
Loading…
Reference in a new issue