Input notify email
This commit is contained in:
parent
63643b840e
commit
555c7b7444
17
encode
17
encode
@ -14,26 +14,31 @@ upload=$(/usr/bin/ls -1tr "$dir"/*.upload 2>/dev/null |head -1)
|
|||||||
|
|
||||||
Log(){ # 1:message 2:returncode(empty: no exit) I:file
|
Log(){ # 1:message 2:returncode(empty: no exit) I:file
|
||||||
echo "$1">>"$log"
|
echo "$1">>"$log"
|
||||||
[[ $2 ]] && exit $2
|
[[ $2 ]] && exit $2 || return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
Mail(){ # 1:kind(0:done, 1:wrong type, 2:encoding error) 2:logline I:to,user,password,smtp,port,name,type,start,finish
|
Mail(){ # 1:kind(0:done, 1:wrong type, 2:encoding error) 2:logline I:email,name,type,start,finish
|
||||||
local sbj msg from="Stream Upload server"
|
local sbj msg from="Stream Upload server"
|
||||||
source "$repopath/mailvars"
|
source "$repopath/mailvars" # I:to,user,password,smtp,port
|
||||||
|
[[ $email ]] && to=$email
|
||||||
sbj[0]="Stream upload done for ${name##*@}"
|
sbj[0]="Stream upload done for ${name##*@}"
|
||||||
sbj[1]="Stream upload wrong type: $type"
|
sbj[1]="Stream upload wrong type: $type"
|
||||||
sbj[2]="Stream upload error encoding"
|
sbj[2]="Stream upload error encoding"
|
||||||
msg[0]="Heya,\n\nThe video $name started encoding on $start and finished on $finish.\n\nStream Upload server"
|
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[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[2]="Heya,\n\nThe file $name started encoding on $start but ran into an error on $finish.\n\nStream Upload server\n"
|
||||||
[[ $to && $user && $password && $smtp && $port ]] &&
|
[[ $to && $user && $password && $smtp && $port ]] &&
|
||||||
mailer -m "$(echo -e "${msg[$1]}")" -t "$to" -s "${sbj[$1]}" -u "$user" -p "$password" -S "$smtp" -P "$port" -f "$from" ||
|
mailer -m "$(echo -e "${msg[$1]}")" -t "$to" -s "${sbj[$1]}" -u "$user" -p "$password" -S "$smtp" -P "$port" -f "$from" &&
|
||||||
|
Log "Mail with subject '${sbj[$1]}' sent to $to" ||
|
||||||
Log "Mail with subject '${sbj[$1]}' could not be sent"
|
Log "Mail with subject '${sbj[$1]}' could not be sent"
|
||||||
Log "$2" $1
|
Log "$2" $1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Rename upload and check type
|
# Rename upload and check type
|
||||||
file=${upload%.upload} name=${file##*/} key=${name%%.*} date=${name##*.} video=$file.mp4
|
file=${upload%.upload} video=$file.mp4 name=${file##*/} key=${name%%.*}
|
||||||
|
rest=${name#*.} date=${rest:0:15} _=${rest:15} email=${_%@*}
|
||||||
|
# If email embedded, strip the '='
|
||||||
|
[[ $email ]] && email=${email:1}
|
||||||
/usr/bin/mv "$upload" "$file"
|
/usr/bin/mv "$upload" "$file"
|
||||||
|
|
||||||
type=$(file -bL --mime-type "$file")
|
type=$(file -bL --mime-type "$file")
|
||||||
|
|||||||
4
stream
4
stream
@ -4,8 +4,8 @@
|
|||||||
# Usage: stream <tag>
|
# Usage: stream <tag>
|
||||||
# The tag refers to video files in $repopath/uploadpage/streams without the
|
# The tag refers to video files in $repopath/uploadpage/streams without the
|
||||||
# '.mp4', that should have been re-encoded by `encode`. The tag has no path
|
# '.mp4', that should have been re-encoded by `encode`. The tag has no path
|
||||||
# information, has the "streamkey" at the start before the dot (it has to have
|
# information, has the "streamkey" at the start before the first dot (there
|
||||||
# a dot!) and the "target" at the very end, after the '@'.
|
# has to be a dot!) and the "target" at the very end, after the last '@'.
|
||||||
|
|
||||||
_=$(realpath -- "${BASH_SOURCE:-$0}") repopath=${_%/*}
|
_=$(realpath -- "${BASH_SOURCE:-$0}") repopath=${_%/*}
|
||||||
log=$repopath/process.log
|
log=$repopath/process.log
|
||||||
|
|||||||
@ -25,13 +25,16 @@ function respond(){
|
|||||||
</td></tr>
|
</td></tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="left">Streamkey:</td>
|
<td class="left">Streamkey:</td>
|
||||||
<td class="right"><input type="text" name="streamkey" id="streamkey" required title="string of 0-9, a-z, A-Z, underscore or dash characters" pattern="[a-zA-Z0-9_-]+"></td></tr>
|
<td class="right"><input type="text" name="streamkey" required title="string of 0-9, a-z, A-Z, underscore or dash characters" pattern="[a-zA-Z0-9_-]+"></td></tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Date and Time:</td>
|
<td>Date & Time:</td>
|
||||||
<td><input type="datetime-local" name="datetime" id="datetime" required></td></tr>
|
<td><input type="datetime-local" name="datetime" required></td></tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Video File:</td>
|
<td>Video File:</td>
|
||||||
<td><input type="file" name="fileToUpload" id="fileToUpload" required accept=".mp4"></td></tr>
|
<td><input type="file" name="file" required accept=".mp4"></td></tr>
|
||||||
|
<tr>
|
||||||
|
<td class="left">Notify email:</td>
|
||||||
|
<td class="right"><input type="email" name="email" title="Not required"></td></tr>
|
||||||
<tr><td><br></td></tr>
|
<tr><td><br></td></tr>
|
||||||
<tr><td></td><td><input type="submit" value="Schedule Stream" name="submit"></td></tr>
|
<tr><td></td><td><input type="submit" value="Schedule Stream" name="submit"></td></tr>
|
||||||
<tr><td><br></td></tr>
|
<tr><td><br></td></tr>
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
input[type=text],[type=file], select, [type=time], [type=date], [type=datetime-local] {
|
input,select {
|
||||||
width:100%;
|
width:100%;
|
||||||
padding:12px 20px;
|
padding:12px 20px;
|
||||||
margin:0;
|
margin:0;
|
||||||
|
|||||||
@ -14,16 +14,20 @@ function Back($msg){
|
|||||||
}
|
}
|
||||||
|
|
||||||
header('Content-type: text/html; charset=utf-8');
|
header('Content-type: text/html; charset=utf-8');
|
||||||
$upload=htmlspecialchars(basename($_FILES['fileToUpload']['name']));
|
$upload=htmlspecialchars(basename($_FILES['file']['name']));
|
||||||
$key=$_POST['streamkey'];
|
$key=$_POST['streamkey'];
|
||||||
$datetime=$_POST['datetime'];
|
$datetime=$_POST['datetime'];
|
||||||
|
$email=$_POST['email'];
|
||||||
|
if($email){
|
||||||
|
$email='='.$email;
|
||||||
|
}
|
||||||
$date=substr($datetime, 0, 10);
|
$date=substr($datetime, 0, 10);
|
||||||
$hour=substr($datetime, 11, 2);
|
$hour=substr($datetime, 11, 2);
|
||||||
$min=substr($datetime, 14, 2);
|
$min=substr($datetime, 14, 2);
|
||||||
$time=$hour.$min;
|
$time=$hour.$min;
|
||||||
$target=$_POST['target'];
|
$target=$_POST['target'];
|
||||||
$dir='streams/';
|
$dir='streams/';
|
||||||
$name=$key.'.'.$date.'_'.$time.'@'.$target;
|
$name=$key.'.'.$date.'_'.$time.$email.'@'.$target;
|
||||||
$file=$dir.$name.'.upload';
|
$file=$dir.$name.'.upload';
|
||||||
print('<!DOCTYPE html>
|
print('<!DOCTYPE html>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
@ -44,13 +48,16 @@ $nextyear=date('Y-m-dHi', strtotime('+1 year'));
|
|||||||
if(strcmp($nextyear, $date.$time)<0){
|
if(strcmp($nextyear, $date.$time)<0){
|
||||||
Back('Scheduling too far into the future: '.$date.' '.$time);
|
Back('Scheduling too far into the future: '.$date.' '.$time);
|
||||||
}
|
}
|
||||||
if($_FILES['fileToUpload']['error']!=UPLOAD_ERR_OK){
|
if($_FILES['file']['error']!=UPLOAD_ERR_OK){
|
||||||
Back('Error uploading the file');
|
Back('Error uploading the file');
|
||||||
}
|
}
|
||||||
if(!move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $file)){
|
if(!move_uploaded_file($_FILES['file']['tmp_name'], $file)){
|
||||||
Back('Error moving the file');
|
Back('Error moving the file');
|
||||||
}
|
}
|
||||||
|
|
||||||
Back('File is now being encoded to "'.$name.'.mp4"<br> <br>
|
print('File is now being encoded to "'.$name.'.mp4"<br> <br>');
|
||||||
Scheduling for '.$date.' at '.$hour.':'.$min.'h on '.$target);
|
if($email){
|
||||||
|
print('When done, an email will be sent to: '.substr($email,1));
|
||||||
|
}
|
||||||
|
Back('Scheduling for '.$date.' at '.$hour.':'.$min.'h on '.$target);
|
||||||
?>
|
?>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user