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

Commit 42137fb

Browse files
authored
docs: simplify rewriting rules (#49)
1 parent 6dd262b commit 42137fb

File tree

2 files changed

+45
-37
lines changed

2 files changed

+45
-37
lines changed

README.md

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Autoscan
22

33
Autoscan replaces the default Plex and Emby behaviour for picking up file changes on the file system.
4-
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.
4+
Autoscan integrates with Sonarr, Radarr, Lidarr and Google Drive to fetch changes in near real-time without relying on the file system.
55

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

5454
### Installing autoscan
5555

56-
As Autoscan is still in active development, we highly recommend you to fetch the latest state of the master branch at all times.
56+
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)!
5757

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

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

7071
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.
7172

72-
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!
73-
7473
## Introduction
7574

7675
Autoscan is split into three distinct modules:
@@ -108,22 +107,22 @@ triggers:
108107
- rewrite:
109108
# /tv contains folders with tv shows
110109
# This path is used within the Sonarr Docker container
111-
- from: /tv/*
110+
- from: /tv/
112111

113112
# /mnt/unionfs/Media/TV links to the same folder, though from the host OS
114113
# This folder is accessed by Autoscan
115-
to: /mnt/unionfs/Media/TV/$1
114+
to: /mnt/unionfs/Media/TV/
116115

117116
targets:
118117
plex:
119118
- rewrite:
120119
# Same folder as above, accessible by Autoscan.
121120
# Note how we strip the "TV" part,
122121
# as we want both Movies and TV.
123-
- from: /mnt/unionfs/Media/*
122+
- from: /mnt/unionfs/Media/
124123

125124
# This path is used within the Plex Docker container
126-
to: /data/$1
125+
to: /data/
127126
```
128127
129128
Let's take a look at the journey of the path `/tv/Westworld/Season 1/s01e01.mkv` coming from Sonarr.
@@ -212,12 +211,12 @@ triggers:
212211
213212
# rewrite drive to the local filesystem
214213
rewrite:
215-
- from: ^/Media/*
216-
to: /mnt/unionfs/Media/$1
214+
- from: ^/Media/
215+
to: /mnt/unionfs/Media/
217216
218217
# filter with regular expressions
219218
include:
220-
- '^/mnt/unionfs/Media/*'
219+
- ^/mnt/unionfs/Media/
221220
exclude:
222221
- '\.srt$'
223222
@@ -226,14 +225,14 @@ triggers:
226225
227226
# filter with regular expressions
228227
include:
229-
- '^/mnt/unionfs/Media/*'
228+
- ^/mnt/unionfs/Media/
230229
exclude:
231230
- '\.(srt|pdf)$'
232231
233232
# rewrite inotify path to unified filesystem
234233
rewrite:
235-
- from: ^/mnt/local/Media/*
236-
to: /mnt/unionfs/Media/$1
234+
- from: ^/mnt/local/Media/
235+
to: /mnt/unionfs/Media/
237236
238237
# local filesystem paths to monitor
239238
paths:
@@ -246,8 +245,8 @@ triggers:
246245
# Rewrite the path from within the container
247246
# to your local filesystem.
248247
rewrite:
249-
- from: /tv/*
250-
to: /mnt/unionfs/Media/TV/$1
248+
- from: /tv/
249+
to: /mnt/unionfs/Media/TV/
251250
252251
radarr:
253252
- name: radarr # /triggers/radarr
@@ -354,8 +353,8 @@ targets:
354353
- url: https://plex.domain.tld # URL of your Plex server
355354
token: XXXX # Plex API Token
356355
rewrite:
357-
- from: /mnt/unionfs/Media/* # local file system
358-
to: /data/$1 # path accessible by the Plex docker container (if applicable)
356+
- from: /mnt/unionfs/Media/ # local file system
357+
to: /data/ # path accessible by the Plex docker container (if applicable)
359358
```
360359

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

383382
- URL. The URL can link to the docker container directly, the localhost or a reverse proxy sitting in front of Emby.
@@ -418,8 +417,8 @@ triggers:
418417
# Rewrite the path from within the container
419418
# to your local filesystem.
420419
rewrite:
421-
- from: /tv/*
422-
to: /mnt/unionfs/Media/TV/$1
420+
- from: /tv/
421+
to: /mnt/unionfs/Media/TV/
423422
424423
radarr:
425424
- name: radarr # /triggers/radarr
@@ -437,15 +436,15 @@ targets:
437436
- url: https://plex.domain.tld # URL of your Plex server
438437
token: XXXX # Plex API Token
439438
rewrite:
440-
- from: /mnt/unionfs/Media/* # local file system
441-
to: /data/$1 # path accessible by the Plex docker container (if applicable)
439+
- from: /mnt/unionfs/Media/ # local file system
440+
to: /data/ # path accessible by the Plex docker container (if applicable)
442441
443442
emby:
444443
- url: https://emby.domain.tld # URL of your Emby server
445444
token: XXXX # Emby API Token
446445
rewrite:
447-
- from: /mnt/unionfs/Media/* # local file system
448-
to: /data/$1 # path accessible by the Emby docker container (if applicable)
446+
- from: /mnt/unionfs/Media/ # local file system
447+
to: /data/ # path accessible by the Emby docker container (if applicable)
449448
```
450449

451450
## Other installation options

autoscan_test.go

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ func TestRewriter(t *testing.T) {
1818
Input: "/mnt/unionfs/Media/Movies/Example Movie/movie.mkv",
1919
Expected: "/data/Movies/Example Movie/movie.mkv",
2020
Rewrites: []Rewrite{{
21-
From: "/mnt/unionfs/Media/*",
22-
To: "/data/$1",
21+
From: "/mnt/unionfs/Media/",
22+
To: "/data/",
2323
}},
2424
},
2525
{
@@ -37,16 +37,16 @@ func TestRewriter(t *testing.T) {
3737
Expected: "/whatever",
3838
Rewrites: []Rewrite{{
3939
From: "^/Media/",
40-
To: "/$1",
40+
To: "/",
4141
}},
4242
},
4343
{
4444
Name: "Unicode (PAS issue #73)",
4545
Input: "/media/b33f/saitoh183/private/Videos/FrenchTV/L'échappée/Season 03",
4646
Expected: "/Videos/FrenchTV/L'échappée/Season 03",
4747
Rewrites: []Rewrite{{
48-
From: "/media/b33f/saitoh183/private/*",
49-
To: "/$1",
48+
From: "/media/b33f/saitoh183/private/",
49+
To: "/",
5050
}},
5151
},
5252
{
@@ -59,17 +59,26 @@ func TestRewriter(t *testing.T) {
5959
Input: "/test/example.mp4",
6060
Expected: "/test/example.mp4",
6161
Rewrites: []Rewrite{{
62-
From: "^/Media/*",
63-
To: "/mnt/unionfs/Media/$1",
62+
From: "^/Media/",
63+
To: "/mnt/unionfs/Media/",
6464
}},
6565
},
6666
{
6767
Name: "Uses second rule if first one does not match",
6868
Input: "/test/example.mp4",
6969
Expected: "/mnt/unionfs/example.mp4",
7070
Rewrites: []Rewrite{
71-
{From: "^/Media/*", To: "/mnt/unionfs/Media/$1"},
72-
{From: "^/test/*", To: "/mnt/unionfs/$1"},
71+
{From: "^/Media/", To: "/mnt/unionfs/Media/"},
72+
{From: "^/test/", To: "/mnt/unionfs/"},
73+
},
74+
},
75+
{
76+
Name: "Hotio",
77+
Input: "/movies4k/example.mp4",
78+
Expected: "/mnt/unionfs/movies4k/example.mp4",
79+
Rewrites: []Rewrite{
80+
{From: "^/movies/", To: "/mnt/unionfs/movies/"},
81+
{From: "^/movies4k/", To: "/mnt/unionfs/movies4k/"},
7382
},
7483
},
7584
}

0 commit comments

Comments
 (0)