|
| 1 | +# PlexSymlinker |
| 2 | + |
| 3 | +This gem allows creating a Plex-friendly folder structure with symlinks for your audio books. |
| 4 | +All you need are audio files with correct tagging, the gem takes care of making Plex understand them without you having to change the way you're organising your files. |
| 5 | + |
| 6 | +**The Problem** |
| 7 | + |
| 8 | +Most of my audio files are in apple's m4b format, leaving me with one file per book most of the times: |
| 9 | + |
| 10 | + 📁 audiobooks |
| 11 | + ∟ 📁 author name |
| 12 | + ∟ book1.m4b |
| 13 | + ∟ book2.m4b |
| 14 | + |
| 15 | +The problem with this structure is that Plex' music agent doesn't quite understand it. |
| 16 | +Even though the files are properly tagged with author, album, etc., Plex tends to create a giant album out of all the files inside - often with the first audio book as album name. |
| 17 | + |
| 18 | +What the Plex music agent expects is a structure like this: |
| 19 | + |
| 20 | + 📁 audiobooks |
| 21 | + ∟ 📁 author name |
| 22 | + ∟ 📁 Book 1 |
| 23 | + ∟ book1.m4b |
| 24 | + ∟ 📁 Book 2 |
| 25 | + ∟ book2.m4b |
| 26 | + |
| 27 | +This would mean that I'd have to introduce single-file-directories into my structure which didn't really make sense for me - especially as I have a lot of "Hörspiele" (mostly german format of short audio books with multiple actors + music). |
| 28 | + |
| 29 | +**This gem's solution** |
| 30 | + |
| 31 | +PlexSymlinker creates symlinks pointing to your actual audio files in exactly the |
| 32 | +structure Plex' music agent expects to find. It uses the embedded tags in your files to build it, |
| 33 | +so even one big directory with all your audio files in it would work as expected. |
| 34 | + |
| 35 | +Just point plex to the symlink directory instead of your actual files and you're good to go. |
| 36 | + |
| 37 | +## Usage |
| 38 | + |
| 39 | +Since the whole purpose of PlexSymlinker is to read a directory full of audio files and |
| 40 | +fill another directory with symlinks, we have to make sure the docker container has access to both of them. |
| 41 | + |
| 42 | +When using the docker image, the audio files directory is expected to be mounted |
| 43 | +as `/app/source` and the directory the symlinks should be placed in as `/app/target`. |
| 44 | + |
| 45 | +💡 You also have to pass in the `SYMLINK_TARGET_DIR` environment variable. |
| 46 | +Since the gem only sees `/app/source` inside the docker container, |
| 47 | +it would point all symlinks there instead of the actual directory on your host machine. |
| 48 | +Just set it to the same directory that you mounted as `/app/source`. |
| 49 | + |
| 50 | +### 0. Make sure your files are properly tagged! |
| 51 | + |
| 52 | +At least the album and album artist fields have to set accordingly. |
| 53 | + |
| 54 | +But since you are planning to import those files into Plex which needs a lot more information, |
| 55 | +it would make sense to fill out all details you can provide. |
| 56 | + |
| 57 | +### 1. Create the directory the symlinks should be placed in (if it doesn't exist yet) |
| 58 | + |
| 59 | +It's important that the directory exists (owned by your current user) before you mount it. |
| 60 | + |
| 61 | + mkdir -p /path/to/symlink/dir |
| 62 | + |
| 63 | +If you ran PlexSymlinker before, you can just re-run it on the same directory again. |
| 64 | +It will automatically sync the symlinks against the actual files. |
| 65 | + |
| 66 | +### 2. Run the docker image |
| 67 | + |
| 68 | +#### MacOS |
| 69 | + |
| 70 | + docker run -it --rm -v /path/to/audiobooks:/app/source:ro -v /path/to/symlink/dir:/app/target --env SYMLINK_TARGET_DIR=/path/to/audiobooks sterexx/plex_symlinker |
| 71 | + |
| 72 | +#### Linux |
| 73 | + |
| 74 | +💡 Under Linux, you have to make sure to set your current user/group id |
| 75 | +with `--user "$(id -u):$(id -g)"` - otherwise, all the generated symlinks/directories |
| 76 | +will be owned by the root user. Docker for mac/windows takes care of that for you automatically. |
| 77 | + |
| 78 | + docker run -it --user "$(id -u):$(id -g)" --rm -v /path/to/audiobooks:/app/source:ro -v /path/to/symlink/dir:/app/target --env SYMLINK_TARGET_DIR=/path/to/audiobooks sterexx/plex_symlinker |
| 79 | + |
| 80 | +### 3. Create a Plex library pointing to the symlink directory |
0 commit comments