aircox-radiocampus/aircox/settings.py
2023-03-13 17:47:00 +01:00

126 lines
3.8 KiB
Python
Executable File

import os
from django.conf import settings
def ensure(key, default):
value = getattr(settings, key, default)
globals()[key] = value
return value
########################################################################
# Global & misc
########################################################################
# group to assign to users at their creation, along with the permissions
# to add to each group.
ensure(
"AIRCOX_DEFAULT_USER_GROUPS",
{
"radio hosts": (
# TODO include content_type in order to avoid clash with potential
# extra applications
# aircox
"change_program",
"change_episode",
"change_diffusion",
"add_comment",
"change_comment",
"delete_comment",
"add_article",
"change_article",
"delete_article",
"change_sound",
"add_track",
"change_track",
"delete_track",
# taggit
"add_tag",
"change_tag",
"delete_tag",
# filer
"add_folder",
"change_folder",
"delete_folder",
"can_use_directory_listing",
"add_image",
"change_image",
"delete_image",
),
},
)
# Directory for the programs data
AIRCOX_PROGRAMS_DIR = ensure("AIRCOX_PROGRAMS_DIR", "programs")
ensure(
"AIRCOX_PROGRAMS_DIR_ABS",
os.path.join(settings.MEDIA_ROOT, AIRCOX_PROGRAMS_DIR),
)
########################################################################
# Programs & Episodes
########################################################################
# default title for episodes
ensure("AIRCOX_EPISODE_TITLE", "{program.title} - {date}")
# date format in episode title (python's strftime)
ensure("AIRCOX_EPISODE_TITLE_DATE_FORMAT", "%-d %B %Y")
########################################################################
# Logs & Archives
########################################################################
# Directory where to save logs' archives
ensure(
"AIRCOX_LOGS_ARCHIVES_DIR",
os.path.join(settings.PROJECT_ROOT, "logs/archives"),
)
# In days, minimal age of a log before it is archived
ensure("AIRCOX_LOGS_ARCHIVES_AGE", 60)
########################################################################
# Sounds
########################################################################
# Sub directory used for the complete episode sounds
ensure("AIRCOX_SOUND_ARCHIVES_SUBDIR", "archives")
# Sub directory used for the excerpts of the episode
ensure("AIRCOX_SOUND_EXCERPTS_SUBDIR", "excerpts")
# Quality attributes passed to sound_quality_check from sounds_monitor
ensure(
"AIRCOX_SOUND_QUALITY",
{
"attribute": "RMS lev dB",
"range": (-18.0, -8.0),
"sample_length": 120,
},
)
# Extension of sound files
ensure("AIRCOX_SOUND_FILE_EXT", (".ogg", ".flac", ".wav", ".mp3", ".opus"))
# Tag sounds as deleted instead of deleting them when file has been removed
# from filesystem (sound monitoring)
ensure("AIRCOX_SOUND_KEEP_DELETED", False)
########################################################################
# Streamer & Controllers
########################################################################
# Controllers working directory
ensure("AIRCOX_CONTROLLERS_WORKING_DIR", "/tmp/aircox")
########################################################################
# Playlist import from CSV
########################################################################
# Columns for CSV file
ensure(
"AIRCOX_IMPORT_PLAYLIST_CSV_COLS",
("artist", "title", "minutes", "seconds", "tags", "info"),
)
# Column delimiter of csv text files
ensure("AIRCOX_IMPORT_PLAYLIST_CSV_DELIMITER", ";")
# Text delimiter of csv text files
ensure("AIRCOX_IMPORT_PLAYLIST_CSV_TEXT_QUOTE", '"')