mirror of https://github.com/pikami/sysadmin.git
Create yt-report.sh
This commit is contained in:
parent
c7e97a1c4e
commit
829d416ac7
|
@ -0,0 +1,42 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
webhook=`cat webhook.txt`
|
||||||
|
template=`cat template.txt`
|
||||||
|
time_now=`date '+%Y-%m-%d %H:%M:%S'`
|
||||||
|
|
||||||
|
archive="/samba/WD_4TB/stuff/VID/yt/archive.txt"
|
||||||
|
reported="yt_reported.txt"
|
||||||
|
|
||||||
|
# Check if files are the same
|
||||||
|
cmp --silent $archive $reported && echo "[$time_now] Up to date!" && exit
|
||||||
|
echo "[$time_now] Not up to date, reporting news!"
|
||||||
|
|
||||||
|
# Set values
|
||||||
|
username="YT-Reporter"
|
||||||
|
main_message="Download report"
|
||||||
|
embed_title=""
|
||||||
|
embed_description="New downloads:"
|
||||||
|
|
||||||
|
# Get diff
|
||||||
|
for line in `comm -23 --nocheck-order $archive $reported`; do
|
||||||
|
if [[ $line != *"youtube"* ]]; then
|
||||||
|
embed_description="$embed_description\n* $line"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Build payload
|
||||||
|
payload="${template/<main_message>/$main_message}"
|
||||||
|
payload="${payload/<username>/$username}"
|
||||||
|
payload="${payload/<embed_title>/$embed_title}"
|
||||||
|
payload="${payload/<embed_description>/$embed_description}"
|
||||||
|
|
||||||
|
# Send payload
|
||||||
|
echo "[$time_now] Sending:" $payload
|
||||||
|
|
||||||
|
curl --header "Content-Type: application/json" \
|
||||||
|
--request POST \
|
||||||
|
--data "$payload" \
|
||||||
|
"$webhook"
|
||||||
|
|
||||||
|
# Update reported entries
|
||||||
|
cp $archive $reported
|
Loading…
Reference in New Issue