musicdlp/backend/config.py
DarkCat09 62ebecc87f
Remove path_length config option
I've misunderstood the FS limits, 255 is for filename, not path.
Path is limited only by libc, it's 4096.
The default outtmpl in musicdlp contains slashes, so it's a path.
But YDL considers it to be a filename, so the whole
outtmpl formatting result is trimmed to path_length.
Do we really need this? I think there are no "malicious" long-named tracks :)
2024-05-06 19:43:32 +04:00

33 lines
978 B
Python

import os
from pathlib import Path
class Config:
def __init__(self) -> None:
self.host = os.getenv('HOST') or '0.0.0.0'
self.port = int(os.getenv('PORT') or 4009)
# This directory will be searched for <site>.txt (e.g. yandex.txt)
# Cookies are in Netscape CSV format, see yt-dlp docs
self.cookies_dir = Path(os.getenv('COOKIES_DIR') or 'cookies')
self.tmpl = os.path.join(
# `artists.0` instead of `artist`, because the latter can contain "feat. ..."
os.getenv('ALBUM_PATH_TMPL') or 'music/%(artists.0)s/%(album)s',
os.getenv('TRACK_FILE_TMPL') or '%(track)s.%(ext)s',
)
# Proxy URL for yt_proxied downloader (can be used for geo-restricted content)
self.yt_proxy = os.getenv('YT_PROXY') or 'http://127.0.0.1:1080'
_config: Config | None = None
def get() -> Config:
global _config
if _config is None:
_config = Config()
return _config