mirror of
https://github.com/Prowlarr/Prowlarr
synced 2025-12-15 21:14:32 +01:00
Fixed: (Cardigann) Magnet generation for public indexers with InfoHash
Fixes #668
This commit is contained in:
parent
08c68e26c1
commit
6d62744667
2 changed files with 34 additions and 3 deletions
|
|
@ -132,10 +132,25 @@ protected virtual IList<ReleaseInfo> CleanupReleases(IEnumerable<ReleaseInfo> re
|
|||
c.DownloadProtocol = Protocol;
|
||||
c.IndexerPriority = ((IndexerDefinition)Definition).Priority;
|
||||
|
||||
//Add common flags
|
||||
if (Protocol == DownloadProtocol.Torrent && ((TorrentInfo)c).DownloadVolumeFactor == 0)
|
||||
if (Protocol == DownloadProtocol.Torrent)
|
||||
{
|
||||
c.IndexerFlags.Add(IndexerFlag.FreeLeech);
|
||||
// generate magnet link from info hash (not allowed for private sites)
|
||||
if (((TorrentInfo)c).MagnetUrl == null && !string.IsNullOrWhiteSpace(((TorrentInfo)c).InfoHash) && ((IndexerDefinition)Definition).Privacy != IndexerPrivacy.Private)
|
||||
{
|
||||
((TorrentInfo)c).MagnetUrl = MagnetLinkBuilder.BuildPublicMagnetLink(((TorrentInfo)c).InfoHash, c.Title);
|
||||
}
|
||||
|
||||
// generate info hash from magnet link
|
||||
if (((TorrentInfo)c).MagnetUrl != null && string.IsNullOrWhiteSpace(((TorrentInfo)c).InfoHash))
|
||||
{
|
||||
((TorrentInfo)c).InfoHash = MagnetLinkBuilder.GetInfoHashFromMagnet(((TorrentInfo)c).MagnetUrl);
|
||||
}
|
||||
|
||||
//Add common flags
|
||||
if (((TorrentInfo)c).DownloadVolumeFactor == 0)
|
||||
{
|
||||
((TorrentInfo)c).IndexerFlags.Add(IndexerFlag.FreeLeech);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MonoTorrent;
|
||||
using NzbDrone.Core.Parser;
|
||||
|
||||
namespace NzbDrone.Core.Indexers
|
||||
{
|
||||
|
|
@ -33,5 +36,18 @@ public static string BuildPublicMagnetLink(string infoHash, string releaseTitle)
|
|||
{
|
||||
return new MagnetLink(InfoHash.FromHex(infoHash), releaseTitle, _trackers).ToV1String();
|
||||
}
|
||||
|
||||
public static string GetInfoHashFromMagnet(string magnet)
|
||||
{
|
||||
try
|
||||
{
|
||||
var xt = ParseUtil.GetArgumentFromQueryString(magnet.ToString(), "xt");
|
||||
return xt.Split(':').Last(); // remove prefix urn:btih:
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue