aboutsummaryrefslogtreecommitdiffstats

Aftercare

Aftercare is a somewhat naive media file post processing script in Groovy. It will move all series episodes under the input folder into neat per serie and per season directories under the output folder. It recognises episode files by their filename extension. The episodes will be renamed into the form

Series Name - SxxExx.ext

The media can be inside directories, but don't have to be. Afterwards these original directories and files will be moved to a done folder with their contents for you to inspect. When something fails, the failed original will me moved to the error folder.

Naive in the sense that it expects original file names like these:

The.Expanse.S03E07.720p.WEB.H264-DEFLATE.mkv

where the series title is everything before the season/episode numbers. The S and E can be lowercase as well, the S can be left out and the E can also be an uppercase or lowercase X. Any dots are replaced with spaces. Any apostrophes in the title are discarded.

Rename and change the file named example.conf and configure which directories, user, group and unix rights should be used:

output      The directory under which your media renderer expects the media files
input       The directory where the originals are
done        The directory where the succesful originals are moved
error       The directory where the failed originals are moved

user        The unix user which will own the resulting media files
group       The unix group which will own the resulting media files
chmod       The unix rights (octal notation) which the resulting media files should have

dry_run     Whether Aftercare should do a dry run

allowed     a list of allowed file types
nrs         a regex matching with how the original filenames state their series and episode number.

You can run the script manually (use of sudo is to set the unix user, group and rights):

$ sudo groovy aftercare.groovy properties.conf

but you shouldn't. The two systemd files will let you run the script automatically every hour and will make the script's log messages appear in the system logs. In aftercare.service, adapt the line starting with ExecStart to point it to where you install Aftercare. Put both files in /etc/systemd/system/ and do:

$ sudo systemctl start aftercare.timer
$ sudo systemctl enable aftercare.timer

If your system doesn't use systemd, you can trigger Aftercare with inotify(7) or a cron job. Don't forget to periodically clean the done and error directories.