mynttt / UpdateTool

A tool to update the IMDB ratings for Plex libraries that contain movies/series and use the IMDB agent to receive ratings
GNU General Public License v3.0
250 stars 12 forks source link

Unable to locate database file #81

Closed leepeuker closed 2 years ago

leepeuker commented 2 years ago

Hey, I have a similar issue like reported in https://github.com/mynttt/UpdateTool/issues/77

It worked fine the last time I checked (a few months ago I think), but after updating the image today via docker-compose pull I got the following error:

plex_imdb_updater    | [ERROR] - 2022-01-02 11:20:45 @ SqliteDatabaseProvider.<init>: Unable to locate database file @ /plexdata/Plug-in Support/Databases/com.plexapp.plugins.library.db
plex_imdb_updater    | [ERROR] - 2022-01-02 11:20:45 @ SqliteDatabaseProvider.<init>: Exiting tool... Please check your configured database path...

My docker-compose.yml:

version: "3"

services:
  plex_imdb_updater:
    image: mynttt/updatetool
    container_name: plex_imdb_updater
    environment:
      - USE_PLEX_SQLITE_BINARY_FOR_WRITE_ACCESS=true
      - TMDB_API_KEY=XXX
      - RUN_EVERY_N_HOURS=6
    volumes:
      - /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server:/plexdata
      - /home/XXX/apps/plex-imdb-updater/config:/config

Here the prove that the db files exist at the configured path:

$ find /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server -name "*.db"
/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.dlna.db
/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.blobs.db
/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db
/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.trakttv.db

I have tried adding OVERRIDE_DATABASE_LOCATION=/plexdata/Plug-in Support/Databases like suggested in the other issue, but it does not help.

mynttt commented 2 years ago

Very strange issue. I do not see any other way of debugging this than looking directly into the container. I have added a debug switch for that - just add the environment variable DOCKER_DEBUG_PRINT_TREE_OF_PLEX_PATHS and assign any non-null value to it.

On startup it will show what the two ENV variables are actually set to and also output a result of tree. This should help us sort out what is actually mounted to the docker and set in the environment variables.

leepeuker commented 2 years ago

Hey, thanks for the answer. Here is the output with DOCKER_DEBUG_PRINT_TREE_OF_PLEX_PATHS:

plex_imdb_updater    | *** VERSION 1.6.4 IS UP TO DATE! ***
plex_imdb_updater    | MAX JVM HEAP: -Xmx256m
plex_imdb_updater    | Enabled native Plex SQLite binary for use in write access!
plex_imdb_updater    | Plex data dir (PLEX_DATA_DIR) => /plexdata
plex_imdb_updater    | Printing tree...
plex_imdb_updater    | /plexdata
plex_imdb_updater    | ├── Logs
plex_imdb_updater    | └── Plug-in\ Support
plex_imdb_updater    |     └── Databases
plex_imdb_updater    | 
plex_imdb_updater    | 3 directories, 0 files

I am irritated by that, shouldn't there be more directories and files there if my plex dir was mounted correctly? But if the mounting does not work, why are there 3 directories? 🤔

mynttt commented 2 years ago

@leepeuker That is extremly strange. Could be a permission issue maybe or for some reasone the docker has actual files there and the files you see in the tree are not the mounted ones but the ones that for whatever reason exist in the container?

Maybe you can try this:

a.) Change the bind mount from /plexdata <=> <real path on your system> to /plexdata1 <=> <real path on your system> b.) Set OVERRIDE_DATABASE_LOCATION to /plexdata1/Plug-in Support/Databases and look what happens.

leepeuker commented 2 years ago

Changed docker-compose.yml to

version: "3"

services:
  plex_imdb_updater:
    image: mynttt/updatetool
    container_name: plex_imdb_updater
    environment:
      - USE_PLEX_SQLITE_BINARY_FOR_WRITE_ACCESS=true
      - TMDB_API_KEY=XXX
      - RUN_EVERY_N_HOURS=6
      - OVERRIDE_DATABASE_LOCATION=/plexdata1/Plug-in\ Support/Databases
    volumes:
      - /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server:/plexdata1
      - /home/XXX/apps/plex-imdb-updater/config:/config

got

plex_imdb_updater    | Plex data dir (PLEX_DATA_DIR) => /plexdata
plex_imdb_updater    | Printing tree...
plex_imdb_updater    | /plexdata [error opening dir]
plex_imdb_updater    | 
plex_imdb_updater    | 0 directories, 0 files
plex_imdb_updater    | ===================
plex_imdb_updater    | Override database location will be used to search for DB (OVERRIDE_DATABASE_LOCATION) => /plexdata1/Plug-in\ Support/Databases
plex_imdb_updater    | Printing tree...
plex_imdb_updater    | /plexdata1/Plug-in\ [error opening dir]
plex_imdb_updater    | Support/Databases [error opening dir]

Seems like the debugging has a problem with maybe the white space in the path? 🤔

mynttt commented 2 years ago

How does this fare?

version: "3"

