Kometa-Team / ImageMaid

Python 3 Script for Cleaning Up Images in Plex
MIT License
279 stars 16 forks source link

I'm getting the error Directory Error: Plex Databases Directory Not Found #16

Closed ChristianMalazarte closed 9 months ago

ChristianMalazarte commented 1 year ago

Version Number

1.0.0

What branch are you on?

master

Describe the Bug

Directory Error: Plex Databases Directory Not Found: /var/lib/plexmediaserver/Library/Application Support/Plex Media Server

MODE=nothing TIMEOUT=600 SLEEP=60 IGNORE_RUNNING=True LOCAL_DB=False USE_EXISTING=False PHOTO_TRANSCODER=False EMPTY_TRASH=False CLEAN_BUNDLES=True OPTIMIZE_DB=True TRACE=False LOG_REQUESTS=False

Logs

No response

aibradford commented 1 year ago

I have the same issue. Its definitely set correctly, but it still tells me the database is missing.

2023-07-26 17:40:00 plex-image-cleanup | | Generic Criticals: | 2023-07-26 17:40:00 plex-image-cleanup | | Directory Error: Plex Databases Directory Not Found: /Users/MYUSERNAME/Library/Application Support/Plex Media Server |

Iyagovos commented 1 year ago

Also now encountering this issue!

dirkhm commented 1 year ago

Same here.

meisnate12 commented 1 year ago

can someone try using develop

BLINGXIN commented 1 year ago

can someone try using develop

aibradford commented 1 year ago

I installed develop branch, and im still receiving the same error.

Directory Error: Plex Directory Not Found: /~/Library/Application Support/Plex Media Server I also tried /Users/MYUSERNAME/LIbrary/Application Support/Plex Media Server

same result both times.

Animosity022 commented 1 year ago

The trick for me was making sure I put the .env file is the right place. I didn't have it in the config directory at first and got the error. Once I moved it to config and ensured it was named ".env", all worked great.

ildise commented 11 months ago

I had the same problem using docker and the solution for me was change PLEX_PATH=/plex in the .env file. Using the docker command provided in the instructions (changing configuration paths with mine as described), the docker image mounts local "config" dir with the .env file in "/config" inside the docker and the same goes for thr Plex local path, mounted in "/plex".

Since the .env file is used by the python script which is run inside the docker, it only sees the "mounted" path "/plex" not the whole local path on the server. After that everything worked like a charm.

I hope I explained it in a comprehensible way.

**I forgoto to say referring to the first post where I saw "MODE=nothing" I used MODE=report instead thus to get the report without changing anything until you're sure it's working correctly!

ctml91 commented 11 months ago

EDIT UPDATE: apparently it doesn't like backslashes on the unix path with spaces, after changing the .env file plex path to include quotes around the path it now works.

Non-working PLEX_PATH=/plex/Library/Application\ Support/Plex\ Media\ Server Working PLEX_PATH="/plex/Library/Application Support/Plex Media Server"

Thankful for the disk space back :)

|====================================================================================================|
|                                   Remove PhotoTranscoder Images                                    |
|           Dir: /plex/Library/Application Support/Plex Media Server/Cache/PhotoTranscoder           |
|====================================================================================================|
| Scanning for PhotoTranscoder Images                                                                |
| Scanning for PhotoTranscoder Images: 1349179 images [00:08, 150366.13 images/s]
| Scanning Complete: Found 1349179 PhotoTranscoder Images to Remove                                  |
| Runtime: 0:00:08                                                                                   |
|                                                                                                    |
| Removing PhotoTranscoder Images                                                                    |
| Removing PhotoTranscoder Images: 100%|█████████████████████████████████████████████████████████████| 1349179/1349179 [02:12<00:00, 10207.55 removed/s]
| Remove Complete: Removed 1349179 PhotoTranscoder Images                                            |
| Space Recovered: 240.09 GBs                                                                        |
| Runtime: 0:02:12

