Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

Commit

Permalink
docs: simplify rewriting rules (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-rots authored Oct 10, 2020
1 parent 6dd262b commit 42137fb
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 37 deletions.
55 changes: 27 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Autoscan

Autoscan replaces the default Plex and Emby behaviour for picking up file changes on the file system.
Autoscan integrates with Sonarr, Radarr and Lidarr (with Google Drive coming soon!) to fetch changes in near real-time without relying on the file system.
Autoscan integrates with Sonarr, Radarr, Lidarr and Google Drive to fetch changes in near real-time without relying on the file system.

Wait, what happened to [Plex Autoscan](https://github.com/l3uddz/plex_autoscan)?
Well, Autoscan is a rewrite of the original Plex Autoscan written in the Go language.
Expand Down Expand Up @@ -53,12 +53,13 @@ However, we are proud of the rewrite and are eager to know your opinion!

### Installing autoscan

As Autoscan is still in active development, we highly recommend you to fetch the latest state of the master branch at all times.
Autoscan offers [pre-compiled binaries](https://github.com/Cloudbox/autoscan/releases/latest) for both Linux and MacOS for each official release. In addition, we also offer a [Docker image](#docker)!

To install the autoscan CLI on your system, make sure:
Alternatively, you can build the Autoscan binary yourself.
To build the autoscan CLI on your system, make sure:

1. Your machine runs Linux, macOS or WSL2
2. You have [Go](https://golang.org/doc/install) installed (1.14 preferred)
2. You have [Go](https://golang.org/doc/install) installed (1.14 or later preferred)
3. You have a GCC compiler present \
*Yup, we need to link to C because of SQLite >:(*
4. Clone this repository and cd into it from the terminal
Expand All @@ -69,8 +70,6 @@ To start autoscan, simply run `./autoscan`. If you want autoscan to be globally

If you need to debug certain Autoscan behaviour, either add the `-v` flag for debug mode or the `-vv` flag for trace mode to get even more details about internal behaviour.

We also offer a [Docker image](#docker)! However, its configuration may be a bit complex as it requires a good understanding of Autoscan's rewriting capabilities. We hope to provide detailed instructions on these rewriting capabilities in the near future!

## Introduction

Autoscan is split into three distinct modules:
Expand Down Expand Up @@ -108,22 +107,22 @@ triggers:
- rewrite:
# /tv contains folders with tv shows
# This path is used within the Sonarr Docker container
- from: /tv/*
- from: /tv/

# /mnt/unionfs/Media/TV links to the same folder, though from the host OS
# This folder is accessed by Autoscan
to: /mnt/unionfs/Media/TV/$1
to: /mnt/unionfs/Media/TV/

targets:
plex:
- rewrite:
# Same folder as above, accessible by Autoscan.
# Note how we strip the "TV" part,
# as we want both Movies and TV.
- from: /mnt/unionfs/Media/*
- from: /mnt/unionfs/Media/

# This path is used within the Plex Docker container
to: /data/$1
to: /data/
```
Let's take a look at the journey of the path `/tv/Westworld/Season 1/s01e01.mkv` coming from Sonarr.
Expand Down Expand Up @@ -212,12 +211,12 @@ triggers:
# rewrite drive to the local filesystem
rewrite:
- from: ^/Media/*
to: /mnt/unionfs/Media/$1
- from: ^/Media/
to: /mnt/unionfs/Media/
# filter with regular expressions
include:
- '^/mnt/unionfs/Media/*'
- ^/mnt/unionfs/Media/
exclude:
- '\.srt$'
Expand All @@ -226,14 +225,14 @@ triggers:
# filter with regular expressions
include:
- '^/mnt/unionfs/Media/*'
- ^/mnt/unionfs/Media/
exclude:
- '\.(srt|pdf)$'
# rewrite inotify path to unified filesystem
rewrite:
- from: ^/mnt/local/Media/*
to: /mnt/unionfs/Media/$1
- from: ^/mnt/local/Media/
to: /mnt/unionfs/Media/
# local filesystem paths to monitor
paths:
Expand All @@ -246,8 +245,8 @@ triggers:
# Rewrite the path from within the container
# to your local filesystem.
rewrite:
- from: /tv/*
to: /mnt/unionfs/Media/TV/$1
- from: /tv/
to: /mnt/unionfs/Media/TV/
radarr:
- name: radarr # /triggers/radarr
Expand Down Expand Up @@ -354,8 +353,8 @@ targets:
- url: https://plex.domain.tld # URL of your Plex server
token: XXXX # Plex API Token
rewrite:
- from: /mnt/unionfs/Media/* # local file system
to: /data/$1 # path accessible by the Plex docker container (if applicable)
- from: /mnt/unionfs/Media/ # local file system
to: /data/ # path accessible by the Plex docker container (if applicable)
```

There are a couple of things to take note of in the config:
Expand All @@ -376,8 +375,8 @@ targets:
- url: https://emby.domain.tld # URL of your Emby server
token: XXXX # Emby API Token
rewrite:
- from: /mnt/unionfs/Media/* # local file system
to: /data/$1 # path accessible by the Emby docker container (if applicable)
- from: /mnt/unionfs/Media/ # local file system
to: /data/ # path accessible by the Emby docker container (if applicable)
```

- URL. The URL can link to the docker container directly, the localhost or a reverse proxy sitting in front of Emby.
Expand Down Expand Up @@ -418,8 +417,8 @@ triggers:
# Rewrite the path from within the container
# to your local filesystem.
rewrite:
- from: /tv/*
to: /mnt/unionfs/Media/TV/$1
- from: /tv/
to: /mnt/unionfs/Media/TV/
radarr:
- name: radarr # /triggers/radarr
Expand All @@ -437,15 +436,15 @@ targets:
- url: https://plex.domain.tld # URL of your Plex server
token: XXXX # Plex API Token
rewrite:
- from: /mnt/unionfs/Media/* # local file system
to: /data/$1 # path accessible by the Plex docker container (if applicable)
- from: /mnt/unionfs/Media/ # local file system
to: /data/ # path accessible by the Plex docker container (if applicable)
emby:
- url: https://emby.domain.tld # URL of your Emby server
token: XXXX # Emby API Token
rewrite:
- from: /mnt/unionfs/Media/* # local file system
to: /data/$1 # path accessible by the Emby docker container (if applicable)
- from: /mnt/unionfs/Media/ # local file system
to: /data/ # path accessible by the Emby docker container (if applicable)
```

## Other installation options
Expand Down
27 changes: 18 additions & 9 deletions autoscan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ func TestRewriter(t *testing.T) {
Input: "/mnt/unionfs/Media/Movies/Example Movie/movie.mkv",
Expected: "/data/Movies/Example Movie/movie.mkv",
Rewrites: []Rewrite{{
From: "/mnt/unionfs/Media/*",
To: "/data/$1",
From: "/mnt/unionfs/Media/",
To: "/data/",
}},
},
{
Expand All @@ -37,16 +37,16 @@ func TestRewriter(t *testing.T) {
Expected: "/whatever",
Rewrites: []Rewrite{{
From: "^/Media/",
To: "/$1",
To: "/",
}},
},
{
Name: "Unicode (PAS issue #73)",
Input: "/media/b33f/saitoh183/private/Videos/FrenchTV/L'échappée/Season 03",
Expected: "/Videos/FrenchTV/L'échappée/Season 03",
Rewrites: []Rewrite{{
From: "/media/b33f/saitoh183/private/*",
To: "/$1",
From: "/media/b33f/saitoh183/private/",
To: "/",
}},
},
{
Expand All @@ -59,17 +59,26 @@ func TestRewriter(t *testing.T) {
Input: "/test/example.mp4",
Expected: "/test/example.mp4",
Rewrites: []Rewrite{{
From: "^/Media/*",
To: "/mnt/unionfs/Media/$1",
From: "^/Media/",
To: "/mnt/unionfs/Media/",
}},
},
{
Name: "Uses second rule if first one does not match",
Input: "/test/example.mp4",
Expected: "/mnt/unionfs/example.mp4",
Rewrites: []Rewrite{
{From: "^/Media/*", To: "/mnt/unionfs/Media/$1"},
{From: "^/test/*", To: "/mnt/unionfs/$1"},
{From: "^/Media/", To: "/mnt/unionfs/Media/"},
{From: "^/test/", To: "/mnt/unionfs/"},
},
},
{
Name: "Hotio",
Input: "/movies4k/example.mp4",
Expected: "/mnt/unionfs/movies4k/example.mp4",
Rewrites: []Rewrite{
{From: "^/movies/", To: "/mnt/unionfs/movies/"},
{From: "^/movies4k/", To: "/mnt/unionfs/movies4k/"},
},
},
}
Expand Down

0 comments on commit 42137fb

Please sign in to comment.