blacktwin / JBOPS

Just a Bunch Of Plex Scripts
1.66k stars 308 forks source link

hide_episode_spoilers.py fails to create the blur thumbnails #334

Open titooo7 opened 2 years ago

titooo7 commented 2 years ago

Describe the bug

The media content is located on a folder mounted with mergerfs, not sure if that matters

Logs

2022-03-14 08:29:21 - DEBUG   :: Thread-3 : Tautulli NotificationHandler :: Checking custom notification conditions for notifier_id 17.
2022-03-14 08:29:21 - DEBUG   :: Thread-3 : Tautulli NotificationHandler :: {1} media_type | is | 'show' or 'season' or 'episode' > 'episode' > True
2022-03-14 08:29:21 - DEBUG   :: Thread-3 : Tautulli NotificationHandler :: Condition logic [blank]: {1} > True
2022-03-14 08:29:21 - DEBUG   :: Thread-3 : Tautulli NotificationHandler :: Custom conditions evaluated to 'True'. Conditions: [True].
2022-03-14 08:29:21 - INFO    :: Thread-3 : Tautulli NotificationHandler :: Preparing notification for notifier_id 17.
2022-03-14 08:29:21 - DEBUG   :: Thread-3 : Tautulli Notifiers :: Trying to run notify script: /config/scripts/JBOPS/utility/hide_episode_spoilers.py, arguments: ['--r$
2022-03-14 08:29:21 - DEBUG   :: Thread-3 : Tautulli Notifiers :: Full script is: ['/usr/bin/python3', '/config/scripts/JBOPS/utility/hide_episode_spoilers.py', '--rat$
2022-03-14 08:29:21 - DEBUG   :: Thread-3 : Tautulli Notifiers :: Executing script in a new thread.
2022-03-14 08:29:21 - DEBUG   :: Thread-141 : Tautulli Notifiers :: Subprocess returned with status code 1.
2022-03-14 08:29:21 - ERROR   :: Thread-141 : Tautulli Notifiers :: Script error:
  Traceback (most recent call last):
    File "/config/scripts/JBOPS/utility/hide_episode_spoilers.py", line 119, in <module>
      modify_episode_artwork(plex, **vars(opts))
    File "/config/scripts/JBOPS/utility/hide_episode_spoilers.py", line 95, in modify_episode_artwork
      with open(episode_artwork, 'wb') as f:
  FileNotFoundError: [Errno 2] No such file or directory: "/mnt/unionfs/tv/The Simpsons/Season 33/The Simpsons - S33E14 - You Won't Believe What This Episode is About - Act Three Will Shock You! [WEBDL-1080p x264 AAC] [CAKES].png"
2022-03-14 08:29:21 - INFO    :: Thread-141 : Tautulli Notifiers :: Script notification sent.
2022-03-14 08:29:21 - INFO    :: Thread-2 : Tautulli Notifiers :: Telegram notification sent.
lunaya commented 2 years ago

I can confirm that this is also happening on my server. I set a trigger for this to happen on play as a test.

-- | -- | --
2022-04-08 03:51:21 | ERROR | Tautulli Notifiers :: Script error:    Traceback (most recent call last):        File "/config/JBOPS/utility/hide_episode_spoilers.py", line 119, in <module>            modify_episode_artwork(plex, **vars(opts))        File "/config/JBOPS/utility/hide_episode_spoilers.py", line 95, in modify_episode_artwork            with open(episode_artwork, 'wb') as f:    FileNotFoundError: [Errno 2] No such file or directory: '/data/tvshows/Band of Brothers/Season 1/Band.of.Brothers.S01E01.Currahee.1080p.Blu-ray.Remux.AVC.DTS-HD.MA.5.1.KRaLiMaRKo.png'
2022-04-08 03:51:21 | DEBUG | Tautulli Notifiers :: Subprocess returned with status code 1.
2022-04-08 03:51:21 | DEBUG | Tautulli Notifiers :: Executing script in a new thread.
2022-04-08 03:51:21 | DEBUG | Tautulli Notifiers :: Full script is: ['/usr/bin/python3', '/config/JBOPS/utility/hide_episode_spoilers.py', '--rating_key', '27865', '--blur', '100']
2022-04-08 03:51:21 | DEBUG | Tautulli Notifiers :: Trying to run notify script: /config/JBOPS/utility/hide_episode_spoilers.py, arguments: ['--rating_key', '27865', '--blur', '100'], action: play
2022-04-08 03:51:21 | INFO | Tautulli NotificationHandler :: Preparing notification for notifier_id 1.
2022-04-08 03:51:21 | DEBUG | Tautulli NotificationHandler :: Custom conditions evaluated to 'True'. Conditions: [True].
2022-04-08 03:51:21 | DEBUG | Tautulli NotificationHandler :: Condition logic [blank]: {1} > True
2022-04-08 03:51:21 | DEBUG | Tautulli NotificationHandler :: {1} media_type \| is \| 'episode' > 'episode' > True
seangreen2 commented 2 years ago

Having the same problem on blur as well. Same FileNotFoundError: [Errno 2] No such file or directory:

blacktwin commented 1 year ago

Does Tautulli have access to the library location? Tautulli would need access to edit the directory where the Plex libraries are.

dasauto1 commented 1 year ago

@blacktwin I ran in to the same issue now, tautulli has rwx permissions to the PhotoTranscoder directory (recursively), so that I do not think is an issue. For now using the --image spoilers.png but I would really like blur if possible. Thanks.

dasauto1 commented 1 year ago

Sorry forgot to add that Tautulli logs doesn't show any errors:

2022-10-25 16:55:53 | INFO | Tautulli Notifiers :: Script notification sent.
-- | -- | --
2022-10-25 16:55:53 | DEBUG | Tautulli Notifiers :: Subprocess returned with status code 0.
2022-10-25 16:55:52 | DEBUG | Tautulli Notifiers :: Executing script in a new thread.
2022-10-25 16:55:52 | DEBUG | Tautulli  Notifiers :: Full script is: ['/opt/.venv/tautulli/bin/python3',  '/opt/tautulli/scripts/hide_episode_spoilers.py', '--rating_key',  '11022', '--blur', '25']
2022-10-25 16:55:52 | DEBUG | Tautulli  Notifiers :: Trying to run notify script:  /opt/tautulli/scripts/hide_episode_spoilers.py, arguments:  ['--rating_key', '11022', '--blur', '25'], action: test
2022-10-25 16:55:52 | INFO | Tautulli NotificationHandler :: Preparing notification for notifier_id 3.
2022-10-25 16:55:52 | DEBUG | Tautulli NotificationHandler :: Notifiers enabled for notify_action 'test' (manual trigger).
2022-10-25 16:55:52 | DEBUG | Sending test Script notification.
2022-10-25 16:55:52 | INFO | Tautulli Notifiers :: Updated notification agent: Script (notifier_id 3).
lunaya commented 1 year ago

FWIW I was eventually able to get the script to work, and yes as @blacktwin noted it did seem to be a permissions issue.

dasauto1 commented 1 year ago

Thanks lunaya. Not sure why I am having issues then. Just to confirm the access needs to given to /cache/PhotoTranscoder right? tautulli definitely has rwx access to this directory (and the ones in them)

lunaya commented 1 year ago

In my case, the machine running the script also needed permissions to every directory that contained video files that would be played by Plex. Because the way that it works for me is that on Plex scan/matching, it will create a png file with the same name as every video file which is just a plain black picture with the word SPOILER on it. So the server machine running the script had to have permissions to every media/series folder in order to write pngs next to the video files.

Plex will then see that there are png files with identical filenames to every mp4, for example, and use that as the episode picture.

dasauto1 commented 1 year ago

Yup that --image is not an issue (works well here). My issue is that --blur doesnt seem to have an effect.

lunaya commented 1 year ago

Ah apologies...yeah in that case I'm not sure. Strange because the process/permissions of writing a new image to the video file location should be the same..

blacktwin commented 1 year ago

--blur doesnt seem to have an effect.

@dasauto1 So the file is created and moved but not set in Plex? If you go to the item's detail page and select Edit > Poster, to you see the blurred image?

dasauto1 commented 1 year ago

@dasauto1 So the file is created and moved but not set in Plex? If you go to the item's detail page and select Edit > Poster, to you see the blurred image?

I don't see any file being created with blur however the --spoiler works well and I see those images along with the file in its respective folder.

blacktwin commented 1 year ago

--spoiler works

? Thats not an argument. Are you only seeing this while testing or while having Tautulli trigger it?

dasauto1 commented 1 year ago

--spoiler works

? Thats not an argument. Are you only seeing this while testing or while having Tautulli trigger it?

Sorry I meant --image spoilers.png works. I am seeing this (blur not working) while testing and while Tautulli triggering it.

MawRojas commented 9 months ago

@blacktwin Hello, I'm having the same problem. Here is the log:

2023-11-30 20:46:06 - DEBUG   :: CP Server Thread-12 : Sending test Script notification.
2023-11-30 20:46:06 - DEBUG   :: CP Server Thread-12 : Tautulli NotificationHandler :: Notifiers enabled for notify_action 'test' (manual trigger).
2023-11-30 20:46:06 - INFO    :: Thread-2 (process_queue) : Tautulli NotificationHandler :: Preparing notification for notifier_id 1.
2023-11-30 20:46:06 - DEBUG   :: Thread-2 (process_queue) : Tautulli Notifiers :: Trying to run notify script: /config/scripts/plex_thumbnails_v2.py, arguments: ['--base_directory', '/mnt/pool/media/Shows/', '--rating_key', '836', '--blur', '25'], action: test
2023-11-30 20:46:06 - DEBUG   :: Thread-2 (process_queue) : Tautulli Notifiers :: Full script is: ['/lsiopy/bin/python3', '/config/scripts/plex_thumbnails_v2.py', '--base_directory', '/mnt/pool/media/Shows/', '--rating_key', '836', '--blur', '25']
2023-11-30 20:46:06 - DEBUG   :: Thread-2 (process_queue) : Tautulli Notifiers :: Executing script in a new thread.
2023-11-30 20:46:07 - DEBUG   :: Thread-23 (run_script) : Tautulli Notifiers :: Subprocess returned with status code 1.
2023-11-30 20:46:07 - ERROR   :: Thread-23 (run_script) : Tautulli Notifiers :: Script error: 
  Traceback (most recent call last):
    File "/config/scripts/plex_thumbnails_v2.py", line 107, in <module>
      modify_episode_artwork(plex, opts.base_directory, opts.rating_key, opts.image, opts.blur, opts.summary_prefix, opts.remove, opts.upload)
    File "/config/scripts/plex_thumbnails_v2.py", line 84, in modify_episode_artwork
      with open(episode_artwork, 'wb') as f:
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  FileNotFoundError: [Errno 2] No such file or directory: '/mnt/pool/media/Shows/Insomniacs After School/S01/S01E01.png'
2023-11-30 20:46:07 - INFO    :: Thread-23 (run_script) : Tautulli Notifiers :: Script notification sent.

Here is my docker container:

  tautulli:
    image: lscr.io/linuxserver/tautulli:latest
    container_name: tautulli
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=America/Mexico_City
    volumes:
      - /home/homelab/docker/config/tautilli:/config
    ports:
      - 8181:8181
    restart: unless-stopped

My main user is 'homelab' and I know it has access to the correct directory:

ls -l /mnt/pool/media/Shows/Insomniacs\ After\ School/
drwxr-xr-x 2 homelab homelab 4096 Nov 21 15:20 S01

And I know the PUID and PGID are correct by running:

id
uid=1000(homelab) gid=1000(homelab) groups=1000(homelab)

What am I missing? Thank you for your help