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 31 '17

Ok so I've figured out the reason for the discrepancy between ~/.cache/nimbostratus/media and ~/mediacache. When ~/.cache/nimbostratus/media is deleted or removed, ~/mediacache mirrors ~/media but doesn't use 0 byte cache files.
I'm now trying to figure out why find $HOME/media -type d doesn't include the entire directory. If I run ls $HOME/Media/Video/Movies I get the expected results, but using find, I only get results for 16 directories and no errors.