forked from gi-yt/fossunited-streaming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload-clip.sh
executable file
·35 lines (31 loc) · 1.94 KB
/
upload-clip.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
homedir="/home/$(whoami)"
streamingdir="${homedir}/fossunited-streaming"
ssh="[email protected]"
vids="${homedir}/Videos"
file="${vids}/$(ls -Art ${vids} | tail -n 1)"
basethumb="${streamingdir}/basethumb.svg"
titlefile="${streamingdir}/title.txt"
audi="1"
if [[ "${file}" != "$(cat ${streamingdir}/lastrec.txt)" ]]; then
txt="$(cat $titlefile)"
uuid="$(uuidgen)"
dir="08d44181-12a5-4b6a-b41b-65c9f6de26a5" # DIRECTORY ON SERVER
title="${txt} | Audi ${audi} | IndiaFOSS 2024"
desc="This is the raw footage of a talk, presented at IndiaFOSS 2024. You can see the talks of IndiaFOSS through these videos until our professionally edited videos are uploaded."
date="$(date +'%Y-%m-%d %H:%M:%S')"
length="$(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 ${file})"
thumbnail="/tmp/thumb.jpg"
sed "s/TALKNAME_REPLACEME/${title}/" ${basethumb} >/tmp/thumb.svg
magick /tmp/thumb.svg "${thumbnail}"
scp "${file}" "${ssh}":/root/osp/osp-app/data/www/videos/${dir}/${uuid}.mp4 #-p ${port}
scp "${thumbnail}" "${ssh}":/root/osp/osp-app/data/www/videos/${dir}/${uuid}.jpg #-p ${port}
ssh ${ssh} "chown -R www-data:www-data /root/osp/osp-app/data/www/videos" #-p ${port}
query="INSERT INTO RecordedVideo (uuid,videoDate,owningUser,channelName, channelID, description, topic, views, length, videoLocation, thumbnailLocation, gifLocation, pending, allowComments, published, originalStreamID) VALUES('${uuid}','${date}', 1, '${title}', ${audi}, '${desc}', 1, 0, ${length}, '${dir}/${uuid}.mp4', '${dir}/${uuid}.jpg', NULL, 0, 1, 1, NULL);"
echo ${query} >/tmp/query.txt
scp "/tmp/query.txt" "${ssh}":/root/osp/osp-mariadb/query.txt # -p ${port}
ssh ${ssh} 'docker exec osp-osp_db-1 bash -c "/usr/bin/mariadb -p -u root --password=REPLACEME -D osp < /var/lib/mysql/query.txt"'
echo $file > ${streamingdir}/lastrec.txt
else
echo "no new recording, exiting"
fi