Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot download trailers.. permission denied #17

Closed
elvis0288 opened this issue Aug 7, 2024 · 34 comments · Fixed by #18
Closed

cannot download trailers.. permission denied #17

elvis0288 opened this issue Aug 7, 2024 · 34 comments · Fixed by #18
Labels
bug Something isn't working good first issue Good for newcomers question Further information is requested

Comments

@elvis0288
Copy link

i have check my permissions on unraid and those folders are set to nobody and read and write for everybody but still i am getting that error.. not sure why.. maybe the fact i am using PUID 1000 and PGID 100 instead of default on radarr is affecting something?

i will add the logs and also my radarr and trailarr config

LOGS:
`2024-08-07T08:59:59-0500 [INFO|main|L085]: Main: Client #505025 connected!

2024-08-07T08:59:59-0500 [INFO|main|L093]: Main: Client #204356 disconnected!

PermissionError: [Errno 13] Permission denied: '/movies'

File "", line 225, in makedirs

File "", line 215, in makedirs

File "", line 215, in makedirs

os.makedirs(trailer_path)

File "/app/backend/core/download/trailer.py", line 137, in download_trailer

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

if download_trailer(media, trailer_folder, is_movie):

File "/app/backend/core/download/trailer.py", line 230, in download_trailers

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

downloaded_media = download_trailers(media_trailer_list, is_movie)

File "/app/backend/core/tasks/download_trailers.py", line 60, in _download_missing_media_trailers

_download_missing_media_trailers(is_movie=True)

File "/app/backend/core/tasks/download_trailers.py", line 84, in download_missing_trailers

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

retval = job.func(*job.args, **job.kwargs)

File "/usr/local/lib/python3.12/site-packages/apscheduler/executors/base.py", line 125, in run_job

Traceback (most recent call last):

2024-08-07T08:59:57-0500 [ERROR|base|L131]: Job "Download Missing Trailers (trigger: interval[1:00:00], next run at: 2024-08-07 09:59:36 CDT)" raised an exception

2024-08-07T08:59:36-0500 [INFO|trailer|L229]: Downloading trailer for '[1]The Lion King'...`

RADARR:
image

TRAILARR:
image

@nandyalu
Copy link
Owner

nandyalu commented Aug 7, 2024

  1. Did you enable Trailer Folder Movie in settings?
  2. Radarr sometimes changes folder permissions on Movie folders. Post the permissions of Movie folder by running ls -all in your unraid.
  3. Post the permissions of Movie folder by running ls -all within Trailarr container.

@elvis0288
Copy link
Author

  1. no, i did not enable trailer folder movie in settings as you suggested me for jellyfin.
  2. you might be right.. it is using the 1000 PUID
    image
  3. can i change the appuser for elvis0288 in the trailarr? would that work?
    image

@nandyalu
Copy link
Owner

nandyalu commented Aug 7, 2024

Not sure if Unraid supports this at the moment, but there is an option to set custom PUID and PGID for the app. I would suggest you to set them to the same as what you are using for Radarr and Sonarr

@nandyalu
Copy link
Owner

nandyalu commented Aug 7, 2024

you can also set APPUSER to desired user.

Environment Variables to set:

- APPUSER:appuser #change to desired username you like
- PUID:1000 #default is 1000, change as needed
- PGID:1000 #default is 1000, change as needed

@elvis0288
Copy link
Author

when doing your suggestion, i am getting this

image

@elvis0288
Copy link
Author

elvis0288 commented Aug 7, 2024

if i use 1000 and 1000 it runs but i still get the error message
image
so difference now is the second elvis0288 should be 1000?

@nandyalu
Copy link
Owner

nandyalu commented Aug 7, 2024

there is a bug with current implementation of PUID/PGID and APPUSER. If a user/group with PUID/PGID already exists, it would fail. I am working on a fix.

Also, APPUSER will be removed as it doesn't have any effect inside the container, so will use PUID/PGID instead within the container.

@elvis0288
Copy link
Author

thank you, so i will remove appuser from the template and leave 1000 and 100 and i guess after your fix 100 should not fail?

thanks!

@nandyalu nandyalu linked a pull request Aug 8, 2024 that will close this issue
@elvis0288
Copy link
Author

after latest update this is the result
image
still giving me permission denied even though i am using 1000 and 100 like i do in radarr.. i guess it should be elvis0288 and 1000
image

@nandyalu
Copy link
Owner

nandyalu commented Aug 8, 2024

I removed APPUSER so it always uses the name as appuser but adds it with supplied PUID and checks if group with PGID already exists, if so adds it to that group, otherwise creates new group with PGID

Check your user PUID by running getent psswd username and set the PUID with that and PGID to 1000

@elvis0288
Copy link
Author

so that is what i did on the template
image
this is what i got back
elvis0288:x:1000:100:main user:/:/bin/false

but still i got this
image

and

