Skip to content

Commit

Permalink
Merge pull request #1 from Stex/release/0.1.1
Browse files Browse the repository at this point in the history
Release/0.1.1
  • Loading branch information
stex authored Jul 28, 2020
2 parents 8c12f1b + 1706f72 commit c3bb425
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 8 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Changelog

## [0.1.1] - 2020-07-28

### Changed

* Removed zeitwerk (there weren't really enough files to even consider it necessary)
* Fixed gem executable

## [0.1.0] - 2020-07-28

Initial Release
3 changes: 1 addition & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
PATH
remote: .
specs:
plex_symlinker (0.1.0)
plex_symlinker (0.1.1)
activesupport (~> 6.0)
ruby-progressbar (~> 1.10)
slop (~> 4.8)
taglib-ruby (~> 1.0)
zeitwerk (~> 2.4)

GEM
remote: https://rubygems.org/
Expand Down
80 changes: 80 additions & 0 deletions README.dockerhub.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# PlexSymlinker

This gem allows creating a Plex-friendly folder structure with symlinks for your audio books.
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.

**The Problem**

Most of my audio files are in apple's m4b format, leaving me with one file per book most of the times:

📁 audiobooks
∟ 📁 author name
∟ book1.m4b
∟ book2.m4b

The problem with this structure is that Plex' music agent doesn't quite understand it.
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.

What the Plex music agent expects is a structure like this:

📁 audiobooks
∟ 📁 author name
∟ 📁 Book 1
∟ book1.m4b
∟ 📁 Book 2
∟ book2.m4b

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).

**This gem's solution**

PlexSymlinker creates symlinks pointing to your actual audio files in exactly the
structure Plex' music agent expects to find. It uses the embedded tags in your files to build it,
so even one big directory with all your audio files in it would work as expected.

Just point plex to the symlink directory instead of your actual files and you're good to go.

## Usage

Since the whole purpose of PlexSymlinker is to read a directory full of audio files and
fill another directory with symlinks, we have to make sure the docker container has access to both of them.

When using the docker image, the audio files directory is expected to be mounted
as `/app/source` and the directory the symlinks should be placed in as `/app/target`.

💡 You also have to pass in the `SYMLINK_TARGET_DIR` environment variable.
Since the gem only sees `/app/source` inside the docker container,
it would point all symlinks there instead of the actual directory on your host machine.
Just set it to the same directory that you mounted as `/app/source`.

### 0. Make sure your files are properly tagged!

At least the album and album artist fields have to set accordingly.

But since you are planning to import those files into Plex which needs a lot more information,
it would make sense to fill out all details you can provide.

### 1. Create the directory the symlinks should be placed in (if it doesn't exist yet)

It's important that the directory exists (owned by your current user) before you mount it.

mkdir -p /path/to/symlink/dir

If you ran PlexSymlinker before, you can just re-run it on the same directory again.
It will automatically sync the symlinks against the actual files.

### 2. Run the docker image

#### MacOS

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

#### Linux

💡 Under Linux, you have to make sure to set your current user/group id
with `--user "$(id -u):$(id -g)"` - otherwise, all the generated symlinks/directories
will be owned by the root user. Docker for mac/windows takes care of that for you automatically.

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

### 3. Create a Plex library pointing to the symlink directory
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ all necessary dependencies and can be used out-of-the-box by mounting the necess

### Using the gem executable

#### 0. Make sure your files are properly tagged!

At least the `album` and `album artist` fields have to set accordingly.

But since you are planning to import those files into Plex which needs a lot more information,
it would make sense to fill out all details you can provide.

#### 1. Run the gem executable with source and target directory

```bash
plex_symlinker /path/to/audiobooks /path/to/symlinks
```

💡 If you ran PlexSymlinker before, you can just re-run it on the same directory again.
It will automatically sync the symlinks against the actual files and even delete no longer existing files.

#### 2. Create a Plex library pointing to the symlink directory

### Using the Docker image

Please refer to [Docker Hub](https://hub.docker.com/r/sterexx/plex_symlinker) for instructions
Expand Down
10 changes: 6 additions & 4 deletions lib/plex_symlinker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
require "pathname"
require "ruby-progressbar"
require "taglib"
require "zeitwerk"

loader = Zeitwerk::Loader.for_gem
loader.setup
loader.eager_load
require "plex_symlinker/file_types/audio_file"
require "plex_symlinker/file_types/mp3"
require "plex_symlinker/file_types/mp4"
require "plex_symlinker/operation"
require "plex_symlinker/symlink"
require "plex_symlinker/version"

module PlexSymlinker
class Error < StandardError; end
Expand Down
2 changes: 1 addition & 1 deletion lib/plex_symlinker/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module PlexSymlinker
VERSION = "0.1.0"
VERSION = "0.1.1"
end
1 change: 0 additions & 1 deletion plex_symlinker.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency "ruby-progressbar", "~> 1.10"
spec.add_runtime_dependency "slop", "~> 4.8"
spec.add_runtime_dependency "taglib-ruby", "~> 1.0"
spec.add_runtime_dependency "zeitwerk", "~> 2.4"
end

0 comments on commit c3bb425

Please sign in to comment.