portier/restream/signals.py

15 lines
474 B
Python
Raw Normal View History

2020-04-15 20:29:59 +02:00
from django.dispatch import receiver
from rtmp.signals import stream_active
2020-04-15 20:29:59 +02:00
from .models import RestreamConfig
from rtmp.models import Stream
from concierge.models import Task
2020-04-20 14:51:44 +02:00
2020-04-15 20:29:59 +02:00
@receiver(stream_active)
def create_tasks(sender, **kwargs):
stream = Stream.objects.get(stream=kwargs['stream'])
configs = RestreamConfig.objects.filter(stream=stream)
2020-04-15 20:29:59 +02:00
for config in configs:
task = Task(stream=stream, type='restream', configuration='{}')
task.save()