Use user's email
This commit is contained in:
parent
4843373cd4
commit
ef653eac10
@ -16,7 +16,7 @@
|
||||
* Make a crontab-entry: "* * * * * $repopath/encode" (replace `$repopath`!).
|
||||
* Install the `mailer` binary by downloading it from the repo at
|
||||
https://https://github.com/pepa65/mailer/releases/latest and moving it to
|
||||
`/usr/local/bin` and make it executable: `chmod +x /usr/local/bin/mailer`.
|
||||
`/usr/bin` and make it executable: `chmod +x /usr/bin/mailer`.
|
||||
If it's not installed, everything except the email will still work.
|
||||
* Run a php/webserver on `$repopath/uploadpage`:
|
||||
- Get it to restart on reboot.
|
||||
@ -65,6 +65,7 @@ sleep 1
|
||||
/usr/bin/killall -9 caddy &>/dev/null
|
||||
/usr/local/bin/caddy start &>/root/caddy.log
|
||||
```
|
||||
and make it executable: `chmod +x /root/Caddy`.
|
||||
|
||||
## Usage
|
||||
* Get a streamkey for the target by scheduling a stream
|
||||
|
||||
7
_vars
7
_vars
@ -8,13 +8,12 @@ interface=''
|
||||
# Timezone for local user
|
||||
tz='UTC'
|
||||
|
||||
# Usersnames/passwords (multiple pairs allowed)
|
||||
# Username/password and Username/email (multiple users allowed)
|
||||
# Defaults to none (no authentication required)
|
||||
declare -A userpw
|
||||
userpw['password1']='xxxxxxxxxx'
|
||||
declare -A umail upw
|
||||
u='username' umail[$u]='emailaddress' upw[$u]='caddy hash-password'
|
||||
|
||||
# Variables for mailer
|
||||
to='(recipient of notifications)'
|
||||
user='(smtp login)'
|
||||
password='(smtp password)'
|
||||
# Defaults to 'mail.gmail.com'
|
||||
|
||||
17
encode
17
encode
@ -18,17 +18,17 @@ Log(){ # 1:message 2:returncode(empty: no exit) I:file
|
||||
}
|
||||
|
||||
Mail(){ # 1:kind(0:done, 1:wrong type, 2:encoding error) 2:logline I:repopath,email,name,type,start,finish
|
||||
source "$repopath/vars" # I:to,user,password,smtp,port
|
||||
source "$repopath/vars" # I:umail,user,password,smtp,port
|
||||
local sbj msg from="Stream Upload server"
|
||||
# Strip the '_' if email set
|
||||
[[ $email ]] && to=${email:1}
|
||||
# If proper email set, use it, otherwise it's the authusername: look up email
|
||||
[[ $email = *@* ]] && to=$email || to=${umail[$email]}
|
||||
[[ $port ]] || port=587
|
||||
sbj[0]="Stream Upload encoding done for ${name##*@}"
|
||||
sbj[1]="Stream Upload file wrong type: $type"
|
||||
sbj[2]="Stream Upload error encoding"
|
||||
msg[0]="Heya,\n\nVideo file with tag $name\nEncoding started on $start and finished on $finish.\n\nStream Upload server"
|
||||
msg[1]="Heya,\n\nThe file $name from $start is of type $type and could not be used.\n\nStream Upload server\n"
|
||||
msg[2]="Heya,\n\nThe file $name started encoding on $start but ran into an error on $finish.\n\nStream Upload server\n"
|
||||
msg[0]="Heya,\n\nEncoded video with tag '$name'.\nEncoding started on $start and finished on $finish.\n\nStream Upload server"
|
||||
msg[1]="Heya,\n\nThe file '$name' from $start is of type '$type' and could not be used.\n\nStream Upload server\n"
|
||||
msg[2]="Heya,\n\nThe file '$name' started encoding on $start but ran into an error on $finish.\n\nStream Upload server\n"
|
||||
if [[ $to && $user && $password && $smtp && $port ]]
|
||||
then
|
||||
mailer -m "$(echo -e "${msg[$1]}")" -t "$to" -s "${sbj[$1]}" -u "$user" -p "$password" -S "$smtp" -P "$port" -f "$from" &&
|
||||
@ -47,6 +47,9 @@ file=${upload%.upload} video=$file.mp4 name=${file##*/} key=${name%%.*}
|
||||
rest=${name#*.} date=${rest:0:15} _=${rest:15} email=${_%@*}
|
||||
mv "$upload" "$file"
|
||||
|
||||
# Strip the '_' if email set
|
||||
[[ $email ]] && email=${email:1}
|
||||
|
||||
type=$(file -bL --mime-type "$file")
|
||||
[[ ! ${type:0:5} = video ]] && Mail 1 "File $name is of type $type"
|
||||
|
||||
@ -61,7 +64,7 @@ ffmpeg -y -i "$file" -c:v libx264 -x264opts no-scenecut -b:v 6M -maxrate 6M -buf
|
||||
error=1
|
||||
|
||||
# Remove logfiles
|
||||
rm "$file-*"
|
||||
rm "$file"-*
|
||||
finish=$(date +'%Y-%m-%d at %H:%M:%S')
|
||||
((error)) && Mail 2 "Error encoding $name"
|
||||
# Remove tailfiles if no errors
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<meta charset="utf-8">
|
||||
<title>Stream Upload</title>
|
||||
<link rel="icon" href="favicon.png">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<link rel="stylesheet" href="page.css">
|
||||
<script>
|
||||
function respond(){
|
||||
const feedback = document.getElementById('response');
|
||||
|
||||
@ -36,6 +36,9 @@ body {
|
||||
width:450px;
|
||||
max-width:450px;
|
||||
}
|
||||
p {
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
table {
|
||||
width:100%;
|
||||
}
|
||||
@ -44,4 +47,4 @@ table {
|
||||
}
|
||||
.right {
|
||||
width:325px;
|
||||
}
|
||||
}
|
||||
@ -7,7 +7,7 @@ if($_SERVER['REQUEST_METHOD']!=='POST'){
|
||||
}
|
||||
|
||||
function Back($msg){
|
||||
print('<br> <br>'.$msg.'<br> <br>
|
||||
print('<p>'.$msg.'</p>
|
||||
<form action="/" method="post">
|
||||
<input type="submit" value="Upload another file" name="submit">
|
||||
</form></div>');
|
||||
@ -21,6 +21,8 @@ $datetime=$_POST['datetime'];
|
||||
$email=$_POST['email'];
|
||||
if($email){
|
||||
$email='_'.$email;
|
||||
} else {
|
||||
$email='_'.$authuser;
|
||||
}
|
||||
$date=substr($datetime, 0, 10);
|
||||
$hour=substr($datetime, 11, 2);
|
||||
@ -34,11 +36,11 @@ print('<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>Encoding</title>
|
||||
<link rel="icon" href="favicon.png">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<link rel="stylesheet" href="page.css">
|
||||
<div class="container">
|
||||
<h1>Encoding</h1>
|
||||
'.($authuser=="" ? "" : 'For: '.$authuser.'<br> <br>').'
|
||||
File: '.$upload);
|
||||
'.($authuser==='' ? '' : '<p>For: <b>'.$authuser.'</b></p>').'
|
||||
<p>File: <b>'.$upload.'</b></p>');
|
||||
if(preg_match('/20[0-9][0-9]-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9]/', $datetime)===false){
|
||||
Back('Date/time somehow incorrect: '.$datetime);
|
||||
}
|
||||
@ -57,9 +59,9 @@ if(!move_uploaded_file($_FILES['file']['tmp_name'], $file)){
|
||||
Back('Error moving the file');
|
||||
}
|
||||
|
||||
print('File is now being encoded to "'.$name.'.mp4"<br> <br>');
|
||||
print('<p>File is now being encoded to <b>'.$name.'.mp4</b></p>');
|
||||
if($email){
|
||||
print('When done, an email will be sent to: '.substr($email,1));
|
||||
print('<p>When done, an email will be sent to <b>'.substr($email,1).'</b></p>');
|
||||
}
|
||||
Back('Scheduling for '.$date.' at '.$hour.':'.$min.'h on '.$target);
|
||||
Back('Scheduling for <b>'.$date.'</b> at <b>'.$hour.':'.$min.'</b>h on <b>'.$target.'</b>');
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user