Added support for streamlink and a waiting page when using the browser
This commit is contained in:
parent
6cc774aa7c
commit
004d913520
@ -30,7 +30,8 @@ Next you will need to tell the streamer to use this service when specified in th
|
||||
```
|
||||
You will also need to specify this service your **config** file.
|
||||
|
||||
|
||||
## Streamlink
|
||||
The stream for youtube can also be started using streamlink. This is less resource intensive but currently there is no way of showing that no stream is active and it might be less stable then the browser.
|
||||
|
||||
## Todo
|
||||
* Add fallback option for the streamer. For example: If youtube does not work, fall back to KDG
|
13
notlive.html
13
notlive.html
@ -3,7 +3,18 @@
|
||||
<head>
|
||||
<title>Immanuelkapel</title>
|
||||
</head>
|
||||
<style>
|
||||
.text_container {
|
||||
margin: auto;
|
||||
width: 60%;
|
||||
padding: 10px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
<body>
|
||||
<h1>Waiting to go live</h1>
|
||||
<div class="text_container">
|
||||
<h1>Wachten totdat de stream live is</h1>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -4,7 +4,7 @@ from selenium import webdriver
|
||||
from selenium.webdriver.chrome.service import Service
|
||||
from selenium.webdriver.chrome.options import Options
|
||||
from webdriver_manager.chrome import ChromeDriverManager
|
||||
|
||||
import os
|
||||
from streaming.youtube import Web_Youtube
|
||||
|
||||
class Streamer:
|
||||
@ -12,7 +12,8 @@ class Streamer:
|
||||
self.config = ConfigParser()
|
||||
self.config.read(config_path)
|
||||
self.load_config_values()
|
||||
self.setup_web_driver()
|
||||
if self.streaming_method == "web":
|
||||
self.setup_web_driver()
|
||||
|
||||
def load_config_values(self):
|
||||
self.streaming_service = self.config.get('main', 'streaming_service').lower()
|
||||
@ -40,7 +41,9 @@ class Streamer:
|
||||
|
||||
def stream(self):
|
||||
if self.streaming_method == "video":
|
||||
self.stream_service.pre_load_actions(self.driver)
|
||||
if self.streaming_service != "youtube":
|
||||
raise NotImplementedError()
|
||||
os.system(f"streamlink {self.stream_service.get_stream_url()} best")
|
||||
else:
|
||||
#Default to web
|
||||
self.stream_service.pre_load_actions(self.driver)
|
||||
|
@ -25,6 +25,18 @@ class Web_Youtube(Web_StreamService):
|
||||
return True
|
||||
return False
|
||||
|
||||
def get_stream_url(self):
|
||||
page = requests.get(self.livestream_url(), cookies={'CONSENT': 'YES+42'})
|
||||
data = page.content.decode()
|
||||
offset = data.find('<link rel="canonical" href="https://www.youtube.com/')
|
||||
line = ""
|
||||
while True:
|
||||
if ">" in line:
|
||||
break
|
||||
line += data[offset]
|
||||
offset += 1
|
||||
return line.split("href=")[-1][:-1]
|
||||
|
||||
def wait_until_live(self):
|
||||
while True:
|
||||
try:
|
||||
|
8
tests/teststream.ini
Normal file
8
tests/teststream.ini
Normal file
@ -0,0 +1,8 @@
|
||||
[main]
|
||||
streaming_method = video
|
||||
streaming_service = youtube
|
||||
|
||||
[kerk]
|
||||
name = test stream
|
||||
youtube_channel_id = UC9X6gGKDv2yhMoofoeS7-Gg
|
||||
kerkdienstgemist_id = 2112-Immanuelkapel
|
Loading…
Reference in New Issue
Block a user