add rsync dependency

This commit is contained in:
Denis Lehmann 2021-06-13 10:01:40 +02:00
parent 25827cf21f
commit 95f8902486
2 changed files with 17 additions and 9 deletions

View file

@ -67,6 +67,8 @@
- The machine shall serve as controller :: An SSH client must be installed and *strm* must be executable.
A machine can be used for multiple purposes, make sure all required dependencies are fulfilled.
If the =playback_directory= is set, [[https://rsync.samba.org/][rsync]] is used to synchronize it with a local directory.
** Installation
@ -162,10 +164,11 @@
# bob@another-machine/media/movies,bob@10.0.0.1/home/bob/series
media_directories=""
# Directory with which the saved playback positions are synchronized on exit of the following form:
# Directory which contains the saved playback positions of the following form:
#
# <SSH connection string><absolute_path_to_media_directory>
#
# It is synchronized with the local ~/.cache/strm directory before and after playing files.
# If it is not set, the mpv resume playback functionality is not enabled by default.
# If <SSH connection string> is not set, 'localhost' is used.
#

21
strm
View file

@ -205,8 +205,10 @@ fi
# Synchronize playback directory
if [ "$list" == false ] && [ "$playback_directory" != "" ]; then
# Make local playback directory if not existent
mkdir -p "$HOME/.cache/strm"
# Check if rsync is installed
if ! command -v rsync &>/dev/null; then
error "rsync was not found, please install it"
fi
# Get connection string and remote directory
IFS="/" read -r connection_string directory <<< "$playback_directory"
@ -216,16 +218,19 @@ if [ "$list" == false ] && [ "$playback_directory" != "" ]; then
connection_string="localhost"
fi
echo -ne "Synchronizing playback directory with $text_bold$(basename $connection_string)$text_reset\n"
# Check validity of directory
if [ "$directory" == "" ]; then
error "Not a valid playback directory ($playback_directory)"
fi
# Make local playback directory if not existent
mkdir -p "$HOME/.cache/strm"
# Add leading and trailing slash to directory if missing
[[ "$directory" != /*/ ]] && directory="/$directory/"
echo -ne "Synchronizing playback directory with $text_bold$(basename $connection_string)$text_reset\n"
# Make remote directory if not existent
ssh -o ConnectTimeout=10 "$connection_string" "mkdir -p $directory"
@ -282,11 +287,11 @@ for media_directory in "${media_directories[@]}"; do
error "Not a valid media directory ($media_directory)"
fi
echo -ne "Fetching results from $text_bold$(basename $directory)$text_reset on $text_bold$connection_string$text_reset\n"
# Add leading and trailing slash to directory if missing
[[ "$directory" != /*/ ]] && directory="/$directory/"
echo -ne "Fetching results from $text_bold$(basename $directory)$text_reset on $text_bold$connection_string$text_reset\n"
# Get search results from remote
# Look for paths matching given queries in visible directories, listing only filenames and links
mapfile -t tmp_results < <(ssh -o ConnectTimeout=10 "$connection_string" find "'$directory'" "${find_arguments[@]}" | sort)
@ -387,11 +392,11 @@ if [ "$list" == false ]; then
connection_string="localhost"
fi
echo -ne "\nSynchronizing playback directory with $text_bold$(basename $connection_string)$text_reset"
# Add leading and trailing slash to directory if missing
[[ "$directory" != /*/ ]] && directory="/$directory/"
echo -ne "\nSynchronizing playback directory with $text_bold$(basename $connection_string)$text_reset"
# Synchronize local to remote
rsync -az --delete "$HOME/.cache/strm/" "$connection_string:$directory"
fi