services:
  plex_imdb_updater:
    image: mynttt/updatetool
    container_name: plex_imdb_updater
    environment:
      - USE_PLEX_SQLITE_BINARY_FOR_WRITE_ACCESS=true
      - TMDB_API_KEY=XXX
      - RUN_EVERY_N_HOURS=6
      - OVERRIDE_DATABASE_LOCATION="/plexdata1/Plug-in Support/Databases"
    volumes:
      - /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server:/plexdata1
      - /home/XXX/apps/plex-imdb-updater/config:/config

In your case it looks like it split the space and thought it was supplied two directories (that obviously would not exist).

leepeuker commented 2 years ago

Ah I should have mentioned, I tried that too already because I had the same thought, but same issue:

plex_imdb_updater    | 0 directories, 0 files
plex_imdb_updater    | ===================
plex_imdb_updater    | Override database location will be used to search for DB (OVERRIDE_DATABASE_LOCATION) => "/plexdata1/Plug-in Support/Databases"
plex_imdb_updater    | Printing tree...
plex_imdb_updater    | "/plexdata1/Plug-in [error opening dir]
plex_imdb_updater    | Support/Databases" [error opening dir]

maybe there is some issue in the debugging code if the path contains white spaces?

mynttt commented 2 years ago

Yeah that's the issue lol. Seems like I forgot to add them there. I'm going to push a new container later on and notify you here.

mynttt commented 2 years ago

Docker with quotes is live! @leepeuker

leepeuker commented 2 years ago

Okay now I am getting an error

plex_imdb_updater    | 0 directories, 0 files
plex_imdb_updater    | ===================
plex_imdb_updater    | Override database location will be used to search for DB (OVERRIDE_DATABASE_LOCATION) => "/plexdata1/Plug-in Support/Databases"
plex_imdb_updater    | Printing tree...
plex_imdb_updater    | "/plexdata1/Plug-in Support/Databases" [error opening dir]

Is there a way to find out what caused the error?

mynttt commented 2 years ago

@leepeuker It looks like the enviroment variable OVERRIDE_DATABASE_LOCATION somehow has the "" in it as seen in the output.

Previously: (OVERRIDE_DATABASE_LOCATION) => /plexdata1/Plug-in\ Support/Databases Now: (OVERRIDE_DATABASE_LOCATION) => "/plexdata1/Plug-in Support/Databases"

Edit: https://stackoverflow.com/questions/46141148/declare-env-variable-which-value-include-space-for-docker-docker-compose/46141244#46141244

Declare it like this in compose: - OVERRIDE_DATABASE_LOCATION=/plexdata1/Plug-in Support/Databases - spaces are legal apperantly.

leepeuker commented 2 years ago

ah good point:

plex_imdb_updater    | 0 directories, 0 files
plex_imdb_updater    | ===================
plex_imdb_updater    | Override database location will be used to search for DB (OVERRIDE_DATABASE_LOCATION) => /plexdata1/Plug-in\ Support/Databases
plex_imdb_updater    | Printing tree...
plex_imdb_updater    | /plexdata1/Plug-in\ Support/Databases

Seems like it now found the directory, but it seems to be empty :(

mynttt commented 2 years ago

Very strange. What happens when you start the docker with the docker CLI (if possible)?

You can modify this command template to your requirements:

docker run -it -e RUN_EVERY_N_HOURS=12 \
    -e TMDB_API_KEY=yourkey \
    -e TVDB_API_KEY=tvdbapikey \
    -v "/mnt/data/Plex Media Server":/plexdata \
    -v "/mnt/data/imdpupdaterconfig":/config \
    mynttt/updatetool

Edit: Removed the detached flag so you should see immediatly on the console what happens and CTRL+C should kill it.

leepeuker commented 2 years ago

Hm, very interesting. It seems to work with docker run 🤯

docker run -it \
    -e USE_PLEX_SQLITE_BINARY_FOR_WRITE_ACCESS=true \
    -e TMDB_API_KEY=XXX\
    -e RUN_EVERY_N_HOURS=6 \
    -e UNLOCK_FOR_NEW_TV_AGENT="X" \
    -v /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server:/plexdata \
    -v /home/XX/apps/plex-imdb-updater/config:/config \
    mynttt/updatetool

I don't get it, is the same envs and volume mappings I use in the docker-compose.yml 🤔 I will investigate that further, if I should find the reason why docker-compose does not work I will update this thread.

Anyways, thank you so much for your time and your help! I am really happy to get updated imdb ratings again 🥳

leepeuker commented 2 years ago

omg I found it. the issue was the backslashes before the whitespaces in

- /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server:/plexdata

after removing them it works (like you mentioned here https://github.com/mynttt/UpdateTool/issues/81#issuecomment-1014903247).

I could swear I tried that multiple times and it did not help, but I guess I either fucked up in another way or just plainly did not do it and remember wrongly 😖

Anyway, thanks for your time again

mynttt commented 2 years ago

Glad it works now! Yeah the docker compose configuration with the spaces is very unintuitive because it deviates from basically everything we now about Linux systems and environment variables 😂