From 8911f90875b4774dc9cd07b3e1a3ffb0f3235ef9 Mon Sep 17 00:00:00 2001 From: bkfox Date: Sat, 12 Dec 2015 15:50:24 +0100 Subject: [PATCH] add liquidsoap output models and configuration --- aircox/liquidsoap/models.py | 28 ++++++++++ .../templates/aircox_liquidsoap/station.liq | 54 ------------------- aircox/programs/models.py | 11 ++-- 3 files changed, 31 insertions(+), 62 deletions(-) delete mode 100644 aircox/liquidsoap/templates/aircox_liquidsoap/station.liq diff --git a/aircox/liquidsoap/models.py b/aircox/liquidsoap/models.py index 4167352..efd4f9a 100644 --- a/aircox/liquidsoap/models.py +++ b/aircox/liquidsoap/models.py @@ -1,3 +1,31 @@ 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 + ) diff --git a/aircox/liquidsoap/templates/aircox_liquidsoap/station.liq b/aircox/liquidsoap/templates/aircox_liquidsoap/station.liq deleted file mode 100644 index 3c7713c..0000000 --- a/aircox/liquidsoap/templates/aircox_liquidsoap/station.liq +++ /dev/null @@ -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 \ - diff --git a/aircox/programs/models.py b/aircox/programs/models.py index 4d765ee..e7804b1 100755 --- a/aircox/programs/models.py +++ b/aircox/programs/models.py @@ -462,14 +462,9 @@ class Program (Nameable): Make sur the program's dir exists (and optionally subdir). Return True if the dir (or subdir) exists. """ - path = self.path - if not os.path.exists(path): - os.mkdir(path) - - if subdir: - path = os.path.join(path, subdir) - if not os.path.exists(path): - os.mkdir(path) + path = os.path.join(self.path, subdir) if subdir else \ + self.path + os.makedirs(path, exist_ok = True) return os.path.exists(path) def find_schedule (self, date):