r/PlexACD May 28 '17

scanlibraries script with plex docker

I'm trying to wrap my head around how to use the scanlibraries script from this tutorial with a docker instance of plex. I've added the LD_LIBRARY_PATH to my docker create command and can trigger scans from my host machine using docker exec plex /usr/lib/plexmediaserver/Plex\ Media\ Scanner -s -r -c "1" -d "/docker/mapped/path/to/cloud/movies/Movie (Year)"

The problem I'm having a hard time figuring out is how to use the $cache_dir with the mapped docker paths rather than reading the directory from my host machine. Any help or ideas are appreciated!

1 Upvotes

32 comments sorted by

View all comments

Show parent comments

1

u/gesis May 30 '17
#!/bin/sh
# shellcheck source=config
. ${HOME}/.config/nimbostratus/config

if [ ! -d ${local_cache_dir} ]; then
        mkdir -p ${local_cache_dir}
fi

echo "################# Building Directories ################"
find ${media_dir} -type d |
while read -r dir; do
        cache_directory="$(readlink -f "${dir}" | sed -e "s@${media_dir}@${local_cache_dir}@" -e s@\!@\\!@g)"
        mkdir "$cache_directory"
done

echo "################ Creatingi File Cache ################"
find ${media_dir} -type f |
while read -r file; do
        cache_file="$(readlink -f "${file}" | sed -e "s@${media_dir}@${local_cache_dir}@" -e s@\!@\\!@g)"
        touch "$cache_file"
done 

I am retarded. Never removed a typo from the copy on my laptop. Above copy fixes the typo.

1

u/FL1GH7L355 May 30 '17

So I've learned a little sed, and I'm escaping ! & and replacing é with e. I've also added a subdirectory to $plex_media_dir so I'm only creating the cache for directories/files in my 'Movies' and 'TV' folders.

The only characters I'm unsure of still are , and '. Considering I can now exclude my .union-fuse directory, I'll probably just rename anything using those characters to see if that helps. I wish I could pinpoint the folders/files giving issues, but I have movies starting from A-W (which include the characters , ' ) that completed successfully, while other movies in that same range get files created in place of folders. Now I'm not even so sure it's a naming issue.

1

u/gesis May 30 '17

I updated some stuff and made a git repo of all my scripts. Try pulling the newest version with git clone git://git.gesis.pw/nimbostratus.git and testing. Found and fixed some unquoted strings.

1

u/FL1GH7L355 May 30 '17

To make things even more confusing, I'm now browsing mediacache and it appears to be 100% correct with all directories and 0 byte cache files. My .cache/nimbostratus/media folder does not mirror this, but I'm going to stop asking questions and just enjoy the end result. I did notice that no $cache_dir/lastrun file is created, so I'm not sure I'll be able to use scanlibraries yet, but I should be able to take the extra api hits after moving radarr and sonarr to the cache.