sound check

This commit is contained in:
bkfox
2023-01-25 13:02:21 +01:00
parent 276e65e0b4
commit 9ec25ed109
13 changed files with 671 additions and 330 deletions

View File

@ -9,6 +9,7 @@ from django.utils.translation import gettext_lazy as _
from taggit.managers import TaggableManager
from aircox import settings
from .program import Program
from .episode import Episode
@ -73,6 +74,8 @@ class SoundQuerySet(models.QuerySet):
)
# TODO:
# - provide a default name based on program and episode
class Sound(models.Model):
"""
A Sound is the representation of a sound file that can be either an excerpt
@ -105,13 +108,14 @@ class Sound(models.Model):
)
def _upload_to(self, filename):
subdir = AIRCOX_SOUND_ARCHIVES_SUBDIR if self.type == self.TYPE_ARCHIVE else \
AIRCOX_SOUND_EXCERPTS_SUBDIR
subdir = settings.AIRCOX_SOUND_ARCHIVES_SUBDIR \
if self.type == self.TYPE_ARCHIVE else \
settings.AIRCOX_SOUND_EXCERPTS_SUBDIR
return os.path.join(self.program.path, subdir, filename)
file = models.FileField(
_('file'), upload_to=_upload_to, max_length=256,
db_index=True,
db_index=True, unique=True,
)
duration = models.TimeField(
_('duration'),
@ -175,6 +179,7 @@ class Sound(models.Model):
return os.path.exists(self.file.path)
# TODO: rename to sync_fs()
def check_on_file(self):
"""
Check sound file info again'st self, and update informations if
@ -183,7 +188,7 @@ class Sound(models.Model):
if not self.file_exists():
if self.type == self.TYPE_REMOVED:
return
logger.info('sound %s: has been removed', self.file.name)
logger.debug('sound %s: has been removed', self.file.name)
self.type = self.TYPE_REMOVED
return True
@ -202,8 +207,8 @@ class Sound(models.Model):
if self.mtime != mtime:
self.mtime = mtime
self.is_good_quality = None
logger.info('sound %s: m_time has changed. Reset quality info',
self.file.name)
logger.debug('sound %s: m_time has changed. Reset quality info',
self.file.name)
return True
return changed

View File

@ -46,7 +46,7 @@ class Station(models.Model):
)
default = models.BooleanField(
_('default station'),
default=True,
default=False,
help_text=_('use this station as the main one.')
)
active = models.BooleanField(