AECX / FinTube

Jellyfin Plugin to import directly from YT
65 stars 9 forks source link

Plugin reports that command was succesful even on error #8

Closed jacksgt closed 1 month ago

jacksgt commented 2 months ago

Hello,

thank you for this awesome plugin - exactly what I need to archive some YouTube videos into my media collection!

I have observed that the plugin does not seem to handle errors (i.e. exit code != 0) from youtube-dl / yt-dlp. As far as I can tell, whatever the exit code of the tool, the plugin always happily reports "File saved". For example, I tried to download a video but the Jellyfin user is not allowed to write into the media collection.

The plugin reported:

Filename: /storage/YouTube/7-MYHOpzT5A
Exec: /usr/bin/yt-dlp -f mp4 -S res:1080 -o "/storage/YouTube/7-MYHOpzT5A-%(title)s.%(ext)s" 7-MYHOpzT5A
File Saved!

Screenshot 2024-04-23 at 21-54-08 Jellyfin

But my library was still empty - only the Jellyfin logs revealed the issue:

[19:55:57] [INF] [67] Jellyfin.Plugin.FinTube.Api.FinTubeActivityController: FinTubeActivityController Loaded
[19:55:57] [INF] [67] Jellyfin.Plugin.FinTube.Api.FinTubeActivityController: FinTubeDLibraries count: 4
[19:56:13] [INF] [67] Jellyfin.Plugin.FinTube.Api.FinTubeActivityController: FinTubeActivityController Loaded
[19:56:13] [INF] [67] Jellyfin.Plugin.FinTube.Api.FinTubeActivityController: FinTubeDownload : 7-MYHOpzT5A to , prefer free format: True audio only: False
[youtube] Extracting URL: 7-MYHOpzT5A
[youtube] 7-MYHOpzT5A: Downloading webpage
[youtube] 7-MYHOpzT5A: Downloading ios player API JSON
[youtube] 7-MYHOpzT5A: Downloading android player API JSON
[youtube] 7-MYHOpzT5A: Downloading player d8a5aa5e
WARNING: Writing cache to '/root/.cache/yt-dlp/youtube-nsig/d8a5aa5e.json' failed: Traceback (most recent call last):
  File "/usr/local/bin/yt-dlp/yt_dlp/cache.py", line 41, in store
    os.makedirs(os.path.dirname(fn), exist_ok=True)
  File "/usr/lib/python3.10/os.py", line 215, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "/usr/lib/python3.10/os.py", line 215, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "/usr/lib/python3.10/os.py", line 225, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/root/.cache'

[youtube] 7-MYHOpzT5A: Downloading m3u8 information
[info] 7-MYHOpzT5A: Downloading 1 format(s): 22
[download] Unable to open file: [Errno 13] Permission denied: '/storage/YouTube/7-MYHOpzT5A-How To Change Your Cassette | Road Bike Maintenance.mp4.part'. Retrying (1/3)...
[download] Unable to open file: [Errno 13] Permission denied: '/storage/YouTube/7-MYHOpzT5A-How To Change Your Cassette | Road Bike Maintenance.mp4.part'. Retrying (2/3)...
[download] Unable to open file: [Errno 13] Permission denied: '/storage/YouTube/7-MYHOpzT5A-How To Change Your Cassette | Road Bike Maintenance.mp4.part'. Retrying (3/3)...
ERROR: unable to open for writing: [Errno 13] Permission denied: '/storage/YouTube/7-MYHOpzT5A-How To Change Your Cassette | Road Bike Maintenance.mp4.part'

Maybe the error handling can be improved :-)

AECX commented 1 month ago

Thanks, when I return to the project I'll keep this in mind!