datetime validation
fix stream details
This commit is contained in:
parent
41cff4126a
commit
f70bac1332
2
encode
2
encode
@ -43,7 +43,7 @@ m=${date:13:2} m=${m#0} h=${date:11:2} h=${h#0}
|
|||||||
D=${date:8:2} D=${D#0} M=${date:5:2} M=${M#0}
|
D=${date:8:2} D=${D#0} M=${date:5:2} M=${M#0}
|
||||||
/usr/bin/crontab -l ||
|
/usr/bin/crontab -l ||
|
||||||
echo -e "# m h dom mon dow command\n" |/usr/bin/crontab -
|
echo -e "# m h dom mon dow command\n" |/usr/bin/crontab -
|
||||||
line="$m $h $D $M "'*'" $repopath/stream '${video##*/}'"
|
line="$m $h $D $M "'*'" $repopath/stream '$name'"
|
||||||
echo -e "$(/usr/bin/crontab -l)\n$line" |/usr/bin/crontab -
|
echo -e "$(/usr/bin/crontab -l)\n$line" |/usr/bin/crontab -
|
||||||
|
|
||||||
Log "crontab: '$line'" 0
|
Log "crontab: '$line'" 0
|
||||||
|
|||||||
10
stream
10
stream
@ -1,13 +1,15 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# stream - Stream video when called from crontab
|
# stream - Stream video when called from crontab
|
||||||
# Usage: stream <video>
|
# Usage: stream <tag>
|
||||||
# The video should have been re-encoded by `encode` first,
|
# The tag refers to video files in $repopath/uploadpage/streams without the
|
||||||
# and have the streamkey at the start of the filename.
|
# '.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
|
||||||
|
# a dot!) and the "target" at the very end, after the '@'.
|
||||||
|
|
||||||
repopath=/var/www
|
repopath=/var/www
|
||||||
log=$repopath/process.log
|
log=$repopath/process.log
|
||||||
in=$repopath/uploadpage/streams/$1 key=${1%%.*} target=${1##*@}
|
in=$repopath/uploadpage/streams/$1.mp4 key=${1%%.*} target=${1##*@}
|
||||||
case $target in
|
case $target in
|
||||||
Facebook) rtmp=rtmps://live-api-s.facebook.com:443/rtmp/$key ;;
|
Facebook) rtmp=rtmps://live-api-s.facebook.com:443/rtmp/$key ;;
|
||||||
YouTube) rtmp=rtmp://a.rtmp.youtube.com/live2/$key ;;
|
YouTube) rtmp=rtmp://a.rtmp.youtube.com/live2/$key ;;
|
||||||
|
|||||||
@ -25,7 +25,7 @@ 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 or underscore characters" pattern="[a-zA-Z0-9_]+"></td></tr>
|
<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>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Date and Time:</td>
|
<td>Date and Time:</td>
|
||||||
<td><input type="datetime-local" name="datetime" id="datetime" required></td></tr>
|
<td><input type="datetime-local" name="datetime" id="datetime" required></td></tr>
|
||||||
|
|||||||
@ -16,9 +16,10 @@ 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['fileToUpload']['name']));
|
||||||
$key=$_POST['streamkey'];
|
$key=$_POST['streamkey'];
|
||||||
$date=substr($_POST['datetime'], 0, 10);
|
$datetime=$_POST['datetime'];
|
||||||
$hour=substr($_POST['datetime'], 11, 2);
|
$date=substr($datetime, 0, 10);
|
||||||
$min=substr($_POST['datetime'], 14, 2);
|
$hour=substr($datetime, 11, 2);
|
||||||
|
$min=substr($datetime, 14, 2);
|
||||||
$time=$hour.$min;
|
$time=$hour.$min;
|
||||||
$target=$_POST['target'];
|
$target=$_POST['target'];
|
||||||
$dir='streams/';
|
$dir='streams/';
|
||||||
@ -32,6 +33,9 @@ print('<!DOCTYPE html>
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<h1>Encoding</h1>
|
<h1>Encoding</h1>
|
||||||
File: '.$upload);
|
File: '.$upload);
|
||||||
|
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);
|
||||||
|
}
|
||||||
$now=date('Y-m-dHi');
|
$now=date('Y-m-dHi');
|
||||||
if(strcmp($now, $date.$time)>0){
|
if(strcmp($now, $date.$time)>0){
|
||||||
Back('Scheduling '.$now.' in the past: '.$date.' '.$time);
|
Back('Scheduling '.$now.' in the past: '.$date.' '.$time);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user