Same here. I'm a little confused by the instructions as it says

Download From Plex API By default, the script will expect to connect to your Plex Server to download the Database using your Plex URL and Plex Token Options

So with the URL and token provided, shouldn't it be fetching the DB using the API instead of looking for a local copy? Is there something in the script that doesn't like unix paths or something, I dont understand why its working for some and not others?

Here are the contents of the docker volume containing my plex library mounted at /plex /plex/Library/Application\ Support/Plex Media Server/

drwxr-xr-x.   3 user user  36K Nov  7 21:37 Logs
drwxr-xr-x.   9 user user  20K Nov  7 21:09 Cache
-rw-------.   1 user user 2.6K Nov  6 11:10 Preferences.xml
-rw-------.   1 user user  13K Nov  4 12:10 Setup Plex.html
drwxr-xr-x. 177 user user  12K Nov  4 12:09 Crash Reports
-rw-r--r--.   1 user user    3 Nov  4 12:09 plexmediaserver.pid
drwxr-xr-x.   4 user user 4.0K Oct  8 14:45 Codecs
-rw-------.   1 user user    0 Jul 15 17:54 Preferences.xml.tmp.2d7ef141-0981-48b6-b958-287ef59125af
-rw-------.   1 user user    0 Jul 15 17:54 Preferences.xml.tmp.de2bd471-d854-4d58-8b0c-c91e7c9f87ab
-rw-------.   1 user user    0 Jul 15 17:54 Preferences.xml.tmp.22dbd4e1-b5bc-423f-ba36-87466aa7868f
-rw-------.   1 user user    0 Jul 15 17:54 Preferences.xml.tmp.2b6d43c0-c935-465d-b40c-6d9d571c10d0
drwxr-xr-x.   3 user user 4.0K Feb 22  2023 Scanners
-rw-------.   1 user user    0 Jan 20  2023 Preferences.xml.tmp.3bd36661-1f63-4e6d-bb6b-0958f66bbee6
-rw-------.   1 user user    0 Jan 20  2023 Preferences.xml.tmp.ec12e1b3-a076-4b2c-865b-e5b14dbe241f
-rw-------.   1 user user    0 Jan 20  2023 Preferences.xml.tmp.a9aede59-3c93-4cc1-9a91-784d2fc88eee
-rw-------.   1 user user    0 Jan 20  2023 Preferences.xml.tmp.b8c6e713-04b3-4330-9eef-f370ca787359
drwxr-xr-x.   8 user user 4.0K Dec 20  2022 Metadata
drwxr-xr-x.   2 user user 4.0K Oct 30  2022 Updates
drwxr-xr-x.   2 user user 4.0K Oct 30  2022 Drivers
-rw-r--r--.   1 user user 2.5K Aug 24  2022 Preferences.xml.bkp
-rw-r--r--.   1 user user    0 Apr 26  2021 Preferences.xml.tmp.09a81854-4b5e-41fa-9757-66aebc3df6c5
-rw-r--r--.   1 user user    0 Apr 26  2021 Preferences.xml.tmp.1c9caf46-7de6-40a3-b751-f22c07dcb4b9
drwxr-xr-x.   8 user user 4.0K Jul  4  2019 Plug-ins
drwxr-xr-x.   2 user user 4.0K May 10  2018 Diagnostics
drwxr-xr-x.   3 user user 4.0K May 16  2015 Thumbnails
drwxr-xr-x.   3 user user 4.0K Jan  2  2015 Media
drwxr-xr-x.   7 user user 4.0K Jan  2  2015 Plug-in Support

