AutoScan Guide

Plex with radarr and sonarr on the same server.

  1. sudo wget https://raw.githubusercontent.com/pazport/autoscan/main/autoscan.yml -O /opt/autoscan.yml

  2. sudo ansible-playbook /opt/autoscan.yml

  3. nano /opt/appdata/autoscan/config.yml

  4. copy this below, to use as a template, then make your own edits.

copy this into the config.yml file. (YOU NEED TO MAKE YOUR OWN EDITS TO THIS BEFORE YOU SAVE)

# override the minimum age to 2 minutes:
minimum-age: 2m

# override the interval scan stats are displayed:
# defaults to 1 hour / 0s to disable
scan-stats: 1h

# you can set multiple anchor files
anchors:
        - /mnt/unionfs/.anchors/cloud.anchor
        - /mnt/unionfs/.anchors/local.anchor

# Optionally, protect your webhooks with authentication
authentication:
  username: hello
  password: general

# port for Autoscan webhooks to listen on
port: 3030

triggers:
# The manual trigger is always enabled, the config only adjusts its priority and the rewrite rules.
  manual:
    priority: 1
    rewrite:

  sonarr:
    # name of sonarr in portainer.
    - name: sonarr
      priority: 2
    # name of sonarr4k in portainer.
    - name: sonarr4k
      priority: 3

  radarr:
    # name of radarr in portainer
    - name: radarr
      priority: 2
    # name of radarr4k in portainer
    - name: radarr4k
      priority: 3

targets:
 plex:
    # plex url
    - url: http://plex:32400
      # plex API key
      token: your plex token here

to get your plex API key. all you need is to use this command. but make sure to use this command on the server that plex is installed on.

sudo cat "/opt/appdata/plex/database/Library/Application Support/Plex Media Server/Preferences.xml" | sed -e 's;^.* PlexOnlineToken=";;' | sed -e 's;".*$;;' | tail -1

now to make sure things are working as they should, run this command and look at the logs.
sudo docker logs --follow autoscan

Now we need to make those anchor file. This allows AutoScan to make sure your mounts are running. If the mount fails, then AutoScan will put the scans in a queue until the mounts become accessible again.

mkdir /mnt/unionfs/.anchors/
touch /mnt/unionfs/.anchors/local.anchor
touch /mnt/unionfs/.anchors/cloud.anchor

Now you have finished making the changes, to save you need to crtl + x then enter y and press enter. Congratulations! You have now made your config.yml file for AutoScan. Now we need to add AutoScan to Radarr and Sonarr.

Sonarr → settings → Connect → click on the + → scroll down and click on Webhook then add the url for AutoScan http://autoscan:3030/triggers/sonarr and the username you applied to the config.yml and same for the password.

autoscan-username and password

autoscan-sonarr

now that Sonarr is completed, we will move onto Radarr.

Radarr → settings → Connect → click on the + → scroll down and click on Webhook then add the url for AutoScan http://autoscan:3030/triggers/radarr and the username you applied to the config.yml and same for the password.

autoscan-username and password

autoscan-radarr

Now all that is completed, and working. If you wish to send a manual scan to plex, then you need to add autoscan to the DNS in CloudFlare as a CNAME. now you can access autoscan. You just need to use https://autoscan.domain.com/triggers/manual

ANY PROBLEMS, PLEASE POP INTO DISCORD AND WE WILL HELP THE BEST WE CAN.

4 Likes

Great Guide @Man1234, very clear! Thanks :grinning_face_with_smiling_eyes:

if you want more examples / snippets and the full config you can find it at GitHub - Cloudbox/autoscan: Autoscan replaces the default Plex and Emby behaviour for picking up changes on the file system..

1 Like

Great guide. Can I ask if the rewrites are necessary as I dont have them on my yml.

But it seems to work ok.

Except for radarr4k.

in radarr4k did you put http://autoscan:3030/triggers/radarr4k as the url?

also, is your radarr4k on plexguide network? check in portainer.

there are some errors in the config above. for example, the rewrites are not necessary.
please try this, of course adapt to your paths and give us feedback:

##############################################################
## This is just a basic config file to get the app to start ##
##############################################################

minimum-age: 2m
scan-delay: 15s

authentication:
  username: usernamehere
  password: passwordhere

anchors:
  - /mnt/unionfs/.anchors/cloud.anchor
  - /mnt/unionfs/.anchors/local.anchor

port: 3030

