forked from rc/aircox
		
	add liquidsoap output models and configuration
This commit is contained in:
		@ -1,3 +1,31 @@
 | 
				
			|||||||
from django.db import models
 | 
					from django.db import models
 | 
				
			||||||
 | 
					from django.utils.translation import ugettext as _, ugettext_lazy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import aircox.programs.models as programs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Output (models.Model):
 | 
				
			||||||
 | 
					    # Note: we don't translate the names since it is project names.
 | 
				
			||||||
 | 
					    Type = {
 | 
				
			||||||
 | 
					        'jack': 0x00,
 | 
				
			||||||
 | 
					        'alsa': 0x01,
 | 
				
			||||||
 | 
					        'icecast': 0x02,
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    station = models.ForeignKey(
 | 
				
			||||||
 | 
					        programs.Station,
 | 
				
			||||||
 | 
					        verbose_name = _('station'),
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					    type = models.SmallIntegerField(
 | 
				
			||||||
 | 
					        _('output type'),
 | 
				
			||||||
 | 
					        choices = [ (y, x) for x,y in Type.items() ],
 | 
				
			||||||
 | 
					        blank = True, null = True
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					    settings = models.TextField(
 | 
				
			||||||
 | 
					        _('output settings'),
 | 
				
			||||||
 | 
					        help_text = _('list of comma separated params available; '
 | 
				
			||||||
 | 
					                      'this is put in the output config as raw text'),
 | 
				
			||||||
 | 
					        blank = True, null = True
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,54 +0,0 @@
 | 
				
			|||||||
{% comment %}
 | 
					 | 
				
			||||||
A station has multiple sources:
 | 
					 | 
				
			||||||
- dealer: a controlled playlist playing once each track, that reloads on file
 | 
					 | 
				
			||||||
    change. This is used for scheduled sounds.
 | 
					 | 
				
			||||||
- streams: a rotate source with all playlists
 | 
					 | 
				
			||||||
- single: security song
 | 
					 | 
				
			||||||
{% endcomment %}
 | 
					 | 
				
			||||||
def make_station_{{ controller.id }} () = \
 | 
					 | 
				
			||||||
    {# dealer #}
 | 
					 | 
				
			||||||
    {% with source=controller.dealer %}
 | 
					 | 
				
			||||||
    {% if source %}
 | 
					 | 
				
			||||||
    dealer = interactive_source('{{ source.id }}', playlist.once( \
 | 
					 | 
				
			||||||
        reload_mode='watch', \
 | 
					 | 
				
			||||||
        "{{ source.path }}", \
 | 
					 | 
				
			||||||
    )) \
 | 
					 | 
				
			||||||
    \
 | 
					 | 
				
			||||||
    dealer_on = interactive.bool("{{ source.id }}_on", false) \
 | 
					 | 
				
			||||||
    {% endif %}
 | 
					 | 
				
			||||||
    {% endwith %}
 | 
					 | 
				
			||||||
    \
 | 
					 | 
				
			||||||
    {# streams #}
 | 
					 | 
				
			||||||
    streams = interactive_source("streams", rotate([ \
 | 
					 | 
				
			||||||
    {% for source in controller.streams.values %}
 | 
					 | 
				
			||||||
    {% with info=source.stream_info %}
 | 
					 | 
				
			||||||
    {% if info.delay %}
 | 
					 | 
				
			||||||
        delay({{ info.delay }}., stream("{{ source.id }}", "{{ source.path }}")), \
 | 
					 | 
				
			||||||
    {% elif info.begin and info.end %}
 | 
					 | 
				
			||||||
        at({ {{info.begin}}-{{info.end}} }, stream("{{ source.id }}", "{{ source.path }}")), \
 | 
					 | 
				
			||||||
    {% endif %}
 | 
					 | 
				
			||||||
    {% endwith %}
 | 
					 | 
				
			||||||
    {% endfor %}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    {% for source in controller.streams.values %}
 | 
					 | 
				
			||||||
    {% if not source.stream_info %}
 | 
					 | 
				
			||||||
        stream("{{ source.id }}", "{{ source.path }}"), \
 | 
					 | 
				
			||||||
    {% endif %}
 | 
					 | 
				
			||||||
    {% endfor %}
 | 
					 | 
				
			||||||
    ])) \
 | 
					 | 
				
			||||||
    \
 | 
					 | 
				
			||||||
    {# station #}
 | 
					 | 
				
			||||||
    interactive_source ( \
 | 
					 | 
				
			||||||
        "{{ controller.id }}", \
 | 
					 | 
				
			||||||
        fallback(track_sensitive = false, [ \
 | 
					 | 
				
			||||||
            at(dealer_on, dealer), \
 | 
					 | 
				
			||||||
            streams, \
 | 
					 | 
				
			||||||
        {% if controller.station.fallback %}
 | 
					 | 
				
			||||||
            single("{{ controller.station.fallback }}"), \
 | 
					 | 
				
			||||||
        {% else %}
 | 
					 | 
				
			||||||
            blank(), \
 | 
					 | 
				
			||||||
        {% endif %}
 | 
					 | 
				
			||||||
        ]) \
 | 
					 | 
				
			||||||
    ) \
 | 
					 | 
				
			||||||
end \
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@ -462,14 +462,9 @@ class Program (Nameable):
 | 
				
			|||||||
        Make sur the program's dir exists (and optionally subdir). Return True
 | 
					        Make sur the program's dir exists (and optionally subdir). Return True
 | 
				
			||||||
        if the dir (or subdir) exists.
 | 
					        if the dir (or subdir) exists.
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        path = self.path
 | 
					        path = os.path.join(self.path, subdir) if subdir else \
 | 
				
			||||||
        if not os.path.exists(path):
 | 
					               self.path
 | 
				
			||||||
            os.mkdir(path)
 | 
					        os.makedirs(path, exist_ok = True)
 | 
				
			||||||
 | 
					 | 
				
			||||||
        if subdir:
 | 
					 | 
				
			||||||
            path = os.path.join(path, subdir)
 | 
					 | 
				
			||||||
            if not os.path.exists(path):
 | 
					 | 
				
			||||||
                os.mkdir(path)
 | 
					 | 
				
			||||||
        return os.path.exists(path)
 | 
					        return os.path.exists(path)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def find_schedule (self, date):
 | 
					    def find_schedule (self, date):
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user