mirror of
https://github.com/kemko/icecast-ripper.git
synced 2026-01-01 15:55:42 +03:00
Rename service to icecast-ripper
This commit is contained in:
10
Makefile
10
Makefile
@@ -1,5 +1,5 @@
|
||||
run:
|
||||
@echo "Starting Icecast Recorder Service"
|
||||
@echo "Starting Icecast Ripper Service"
|
||||
python src/main.py
|
||||
|
||||
test:
|
||||
@@ -7,12 +7,12 @@ test:
|
||||
python -m unittest discover -s tests/
|
||||
|
||||
build:
|
||||
@echo "Building Docker image for Icecast Recorder Service"
|
||||
docker build -t icecast-recorder .
|
||||
@echo "Building Docker image for Icecast Ripper Service"
|
||||
docker build -t icecast-ripper .
|
||||
|
||||
docker-run: build
|
||||
@echo "Running Icecast Recorder Service in a Docker container"
|
||||
docker run -p 8080:8080 --env-file .env.example icecast-recorder
|
||||
@echo "Running Icecast Ripper Service in a Docker container"
|
||||
docker run -p 8080:8080 --env-file .env.example icecast-ripper
|
||||
|
||||
clean:
|
||||
@echo "Cleaning up pycache and .pyc files"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
icecast-recorder:
|
||||
image: ghcr.io/kemko/icecast-recorder:master
|
||||
icecast-ripper:
|
||||
image: ghcr.io/kemko/icecast-ripper:master
|
||||
ports:
|
||||
- "8080:8080"
|
||||
environment:
|
||||
|
||||
@@ -21,7 +21,7 @@ DEFAULTS = {
|
||||
|
||||
def parse_arguments():
|
||||
"""Parse command line arguments"""
|
||||
parser = argparse.ArgumentParser(description='Icecast Recorder Service')
|
||||
parser = argparse.ArgumentParser(description='Icecast Ripper Service')
|
||||
parser.add_argument('--server-host', help='Server host name with protocol')
|
||||
parser.add_argument('--server-port', type=int, help='Server port number')
|
||||
parser.add_argument('--stream-url', help='URL of the Icecast stream to monitor and record')
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Main entry point for the Icecast stream checker and recorder"""
|
||||
"""Main entry point for the Icecast stream checker and ripper"""
|
||||
import asyncio
|
||||
from server import start_server
|
||||
from stream_checker import StreamChecker
|
||||
@@ -6,7 +6,7 @@ from config import load_configuration
|
||||
from logger import log_event
|
||||
|
||||
def main():
|
||||
"""Main entry point for the Icecast stream checker and recorder"""
|
||||
"""Main entry point for the Icecast stream checker and ripper"""
|
||||
# Load configuration from command line arguments and environment variables
|
||||
config = load_configuration()
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
"""Recorder class for recording a stream to a file"""
|
||||
"""Ripper class for recording a stream to a file"""
|
||||
import os
|
||||
from datetime import datetime, timedelta
|
||||
import aiohttp
|
||||
from logger import log_event
|
||||
from utils import sanitize_filename
|
||||
|
||||
class Recorder: # pylint: disable=too-many-instance-attributes
|
||||
"""Recorder class for recording a stream to a file"""
|
||||
class Ripper: # pylint: disable=too-many-instance-attributes
|
||||
"""Ripper class for recording a stream to a file"""
|
||||
def __init__(self, stream_url, output_directory, timeout_connect=10, timeout_read=30):
|
||||
self.stream_url = stream_url
|
||||
self.output_directory = output_directory
|
||||
@@ -74,5 +74,5 @@ class Recorder: # pylint: disable=too-many-instance-attributes
|
||||
})
|
||||
|
||||
def is_active(self):
|
||||
"""Check if the recorder is currently recording a stream"""
|
||||
"""Check if the ripper is currently recording a stream"""
|
||||
return self.is_recording
|
||||
@@ -1,22 +1,22 @@
|
||||
"""Checking the stream status and starting the recorder"""
|
||||
"""Checking the stream status and starting the ripper"""
|
||||
import asyncio
|
||||
from aiohttp import ClientSession, ClientTimeout
|
||||
from recorder import Recorder
|
||||
from ripper import Ripper
|
||||
from logger import log_event
|
||||
|
||||
class StreamChecker:
|
||||
"""Checking the stream status and starting the recorder"""
|
||||
"""Checking the stream status and starting the ripper"""
|
||||
def __init__(self, stream_url, check_interval, timeout_connect, output_directory, timeout_read=30): # pylint: disable=too-many-arguments
|
||||
self.stream_url = stream_url
|
||||
self.check_interval = check_interval
|
||||
self.timeout_connect = timeout_connect
|
||||
self.timeout_read = timeout_read
|
||||
self.output_directory = output_directory
|
||||
self.recorder = None
|
||||
self.ripper = None
|
||||
self.is_stream_live = False
|
||||
|
||||
async def check_stream(self, session):
|
||||
"""Check if the stream is live and start the recorder if needed"""
|
||||
"""Check if the stream is live and start the ripper if needed"""
|
||||
try:
|
||||
timeout = ClientTimeout(connect=self.timeout_connect)
|
||||
async with session.get(self.stream_url, timeout=timeout, allow_redirects=True) as response:
|
||||
@@ -38,8 +38,8 @@ class StreamChecker:
|
||||
async with ClientSession() as session:
|
||||
await self.check_stream(session)
|
||||
|
||||
if self.is_stream_live and (self.recorder is None or not self.recorder.is_active()):
|
||||
self.recorder = Recorder(self.stream_url, self.output_directory, self.timeout_read)
|
||||
await self.recorder.start_recording()
|
||||
if self.is_stream_live and (self.ripper is None or not self.ripper.is_active()):
|
||||
self.ripper = Ripper(self.stream_url, self.output_directory, self.timeout_read)
|
||||
await self.ripper.start_recording()
|
||||
|
||||
await asyncio.sleep(int(self.check_interval))
|
||||
|
||||
Reference in New Issue
Block a user