Skip to content

Commit

Permalink
Added support for the AMC script.
Browse files Browse the repository at this point in the history
  • Loading branch information
jlesage committed Oct 14, 2019
1 parent 870b7a0 commit 3d63add
Show file tree
Hide file tree
Showing 5 changed files with 376 additions and 2 deletions.
19 changes: 18 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ RUN \
add-pkg \
p7zip \
unrar \
findutils \
coreutils \
nss \
gtk+2.0 \
openjdk8-jre \
Expand Down Expand Up @@ -109,11 +111,26 @@ RUN \
COPY rootfs/ /

# Set environment variables.
ENV APP_NAME="FileBot"
ENV APP_NAME="FileBot" \
OPENSUBTITLES_USERNAME= \
OPENSUBTITLES_PASSWORD= \
AMC_INTERVAL="1800" \
AMC_INPUT_STABLE_TIME="10" \
AMC_ACTION="test" \
AMC_CONFLICT="auto" \
AMC_MUSIC_FORMAT="{plex}" \
AMC_MOVIE_FORMAT="{plex}" \
AMC_SERIES_FORMAT="{plex}" \
AMC_ANIME_FORMAT="{plex}" \
AMC_PROCESS_MUSIC="y" \
AMC_SUBTITLE_LANG= \
AMC_CUSTOM_OPTIONS=

# Define mountable directories.
VOLUME ["/config"]
VOLUME ["/storage"]
VOLUME ["/watch"]
VOLUME ["/output"]

