forked from rc/aircox
sound check
This commit is contained in:
@ -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
|
||||
|
@ -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(
|
||||
|
Reference in New Issue
Block a user