mirror of
https://git.lapiole.org/dani/ansible-roles.git
synced 2025-08-04 07:37:20 +02:00
Update to 2021-12-01 19:13
This commit is contained in:
83
roles/jitsi_jibri/templates/finalize.pl.j2
Normal file
83
roles/jitsi_jibri/templates/finalize.pl.j2
Normal file
@@ -0,0 +1,83 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use JSON;
|
||||
use YAML::Tiny;
|
||||
use Getopt::Long;
|
||||
use Email::MIME;
|
||||
use Email::Sender::Simple qw(sendmail);
|
||||
use File::Basename;
|
||||
use utf8;
|
||||
|
||||
my $conf = {};
|
||||
my $opt = {
|
||||
config => '{{ jitsi_root_dir }}/etc/jibri/finalize.yml'
|
||||
};
|
||||
|
||||
GetOptions(
|
||||
"config=s" => \$opt->{config}
|
||||
);
|
||||
|
||||
sub send_mail {
|
||||
my ($subject, $dest, $body) = @_;
|
||||
my $mail = Email::MIME->create(
|
||||
header_str => [
|
||||
From => $conf->{from},
|
||||
To => $dest,
|
||||
Subject => $subject
|
||||
],
|
||||
attributes => {
|
||||
charset => 'utf-8',
|
||||
encoding => 'base64'
|
||||
},
|
||||
body_str => $body
|
||||
);
|
||||
sendmail($mail);
|
||||
}
|
||||
|
||||
# Read config file
|
||||
if (-e $opt->{config}){
|
||||
my $yaml = YAML::Tiny->read( $opt->{config} )
|
||||
or die "Config file " . $opt->{config} . " is invalid\n";
|
||||
if ( not $yaml->[0] ) {
|
||||
die "Config file " . $opt->{config} . " is invalid\n";
|
||||
}
|
||||
$conf = $yaml->[0];
|
||||
}
|
||||
|
||||
$conf->{notify} ||= [];
|
||||
my $recording = $ARGV[0];
|
||||
|
||||
my $metadata = {};
|
||||
if (-e "$recording/metadata.json"){
|
||||
open(my $jst, "$recording/metadata.json") or die "$!";
|
||||
local $/;
|
||||
$metadata = from_json(<$jst>);
|
||||
}
|
||||
|
||||
my $video = undef;
|
||||
opendir ( DIR, $recording ) || die "Error in opening dir $recording\n";
|
||||
while( (my $filename = readdir(DIR))) {
|
||||
if ($filename =~ m/\.mp4$/){
|
||||
$video = basename($filename);
|
||||
last;
|
||||
}
|
||||
}
|
||||
closedir(DIR);
|
||||
|
||||
foreach my $participant (@{$metadata->{participants}}){
|
||||
push @{$conf->{notify}}, $participant->{user}->{id};
|
||||
}
|
||||
|
||||
if (defined $video){
|
||||
foreach my $dest (@{$conf->{notify}}){
|
||||
send_mail(
|
||||
"Enregistrement Jitsi Meet",
|
||||
$dest,
|
||||
"L'enregistrement vidéo est disponible à l'adresse $conf->{base_url}/" .
|
||||
basename($recording) . "/$video\n"
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user