mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-04-24 05:47:22 -04:00
Fixed: (AvistaZBase) Parse response with STJson
Also ensure GetToken is using a proxied request and rate limit
This commit is contained in:
parent
993d189c61
commit
c81cbc801a
3 changed files with 18 additions and 26 deletions
|
@ -1,5 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.Definitions.Avistaz
|
||||
{
|
||||
|
@ -9,34 +9,34 @@ namespace NzbDrone.Core.Indexers.Definitions.Avistaz
|
|||
public string Download { get; set; }
|
||||
public Dictionary<string, string> Category { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "movie_tv")]
|
||||
[JsonPropertyName("movie_tv")]
|
||||
public AvistazIdInfo MovieTvinfo { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "created_at")]
|
||||
[JsonPropertyName("created_at")]
|
||||
public string CreatedAt { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "file_name")]
|
||||
[JsonPropertyName("file_name")]
|
||||
public string FileName { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "info_hash")]
|
||||
[JsonPropertyName("info_hash")]
|
||||
public string InfoHash { get; set; }
|
||||
public int? Leech { get; set; }
|
||||
public int? Completed { get; set; }
|
||||
public int? Seed { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "file_size")]
|
||||
[JsonPropertyName("file_size")]
|
||||
public long? FileSize { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "file_count")]
|
||||
[JsonPropertyName("file_count")]
|
||||
public int? FileCount { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "download_multiply")]
|
||||
[JsonPropertyName("download_multiply")]
|
||||
public double? DownloadMultiply { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "upload_multiply")]
|
||||
[JsonPropertyName("upload_multiply")]
|
||||
public double? UploadMultiply { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "video_quality")]
|
||||
[JsonPropertyName("video_quality")]
|
||||
public string VideoQuality { get; set; }
|
||||
public string Type { get; set; }
|
||||
public List<AvistazLanguage> Audio { get; set; }
|
||||
|
@ -64,21 +64,10 @@ namespace NzbDrone.Core.Indexers.Definitions.Avistaz
|
|||
public string Tmdb { get; set; }
|
||||
public string Tvdb { get; set; }
|
||||
public string Imdb { get; set; }
|
||||
public string Title { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "tv_episode")]
|
||||
public string TvEpisode { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "tv_season")]
|
||||
public string TVSeason { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "tv_full_season")]
|
||||
public bool TVFullSeason { get; set; }
|
||||
}
|
||||
|
||||
public class AvistazAuthResponse
|
||||
{
|
||||
public string Token { get; set; }
|
||||
public string Expiry { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ using System.Threading.Tasks;
|
|||
using FluentValidation.Results;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Common.Serializer;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
|
||||
|
@ -120,12 +121,13 @@ namespace NzbDrone.Core.Indexers.Definitions.Avistaz
|
|||
.AddFormParameter("password", Settings.Password)
|
||||
.AddFormParameter("pid", Settings.Pid.Trim())
|
||||
.Accept(HttpAccept.Json)
|
||||
.WithRateLimit(RateLimit.TotalSeconds)
|
||||
.Build();
|
||||
|
||||
var response = await _httpClient.PostAsync<AvistazAuthResponse>(authLoginRequest);
|
||||
var token = response.Resource.Token;
|
||||
var response = await _httpClient.ExecuteProxiedAsync(authLoginRequest, Definition);
|
||||
var authResponse = STJson.Deserialize<AvistazAuthResponse>(response.Content);
|
||||
|
||||
return token;
|
||||
return authResponse.Token;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ using System.Linq;
|
|||
using System.Net;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Common.Serializer;
|
||||
using NzbDrone.Core.Indexers.Exceptions;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
@ -42,9 +43,9 @@ namespace NzbDrone.Core.Indexers.Definitions.Avistaz
|
|||
throw new IndexerException(indexerResponse, $"Unexpected response header {indexerResponse.HttpResponse.Headers.ContentType} from indexer request, expected {HttpAccept.Json.Value}");
|
||||
}
|
||||
|
||||
var jsonResponse = new HttpResponse<AvistazResponse>(indexerResponse.HttpResponse);
|
||||
var jsonResponse = STJson.Deserialize<AvistazResponse>(indexerResponse.HttpResponse.Content);
|
||||
|
||||
foreach (var row in jsonResponse.Resource.Data)
|
||||
foreach (var row in jsonResponse.Data)
|
||||
{
|
||||
var details = row.Url;
|
||||
var link = row.Download;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue