Skip to content

Commit c3bb425

Browse files
authored
Merge pull request #1 from Stex/release/0.1.1
Release/0.1.1
2 parents 8c12f1b + 1706f72 commit c3bb425

7 files changed

Lines changed: 118 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Changelog
2+
3+
## [0.1.1] - 2020-07-28
4+
5+
### Changed
6+
7+
* Removed zeitwerk (there weren't really enough files to even consider it necessary)
8+
* Fixed gem executable
9+
10+
## [0.1.0] - 2020-07-28
11+
12+
Initial Release

Gemfile.lock

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
PATH
22
remote: .
33
specs:
4-
plex_symlinker (0.1.0)
4+
plex_symlinker (0.1.1)
55
activesupport (~> 6.0)
66
ruby-progressbar (~> 1.10)
77
slop (~> 4.8)
88
taglib-ruby (~> 1.0)
9-
zeitwerk (~> 2.4)
109

1110
GEM
1211
remote: https://rubygems.org/

README.dockerhub.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,24 @@ all necessary dependencies and can be used out-of-the-box by mounting the necess
5959

6060
### Using the gem executable
6161

62+
#### 0. Make sure your files are properly tagged!
63+
64+
At least the `album` and `album artist` fields have to set accordingly.
65+
66+
But since you are planning to import those files into Plex which needs a lot more information,
67+
it would make sense to fill out all details you can provide.
68+
69+
#### 1. Run the gem executable with source and target directory
70+
71+
```bash
72+
plex_symlinker /path/to/audiobooks /path/to/symlinks
73+
```
74+
75+
💡 If you ran PlexSymlinker before, you can just re-run it on the same directory again.
76+
It will automatically sync the symlinks against the actual files and even delete no longer existing files.
77+
78+
#### 2. Create a Plex library pointing to the symlink directory
79+
6280
### Using the Docker image
6381

6482
Please refer to [Docker Hub](https://hub.docker.com/r/sterexx/plex_symlinker) for instructions

lib/plex_symlinker.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
require "pathname"
55
require "ruby-progressbar"
66
require "taglib"
7-
require "zeitwerk"
87

9-
loader = Zeitwerk::Loader.for_gem
10-
loader.setup
11-
loader.eager_load
8+
require "plex_symlinker/file_types/audio_file"
9+
require "plex_symlinker/file_types/mp3"
10+
require "plex_symlinker/file_types/mp4"
11+
require "plex_symlinker/operation"
12+
require "plex_symlinker/symlink"
13+
require "plex_symlinker/version"
1214

1315
module PlexSymlinker
1416
class Error < StandardError; end

lib/plex_symlinker/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module PlexSymlinker
2-
VERSION = "0.1.0"
2+
VERSION = "0.1.1"
33
end

plex_symlinker.gemspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,4 @@ Gem::Specification.new do |spec|
2828
spec.add_runtime_dependency "ruby-progressbar", "~> 1.10"
2929
spec.add_runtime_dependency "slop", "~> 4.8"
3030
spec.add_runtime_dependency "taglib-ruby", "~> 1.0"
31-
spec.add_runtime_dependency "zeitwerk", "~> 2.4"
3231
end

0 commit comments

Comments
 (0)