Fixed: (Gazelle) Use InfoUrl for GUID to avoid global duplicates

pull/756/head
Qstick 3 years ago
parent a5e13ca776
commit b9dfe5e359

@ -52,6 +52,8 @@ namespace NzbDrone.Core.Indexers.Gazelle
foreach (var result in jsonResponse.Resource.Response.Results) foreach (var result in jsonResponse.Resource.Response.Results)
{ {
var posterUrl = GetPosterUrl(result.Cover);
if (result.Torrents != null) if (result.Torrents != null)
{ {
foreach (var torrent in result.Torrents) foreach (var torrent in result.Torrents)
@ -66,9 +68,11 @@ namespace NzbDrone.Core.Indexers.Gazelle
title += " [Cue]"; title += " [Cue]";
} }
var infoUrl = GetInfoUrl(result.GroupId, id);
var release = new GazelleInfo() var release = new GazelleInfo()
{ {
Guid = string.Format("Gazelle-{0}", id), Guid = infoUrl,
Title = WebUtility.HtmlDecode(title), Title = WebUtility.HtmlDecode(title),
Container = torrent.Encoding, Container = torrent.Encoding,
Files = torrent.FileCount, Files = torrent.FileCount,
@ -76,11 +80,12 @@ namespace NzbDrone.Core.Indexers.Gazelle
Codec = torrent.Format, Codec = torrent.Format,
Size = long.Parse(torrent.Size), Size = long.Parse(torrent.Size),
DownloadUrl = GetDownloadUrl(id), DownloadUrl = GetDownloadUrl(id),
InfoUrl = GetInfoUrl(result.GroupId, id), InfoUrl = infoUrl,
Seeders = int.Parse(torrent.Seeders), Seeders = int.Parse(torrent.Seeders),
Peers = int.Parse(torrent.Leechers) + int.Parse(torrent.Seeders), Peers = int.Parse(torrent.Leechers) + int.Parse(torrent.Seeders),
PublishDate = torrent.Time.ToUniversalTime(), PublishDate = torrent.Time.ToUniversalTime(),
Scene = torrent.Scene, Scene = torrent.Scene,
PosterUrl = posterUrl
}; };
var category = torrent.Category; var category = torrent.Category;
@ -100,19 +105,21 @@ namespace NzbDrone.Core.Indexers.Gazelle
{ {
var id = result.TorrentId; var id = result.TorrentId;
var groupName = WebUtility.HtmlDecode(result.GroupName); var groupName = WebUtility.HtmlDecode(result.GroupName);
var infoUrl = GetInfoUrl(result.GroupId, id);
var release = new GazelleInfo() var release = new GazelleInfo()
{ {
Guid = string.Format("Gazelle-{0}", id), Guid = infoUrl,
Title = groupName, Title = groupName,
Size = long.Parse(result.Size), Size = long.Parse(result.Size),
DownloadUrl = GetDownloadUrl(id), DownloadUrl = GetDownloadUrl(id),
InfoUrl = GetInfoUrl(result.GroupId, id), InfoUrl = infoUrl,
Seeders = int.Parse(result.Seeders), Seeders = int.Parse(result.Seeders),
Peers = int.Parse(result.Leechers) + int.Parse(result.Seeders), Peers = int.Parse(result.Leechers) + int.Parse(result.Seeders),
Files = result.FileCount, Files = result.FileCount,
Grabs = result.Snatches, Grabs = result.Snatches,
PublishDate = DateTimeOffset.FromUnixTimeSeconds(result.GroupTime).UtcDateTime, PublishDate = DateTimeOffset.FromUnixTimeSeconds(result.GroupTime).UtcDateTime,
PosterUrl = posterUrl
}; };
var category = result.Category; var category = result.Category;
@ -147,7 +154,19 @@ namespace NzbDrone.Core.Indexers.Gazelle
return url.FullUri; return url.FullUri;
} }
private string GetInfoUrl(string groupId, int torrentId) protected virtual string GetPosterUrl(string cover)
{
if (!string.IsNullOrEmpty(cover))
{
return cover.StartsWith("http") ?
new HttpUri(cover).FullUri :
new HttpUri(_settings.BaseUrl).CombinePath(cover).FullUri;
}
return null;
}
protected virtual string GetInfoUrl(string groupId, int torrentId)
{ {
var url = new HttpUri(_settings.BaseUrl) var url = new HttpUri(_settings.BaseUrl)
.CombinePath("/torrents.php") .CombinePath("/torrents.php")

Loading…
Cancel
Save