mirror of
https://github.com/Prowlarr/Prowlarr
synced 2025-12-06 08:34:28 +01:00
Fixed: Handle wonky timestamps from Orpheus
This commit is contained in:
parent
4f83116413
commit
0e05d86a58
2 changed files with 43 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Indexers.Gazelle
|
namespace NzbDrone.Core.Indexers.Gazelle
|
||||||
{
|
{
|
||||||
|
|
@ -59,6 +60,7 @@ public class GazelleRelease
|
||||||
public int TotalSeeders { get; set; }
|
public int TotalSeeders { get; set; }
|
||||||
public int TotalSnatched { get; set; }
|
public int TotalSnatched { get; set; }
|
||||||
public long MaxSize { get; set; }
|
public long MaxSize { get; set; }
|
||||||
|
[JsonConverter(typeof(GazelleTimestampConverter))]
|
||||||
public long GroupTime { get; set; }
|
public long GroupTime { get; set; }
|
||||||
public List<GazelleTorrent> Torrents { get; set; }
|
public List<GazelleTorrent> Torrents { get; set; }
|
||||||
public bool IsFreeLeech { get; set; }
|
public bool IsFreeLeech { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
using System;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Indexers.Gazelle
|
||||||
|
{
|
||||||
|
public class GazelleTimestampConverter : JsonConverter
|
||||||
|
{
|
||||||
|
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||||
|
{
|
||||||
|
if (value == null)
|
||||||
|
{
|
||||||
|
writer.WriteNull();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
writer.WriteValue(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||||
|
{
|
||||||
|
if (objectType == typeof(long))
|
||||||
|
{
|
||||||
|
return Convert.ToInt64(reader.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (objectType == typeof(string))
|
||||||
|
{
|
||||||
|
var date = DateTimeOffset.Parse(reader.Value.ToString());
|
||||||
|
return date.ToUnixTimeSeconds();
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new JsonSerializationException("Can't convert type " + existingValue.GetType().FullName + " to timestamp");
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool CanConvert(Type objectType)
|
||||||
|
{
|
||||||
|
return objectType == typeof(long) || objectType == typeof(string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue