l3uddz / plex_autoscan

Script to assist sonarr/radarr with plex imports. Will only scan the folder that has been imported, instead of the whole library section.
GNU General Public License v3.0
396 stars 70 forks source link

How to send seriesID while using Manual processing #122

Closed Iguana9999phil closed 4 years ago

Iguana9999phil commented 4 years ago

I’m using Plex autoscan with the “Fix mismatch” feature which works great. Sometimes I use an manual trigger to Plex autoscan to let it scan a whole Serie directory etc using curl. I’m sending a minimal json with only the path variable '{ "path": "'"$FILE"'" }' is it also possible to add serieID (and maybe other info out of sonarr / radarr) to the json so manual will also do a fix mismatch check?

desimaniac commented 4 years ago

Pasted examples of the items you'll need in your json request for the PLEX_FIX_MISMATCHED feature to work.

You'll need to use Download for eventType (vs manual). The path fields are different with this, see below.

Note: Every item listed below is needed (eg. title, path, relative path, etc).

Episodes:

{
   "episodeFile":{
      "relativePath":"Season 02/God.Friended.Me.2018.S02E06.1080p.WEB.x264-TBS.mkv"
   },
   "eventType":"Download",
   "isUpgrade":false,
   "series":{
      "path":"/mnt/unionfs/Media/TV/God Friended Me (2018)",
      "title":"God Friended Me",
      "tvdbId":349684
   }
}

Movies:

For movies, youll need either TMDb ID or IMDb ID. If you have both, IMDb ID will be preferred.

{
    "eventType": "Download",
    "isUpgrade": false,
    "movie": {
        "folderPath": "/mnt/unionfs/Media/Movies/Angels Crest (2011)"
    },
    "movieFile": {
        "relativePath": "Angels.Crest.2011.720p.BluRay.x264-CRISC.mkv"
    },
    "remoteMovie": {
        "imdbId": "tt1559040",
        "title": "Angels Crest",
        "tmdbId": 77957
    }
}
Iguana9999phil commented 4 years ago

Perfect! Just had a quick test and works as expected. Thanks!

thomaspriv commented 4 years ago

When posting the below json request to my webhook I see the following log outputs.

JSON

{
   "episodeFile":{
      "relativePath":""
   },
   "eventType":"Download",
   "isUpgrade":false,
   "series":{
      "path":"/mnt/NAS/media/Series/Suits",
      "title":"Suits",
      "tvdbId":247808
   }
}

journalctl output

Nov 08 09:51:32 hyperion scan.py[10846]:  2019-11-08 09:51:32,051 -     INFO -  AUTOSCAN [140465117652800]: Client '192.168.1.155' scan request for series: '/mnt/NAS/media/Series/Suits/', event: 'Download'
Nov 08 09:51:32 hyperion scan.py[10846]:  2019-11-08 09:51:32,067 -     INFO -  AUTOSCAN [140465117652800]: Added '/mnt/NAS/media/Series/Suits/' to database.
Nov 08 09:51:32 hyperion scan.py[10846]:  2019-11-08 09:51:32,067 -     INFO -  AUTOSCAN [140465117652800]: Proceeding with scan...
Nov 08 09:51:32 hyperion scan.py[10846]:  2019-11-08 09:51:32,067 -     INFO -      PLEX [140465076201216]: Scan request from Sonarr for '/mnt/NAS/media/Series/Suits/'.
Nov 08 09:51:32 hyperion scan.py[10846]:  2019-11-08 09:51:32,067 -     INFO -      PLEX [140465076201216]: Sleeping for 180 seconds...
Nov 08 09:54:32 hyperion scan.py[10846]:  2019-11-08 09:54:32,167 -     INFO -      PLEX [140465076201216]: File '/mnt/NAS/media/Series/Suits/' exists on check 1 of 10.
Nov 08 09:54:32 hyperion scan.py[10846]:  2019-11-08 09:54:32,168 -     INFO -      PLEX [140465076201216]: Scan request is now being processed...
Nov 08 09:54:32 hyperion scan.py[10846]:  2019-11-08 09:54:32,180 -     INFO -      PLEX [140465076201216]: No 'Plex Media Scanner' processes were found.
Nov 08 09:54:32 hyperion scan.py[10846]:  2019-11-08 09:54:32,180 -     INFO -      PLEX [140465076201216]: Running Plex Media Scanner for: /mnt/NAS/media/Series/Suits/
Nov 08 09:54:32 hyperion sudo[30453]: plex_autoscan : TTY=unknown ; PWD=/opt/plex_autoscan ; USER=plex ; COMMAND=/bin/bash -c export LD_LIBRARY_PATH=/usr/lib/plexmediaserver/lib;export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/var/lib/plexmediaserver/Library/Application\ Support;/usr/lib/plexmediaserver/Plex\ Media\ Scanner --scan --refresh --section 2 --directory /mnt/NAS/media/Series/Suits/
Nov 08 09:54:32 hyperion sudo[30453]: pam_unix(sudo:session): session opened for user plex by (uid=0)
Nov 08 09:54:32 hyperion sudo[30453]: pam_unix(sudo:session): session closed for user plex
Nov 08 09:54:32 hyperion scan.py[10846]:  2019-11-08 09:54:32,493 -     INFO -      PLEX [140465076201216]: Finished scan!
Nov 08 09:54:33 hyperion scan.py[10846]:  2019-11-08 09:54:33,500 -     INFO -      PLEX [140465076201216]: There are 0 queued items remaining.

But in Plex I don't see the correct matched series and nothing seems to be happening. Can you tell me what I am doing wrong?

Thanks in advance.

desimaniac commented 4 years ago

Pretty sure it needed to send the episode file on the request not only the parent folder. When it splits it, it will split the other files as well.

Iguana9999phil commented 4 years ago

Other question related to my first. As Plex autoscan can verify against the Plex database is it possible to let it also check if a scan request is already available in Plex? I'm using the manual feature to do an interval scan on my server. Every couple of hours it indexes the newly added media and send a manual scan for newly added to Plex. This makes Plex scan every file in the list while most are available already. If Plex autoscan is able to verify first before letting Plex scan it would lower I/O considerable. I understand this is an edge case though but curious if it would be possible.

desimaniac commented 4 years ago

Plex Media Scanner will go through stuff you already have quickly and skip over them.

However, You should be sending specific file requests to PAS, so that PAS in-turn tells Plex Media Scanner to scan the parent folder, which would ideally be the season folder if you are using standard folder structure, and not sending the series folder (eg .../Suits/) in the request.

We use Plex Media Scanner to do folder scans. Not specific file ones.

Sent with GitHawk

Iguana9999phil commented 4 years ago

So would it make a difference if I send a manual request to PAS for the season folder or the specific episode? As Plex scans the season folder regardless.

desimaniac commented 4 years ago

It uses the specific episode for the mismatch checking.

Sent with GitHawk