Plex Automatic Scanning

kamos69

Blitz 1st Class
Original poster
Donor
78
51
PG Version
6.054
Server Type
Remote - Dedicated Server
After PG Scan was shelved I set out to get the original script working for PG. This is a quick guide to getting it setup .

Plex Autoscan is a python script that assists in the importing of Sonarr, Radarr, and Lidarr dowloads into Plex Media Server.

It does this by creating a webserver to accept webhook requests from these apps, and in turn, sends a scan request to Plex. Plex will then only scan the parent folder (i.e. season folder for TV shows, movie folder for movies, and album folders for music) of the media file (versus scanning the entire library folder).
Steps:
  • Follow the installation steps on the github page
    • Don't follow the last step, i.e. don't start the service.
  • cd /opt/plex_autscan/config/
  • wget https://raw.githubusercontent.com/kamos69/scripts/master/config.json
    • Add your Plex token, you can use this script: sudo bash /opt/plex_autoscan/scripts/plex_token.sh
  • Update the startup file: sudo nano /etc/systemd/system/plex_autoscan.service
    • You need a user with elevated privileges to run the script, so change the following if necessary:
      • User=YOUR_USER -> User=0
      • Group=YOUR_USER -> Group=0
  • Reload the daemon: sudo systemctl daemon-reload
  • Start the service: sudo systemctl start plex_autoscan.service
  • You can monitor the service with: sudo tail -f /opt/plex_autoscan/plex_autoscan.log
There's more information about the script on the github page regarding manual triggers, Sonarr and Radarr setup, rclone integration, etc.

Credit to l3uddz for the script and @Bryde for the config.
 
Last edited:

hooper

Blitz Legioner
Staff
Donor
247
79
I can't get this to work even with the config provided.

here is the error I get just trying to run the python scan.py sections command


plexguide@server-anon:/opt/plex_autoscan$ python scan.py sections
2018-09-12 16:55:29,599 - INFO - CONFIG [XXXXXXXXXXXX]: Using default setting --loglevel=INFO
2018-09-12 16:55:29,599 - INFO - CONFIG [XXXXXXXXXXXX]: Using default setting --cachefile=cache.db
2018-09-12 16:55:29,599 - INFO - CONFIG [XXXXXXXXXXXX]: Using default setting --tokenfile=token.json
2018-09-12 16:55:29,599 - INFO - CONFIG [XXXXXXXXXXXX]: Using default setting --queuefile=queue.db
2018-09-12 16:55:29,599 - INFO - CONFIG [XXXXXXXXXXXX]: Using default setting --logfile=plex_autoscan.log
2018-09-12 16:55:29,599 - INFO - CONFIG [XXXXXXXXXXXX]: Using default setting --config=config/config.json

