#!/usr/bin/env python3
import datetime
import subprocess
import time
from urllib.request import Request, urljoin, urlopen
from bs4 import BeautifulSoup
CSS_SELECTOR = "div.thumbnail__thumb.thumbnail__thumb--live > a.videostream__link.link"
def get_latest():
base_url = "https://rumble.com"
channel = "c/SC360Media/livestreams"
browser = "Mozilla/5.0 (X11; Linux x86_64; rv:126.0) Gecko/20100101 Firefox/126.0"
headers = {"User-Agent": browser}
url = urljoin(base_url, channel)
request = Request(url, headers=headers)
while True:
content = urlopen(request).read()
doc = BeautifulSoup(content, "html.parser")
try:
live = doc.select_one(CSS_SELECTOR)["href"]
except TypeError as e:
now = datetime.datetime.now().replace(microsecond=0)
print(f"[{now}]: Bitte warten, Sendung ist noch nicht live")
time.sleep(10)
continue
else:
return urljoin(base_url, live)
if __name__ == "__main__":
# get url, blocks until it selects a live-stream
url = get_latest()
# start firefox or open a new tab if a firefox process is active
proc = subprocess.Popen(
["firefox", url], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
)
Comments
0 B
|👍
/👎