2024-08-07T18:52:42-0500 [INFO|trailer|L215]: Downloading trailers for 498 movies
2024-08-07T18:52:42-0500 [INFO|trailer|L229]: Downloading trailer for '[1]The Lion King'...
ERROR: Job "Download Missing Trailers (trigger: interval[1:00:00], next run at: 2024-08-07 19:52:42 CDT)" raised an exception
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/apscheduler/executors/base.py", line 125, in run_job
retval = job.func(*job.args, **job.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/backend/core/tasks/download_trailers.py", line 84, in download_missing_trailers
_download_missing_media_trailers(is_movie=True)
File "/app/backend/core/tasks/download_trailers.py", line 60, in _download_missing_media_trailers
downloaded_media = download_trailers(media_trailer_list, is_movie)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/backend/core/download/trailer.py", line 230, in download_trailers
if download_trailer(media, trailer_folder, is_movie):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/backend/core/download/trailer.py", line 137, in download_trailer
os.makedirs(trailer_path)
File "", line 215, in makedirs
File "", line 215, in makedirs
File "", line 225, in makedirs
PermissionError: [Errno 13] Permission denied: '/movies'
2024-08-07T18:53:02-0500 [ERROR|base|L131]: Job "Download Missing Trailers (trigger: interval[1:00:00], next run at: 2024-08-07 19:52:42 CDT)" raised an exception
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/apscheduler/executors/base.py", line 125, in run_job
retval = job.func(*job.args, **job.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/backend/core/tasks/download_trailers.py", line 84, in download_missing_trailers
_download_missing_media_trailers(is_movie=True)
File "/app/backend/core/tasks/download_trailers.py", line 60, in _download_missing_media_trailers
downloaded_media = download_trailers(media_trailer_list, is_movie)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/backend/core/download/trailer.py", line 230, in download_trailers
if download_trailer(media, trailer_folder, is_movie):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/backend/core/download/trailer.py", line 137, in download_trailer
os.makedirs(trailer_path)
File "", line 215, in makedirs
File "", line 215, in makedirs
File "", line 225, in makedirs
PermissionError: [Errno 13] Permission denied: '/movies'

@nandyalu
Copy link
Owner

nandyalu commented Aug 8, 2024

You have a permissions problem.

Try running this command (probably as sudo):

cat /etc/passwd

PUID and PGID are the numbers in output. Refer this for help.

Then check the PUID and PGID for the /movies and /tvshows folders, apply those to Trailarr app.

@elvis0288
Copy link
Author

well but i do not understand i am using the same PUID and PGID than radarr and sonarr the difference is that when trailarr runs, in the logs it shows that it is actually trying to create a user 'appuser' instead of elvis0288 which is PUID 1000. so at the end the docker folders will have appuser appuser instead of elvis0288 1000

Creating '/data' folder for storing database and other config files
Group with GID '100' already exists, using group 'users'
Creating user 'appuser' with UID '1000'
Changing the owner of app and data directories to 'appuser'
Switching to user 'appuser' and starting the application
Running application as user: appuser

@morpheus302
Copy link

Same error on unraid here. tried PUID 99 PGID 100 1000/1000 99/100
cat /etc/passwd
nobody:x:99:100:nobody:/:/bin/false
ls -all
drwxrwxrwx 1 nobody users 62 Aug 7 2021 ./
drwxrwxrwx 1 nobody users 89 Oct 1 2023 ../
drwxrwxrwx 1 nobody users 34 May 1 2022 Docs/
drwxr-xr-x 1 nobody users 29 Sep 10 2022 HB_output/
drwxr-xr-x 1 nobody users 4096 Aug 3 13:37 Movies/
drwxrwxrwx 1 nobody users 76 Aug 29 2021 Music/
drwxr-xr-x 1 nobody users 4096 Jul 21 23:17 Shows/
drwxrwxrwx 1 nobody users 67 Feb 6 2024 books/
drwxrwxrwx 1 nobody users 6 Aug 7 2021 podcasts/

@nandyalu
Copy link
Owner

nandyalu commented Aug 8, 2024

A quick google search for unraid docker permissions issue revealed that there are issues with unraid and docker container permissions.

Looks like a solution is to set PUID to 99 (which is for user nobody) and PGID to 100 (for group users) (taken from this comment

@elvis0288 @morpheus302 Can you try using these and report back if it works?

@nandyalu
Copy link
Owner

nandyalu commented Aug 8, 2024

For the container using 'appdata' user, that is the default, but it's just how containers work. However, the user name and group name doesn't matter, it's the PUID and PGID that matters. And app will set those to the supplied PUID/PGID so it should work. It's working on other systems (I tried on Ubuntu 22.04)

@nandyalu nandyalu added the bug Something isn't working label Aug 8, 2024
@elvis0288
Copy link
Author

using 99:100 i get the following on the logs
image
and it will still failed with the permissions

@elvis0288
Copy link
Author

i went into sonarr and radarr and use exactly what i have in those which is
image
image
they also have umask but i am not sure if it is needed for trailarr. but that exact same PGID and PUID is what i have on trailarr but it does not work

@nandyalu
Copy link
Owner

nandyalu commented Aug 8, 2024

I understand that Radarr has PGID set to 1000. But can you try setting it as 100 for Trailarr and see if it works?

@elvis0288
Copy link
Author

i did try 100 as PUID but i am getting the same issue
image

@nandyalu
Copy link
Owner

nandyalu commented Aug 8, 2024

Looks like appuser is created with PUID/PGID as 100/100. Please try PUID=99 and PGID=100 and check if you are still getting permission related errors when trying to download a trailer?

@elvis0288
Copy link
Author

elvis0288 commented Aug 8, 2024

Yes, still getting permission denied
image
image

@elvis0288
Copy link
Author

elvis0288 commented Aug 8, 2024

something i would like to point out and not sure if it even matter is that inside the movies folder i have 3 other folders. all of them with same permissions. tried doing /movies/movies but same result

drwxr-xr-x 1 nobody users 20480 Aug 2 10:53 movies/
drwxr-xr-x 1 nobody users 4096 Aug 6 09:02 movies_animated/
drwxr-xr-x 1 nobody users 10 Jun 5 08:37 movies_requested/

and inside is where the movies from radarr are located

@nandyalu
Copy link
Owner

nandyalu commented Aug 8, 2024

Here's the code from trailer.py where error occurred:
image

Error is occurring on line 137 where it's trying to create the trailer_path (which is the folder path where trailer needs to be saved), here's 2 scenarios where app would try to create that path:

  1. line 132 checks if a Trailers folder is needed (based on setting Trailer Folder Movie) and line 133 will apply it to trailer_path. If a Trailers folder needs to be created, it will be created in line 137 if it doesn't exist already. At this point trailer_path would look something like /movies/<movie folder name>/Trailers
  2. If Trailers folder is not needed, but movie folder doesn't exist already (line 136), then app would create it in line 137.

So, is it possible that movie folder path doesn't exist yet in your system and when app is trying to create it, it's failing as it doesn't have permissions to create it?

@elvis0288
Copy link
Author

elvis0288 commented Aug 8, 2024

so checking on the error which is trying to do lion king, it is indeed in there. and i have trailer folder movie as false..

would the spaces maybe breaking it?

image

image

@nandyalu
Copy link
Owner

nandyalu commented Aug 8, 2024

Upon further reading, it looks like template has Radarr Root and Sonarr Root mapped to /data/media/movies and /data/media/tv inside the container. But app uses the /data folder inside container (which can also be mapped) to save app data and configs.
image

It is a problem with template itself, in the template Radarr Root and Sonarr Root should be mapped to /movies and /tv. As app will get the path for a The Lion King movie from Radarr as /movies/The Lion King (2019) and when it tries to look for that path inside container, it's not there as it's mapped to /data/media/movies

@elvis0288
Copy link
Author

you were right... so i change the template to this:
image
looks like it is finally downloading
image

@nandyalu
Copy link
Owner

nandyalu commented Aug 8, 2024

I have no knowledge about unraid templates, can anyone create their own template?

@nandyalu nandyalu added good first issue Good for newcomers question Further information is requested labels Aug 8, 2024
@elvis0288
Copy link
Author

i will ask JPDVM2014 who created the unraid template to fix it

@nandyalu
Copy link
Owner

nandyalu commented Aug 8, 2024

@JPDVM2014 looks like you created the Trailarr template for Unraid, can you update it to also take input for both <LOCAL_MEDIA_FOLDER> and <RADARR_ROOT_FOLDER> and similarly for Sonarr too, to make sure both of those gets sent to docker run command?

@JPDVM2014
Copy link

So, I actually made the template based on my working install. I use /data/media/movies and /data/media/tv as my root folders, and it's working fine.

Maybe it would be better to just leave that blank so people have to fill it in themselves?

Screenshot_20240808_133032_Vivaldi.jpg

@nandyalu
Copy link
Owner

nandyalu commented Aug 8, 2024

Yeah, it would be best to leave them blank to let people fill them in. If you can add a comment or placeholder, that would be great!

Here's the instructions from README, you could add something similar

Change <LOCAL_APPDATA_FOLDER> to the folder where you want to store the application data.
Change <LOCAL_MEDIA_FOLDER> to the folder where your media is stored.
Change <RADARR_ROOT_FOLDERS> to the folder where Radarr stores movies.
Change <SONARR_ROOT_FOLDERS> to the folder where Sonarr stores TV shows.

@JPDVM2014
Copy link

Actually you are right, I can just put the LOCAL_MEDIA_FOLDER like you have. Then it will have to be filled out manually before it will work at all.

I also added the PUID and PGID variables so they are there if anyone needs to adjust them.

Screenshot_20240808_134904_Vivaldi.jpg

@nandyalu
Copy link
Owner

nandyalu commented Aug 8, 2024

Perfect! Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants