Cloudbox / autoscan

Autoscan replaces the default Plex and Emby behaviour for picking up changes on the file system.
MIT License
594 stars 49 forks source link

Flattened directory structure results in file paths incorrectly being sent to Plex #199

Closed Hunsu closed 6 months ago

Hunsu commented 1 year ago

When adding a new file in a library's folder, autoscan is calling plex with the path of that file. But plex only support paths to folders. Autoscan should send the file folder in the refresh request.

Did I miss some configuration ?

robson90 commented 10 months ago

Can you pls show your log output ?

Mine is something like this: `Aug 17 07:38:35 INF Scan moved to processor event=Download id=cjessutgmqks3ktkh23g method=POST path="/mnt/unionfs/series// S07" url=/triggers/sonarr

Aug 17 07:40:56 INF Scan stats processed=178 remaining=1

Aug 17 07:41:40 INF Scan moved to target library=TV-Serien path="/series// S07" target=plex url=`

Hunsu commented 10 months ago

Your case works because you are passing a subfolder of your library folder. For tv shows it works for me. But I don't create folders for each movie I add so when passing '/mnt/plex/Movies/my.new.movie.mkv' I got that error. I will post logs later.

Hunsu commented 10 months ago
Aug 19 08:22:08 INF Initialised processor anchors=[] min_age=4s
Aug 19 08:22:08 WRN Webhooks running without authentication
Aug 19 08:22:08 INF Initialised triggers bernard=0 inotify=1 lidarr=0 manual=1 radarr=0 readarr=0 sonarr=0
Aug 19 08:22:08 INF Starting server on :3030
    Aug 19 08:22:08 INF Initialised targets autoscan=0 emby=0 jellyfin=0 plex=1
Aug 19 08:22:08 INF Initialised version=" (@)"
Aug 19 08:22:08 INF Processor started
    Aug 19 08:22:38 INF Scan moved to processor id=cjg5vbnr4stptbm1rvc0 method=POST path="/mnt/plex/Anime/XXX/Season 0/XXXX.avi" url=/triggers/manual?dir=%2mnt%2Fplex%2FAnime%2FXXX%2FSeason+0%2FXXX.avi
Aug 19 08:22:53 INF Scan moved to target library=Anime path="/mnt/plex/Anime/XXX/Season 0/XXXX.avi" target=plex url=http://localhost:32400

Aug 19, 2023 08:22:53.480 [139936283015992] INFO - Request: [127.0.0.1:39356 (Loopback)] PUT /library/sections/2/refresh?path=%2mnt%2Fplex%2FAnime%2FXXX%2FSeason+0%2FXXX.avi (3 live) #2b69 GZIP Signed-in Token (XXX) (XXX)
Aug 19, 2023 08:22:53.524 [139936361360184] INFO - Completed: [127.0.0.1:39356] 200 PUT /library/sections/2/refresh?path=%2mnt%2Fplex%2FAnime%2FXXX%2FSeason+0%2FXXX.avi (3 live) #2b69 GZIP 44ms 195 bytes (pipelined: 1)
Aug 19, 2023 08:22:53.973 [139936331348792] ERROR - Failed to create iterator to "/mnt/plex/Anime/XXX/Season 0/XXXX.avi": Not a directory
robson90 commented 10 months ago

I See. Im sorry I don't know if your use case should work with autoscan.

The only thing I can do is providing my config.

triggers:
  inotify:
    - priority: 0

      # filter with regular expressions
      include:
        - ^/mnt/unionfs/

      # rewrite inotify path to unified filesystem
      rewrite:
            - from: ^/data/
              to: /mnt/unionfs/

      # local filesystem paths to monitor
      paths:
        - path: /mnt/unionfs/filme
        - path: /mnt/unionfs/filme4
        - path: /mnt/unionfs/series
        - path: /mnt/unionfs/series4

  radarr:
    - name: radarr   # /triggers/radarr
      rewrite: 
        - from: /data/#3_Filme
          to: /mnt/unionfs/filme

targets:
  plex:
    - url: <URL> # URL of your Plex server
      token: <TOKE> # Plex API Token
      rewrite:
        - from: /mnt/unionfs/filme # local file system
          to: /filme # path accessible by the Plex docker container (if applicable)
        - from: /mnt/unionfs/filme4
          to: /filme4

I started with arr´s and then switched to inotify, because it listens on Drive activity and changes. Works for me flawlessly.

Bryzgalin commented 6 months ago

It seems this is fixed in this fork Allow root folders to be refreshed

m-rots commented 6 months ago

TLDR: When files are located directly in the library folder, scans do not succeed as Autoscan does not support scanning entire libraries. E.g. a library with path /mnt/unionfs/Movies results in /mnt/unionfs/Movies/movie.mp4 not being scanned, as Autoscan sends /mnt/unionfs/Movies/movie.mp4 instead of /mnt/unionfs/Movies.

This issue will not be fixed as one of Autoscan's core tenets is to make scanning more efficient. However, a flattened directory structure will always result in a full rescan, which in fact does not make things more efficient. Thus the two are incompatible.