streamer sound uri/path

This commit is contained in:
bkfox
2022-03-26 16:23:46 +01:00
parent 66f02bdb05
commit fb665aff5d
7 changed files with 32 additions and 9 deletions

View File

@ -46,7 +46,13 @@ class SoundQuerySet(models.QuerySet):
""" Return sounds that are archives """
return self.filter(type=Sound.TYPE_ARCHIVE)
def paths(self, archive=True, order_by=True):
def path(self, paths):
if isinstance(paths, str):
return self.filter(file=paths.replace(conf.MEDIA_ROOT + '/', ''))
return self.filter(file__in=(p.replace(conf.MEDIA_ROOT + '/', '')
for p in paths))
def playlist(self, archive=True, order_by=True):
"""
Return files absolute paths as a flat list (exclude sound without path).
If `order_by` is True, order by path.
@ -104,6 +110,7 @@ class Sound(models.Model):
file = models.FileField(
_('file'), upload_to=_upload_to, max_length=256,
db_index=True,
)
duration = models.TimeField(
_('duration'),