finished work with recorders

This commit is contained in:
Vitalii Lebedynskyi
2022-08-14 23:03:22 +03:00
parent 3133f24bdd
commit 0089dc2982
3 changed files with 66 additions and 28 deletions

View File

@@ -9,22 +9,35 @@ class TwitchVideoRecorder:
refresh_timeout = 15
streamlink_process = None
def run(self, streamer_name, output_file, quality="480p"):
def run(self, streamer_name, output_file, quality="720p"):
self.is_running = True
self._record_stream(streamer_name, output_file, quality)
def stop(self):
if self.streamlink_process:
self.streamlink_process.kill()
try:
if self.streamlink_process:
self.streamlink_process.terminate()
self.streamlink_process = None
logger.error("Video stopped")
except BaseException as e:
logger.error("Unable to stop video")
logger.error(e)
self.is_running = False
def _record_stream(self, streamer_name, output_file, quality):
# subprocess.call()
self.streamlink_process = subprocess.Popen([
"streamlink",
"--twitch-disable-ads",
"twitch.tv/" + streamer_name,
quality,
"-o",
output_file
])
try:
self.streamlink_process = subprocess.Popen([
"streamlink",
"--twitch-disable-ads",
"twitch.tv/" + streamer_name,
quality,
"-o",
output_file
])
self.is_running = True
except BaseException as e:
logger.error("Unable to run streamlink")
logger.error(e)
self.is_running = False