TheBeastLT / torrentio-scraper

Apache License 2.0
859 stars 105 forks source link

"Torrent download failed" errors with AllDebrid #148

Closed mattalxndr closed 1 year ago

mattalxndr commented 1 year ago

For the past month or two, Stremio has been giving me errors when I try to use Torrentio/AllDebrid to stream movies.

To recreate

  1. Configure Stremio to use Torrentio with AllDebrid.
  2. Stream a movie or TV series that is cached in AllDebrid (shows "[AD+]" in title), but is new to your AllDebrid accout (a movie that does not appear under "Magnet" in AllDebrid account).

What I expect to happen

The movie is streamed.

What actually happens

I get the "Torrent download failed" screen:

Sometimes when I wait for a few minutes and try again, it works.

Notes

I am using this little script to test:

#!/bin/bash
# Usage:
# export AD_KEY='******'
# ./bug.sh tt123456

set -euo pipefail

command -v jq >/dev/null || { echo 'Install jq'; exit 1; }

TORR_BASE_URL=${TORR_BASE_URL:-"https://torrentio.strem.fun/"}
AD_KEY=${AD_KEY:-}

[[ $AD_KEY ]] || { echo 'Run this then try again: export AD_KEY="**"'; exit 1; }
base_url="${TORR_BASE_URL}alldebrid=${AD_KEY}"

imdb_movie_id=${1:-}
[[ $imdb_movie_id = tt* ]] || { echo 'Pass in IMDb ID of a movie'; exit 1; }

api_url="${base_url}/stream/movie/${imdb_movie_id}.json"
echo "Requesting ${api_url} ..."
result=$(curl -s "$api_url")
#echo "$result" | jq .
torr_stream_url=$(echo "$result" | jq -r '.streams[0].url')
[[ $torr_stream_url = htt* ]] || { echo 'Script error: No URL returned from '"$torr_stream_url"; exit 0; }

echo "Requesting ${torr_stream_url} ..."
result=$(curl -s --head "$torr_stream_url")
#echo "$result"
resolved_url=$(echo "$result" | grep '^location: ' | sed 's/location: //')
[[ $resolved_url ]] || { echo 'Script error: Failed to resolve URL'; exit 1; }

echo
echo "Resolved URL: $resolved_url"
echo "Expected:     ${TORR_BASE_URL}videos/download_failed_v2.mp4"

if [[ $resolved_url = *download_failed* ]]; then
    echo 'BUG RECREATED'
else
    echo 'BUG NOT RECREATED'
fi

This is what happens for me:

% export AD_KEY='******'
% ./bug.sh tt0120655
Requesting https://torrentio.strem.fun/alldebrid=*****/stream/movie/tt0120655.json ...
Requesting https://torrentio.strem.fun/alldebrid/*****/a7f01deae9eef7ec34906d0ab4e9707dd893dd17/Dogma%20(1999)%20%5B2160p%2FHEVC%2FDD51%5D%20%5Bh3llg0d%5D/null/Dogma%20(1999)%20%5B2160p%2FHEVC%2FDD51%5D%20%5Bh3llg0d%5D ...

Resolved URL: https://torrentio.strem.fun/videos/download_failed_v2.mp4
Expected:     https://torrentio.strem.fun/videos/download_failed_v2.mp4
BUG RECREATED

If I wait for a few minutes and try again, it works:

% ./bug.sh tt0120655
Requesting https://torrentio.strem.fun/alldebrid=*****/stream/movie/tt0120655.json ...
Requesting https://torrentio.strem.fun/alldebrid/*****/a7f01deae9eef7ec34906d0ab4e9707dd893dd17/Dogma%20(1999)%20%5B2160p%2FHEVC%2FDD51%5D%20%5Bh3llg0d%5D/null/Dogma%20(1999)%20%5B2160p%2FHEVC%2FDD51%5D%20%5Bh3llg0d%5D ...

Resolved URL: https://kfg79a.debrid.it/dl/2v8lvey4f5c/Dogma.1999.2160p.BluRay.x265.DD51.h3llg0d.mkv
Expected:     https://torrentio.strem.fun/videos/download_failed_v2.mp4
BUG NOT RECREATED

Though the script only supports movie IDs, the bug happens with TV shows too.

TheBeastLT commented 1 year ago

AllDebrid was having roubles on their side a lot of the time, and during my testing I wasn't able to replicate any errors and everything went fine, so my guess it's something irregular on alldebrid side.

mattalxndr commented 1 year ago

I heard about the recent problems and noticed a red message at the top of my account for a while, so I understand why you may assume that that is the issue. But this was happening before that, and it's still happening, even though the red message is gone.

Also, when a video is requested (that part works), it always shows up in AllDebrid immediately. If fact, that's been my workaround so far. Request the video in Stremio, then hop over to AllDebrid (or Discover > Other > AllDebrid) and stream it directly.

If you have access to the logs, you could check this request out and maybe it would shed some light:

~ % ./bug.sh tt0033467
Requesting https://torrentio.strem.fun/alldebrid=****/stream/movie/tt0033467.json ...
Requesting https://torrentio.strem.fun/alldebrid/****/2dac9176630baef7211d42fa7432275a1e9bfd52/Citizen%20Kane%20(1941)%20Criterion%20(2160p%20BluRay%20x265%20HEVC%2010bit%20HDR%20AAC%201.0%20Tigole)%20%5BQxR%5D/null/Citizen%20Kane%20(1941)%20Criterion%20(2160p%20BluRay%20x265%20HEVC%2010bit%20HDR%20AAC%201.0%20Tigole)%20%5BQxR%5D ...

Resolved URL: https://torrentio.strem.fun/videos/download_failed_v2.mp4
Expected:     https://torrentio.strem.fun/videos/download_failed_v2.mp4
BUG RECREATED
~ % date -u
Thu Oct 12 05:45:58 AM UTC 2023
TheBeastLT commented 1 year ago

Could you try again now? Seems like you have too many magnets on your accounts (limit is 1000 across all tabs) and there's logic to delete the last one before adding new one, and this logic might be the cause for this error.

mattalxndr commented 1 year ago

Working great now, thanks for the attention. :partying_face: