Swift Package Index

Plex-Monitr

https://github.com/ponyboy47/Plex-Monitr.git

Plex media management made easy!


Compatibility

  • 0.8.2 and master
    5.3
    5.2
    5.1
    5.0
    4.2
  • 0.8.2 and master
    iOS
    macOS(Intel)
    macOS(ARM)
    Linux
    tvOS
    watchOS

Monitr: Build Status

Let's be honest. Managing your Plex media can be a pain. Especially when you have a ton of new stuff you want to add all at once or if you are just constantly adding new stuff! That's where Monitr comes in.

Downloading movies or tv shows or ripping cds/dvds/blu-rays is now the hardest part of getting new media onto your plex server. No more manually placing files or hacking together the proper metadata for your media. Monitr makes adding new media to your Plex server much easier. Just make sure you add new files to a designated "downloads" directory and that's all! Monitr puts it exactly where Plex wants it and names it appropriately so that Plex can identify it and find it's proper metadata match.

It works by watching a designated "Downloads" directory and whenever a new video, audio, or subtitle file is added to that directory, Monitr will automatically move it right to where it should be, then Plex takes care of the rest!

You can also configure Monitr to automatically transcode media into Plex Direct Play/Stream capable formats. This means that Plex won't have to transcode media on-the-go and can help keep your CPU load lower when watching movies or TV shows.

It supports either Linux or macOS operating systems using Apple's Swift language (and a tiny bit of C for some of the stuff on Linux). It also has some dependencies, like ruby (if you're enabling the conversion capabilities).


Features:

  • Cross-system compatability
    • Linux (tested on Ubuntu 16.04) <- This is my primary development environment
    • macOS (tested on macOS Sierra 10.12)
  • Monitors a downloads directory for when files are moved into it
  • Supports most Plex media types
    • Movies & TV Shows
      • Including subtitles
    • Music
    • Home Videos
  • Automatically converts media to Plex Direct Play/Stream capable formats
    • It uses the most common Direct Play/Stream formats by default, but you can configure the conversion settings however you'd like
    • Automatic media transcoding can be ran immediately when new media is added, or later as a scheduled task when the server will most likely not be in use

Installation

Linux (Tested on Ubuntu 16.04)

# transcode_video dependency installation (only needed if you're going to enable automatic media conversion)
sudo add-apt-repository ppa:stebbins/handbrake-releases
sudo add-apt-repository ppa:jonathonf/ffmpeg-3
sudo apt-get remove handbrake* ffmpeg && sudo apt autoremove
sudo apt-get update
sudo apt-get install -y ruby handbrake-cli ffmpeg mkvtoolnix mp4v2-utils libav-tools x264 x265

# transcode_video installation (only needed if you're going to enable automatic media conversion)
sudo gem install video_transcoding

# Swiftenv installation (makes installing and updating swift super easy)
git clone https://github.com/kylef/swiftenv.git ~/.swiftenv
echo 'export SWIFTENV_ROOT="$HOME/.swiftenv"' >> ~/.bash_profile
echo 'export PATH="$SWIFTENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(swiftenv init -)"' >> ~/.bash_profile
source ~/.bash_profile

# Plex-Monitr and swift installation
git clone https://github.com/Ponyboy47/Plex-Monitr.git
cd Plex-Monitr
swiftenv install $(cat .swift-version)
swift build
swift run monitr

macOS (Tested on macOS High Sierra 10.13.2)

# Homebrew installation (To install swiftenv and also the transcode_video dependencies)
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

# transcode_video dependencies and installation (only needed if you're going to enable automatic media conversion)
brew install handbrake ffmpeg mkvtoolnix mp4v2 && gem install video_transcoding

# Makes installing and updating swift super easy
brew install kylef/formulae/swiftenv

# Plex-Monitr and swift installation
git clone https://github.com/Ponyboy47/Plex-Monitr.git
cd Plex-Monitr
swiftenv install $(cat .swift-version)
swift build
swift run monitr

Updating

cd ~/Plex-Monitr
rm Package.{resolved,pins}
# If config changes have been made, you will need to regenerate and save your new config
rm ~/.config/monitr/settings.json
git pull
swiftenv install $(.swift-version)
swift package update
swift build
swift run monitr

Usage:

CLI Arguments:

There are a number of ways to configure your Monitr. Like any CLI application, any of these arguments can be used at the same time to create the exact Monitr that you need.

