itsToggle / rclone_RD

RClone Fork that implements RealDebrid
https://rclone.org
MIT License
176 stars 34 forks source link

automatically re-download dead torrents #14

Closed itsToggle closed 1 year ago

itsToggle commented 1 year ago

As described in issue #6, sometimes torrents are marked "dead" by realdebrid. This is caused by broken restricted links, which I previously stated cant be regenerated.

I aim to fix this issue, as it appears to occur more often of late, at least for me.

itsToggle commented 1 year ago

It seems to also be possible to redownload torrents that are not marked as "dead" by realdebrid, but do contain dead links. The solution im working on will also solve #10

joshali1990 commented 1 year ago

I noticed that I don't run in to this problem with using a webdav mounting program like net drive. Do you know the drawbacks for mounting this way vs your fork?

itsToggle commented 1 year ago

That's not possible. The realdebrid webdav would have to re-add the torrent, which would put it to the top of the /torrents page on realdebrid.com - which it doesn't. The webdav version will simply not display broken files, which is not better than the way my fork handles this case currently.

I've already coded a solution for this problem, I'm just optimizing it at the moment.

The downsides of realdebrids webdav are listed on the rclone_rd github readme, they include a torrent limit of 200, constant re-discovering of media when using plex, etc

joshali1990 commented 1 year ago

Gotcha. So if I add the webdav to a net drive mount even though all the files show up on first load, eventually the files will need to be un-restricted again? Not sure what you mean by it won't display broken files. Your fork give's me "error_code": 19 for some files, but they're showing up on my net drive mount. I'll wait for your fix anyway since it seems faster.

itsToggle commented 1 year ago

From #6:

When a torrent finishes downloading, RealDebrid generates restricted links that first need to be unrestricted to get access to the files.

Working restricted links that havent been unrestricted yet, or their unrestricted link has been removed after one week, will automatically be unrestricted by rclone.

Sometimes though, a restricted link might become broken on RealDebrids servers.

Ok so "unrestricting" the "restricted" links you see on the /torrents page of realdebrid.com is not the problem - both my fork and their webdav can do this. The problem occurs when the restricted links break and therefore cant be unrestricted again. My fork will display the error 19 code when that happens, and so should realdebrids webdav implementation - or they dont display the broken file, or the file simply wont load if you try to watch it. The only way to fix this error is to re-add the entire torrent. Ill add that capability tonight or tomorrow, depending on how testing goes :)

joshali1990 commented 1 year ago

Hmm interesting,

I think for me it's displaying the error code for files where the link hasn't broken unless I'm mistaken. They show up fine in webdav, but not on your fork. Maybe what's happening is I have the torrent added multiple times, one broken and one not, but the fork is only displaying the version with the broken links?

itsToggle commented 1 year ago

Could be, but I'm currently guessing that you won't be able to actually open all the torrents files.

Anyway, I've released a beta version of rclone_rd which should solve this issue. I've tested it as far as I can and it was able to redownload my 5 broken torrents. Feel free to test it out and report back, I'll have to wait until another of my torrents breaks to be 100% certain this works.

joshali1990 commented 1 year ago

Thanks, just tried to build it on my Mac but got an error:

github.com/rclone/rclone/backend/realdebrid

backend/realdebrid/realdebrid.go:394:31: torrent.Files undefined (type api.Item has no field or method Files) backend/realdebrid/realdebrid.go:434:10: torrent.Status undefined (type api.Item has no field or method Status) backend/realdebrid/realdebrid.go:535:16: torrent.Status undefined (type api.Item has no field or method Status)

itsToggle commented 1 year ago

I see! Thanks for testing, will fix this in a minute or two :)

itsToggle commented 1 year ago

Changes have been commited. I simply forgot to update one of the files :)

joshali1990 commented 1 year ago

I've been testing it out, but it seems a lot glitchier on my Mac. Crashes a lot more and it's hit or miss whether or not it'll mount the drive.

itsToggle commented 1 year ago

Can you provide any actual error codes please? I can't debug anything from that information. It runs absolutely fine for me. But then again I don't have any broken torrents right now, perhaps you have a bunch.

joshali1990 commented 1 year ago

I think the issue is I'm in the process of rebuilding my entire plex library which is causing rclone to crash. Not getting any actual error codes, the drive just disconnects from time to time. I'll see how it runs when the library scan is done.

joshali1990 commented 1 year ago

Seems to be working alright now. I noticed that the new files don’t show up on the drive until I add another file after that. Have you run into this?

itsToggle commented 1 year ago

Okay so the way rclone_rd works, it needs to get all your torrents from /torrents and all your download links from /downloads. The realdebrid API limits these request, so each request will only return 100 items. If these requests would need to be made every time a file is opened, access times would he huge. To prevent this, rclone_rd is doing the following:

When starting rclone_rd, all torrents and links are requested and a local copy of that list is saved. When you then open a file, rclone_rd simply checks if the total number of torrents or the total number of links has changed compared to the local list, and only updates the list entirely if a change has been detected. This works great 99% of the time, but there are a few ways this can lead to the behavior you've described:

If you remove a torrent from realdebrid (either on the website or by deleting it on Plex) and then quickly add another torrent, the total number of torrents will not have changed and rclone_rd will not display the new files.

itsToggle commented 1 year ago

implemented and stable, will move 1.6 out of beta