triggers:

  manual:
    priority: 0

  sonarr:
    - name: sonarr
      priority: 2
    - name: sonarr4k
      priority: 4

  radarr:
    - name: radarr
      priority: 2
    - name: radarr4k
      priority: 4

  inotify:
    - priority: 1

      include:
        - ^/mnt/unionfs/

      exclude:
        - '\.(srt|pdf)'
        - ​^/mnt/unionfs/nzb/
        - ​^/mnt/unionfs/torrent/

      paths:
      - path: /mnt/unionfs/Movies
      - path: /mnt/unionfs/Movies-4k
      - path: /mnt/unionfs/TV
      - path: /mnt/unionfs/TV-4K

targets:
  plex:
    - url: http://plex:32400
      token: tokenhere
1 Like

Stupid question, probably, but how do you configure this for Emby?

there are no stupid questions…
instead of plex you take emby

targets:
  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/ # path accessible by the Emby docker container (if applicable)

you will find this at the original repo:

(rewrite is probably not necessary if you don’t have bernard)

1 Like

That’s awesome! Thanks! Do you then turn off the real time monitoring in Emby once autoscan is configured?

yes, i never have real time monitoring on. that can cause API problems with mounts. autoscan supports plex,emby and jellyfin. i have tested on all 3. and works fine.

thanks for the reminder mate. i had both setup the night i wrote this up. i will delete the rewrites from this.

2 Likes

Is there anyway of seething this up on a feeder box as I have tried and I get this
WRN No target libraries found error="/mnt/unionfs/tv/The Chi (2017)/Season 4: failed determining libraries" target=plex url=http://myipplexbox:32400
I have a feeder hetzner cloud to upload and I have plex on my own server.
Any help would be appreciated

is plex seeing the folders the at the same location. so on your feeder it is /mnt/unionfs/tv/The Chi (2017) but is it the same on your plex server?

My feeder box is mnt/unionfs/tv
And my plex is mnt/disks/tdrive/tv
How do I add them to autoscan as it’s on a different box?

try this please.

  plex:
# plex url
    - url: http://plex:32400
# plex API key
      token: your plex token here
      rewrite:
        - from: /mnt/unionfs/
          to: /mnt/disk/tdrive/ ```

WRN No target libraries found error="/mnt/disks/tdrive/ ```tv/House/Season 7: failed determining libraries" target=plex url=https://plex.mydomain.com
This is what I get

##############################################################

This is just a basic config file to get the app to start

##############################################################

minimum-age: 2m
scan-delay: 15s

authentication:
username: xxxxxx
password: xxxxxx

anchors:

  • /mnt/unionfs/.anchors/cloud.anchor
  • /mnt/unionfs/.anchors/local.anchor

port: 3030

triggers:

manual:
priority: 0

sonarr:
- name: sonarr
priority: 2
- name: sonarr4k
priority: 4

radarr:
- name: radarr
priority: 2
- name: radarr4k
priority: 4

inotify:
- priority: 1

  include:
    - ^/mnt/unionfs/

  exclude:
    - '\.(srt|pdf)'
    - ​^/mnt/unionfs/nzb/
    - ​^/mnt/unionfs/torrent/

  paths:
  - path: /mnt/unionfs/movies
  - path: /mnt/unionfs/4kmovies
  - path: /mnt/unionfs/tv
  - path: /mnt/unionfs/Shows4k

targets:
plex:
- url: https://plex.mydomain.com
token:plexToken
rewrite:
- from: /mnt/unionfs/
to: /mnt/disks/tdrive/ ```
This is my whole config file

Can anyone help me to get bernard (google drive monitoring) working?

My service-account.json is located at /opt/appdata/service-account.json and I added this to my config.yml:

bernard:
- account: service-account.json
cron: “*/5 * * * *”
priority: 0
drives:
- id: team-drive-id-1
- id: team-drive-id-2
- id: team-drive-id-3

but when I run autoscan I get the following error:

Jun 9 21:02:05 FTL Failed initialising trigger error=“open service-account.json: no such file or directory: fatal error” trigger=bernard

Do I need to modify something on autoscan.yml if I want to use bernard?

I think you need to make it /config/service-account.json

Check your volume mounts but usually /opt/appdata/app is shared to the container as /config

Here you can see my volume mount points:

If I use /config/json then I get a different error:

Jun 10 07:37:06 FTL Failed initialising trigger error=“invalid character ‘\n’ in string literal: fatal error” trigger=bernard