-
Notifications
You must be signed in to change notification settings - Fork 0
/
show-downloader.sh
executable file
·55 lines (53 loc) · 2.09 KB
/
show-downloader.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
echo "Begin the script downloady thingy"
while true ; do
# Grab all the shows in the directory
IFS=$'\n'
shows=(`rclone lsf nickdrive:/wmfo-shows/ --max-depth=1`)
for show in "${shows[@]}"
do
# Skip directories
if [[ $show == */ ]] ; then
#echo "Skipping directory $show"
continue
fi
filename=$(basename -- "$show")
extension="${filename##*.}"
filename_short="${filename%.*}"
if [ "$extension" != "wav" ] && [ "$extension" != "mp3" ] ; then
continue
fi
if [[ $show == rejected-* ]] ; then
continue
fi
chars_before_underscore=`echo $show | cut -f 1 -d'_' | wc -c`
chars_before_dash=`echo $show | cut -f 1 -d'-' | wc -c`
if [ $chars_before_underscore -ne 9 ] || [ $chars_before_dash -ne 14 ] ; then
rclone moveto "nickdrive:/wmfo-shows/$show" "nickdrive:/wmfo-shows/rejected-date-format-$show"
echo "`date` Skipping $show due to incorrect formatting"
continue
fi
date_string=`echo "$show" | cut -f1 -d'-' | sed "s/_/ /g"`
next_show_date_seconds=`date --date="$date_string" +%s`
date_seconds=`date +%s`
date_plus_a_year=`date -d '1 year hence' +%s`
if [ $next_show_date_seconds -lt $date_seconds ] || [ $next_show_date_seconds -gt $date_plus_a_year ] ; then
rclone moveto "nickdrive:/wmfo-shows/$show" "nickdrive:/wmfo-shows/rejected-date-wrong-$show"
echo "`date` Skipping $show due to being a weird date"
continue
fi
rclone ls "nickdrive:/wmfo-shows/already-imported-shows/$show" 2>/dev/null
if [ $? -eq 0 ] ; then
rclone moveto "nickdrive:/wmfo-shows/$show" "nickdrive:/wmfo-shows/rejected-already-imported-$show"
echo "`date` Skipping $show due to being a duplicate"
continue
fi
echo -ne "`date`: starting $show download..."
rclone copy "nickdrive:/wmfo-shows/$show" /home/wmfo-dj/Downloads/show-queue
rdimport --autotrim-level=0 --metadata-pattern=%t.wav --delete-source Shows /home/wmfo-dj/Downloads/show-queue/*
rclone move "nickdrive:/wmfo-shows/$show" nickdrive:/wmfo-shows/already-imported-shows/
echo "Success!"
done
#echo "We are done for now. Will check again in 10 minutes."
sleep 600
done