2018-09-12 16:55:29,722 - INFO - AUTOSCAN [XXXXXXXXXXXX]:
_ _
_ __ | | _____ __ __ _ _ _| |_ ___ ___ ___ __ _ _ __
| '_ \| |/ _ \ \/ / / _` | | | | __/ _ \/ __|/ __/ _` | '_ \
| |_) | | __/> < | (_| | |_| | || (_) \__ \ (_| (_| | | | |
| .__/|_|\___/_/\_\ \__,_|\__,_|\__\___/|___/\___\__,_|_| |_|
|_|

#########################################################################
# Author: l3uddz #
# URL: https://github.com/l3uddz/plex_autoscan #
# -- #
# Part of the Cloud project: https://Cloud.rocks #
#########################################################################
# GNU General Public License v3.0 #
#########################################################################

2018-09-12 16:55:29,723 - INFO - PLEX [XXXXXXXXXXXX]: Using Plex Scanner



terminate called after throwing an instance of 'boost::filesystem::filesystem_error'
what(): boost::filesystem::create_directories: Permission denied: "/config/Library/Logs"
****** PLEX MEDIA SCANNER CRASHED, CRASH REPORT WRITTEN: /config/Library/Application Support/Plex Media Server/Crash Reports/1.13.7.5369-xxxxxxxx/PLEX MEDIA SCANNER/25f536d8-8ab1-ae64-xxxxxxx-xxxxxxxxx.dmp
bash: line 1: 26160 Aborted /usr/lib/plexmediaserver/Plex\ Media\ Scanner --list
 

kamos69

Blitz 1st Class
Original poster
Donor
78
51
I can't get this to work even with the config provided.

here is the error I get just trying to run the python scan.py sections command


plexguide@server-anon:/opt/plex_autoscan$ python scan.py sections
2018-09-12 16:55:29,599 - INFO - CONFIG [XXXXXXXXXXXX]: Using default setting --loglevel=INFO
2018-09-12 16:55:29,599 - INFO - CONFIG [XXXXXXXXXXXX]: Using default setting --cachefile=cache.db
2018-09-12 16:55:29,599 - INFO - CONFIG [XXXXXXXXXXXX]: Using default setting --tokenfile=token.json
2018-09-12 16:55:29,599 - INFO - CONFIG [XXXXXXXXXXXX]: Using default setting --queuefile=queue.db
2018-09-12 16:55:29,599 - INFO - CONFIG [XXXXXXXXXXXX]: Using default setting --logfile=plex_autoscan.log
2018-09-12 16:55:29,599 - INFO - CONFIG [XXXXXXXXXXXX]: Using default setting --config=config/config.json

2018-09-12 16:55:29,722 - INFO - AUTOSCAN [XXXXXXXXXXXX]:
_ _
_ __ | | _____ __ __ _ _ _| |_ ___ ___ ___ __ _ _ __
| '_ \| |/ _ \ \/ / / _` | | | | __/ _ \/ __|/ __/ _` | '_ \
| |_) | | __/> < | (_| | |_| | || (_) \__ \ (_| (_| | | | |
| .__/|_|\___/_/\_\ \__,_|\__,_|\__\___/|___/\___\__,_|_| |_|
|_|

#########################################################################
# Author: l3uddz #
# URL: https://github.com/l3uddz/plex_autoscan #
# -- #
# Part of the Cloud project: https://Cloud.rocks #
#########################################################################
# GNU General Public License v3.0 #
#########################################################################

2018-09-12 16:55:29,723 - INFO - PLEX [XXXXXXXXXXXX]: Using Plex Scanner



terminate called after throwing an instance of 'boost::filesystem::filesystem_error'
what(): boost::filesystem::create_directories: Permission denied: "/config/Library/Logs"
****** PLEX MEDIA SCANNER CRASHED, CRASH REPORT WRITTEN: /config/Library/Application Support/Plex Media Server/Crash Reports/1.13.7.5369-xxxxxxxx/PLEX MEDIA SCANNER/25f536d8-8ab1-ae64-xxxxxxx-xxxxxxxxx.dmp
bash: line 1: 26160 Aborted /usr/lib/plexmediaserver/Plex\ Media\ Scanner --list
Looks like a permissions issue. Try running it with sudo: sudo python scan.py sections
 

kamos69

Blitz 1st Class
Original poster
Donor
78
51
I also realised that I didn't remove my Plex token from then config. I've updated the guide, you should user your own Plex Token.
 

hooper

Blitz Legioner
Staff
Donor
247
79
I also realised that I didn't remove my Plex token from then config. I've updated the guide, you should user your own Plex Token.
I should have mentioned that I get the same error with sudo and I had also fixed the issue with the Plex token.

Are you able to successfully run the command I get this error on?
 

kamos69

Blitz 1st Class
Original poster
Donor
78
51
I should have mentioned that I get the same error with sudo and I had also fixed the issue with the Plex token.

Are you able to successfully run the command I get this error on?
Yes.

Code:
kamos@boxee1:/opt/plex_autoscan$ sudo python scan.py sections
 2018-09-13 16:54:20,562 -     INFO -    CONFIG [140235557062464]: Using default setting --loglevel=INFO
 2018-09-13 16:54:20,562 -     INFO -    CONFIG [140235557062464]: Using default setting --cachefile=cache.db
 2018-09-13 16:54:20,562 -     INFO -    CONFIG [140235557062464]: Using default setting --tokenfile=token.json
 2018-09-13 16:54:20,562 -     INFO -    CONFIG [140235557062464]: Using default setting --queuefile=queue.db
 2018-09-13 16:54:20,562 -     INFO -    CONFIG [140235557062464]: Using default setting --logfile=plex_autoscan.log
 2018-09-13 16:54:20,562 -     INFO -    CONFIG [140235557062464]: Using default setting --config=config/config.json
 2018-09-13 16:54:20,666 -     INFO -  AUTOSCAN [140235557062464]:
        _                         _
  _ __ | | _____  __   __ _ _   _| |_ ___  ___  ___ __ _ _ __
 | '_ \| |/ _ \ \/ /  / _` | | | | __/ _ \/ __|/ __/ _` | '_ \
 | |_) | |  __/>  <  | (_| | |_| | || (_) \__ \ (_| (_| | | | |
 | .__/|_|\___/_/\_\  \__,_|\__,_|\__\___/|___/\___\__,_|_| |_|
 |_|

#########################################################################
# Author:   l3uddz                                                      #
# URL:      https://github.com/l3uddz/plex_autoscan                     #
# --                                                                    #
# Part of the Cloud project: https://Cloud.rocks                  #
#########################################################################
# GNU General Public License v3.0                                       #
#########################################################################

 2018-09-13 16:54:20,666 -     INFO -      PLEX [140235557062464]: Using Plex Scanner
  4: Anime
  1: Movies
  7: Movies 4K
  2: TV Shows
  3: UFC
 

hooper

Blitz Legioner
Staff
Donor
247
79
ok, I will smack the install of plex_autoscan and start fresh.

oh, one other question, do you run plexguide under a specific user or did you install with root?
 

kamos69

Blitz 1st Class
Original poster
Donor
78
51
ok, I will smack the install of plex_autoscan and start fresh.

oh, one other question, do you run plexguide under a specific user or did you install with root?
I run it with a specific user.
 

captngimpy

Blitz 1st Class
58
15
So I was able to get the plex auto scan setup and working but I am having some issues with it since i am using the sonarr/radarr mp4 automator docker images. Nzbget will download send a report to sonar/radarr which will then initiate the move to /mnt/move and do the convert then blitz kicks in and uploads the mp4 then the report gets sent to plex autoscan for it to watch for the file. Except it gets told the files original mkv name so it never ends up finding the file and doesn't scan. I have tried to set it to scan the directory if it fails to find a file but so far its not working. Wondering if you guys have any suggestions.
 

daveftw84

Blitz Samurai
Donor
332
39
can sonar and radar talk to it remotely?

---- Automatically Merged Double Post ----

cause I have a feeder and then the actual plex server. can I install this on the server and set it up the feeder to talk to it
 
Last edited:

captngimpy

Blitz 1st Class
58
15
They can and that's why I ran in to trouble since I'm running the mp4 conversion at the nzbget it has saved me a lot of work and time and saved my server a lot of over head from scanning through the whole library
 
Assists Greatly with Development Costs

daveftw84

Blitz Samurai
Donor
332
39
ok, i have the radar and sonar set. it said it couldn't find a movie and gave up. so I set the delay to 10 mins. give it time to upload but your comment about so slow has me thinking if that was a good idea

---- Automatically Merged Double Post ----

but it looks like its working

---- Automatically Merged Double Post ----

maybe not PLEX [140372190652160]: File '/unionfs/tv/AFV/Season 29/America's Funniest Home Videos - S29E06 - Work Mishaps, Beach Birds, and Small Animal Scares WEBDL-720p.mkv' did not exist on check 1 of 10, checking again in 60 seconds.

---- Automatically Merged Double Post ----

root@s125638:/home/customer# ls '/mnt/unionfs/tv/AFV/Season 29'
AFV - S29E01 - Winter Blunderland, Prank You Very Much, and #NotTrending WEBDL-720p.mkv AFV - S29E04 - Animal Thieves, Climbing Fails, and Wax Off WEBDL-720p.mkv
AFV - S29E02 - Soccer Fails, Party Fouls, and Doggy Disappearing Acts WEBDL-720p.mkv America's Funniest Home Videos - S29E05 - Costume Catastrophes, Spooky Scares, and Smashing Pumpkins WEBDL-720p.mkv
AFV - S29E03 - Money Mishaps, Hair Cuts Get Hairy, and A New Grandma WEBDL-720p.mkv America's Funniest Home Videos - S29E06 - Work Mishaps, Beach Birds, and Small Animal Scares WEBDL-720p.mkv

root@s125638:/home/customer# sudo tail -f /opt/plex_autoscan/plex_autoscan.log
#########################################################################
2018-11-05 03:10:27,630 - INFO - AUTOSCAN [140372257097472]: Starting server: http://0.0.0.0:3467/pass
2018-11-05 03:22:18,955 - INFO - AUTOSCAN [140372257097472]: Client '198.204.243.242' scan request for series: '/unionfs/tv/AFV/Season 29/America's Funniest Home Videos - S29E06 - Work Mishaps, Beach Birds, and Small Animal Scares WEBDL-720p.mkv', event: 'Download'

---- Automatically Merged Double Post ----

_ __ | | _____ __ __ _ _ _| |_ ___ ___ ___ __ _ _ __
| '_ \| |/ _ \ \/ / / _` | | | | __/ _ \/ __|/ __/ _` | '_ \
| |_) | | __/> < | (_| | |_| | || (_) \__ \ (_| (_| | | | |
| .__/|_|\___/_/\_\ \__,_|\__,_|\__\___/|___/\___\__,_|_| |_|
|_|
#########################################################################
# Author: l3uddz #
# URL: https://github.com/l3uddz/plex_autoscan #
# -- #
# Part of the Cloud project: https://Cloud.works #
#########################################################################
# GNU General Public License v3.0 #
#########################################################################
2018-11-05 04:16:29,258 - INFO - PLEX [140525730244352]: Using Plex Scanner
bash: /usr/lib/plexmediaserver/Plex Media Scanner: No such file or directory
root@s125638:/opt/plex_autoscan#
 
Last edited:

daveftw84

Blitz Samurai
Donor
332
39
I got it,
was making a config.json2 on mistake. there was already an file before downloading your config
 

daveftw84

Blitz Samurai
Donor
332
39
ERROR - PLEX [140692894496512]: Could not loc ate record in media_parts where file = '/unionfs/tv/Orphan Black/Season 2/Orphan Black - S02E10 - By Means Which Have Never Yet Been Tried Bluray-1080p.mkv', 1/

---- Automatically Merged Double Post ----

it was working , now its not. keep getting these
 
Last edited:

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Similar threads