forked from rc/aircox
start to work on stats
This commit is contained in:
@ -1,150 +0,0 @@
|
||||
{% comment %}
|
||||
TODO: update doc
|
||||
Base configuration file to configure a station on liquidsoap.
|
||||
|
||||
# Interactive elements:
|
||||
An interactive element is accessible to the people, in order to:
|
||||
- get metadata
|
||||
- skip the current sound
|
||||
- enable/disable it
|
||||
|
||||
# Element of the context
|
||||
We use theses elements from the template's context:
|
||||
- controller: controller describing the station itself
|
||||
- settings: global settings
|
||||
|
||||
# Overwrite the template
|
||||
It is possible to overwrite the template, there are blocks at different
|
||||
position in order to do it. Keep in mind that you might want to avoid to
|
||||
put station specific configuration in the template itself.
|
||||
{% endcomment %}
|
||||
|
||||
|
||||
{% block functions %}
|
||||
{% comment %}
|
||||
An interactive source is a source that:
|
||||
- is skippable through the given id on external interfaces
|
||||
- can be disabled
|
||||
- store metadata
|
||||
{% endcomment %}
|
||||
def interactive_source (id, s, ~active=true, ~disable_switch=false) =
|
||||
s = store_metadata(id=id, size=1, s)
|
||||
add_skip_command(s)
|
||||
if disable_switch then
|
||||
s
|
||||
else
|
||||
at(interactive.bool('#{id}_active', active), s)
|
||||
end
|
||||
end
|
||||
|
||||
{% comment %}
|
||||
A stream is a source that:
|
||||
- is a playlist on random mode (playlist object accessible at {id}_playlist
|
||||
- is interactive
|
||||
{% endcomment %}
|
||||
def stream (id, file) =
|
||||
s = playlist(id = '#{id}_playlist', mode = "random", reload_mode='watch',
|
||||
file)
|
||||
interactive_source(id, s)
|
||||
end
|
||||
{% endblock %}
|
||||
|
||||
{% block functions_extras %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block config %}
|
||||
set("server.socket", true)
|
||||
set("server.socket.path", "{{ station.streamer.socket_path }}")
|
||||
set("log.file.path", "{{ station.path }}/liquidsoap.log")
|
||||
{% for key, value in settings.AIRCOX_LIQUIDSOAP_SET.items %}
|
||||
set("{{ key|safe }}", {{ value|safe }})
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
||||
{% block config_extras %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block sources %}
|
||||
live = fallback([
|
||||
{% with source=station.dealer %}
|
||||
interactive_source('{{ source.id }}',
|
||||
playlist.once(reload_mode='watch', "{{ source.path }}"),
|
||||
active=false
|
||||
),
|
||||
{% endwith %}
|
||||
])
|
||||
|
||||
|
||||
stream = fallback([
|
||||
rotate([
|
||||
{% for source in station.sources %}
|
||||
{% if source != station.dealer %}
|
||||
{% with stream=source.stream %}
|
||||
{% if stream.delay %}
|
||||
delay({{ stream.delay }}.,
|
||||
stream("{{ source.id }}", "{{ source.path }}")),
|
||||
{% elif stream.begin and stream.end %}
|
||||
at({ {{stream.begin}}-{{stream.end}} },
|
||||
stream("{{ source.id }}", "{{ source.path }}")),
|
||||
{% elif not stream %}
|
||||
stream("{{ source.id }}", "{{ source.path }}"),
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
]),
|
||||
|
||||
blank(id="blank", duration=0.1),
|
||||
])
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block sources_extras %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
def to_live(stream,live)
|
||||
stream = fade.final(duration=2., type='log', stream)
|
||||
live = fade.initial(duration=2., type='log', live)
|
||||
add(normalize=false, [stream,live])
|
||||
end
|
||||
|
||||
def to_stream(live,stream)
|
||||
source.skip(stream)
|
||||
add(normalize=false, [live,stream])
|
||||
end
|
||||
|
||||
|
||||
{% block station %}
|
||||
{{ station.streamer.id }} = interactive_source (
|
||||
"{{ station.streamer.id }}",
|
||||
fallback(
|
||||
track_sensitive=false,
|
||||
transitions=[to_live,to_stream],
|
||||
[ live, stream ]
|
||||
),
|
||||
disable_switch=true
|
||||
)
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block station_extras %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block outputs %}
|
||||
{% for output in station.output_set.all %}
|
||||
output.{{ output.get_type_display }}(
|
||||
{{ station.streamer.id }},
|
||||
{% if controller.settings %},
|
||||
{{ output.settings }}
|
||||
{% endif %}
|
||||
)
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
||||
{% block output_extras %}
|
||||
{% endblock %}
|
||||
|
46
aircox/templates/aircox/controllers/stats.html
Normal file
46
aircox/templates/aircox/controllers/stats.html
Normal file
@ -0,0 +1,46 @@
|
||||
{% load i18n %}
|
||||
|
||||
<div id='stats'>
|
||||
{% for stats in statistics %}
|
||||
<section class="station">
|
||||
<header>
|
||||
<h1>{{ stats.station.name }}</h1>
|
||||
<h2>- {{ stats.date|date:'l d F Y' }}</h2>
|
||||
</header>
|
||||
|
||||
<table border=1>
|
||||
<tr>
|
||||
<th>{% trans "Date" %}</th>
|
||||
{# Translators "Header for statistics view" #}
|
||||
<th>{% trans "Diffusion or sound played" %}
|
||||
<th colspan="100"></th>
|
||||
</tr>
|
||||
|
||||
{% for item in stats.items %}
|
||||
<tr>
|
||||
<td>{{ item.date|date:"H:i" }}</td>
|
||||
{# TODO: logs #}
|
||||
<td>{{ item.program.name }}</td>
|
||||
{% for tag,count in item.tags %}
|
||||
<td>{{ tag }}: {{ count }}</td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
<tr>
|
||||
<td>{{ stats.date|date:'d/m/Y' }}</td>
|
||||
<td>{% trans "Total and average" %} ({{ stats.tracks_count }})</td>
|
||||
{% for tag, count, average in stats.tags %}
|
||||
<td>{{ tag }}: <b>{{ count }} / {{ average|floatformat }}%</b></td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
</table>
|
||||
</section>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user