-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New: Flood Download Client #4159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Ping @markus101. Happy holidays! I would be appreciated if you can give some preliminary reviews. I deployed the PR on my Sonarr/Radarr instances, and the PR is working perfectly fine so far. Thanks. BTW: I joined the Sonarr Discord. Feel free to contact me directly if necessary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't tested, but left some preliminary comments.
_proxy = proxy; | ||
} | ||
|
||
private static IEnumerable<string> HandleTags(RemoteEpisode media, FloodSettings settings) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
media
-> remoteEpisode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
public bool StartOnAdd { get; set; } | ||
|
||
[FieldDefinition(12, Label = "Sequential Download", Type = FieldType.Checkbox, Advanced = true)] | ||
public bool SequentialDownload { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not have plans to support this for other clients, so we don't want to support it for flood either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SequentialDownload
removed.
RuleFor(c => c.Host).ValidHost(); | ||
RuleFor(c => c.Port).InclusiveBetween(1, 65535); | ||
|
||
RuleFor(c => c.TargetRatio).GreaterThanOrEqualTo(0).Unless(c => c.TargetRatio == -1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ratio limits in clients are based on indexer settings, there shouldn't be a setting for flood.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TargetRatio
removed.
{ | ||
var result = item.Clone(); | ||
|
||
var contentPaths = _proxy.GetTorrentContentPaths(item.DownloadId, Settings); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be fetched when the torrents are fetched? Avoiding the extra API call? The output path is already being set in GetItems
what is that directory if it's not where it should be imported from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, no. Get torrent API call provides directory path only. There are many cases: single-file vs. multi-file, base directory vs. sub directory.
When the torrent is single-file, Sonarr expects path to the file. Otherwise, it will try to import the whole directory, which can cause problems if there are unrelated files in the directory. For multi-file torrents, Sonarr expects path to the base directory of the torrent.
As such, an additional API call to fetch the list of contents of a torrent is required. It is more efficient (resource saving) to fetch when the import is requested.
item.Status = DownloadItemStatus.Paused; | ||
} | ||
|
||
if (Settings.TargetRatio != -1 && item.SeedRatio > Settings.TargetRatio) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned on the setting the target ratio comes from the indexer, there is a big discussion on how to do this in rtorrent here: #3632
The big thing is we don't want Sonarr to be a seedtime/ratio manager, it can pass the limits to the client, but the client should be able to indicate when the time/ratio has been met.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TargetRatio
removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found a couple issues while testing, will be able to test more once the path issue is resolved.
{ | ||
// For multi-file torrent, OutputPath should be the path of base directroy of torrent. | ||
// isBasePath is false by default. Presumably base directory would be first fragment of path of content. | ||
result.OutputPath = item.OutputPath + new OsPath(contentPaths[0].Split(new char[] { '\\', '/' }, StringSplitOptions.RemoveEmptyEntries)[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not working for multi-file torrents. It currently returns the path to the first file, but instead I believe it should just be returning item.OutputPath
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
item.OutputPath
is the directory
of TorrentProperties
, which, by definition, is always a directory. This directory may or may not be the base directory. This causes problems as Sonarr can grab contents of unrelated torrents which reside in the same destination directory.
This line of code tries to combine the directory with the first segment (directory) of a content when the torrent is multi-file:
TorrentProperties.directory + first path segment of first content of a multi-file torrent (path -> split -> pathSegments[0])
/mnt/data0/downloads
+ Big.Buck.Bunny.1080P
/Soundtracks/Bunny.wav
I tested with a multi-file torrent. It seems that this approach works fine as torrent clients always create a sub-directory for multi-file torrents by default.
For single-file torrents, Sonarr expects path to a single file, which is handled by another case (above).
What's not working? Did this line of code fail to get the first segment, combine paths, or...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It currently returns the path to the first file.
It gave me the path to a text file, not a folder. Even if it happened to give me a video file it'd be wrong for a multi-video file download.
result.OutputPath
is set to C:\downloads\torrents\test\The.Rookie.S03E02.WEBRip.x264-ION10\RARBG.txt
.
item.OutputPath
is set to C:\timebomb\downloads\torrents\test\The.Rookie.S03E02.WEBRip.x264-ION10
For multi-file this should just return the path, but if there is single file torrent inside a job folder you're probably going to see issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In your case, directory
is the base directory, which is indeed a possible case. This case is not unhandled here. I assume there are some differences in how clients handle root directory of a multi-file torrent. I will work out a more robust method for detection of base directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, they pretty much universally suck at it, we're sometimes left guessing which has lead to issues in the past and somewhat recently with qbit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is done. Please try it.
BTW: Sonarr can probably utilize a method that returns an array of paths (of contents of torrents) instead. That allows things to be much more precise and eliminates any interferences and inconsistencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Working much better now. In the future please don't squash fixes immediately, we can do that when merging the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack. It is a shame that Github PR does not have the capability to compare different versions of change sets directly. I typically use more professional Code Review tools like Gerrit, which does have the capability (and as result, pushing additional commits can be "stupid").
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fortunately, though, there is a commit compare function: https://github.com/jesec/Sonarr/compare/17237a0e..0cae35f3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Working great, just the warning to add then we'll get it landed.
} | ||
|
||
public override string Name => "Flood"; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Until we have remove support we need to add:
public override ProviderMessage Message => new ProviderMessage("Sonarr is unable to remove torrents that have finished seeding when using Flood", ProviderMessageType.Warning);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually the current behavior is that Sonarr defaults to instant removal of completed torrents, which is not a desired behavior in BitTorrent community.
If we want to add the warning, I think it would be a good idea to make item.CanMoveFiles
and item.CanBeRemoved
always false so Sonarr won't instant remove completed torrents. Otherwise the warning can be misleading and needs to be reworded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah you’re absolutely correct, I missed that part. That + the warning then, please.
@markus101 Can you check what happened with CI? I don't have access to TeamCity. |
@jesec there’s the little login as guest button on the page! (Not obvious, I missed it too!) |
Thanks. I think it is a flaky test which does not appear to be related to this PR. |
Thanks for all the work on this @jesec! |
Database Migration
NO
Description
Add support for Flood, a modern Web UI for various torrent clients.