debridmediamanager / zurg-testing

A self-hosted Real-Debrid webdav server you can use with Infuse. Together with rclone it can mount your Real-Debrid torrent library into your filesystem and load it to Plex or Jellyfin.
526 stars 41 forks source link

Bug: Tries to repair a 503/404 status file that cannot be streamed #90

Closed espensgr closed 8 months ago

espensgr commented 9 months ago

Expected Behavior All mounted files should be able to play/stream.

Actual Behavior Mount get WARN router Received a 503 Service Unavailable status code for file or WARN router Received a 404 Not Found status code for file When i try to stream it from Real-debrid it never plays their either, and when i try to download the link from Real debrid i get https://real-debrid.com/d/5ZPMTXZBET6B4ZBM4WTT5HQ2FE: hoster_unavailable. So i guess the file dont exist any more or cant be served. So the mount should skip this file i guess, and not try to repair it indefinitely? Trying to redownload the torrent doesn't do anything in these cases. I guess it should only mount streamable files? Maybe with help from the /streaming/mediaInfos/{id} endpoint in the api. Just a curl HEAD with 200 response should do it maybe. Or the /unrestrict/link endpoint to see if it is streamable.

The result of all this is that Plex tries to scan that file to get info from it, but it doesn't get that. Eventually it will go to another file, but it takes a long time. This is mostly regarding tv shows, that has so many files to index.

Detailed Steps Plex is mounted directly to the Zurg mount folders.

Operating System Linux

Environment Setup Have it setup on Elfhosted, with the Zurg and Rclone WebDAV Mount (Real Debrid via Zurg) that is mounted to a Plex pod there. So it's a kubernetes setup. zurg version: v0.9.3-hotfix.11

Logs Here is a log with items that have non streamable items that Zurg tries to repair by redownloading over and over. zurg-2024-02-19.log

Zurg Configuration This is the config elfhosted comes with, haven't changed anything, it may be improved on.

# Zurg configuration version
zurg: v1
token: XXX # https://real-debrid.com/apitoken

# basic functionality
host: "[::]" # do not change this if you are running it inside a docker container
port: 9999 # do not change this if you are running it inside a docker container
concurrent_workers: 32
check_for_changes_every_secs: 10

# misc configs
retain_folder_name_extension: false # if true, zurg won't modify the filenames from real-debrid
retain_rd_torrent_name: true # if true, it will strictly follow RD API torrent name property w/c should make this more compatible with rdt-client
auto_delete_rar_torrents: true # if true, zurg will delete unstreamable rar files (these torrents will always be compressed in a rar archive no matter what files you select)
use_download_cache: false # if true, during zurg initialization, it will fetch all downloads to unrestrict links faster
enable_repair: true # BEWARE! THERE CAN ONLY BE 1 INSTANCE OF ZURG THAT SHOULD REPAIR YOUR TORRENTS
on_library_update: sh plex_update.sh "$@"
ignore_renames: true

# network configs
network_buffer_size: 1048576 # 1 MiB
serve_from_rclone: false # serve file data from rclone, not from zurg (zurg will only provide rclone the link to download)
verify_download_link: true # if true, zurg will check if the link is truly streamable; only relevant if serve_from_rclone is set to true (as it already does this all the time if serve_from_rclone is false)
force_ipv6: false # force connect to real-debrid ipv6 addresses
rate_limit_sleep_secs: 6 # wait time after getting a 429 from Real-Debrid API
realdebrid_timeout_secs: 60 # api timeout
retries_until_failed: 5 # api failures until considered failed

# List of directory definitions and their filtering rules
directories:
  # Configuration for anime shows
  anime:
    group: media # directories on different groups have duplicates of the same torrent
    group_order: 10 # group order = priority, it defines who eats first on a group
    filters:
      - and: # you can use nested 'and' & 'or' conditions
        - has_episodes: true # intelligent detection of episode files inside a torrent
        - any_file_inside_regex: /^\[/ # usually anime starts with [ e.g. [SubsPlease]
        - any_file_inside_not_regex: /s\d\de\d\d/i # and usually anime doesn't use SxxExx

  shows:
    group: media
    group_order: 20
    filters:
      - has_episodes: true  # intelligent detection of episode files inside a torrent

  movies:
    group: media  # because anime, shows and movies are in the same group,
    group_order: 30 # and anime and shows has a lower group_order number than movies, all torrents that doesn't fall into the previous 2 will fall into movies
    only_show_the_biggest_file: true # let's not show the other files besides the movie itself
    filters:
      - regex: /.*/ # you cannot leave a directory without filters because it will not have any torrents in it

Have tried to collect enough info for this issue, but if something is missing just let me know and i will try to provide it.

This may also be a problem on the Real debrid end that there is no integrity check off the files that they sever from the api.

yowmamasita commented 9 months ago

zurg will first attempt to repair it

on that duration, zurg will return a File locked status on requests to fetch the file (this is only visible to the client, not present on the logs)

once it is repaired, it will be playable again

espensgr commented 9 months ago

Thanks for the reply, some questions regarding that. But what if the file never is playable, then it cannot be repaired, and then you are left with an unplayable file that is "fixed"? What does the repair try to do? Does Plex skip files with this file locked status, or will it still try to analyze it?