mirror of
https://github.com/correl/turntable.git
synced 2024-11-23 19:19:55 +00:00
28 lines
814 B
Python
28 lines
814 B
Python
import logging
|
|
import os
|
|
|
|
import requests
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class Icecast:
|
|
def __init__(self, host: str, port: int, mountpoint: str, user: str, password: str):
|
|
self.host = host
|
|
self.port = port
|
|
self.mountpoint = mountpoint
|
|
self.credentials = (user, password)
|
|
|
|
def set_title(self, title: str):
|
|
try:
|
|
requests.get(
|
|
f"http://{self.host}:{self.port}/admin/metadata",
|
|
params={
|
|
"mount": os.path.join("/", self.mountpoint),
|
|
"mode": "updinfo",
|
|
"song": title,
|
|
},
|
|
auth=self.credentials,
|
|
)
|
|
except requests.RequestException as e:
|
|
logger.warning("Failed to update icecast metadata: %s", e)
|