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

Plex library failed determining if using "Stand-Alone Movie Files"-structure #183

Open hoffmann2002 opened 1 year ago

hoffmann2002 commented 1 year ago

Hi,

if a plex target library is not organized in subdirectories and therefore using "Stand-Alone Movie Files"-Structure as described on plex.tv it will not be refreshed.

The changes will be detected, but the trigger will not find the corresponding library.

Dec 21 12:13:45 DBG Retrieved libraries libraries=[{"ID":5,"Name":"Movies","Path":"/srv/data/Movies/Mobile/"},{"ID":5,"Name":"Movies","Path":"/srv/data/Movies/HD/"},{"ID":3,"Name":"Music","Path":"/srv/data/Musik/"}] target=plex url=http://plexserver:32400
Dec 21 12:13:45 INF Initialised targets autoscan=0 emby=0 jellyfin=0 plex=1
Dec 21 12:13:45 INF Initialised version="1.3.0 (5c66ab8@1646220421)"
Dec 21 12:13:45 INF Processor started
Dec 21 12:15:33 INF Scan moved to processor path=/srv/data/Movies/Mobile trigger=inotify
Dec 21 12:16:45 WRN No target libraries found error="/srv/data/Movies/Mobile: failed determining libraries" target=plex url=http://plexserver:32400
hoffmann2002 commented 1 year ago

A possible patch can be the following:

From 42fbfbad008a332a437ac1d49391a8decb0e3f99 Mon Sep 17 00:00:00 2001
From: hoffmann2002
Date: Wed, 21 Dec 2022 17:56:50 +0100
Subject: [PATCH] libraries trailing slashes are irgnored

---
 targets/plex/plex.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/targets/plex/plex.go b/targets/plex/plex.go
index ec526f9..0b0f525 100644
--- a/targets/plex/plex.go
+++ b/targets/plex/plex.go
@@ -110,7 +110,7 @@ func (t target) getScanLibrary(folder string) ([]library, error) {
        libraries := make([]library, 0)

        for _, l := range t.libraries {
-               if strings.HasPrefix(folder, l.Path) {
+               if strings.HasPrefix(folder, strings.TrimSuffix(l.Path,"/")) {
                        libraries = append(libraries, l)
                }
        }
-- 
2.34.1