And the Plug-in Support directory contains the Databases folder I am assuming it is searching for (but again shouldn't it be using the plex URL + token? /plex/Library/Application\ Support/Plex Media Server/Plug-in Support

total 20K
drwxr-xr-x.  2 user user 4.0K Nov  6 21:00 Databases
drwxr-xr-x.  2 user user 4.0K Dec 24  2020 Preferences
drwxr-xr-x. 24 user user 4.0K Dec  9  2020 Caches
drwxr-xr-x. 24 user user 4.0K Dec  9  2020 Data
drwxr-xr-x. 11 user user 4.0K Oct  4  2019 Metadata Combination

Config

|     Version: 1.0.0 (Docker)                                                                        |
|     Platform: Linux-6.4.15-200.fc38.x86_64-x86_64-with-glibc2.28                                   |
|     Memory: 8 GB                                                                                   |
|====================================================================================================|
| Run Command: plex_image_cleanup.py                                                                 |
| --plex (PLEX_PATH): /plex/Library/Application\ Support/Plex\ Media\ Server/                        |
| --mode (MODE): report                                                                              |
| --schedule (SCHEDULE):                                                                             |
| --url (PLEX_URL): (redacted)                                                                       |
| --token (PLEX_TOKEN): (redacted)                                                                   |
| --discord (DISCORD): None                                                                          |
| --timeout (TIMEOUT): 600                                                                           |
| --sleep (SLEEP): 60                                                                                |
| --ignore (IGNORE_RUNNING): False                                                                   |
| --local (LOCAL_DB): False                                                                          |
| --existing (USE_EXISTING): False                                                                   |
| --photo-transcoder (PHOTO_TRANSCODER): False                                                       |
| --empty-trash (EMPTY_TRASH): False                                                                 |
| --clean-bundles (CLEAN_BUNDLES): False                                                             |
| --optimize-db (OPTIMIZE_DB): False                                                                 |
| --trace (TRACE): False                                                                             |
| --log-requests (LOG_REQUESTS): False
Jacob-Lasky commented 10 months ago

I was having the same problem with Docker in UnRAID.

What I had to do was put set the PLEX_PATH container variable to something (I set it to /plex) image

And then I had to set a new Path variable. In my case, the Container Path is /plex and the Host Path is /mnt/user/appdata/plex/Library/Application Support/Plex Media Server/. image image

TopperBG commented 10 months ago

Write the Plex path in double quotes, I'm not familiar with UnRAID but guess same dpendancy as Docker

"/plex/Library/Application Support/Plex Media Server"

ratounade commented 6 months ago

Hi guys, I am still struggling on configuring https://github.com/meisnate12/Plex-Image-Cleanup. I have my Plex on a WD NAS; it appears that PlexMediaServer is on '/mnt/HD/HD_a2/Nas_Prog/plex_conf/Plex Media Server/'

But when I set PLEX_PATH="/mnt/HD/HD_a2/Nas_Prog/plex_conf/Plex Media Server/" I obtain an error : "Directory Error: Plex Databases Directory Not Found: C:\mnt\HD\HD_a2\Nas_Prog\plex_conf\Plex Media Server"

NB : I launch my cleaning script from windows I would appreciate your help ! thx 😩

ildise commented 6 months ago

Hi, ratounade. I do not use Windows with a Nas, I have a Ubuntu server with Plex and Docker installed on it so I can't say for sure but since you are launching the app from Windows, the "path" to plex installation should be as "seen" from your windows machine.

I mean that I don't think you can see the plex folder from windows using "/mnt/HD/HD_a2/Nas_Prog/plex_conf/Plex Media Server/" I think it should be somehnig like "\nas-name_or_ip\shared folder\to\Plex Media Server" otherwise the script can't reach the db files to analyze.

If you can't share that folder from your nas to be reachable from your windows machine, I think the only way is the one described in the instructions using the "token" and access Plex server from its "public" address and port.

I hope this can be useful to you.

ratounade commented 6 months ago

Hi @ildise thank you for your help. I found a solution : I have installed both WinFsp and SSHFS-Win allowing to map via SSHFS on Windows "E:" to my NAS "/mnt/HD/HD_a2/Nas_Prog/plex_conf/Plex Media Server/" then it became a piece of cake to put "E:" in the .env file