See the usage/help text:

-h or --help

See the current version of monitr:

-v or --version

Set the Config file to use/save to:

-f or --config

Set the Plex Library directory:

-p or --plex-dir

Set the Download directories to monitor:

-d or --download-dirs

Set the Home Video directories to monitor

--home-video-download-dirs

Set the Convert flag (whether to convert media to Direct Play formats for plex):

-c or --convert

Set whether to convert media files immediately, or as a scheduled task:

-i or --convert-immediately

Set when scheduled media file conversion tasks should begin (uses a cron string):

-a or --convert-cron-start

Set when scheduled media file conversion tasks stops (uses a cron string):

-z --convert-cron-end

Set the number of simultaneous conversion threads we can have running at one time:

--convert-threads

Set whether of not to delete the original media file after converting it:

--delete-original

Set the transcode-video command to use the Contrained Average Bitrate ratecontrol system:

--abr or --average-bitrate-rcs defaults to false NOTE: To determine if you should use this option, run transcode-video --help and read the information about the --abr option.

Use the h265 encoder instead of the default handbrake encoder (h264):

--x265 defaults to false NOTE: To determine if you should use this option, you may want to check out this link if you're trying to dramatically reduce file sizes when converting and can use the h265 converter. If you need me to expose additional options to the transcode-video command, create a new issue and I can do that pretty easily.

The targets to use in the transcode-video command:

-t or --target May be used multiple times NOTE: To determine if/how to use this option, run transcode-video --help and read the information about the --target options.

The transcode speed to use:

--speed or --transcode-speed

The x264 speed preset:

--x264-preset

Set the container to use when converting video files:

--convert-video-container

Set the codec to use when converting video streams:

--convert-video-codec

Set the container to use when converting audio files:

--convert-audio-container

Set the codec to use when converting audio streams:

--convert-audio-codec

Set whether to scan for foreign audio subtitles and burn them into a video stream:

--convert-video-subtitle-scan defaults to false NOTE: This is an experimental feature in the transcode_video tool. If it screws up, you could end up with the wrong subtitle track burned into your video. See @donmelton's own documentation on this feature in his transcode_video. If you are going to use this, it is HIGHLY RECOMMENDED that you do not use the --delete-original flag, just to be safe.

Set the preferred language to use when converting media:

--convert-language

Set the maximum framerate to use when converting video streams:

--convert-video-max-framerate

Set the directory to use for conversion jobs when deleteOriginal is false:

--convert-temp-dir

Set whether or not subtitle files should be deleted or preserved for video media:

--delete-subtitles

Set whether or not to save these config settings to the config file:

-s or --save-settings defaults to false The current settings are saved at the --config-file path (defaults to ~/.config/monitr/settings.json) NOTE: If true, subsequent monitr instances will load the settings file from the --config-file option and use its config values instead of the usual defaults.

Set the default logging level to use:

--level or --log-level

Set the log file to use:

-o or --log-file


TODO:

  • Make a graphic
  • Logging
  • The CLI boolean flags with a default value of true cannot be set to false. Fix it.
  • Do something with files that failed to be moved
  • Don't register downloads with x264 as a TV show of Season 2 Episode 64 (Downpour)
  • Better subtitle file support
  • Make an option for deleting subtitle files upon import
  • Get show name/season from parent directory? (Useful when there is an organized directory structure, but file names do not contain all the relevant info)
  • Convert media to Plex Direct Play/Stream formats with Handbrake CLI or ffmpeg
  • Preserve TV show episode titles
  • Support multi-part TV show episodes
  • Create a command to display the statistics
  • Support monitoring multiple directories
  • Watch a specific directory for Home Videos
  • Make the entire program more asynchronous
    • Continue execution while converting media (Just add new stuff to a queue)
    • Finishing conversion automatically continues to moveMedia()
      • Set up Operations for moving & converting
      • Set up Operation dependency chains for automatic asynchronous behaviors
  • Improve the stability with large amounts of conversion jobs
  • Swift 4
  • Dynamically add paths to watch lists (such as an auto-generated directory inside users' home directories)
  • Remove configurable items that aren't actually configurable (if no CLI option, then no configuration)
  • Unit tests
  • Only allow one running instance of monitr
  • Moving batches of files at a time into the downloads directories causes issues