You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
862 B
Python
33 lines
862 B
Python
#!/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)
|
|
|