forked from rc/aircox
		
	player end of playlist, switch to live
This commit is contained in:
		@ -78,13 +78,13 @@ class Program(Page):
 | 
			
		||||
        """ Return absolute path to program's dir """
 | 
			
		||||
        return os.path.join(conf.MEDIA_ROOT, self.path)
 | 
			
		||||
 | 
			
		||||
    def archives_path(self, abs=False):
 | 
			
		||||
        return os.path.join(abs and self.abspath or self.path,
 | 
			
		||||
                            settings.AIRCOX_SOUND_ARCHIVES_SUBDIR)
 | 
			
		||||
    @property
 | 
			
		||||
    def archives_path(self):
 | 
			
		||||
        return os.path.join(self.path, settings.AIRCOX_SOUND_ARCHIVES_SUBDIR)
 | 
			
		||||
 | 
			
		||||
    def excerpts_path(self, abs=False):
 | 
			
		||||
        return os.path.join(abs and self.abspath or self.path,
 | 
			
		||||
                            settings.AIRCOX_SOUND_ARCHIVES_SUBDIR)
 | 
			
		||||
    @property
 | 
			
		||||
    def excerpts_path(self):
 | 
			
		||||
        return os.path.join(self.path, settings.AIRCOX_SOUND_ARCHIVES_SUBDIR)
 | 
			
		||||
 | 
			
		||||
    def __init__(self, *kargs, **kwargs):
 | 
			
		||||
        super().__init__(*kargs, **kwargs)
 | 
			
		||||
 | 
			
		||||
@ -2,7 +2,7 @@ from enum import IntEnum
 | 
			
		||||
import logging
 | 
			
		||||
import os
 | 
			
		||||
 | 
			
		||||
from django.conf import settings as main_settings
 | 
			
		||||
from django.conf import settings as conf
 | 
			
		||||
from django.db import models
 | 
			
		||||
from django.db.models import Q, Value as V
 | 
			
		||||
from django.db.models.functions import Concat
 | 
			
		||||
@ -48,20 +48,19 @@ class SoundQuerySet(models.QuerySet):
 | 
			
		||||
 | 
			
		||||
    def paths(self, archive=True, order_by=True):
 | 
			
		||||
        """
 | 
			
		||||
        Return paths as a flat list (exclude sound without path).
 | 
			
		||||
        Return files absolute paths as a flat list (exclude sound without path).
 | 
			
		||||
        If `order_by` is True, order by path.
 | 
			
		||||
        """
 | 
			
		||||
        if archive:
 | 
			
		||||
            self = self.archive()
 | 
			
		||||
        if order_by:
 | 
			
		||||
            self = self.order_by('path')
 | 
			
		||||
        return self.filter(file__isnull=False) \
 | 
			
		||||
                   .annotate(file_path=Concat(V(conf.MEDIA_ROOT), 'file'))  \
 | 
			
		||||
                   .values_list('file_path', flat=True)
 | 
			
		||||
            self = self.order_by('file')
 | 
			
		||||
        return [os.path.join(conf.MEDIA_ROOT, file) for file in self.filter(file__isnull=False) \
 | 
			
		||||
                   .values_list('file', flat=True)]
 | 
			
		||||
 | 
			
		||||
    def search(self, query):
 | 
			
		||||
        return self.filter(
 | 
			
		||||
            Q(name__icontains=query) | Q(path__icontains=query) |
 | 
			
		||||
            Q(name__icontains=query) | Q(file__icontains=query) |
 | 
			
		||||
            Q(program__title__icontains=query) |
 | 
			
		||||
            Q(episode__title__icontains=query)
 | 
			
		||||
        )
 | 
			
		||||
@ -179,7 +178,7 @@ class Sound(models.Model):
 | 
			
		||||
        if self.type == self.TYPE_REMOVED and self.program:
 | 
			
		||||
            changed = True
 | 
			
		||||
            self.type = self.TYPE_ARCHIVE \
 | 
			
		||||
                if self.file.path.startswith(self.program.archives_path) else \
 | 
			
		||||
                if self.file.name.startswith(self.program.archives_path) else \
 | 
			
		||||
                self.TYPE_EXCERPT
 | 
			
		||||
 | 
			
		||||
        # check mtime -> reset quality if changed (assume file changed)
 | 
			
		||||
@ -195,7 +194,7 @@ class Sound(models.Model):
 | 
			
		||||
        return changed
 | 
			
		||||
 | 
			
		||||
    def __check_name(self):
 | 
			
		||||
        if not self.name and self.file and self.file.path:
 | 
			
		||||
        if not self.name and self.file and self.file.name:
 | 
			
		||||
            # FIXME: later, remove date?
 | 
			
		||||
            self.name = os.path.basename(self.file.name)
 | 
			
		||||
            self.name = os.path.splitext(self.name)[0]
 | 
			
		||||
 | 
			
		||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@ -180,7 +180,7 @@ export default {
 | 
			
		||||
            let src = null;
 | 
			
		||||
 | 
			
		||||
            // from playlist
 | 
			
		||||
            if(playlist !== null) {
 | 
			
		||||
            if(playlist !== null && index != -1) {
 | 
			
		||||
                let item = this.$refs[playlist].get(index);
 | 
			
		||||
                if(!item)
 | 
			
		||||
                    throw `No sound at index ${index} for playlist ${playlist}`;
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user