-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsynology-watchlist.sh
More file actions
executable file
·79 lines (70 loc) · 2.24 KB
/
synology-watchlist.sh
File metadata and controls
executable file
·79 lines (70 loc) · 2.24 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
# uses .netrc file for credentials
# get urls from http://synology-nas:5005/video/ or https://synology-nas:5006/video/
#To add:
# -
echo "Downloads (Movie-)Files from NAS and deletes files from local disk that have been commented."
echo "Can be called with additional dir to copy files to usb drive after download."
echo "Usage: $0 [/path/to/extra/copy]"
echo "###############################"
WGETCMD="wget -c -nc --no-verbose --no-check-certificate"
VIDEODIR=$HOME/Videos
# Files to download. To remove the file afterwards just comment the line
files="
http://synology-nas:5005/video/movies/movie-name/movie-name.mkv
#http://synology-nas:5005/video/movies/other-movie/movie-that-can-be-deleted-locally.mkv
http://synology-nas:5005/video/tvshows/some-show/Season.04/very-long-episode-title.mp4
"
if [ ! -z "$1" ] && [ -d "$1" ]; then
echo "###############################"
echo "getting files from $1 first"
rsync -avPh --size-only --update --stats --exclude 1_synology_watchlist.sh $1/Videos/ $VIDEODIR
fi
cd $VIDEODIR
for url in $files; do
filename=${url##*/}
url2=${url%.*} # url without file extension
filename2=${url2##*/}
nametemp=${url##*tvshows/}
name=${nametemp%/Season*}
nameclean=${name//%20/.}
shownfo=${url%/Season*}
# case statement to download movies and tvshows into different dirs
case "$url" in
*video/tvshows*)
mkdir -p $VIDEODIR/tvshows/"$nameclean" && cd $VIDEODIR/tvshows/"$nameclean"
$WGETCMD $shownfo/tvshow.nfo 2>/dev/null
;;
*video/movies*)
mkdir -p $VIDEODIR/movies && cd $VIDEODIR/movies
;;
*)
mkdir -p $VIDEODIR/misc && cd $VIDEODIR/misc
;;
esac
# case statement to remove commented files
case "$url" in
\#*)
echo "$filename was commented.. removing it."
rm $filename 2>/dev/null
rm $filename2.nfo 2>/dev/null
rm tvshow.nfo 2>/dev/null
;;
*)
echo "downloading $filename"
$WGETCMD $url
$WGETCMD $url2.nfo
;;
esac
cd $VIDEODIR
done
# delete empty folders
find $VIDEODIR -type d -empty -exec rmdir {} \; 2>/dev/null
if [ ! -z "$1" ] && [ -d "$1" ]; then
echo "###############################"
echo "copying to path $1"
rsync -avPh --size-only --update --delete --exclude 1_synology_watchlist.sh --stats $VIDEODIR $1
cp $0 $1/Videos/1_synology_watchlist.sh
df -h $1
fi
df -h $VIDEODIR