# Metadata.
LABEL \
Expand Down
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ just works.
* [License](#license)
* [Installing a License](#installing-a-license)
* [Donation Supported Version](#donation-supported-version)
* [Automated Media Center (AMC)](#automated-media-center-amc)
* [Support or Contact](#support-or-contact)

## Quick Start
Expand Down Expand Up @@ -105,6 +106,19 @@ of this parameter has the format `<VARIABLE_NAME>=<VALUE>`.
|`VNC_PASSWORD`| Password needed to connect to the application's GUI. See the [VNC Password](#vnc-password) section for more details. | (unset) |
|`X11VNC_EXTRA_OPTS`| Extra options to pass to the x11vnc server running in the Docker container. **WARNING**: For advanced users. Do not use unless you know what you are doing. | (unset) |
|`ENABLE_CJK_FONT`| When set to `1`, open source computer font `WenQuanYi Zen Hei` is installed. This font contains a large range of Chinese/Japanese/Korean characters. | `0` |
|`OPENSUBTITLES_USERNAME`| Username of your [OpenSubtitles](https://www.opensubtitles.org) account. Required to download subtitles. | (unset) |
|`OPENSUBTITLES_PASSWORD`| Password of your [OpenSubtitles](https://www.opensubtitles.org) account. Required to download subtitles. | (unset) |
|`AMC_INTERVAL`| Time (in seconds) between each invocation of the Automated Media Center (AMC) script. | `1800` |
|`AMC_INPUT_STABLE_TIME`| Time (in seconds) during which properties (e.g. size, time, etc) of files in the watch folder need to remain the same before invoking the Automated Media Center (AMC) script. This is to avoid processing the watch folder while files are being copied. | `10` |
|`AMC_ACTION`| Action performed by the Automated Media Center (AMC) script on files. Valid values are `test`, `copy`, `move` or `hardlink`. Use the `test` operation to perform a dry-run and verify that everything gets matched up correctly. | `test` |
|`AMC_CONFLICT`| Conflict resolution strategy used by the Automated Media Center (AMC) script: `skip` never overrides existing files, while `auto` overrides existing file only if new media is better. | `auto` |
|`AMC_MUSIC_FORMAT`| Define how music files are renamed by the Automated Media Center (AMC) script. Filebot supports a very powerful naming scheme. See [Format Expressions](https://www.filebot.net/naming.html) for complete documentation. | `{plex}` |
|`AMC_MOVIE_FORMAT`| Define how movie files are renamed by the Automated Media Center (AMC) script. Filebot supports a very powerful naming scheme. See [Format Expressions](https://www.filebot.net/naming.html) for complete documentation. | `{plex}` |
|`AMC_SERIES_FORMAT`| Define how TV series files are renamed by the Automated Media Center (AMC) script. Filebot supports a very powerful naming scheme. See [Format Expressions](https://www.filebot.net/naming.html) for complete documentation. | `{plex}` |
|`AMC_ANIME_FORMAT`| Define how anime files are renamed by the Automated Media Center (AMC) script. Filebot supports a very powerful naming scheme. See [Format Expressions](https://www.filebot.net/naming.html) for complete documentation. | `{plex}` |
|`AMC_PROCESS_MUSIC`| When set to `y`, music files are processed by the Automated Media Center (AMC) script. A value of `n` does not process them. | `y` |
|`AMC_SUBTITLE_LANG`| Comma-separated list of subtitle languages to download. Example: `en,de,fr`. | (unset) |
|`AMC_CUSTOM_OPTIONS`| Custom arguments to pass to the Automated Media Center (AMC) script. | (unset) |

### Data Volumes

Expand Down Expand Up @@ -479,6 +493,27 @@ To revert to this version, create the container by using
**NOTE**: While no license is required to use this version, it is no longer
supported and maintained by the author of FileBot.

## Automated Media Center (AMC)

This container supports the FileBot's
[Automated Media Center](https://www.filebot.net/forums/viewtopic.php?t=215)
(AMC) script. This script automatically and smartly organizes movies, TV shows,
anime and music.

Basically, files copied to the `/watch` container folder are automatically
renamed and organized to the `output` container folder.

Configuration of the AMC script is done via `AMC_*` environment variables. See
the [Environment Variables](#environment-variables) section for the list and
descriptions of environment variables that can be set.

To see what the AMC script is doing, see the container's log.

**NOTE**: By default, the script runs in dry mode, meaning that no change is
performed. This allows you to verify that results produced by the script are
correct. Then, the `AMC_ACTION` environment variable can be updated to perform
changes to the file system.

[TimeZone]: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones

## Support or Contact
Expand Down
180 changes: 179 additions & 1 deletion appdefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,29 @@ To revert to this version, create the container by using
supported and maintained by the author of {{ defs.app.friendly_name }}.
</content>
</section>
<section>
<title level="2">Automated Media Center (AMC)</title>
<content>
This container supports the {{ defs.app.friendly_name }}'s
[Automated Media Center](https://www.filebot.net/forums/viewtopic.php?t=215)
(AMC) script. This script automatically and smartly organizes movies, TV shows,
anime and music.

Basically, files copied to the `/watch` container folder are automatically
renamed and organized to the `output` container folder.

Configuration of the AMC script is done via `AMC_*` environment variables. See
the [Environment Variables](#environment-variables) section for the list and
descriptions of environment variables that can be set.

To see what the AMC script is doing, see the container's log.

**NOTE**: By default, the script runs in dry mode, meaning that no change is
performed. This allows you to verify that results produced by the script are
correct. Then, the `AMC_ACTION` environment variable can be updated to perform
changes to the file system.
</content>
</section>
</documentation>
<!-- Changelog of the application. -->
<history>
Expand Down Expand Up @@ -159,7 +182,162 @@ supported and maintained by the author of {{ defs.app.friendly_name }}.
</app>
<container>
<!-- Environment variables -->
<environment_variables/>
<environment_variables>
<environment_variable>
<name>OPENSUBTITLES_USERNAME</name>
<description>Username of your [OpenSubtitles](https://www.opensubtitles.org) account. Required to download subtitles.</description>
<default></default>
<unraid_template>
<title>OpenSubtitles Username</title>
<description>Username of your OpenSubtitles (https://www.opensubtitles.org) account. Required to download subtitles.</description>
<display>always</display>
<required>false</required>
<mask>false</mask>
</unraid_template>
</environment_variable>
<environment_variable>
<name>OPENSUBTITLES_PASSWORD</name>
<description>Password of your [OpenSubtitles](https://www.opensubtitles.org) account. Required to download subtitles.</description>
<default></default>
<unraid_template>
<title>OpenSubtitles Passowrd</title>
<description>Password of your OpenSubtitles (https://www.opensubtitles.org) account. Required to download subtitles.</description>
<display>always</display>
<required>false</required>
<mask>false</mask>
</unraid_template>
</environment_variable>
<environment_variable>
<name>AMC_INTERVAL</name>
<description>Time (in seconds) between each invocation of the Automated Media Center (AMC) script.</description>
<default>1800</default>
<unraid_template>
<title>Automated Media Center: Interval</title>
<display>always</display>
<required>false</required>
<mask>false</mask>
</unraid_template>
</environment_variable>
<environment_variable>
<name>AMC_INPUT_STABLE_TIME</name>
<description>Time (in seconds) during which properties (e.g. size, time, etc) of files in the watch folder need to remain the same before invoking the Automated Media Center (AMC) script. This is to avoid processing the watch folder while files are being copied.</description>
<default>10</default>
<unraid_template>
<title>Automated Media Center: Input Stable Time</title>
<display>always</display>
<required>false</required>
<mask>false</mask>
</unraid_template>
</environment_variable>
<environment_variable>
<name>AMC_ACTION</name>
<description>Action performed by the Automated Media Center (AMC) script on files. Valid values are `test`, `copy`, `move` or `hardlink`. Use the `test` operation to perform a dry-run and verify that everything gets matched up correctly.</description>
<default>test</default>
<unraid_template>
<title>Automated Media Center: Action</title>
<description>Action performed by the Automated Media Center (AMC) script on files. Valid values are [b][i]test[/i][/b], [b][i]copy[/i][/b], [b][i]move[/i][/b] or [b][i]hardlink[/i][/b]. Use the [b][i]test[/i][/b] operation to perform a dry-run and verify that everything gets matched up correctly.</description>
<display>always</display>
<required>false</required>
<mask>false</mask>
</unraid_template>
</environment_variable>
<environment_variable>
<name>AMC_CONFLICT</name>
<description>Conflict resolution strategy used by the Automated Media Center (AMC) script: `skip` never overrides existing files, while `auto` overrides existing file only if new media is better.</description>
<default>auto</default>
<unraid_template>
<title>Automated Media Center: Conflict Resolution</title>
<description>Conflict resolution strategy used by the Automated Media Center (AMC) script. When set to [b][i]skip[/i][/b], existing files are never overriden. [b][i]auto[/i][/b] overrides existing file only if new media is better.</description>
<display>always</display>
<required>false</required>
<mask>false</mask>
</unraid_template>
</environment_variable>
<environment_variable>
<name>AMC_MUSIC_FORMAT</name>
<description>Define how music files are renamed by the Automated Media Center (AMC) script. Filebot supports a very powerful naming scheme. See [Format Expressions](https://www.filebot.net/naming.html) for complete documentation.</description>
<default>{plex}</default>
<unraid_template>
<title>Automated Media Center: Music Format</title>
<description>Define how music files are renamed by the Automated Media Center (AMC) script. Filebot supports a very powerful naming scheme. See [i]https://www.filebot.net/naming.html[/i] for complete documentation.</description>
<display>always</display>
<required>false</required>
<mask>false</mask>
</unraid_template>
</environment_variable>
<environment_variable>
<name>AMC_MOVIE_FORMAT</name>
<description>Define how movie files are renamed by the Automated Media Center (AMC) script. Filebot supports a very powerful naming scheme. See [Format Expressions](https://www.filebot.net/naming.html) for complete documentation.</description>
<default>{plex}</default>
<unraid_template>
<title>Automated Media Center: Movie Format</title>
<description>Define how movie files are renamed by the Automated Media Center (AMC) script. Filebot supports a very powerful naming scheme. See [i]https://www.filebot.net/naming.html[/i] for complete documentation.</description>
<display>always</display>
<required>false</required>
<mask>false</mask>
</unraid_template>
</environment_variable>
<environment_variable>
<name>AMC_SERIES_FORMAT</name>
<description>Define how TV series files are renamed by the Automated Media Center (AMC) script. Filebot supports a very powerful naming scheme. See [Format Expressions](https://www.filebot.net/naming.html) for complete documentation.</description>
<default>{plex}</default>
<unraid_template>
<title>Automated Media Center: TV Series Format</title>
<description>Define how TV series files are renamed by the Automated Media Center (AMC) script. Filebot supports a very powerful naming scheme. See [i]https://www.filebot.net/naming.html[/i] for complete documentation.</description>
<display>always</display>
<required>false</required>
<mask>false</mask>
</unraid_template>
</environment_variable>
<environment_variable>
<name>AMC_ANIME_FORMAT</name>
<description>Define how anime files are renamed by the Automated Media Center (AMC) script. Filebot supports a very powerful naming scheme. See [Format Expressions](https://www.filebot.net/naming.html) for complete documentation.</description>
<default>{plex}</default>
<unraid_template>
<title>Automated Media Center: Anime Format</title>
<description>Define how anime files are renamed by the Automated Media Center (AMC) script. Filebot supports a very powerful naming scheme. See [i]https://www.filebot.net/naming.html[/i] for complete documentation.</description>
<display>always</display>
<required>false</required>
<mask>false</mask>
</unraid_template>
</environment_variable>
<environment_variable>
<name>AMC_PROCESS_MUSIC</name>
<description>When set to `y`, music files are processed by the Automated Media Center (AMC) script. A value of `n` does not process them.</description>
<default>y</default>
<unraid_template>
<title>Automated Media Center: Process Music</title>
<description>When set to [b][i]y[/i][/b], music files are processed by the Automated Media Center (AMC) script. A value of [b][i]n[/i][/b] does not process them.</description>
<display>always</display>
<required>false</required>
<mask>false</mask>
</unraid_template>
</environment_variable>
<environment_variable>
<name>AMC_SUBTITLE_LANG</name>
<description>Comma-separated list of subtitle languages to download. Example: `en,de,fr`.</description>
<default></default>
<unraid_template>
<title>Automated Media Center: Custom Options</title>
<description>Comma-separated list of subtitle languages to download. Example: [b][i]en,de,fr[i][b].</description>
<display>always</display>
<required>false</required>
<mask>false</mask>
</unraid_template>
</environment_variable>
<environment_variable>
<name>AMC_CUSTOM_OPTIONS</name>
<description>Custom arguments to pass to the Automated Media Center (AMC) script.</description>
<default></default>
<unraid_template>
<title>Automated Media Center: Custom Options</title>
<description>Custom arguments to pass to the Automated Media Center (AMC) script.</description>
<display>advanced</display>
<required>false</required>
<mask>false</mask>
</unraid_template>
</environment_variable>
</environment_variables>
<!-- Volumes -->
<volumes/>
<!-- Network ports -->
Expand Down
16 changes: 16 additions & 0 deletions rootfs/etc/cont-init.d/filebot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,23 @@ if [ ! -f "$LICENSE_PATH" ]; then
fi
fi

# Set OpenSubtitles credentials.
if [ -n "${OPENSUBTITLES_USERNAME:-}" ] && [ -n "${OPENSUBTITLES_PASSWORD:-}" ]; then
printf "$OPENSUBTITLES_USERNAME\n$OPENSUBTITLES_PASSWORD\n" | /opt/filebot/filebot -script fn:configure
fi

# Take ownership of the config directory content.
find /config -mindepth 1 -exec chown $USER_ID:$GROUP_ID {} \;

# Take ownership of the output directory.
if ! chown $USER_ID:$GROUP_ID /output; then
# Failed to take ownership of /output. This could happen when,
# for example, the folder is mapped to a network share.
# Continue if we have write permission, else fail.
if s6-setuidgid $USER_ID:$GROUP_ID [ ! -w /output ]; then
log "ERROR: Failed to take ownership and no write permission on /output."
exit 1
fi
fi

# vim: set ft=sh :
Loading

0 comments on commit 3d63add

Please sign in to comment.