Cleanup Trakt implementation
This commit is contained in:
parent
0fad20e327
commit
a26163b646
|
@ -28,7 +28,7 @@ namespace NzbDrone.Core.ImportLists.Trakt.List
|
|||
|
||||
link += $"/users/{Settings.Username.Trim()}/lists/{Settings.Listname.ToUrlSlug()}/items/shows?limit={Settings.Limit}";
|
||||
|
||||
var request = new ImportListRequest($"{link}", HttpAccept.Json);
|
||||
var request = new ImportListRequest(link, HttpAccept.Json);
|
||||
|
||||
request.HttpRequest.Headers.Add("trakt-api-version", "2");
|
||||
request.HttpRequest.Headers.Add("trakt-api-key", ClientId);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Serializer;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
namespace NzbDrone.Core.ImportLists.Trakt.Popular
|
||||
|
@ -30,11 +30,11 @@ namespace NzbDrone.Core.ImportLists.Trakt.Popular
|
|||
|
||||
if (_settings.TraktListType == (int)TraktPopularListType.Popular)
|
||||
{
|
||||
jsonResponse = JsonConvert.DeserializeObject<List<TraktSeriesResource>>(_importResponse.Content);
|
||||
jsonResponse = STJson.Deserialize<List<TraktSeriesResource>>(_importResponse.Content);
|
||||
}
|
||||
else
|
||||
{
|
||||
jsonResponse = JsonConvert.DeserializeObject<List<TraktResponse>>(_importResponse.Content).SelectList(c => c.Show);
|
||||
jsonResponse = STJson.Deserialize<List<TraktResponse>>(_importResponse.Content).SelectList(c => c.Show);
|
||||
}
|
||||
|
||||
// no movies were return
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace NzbDrone.Core.ImportLists.Trakt.Popular
|
|||
var filtersAndLimit = $"?years={Settings.Years}&genres={Settings.Genres?.ToLower()}&ratings={Settings.Rating}&limit={Settings.Limit}{Settings.TraktAdditionalParameters}";
|
||||
link += filtersAndLimit;
|
||||
|
||||
var request = new ImportListRequest($"{link}", HttpAccept.Json);
|
||||
var request = new ImportListRequest(link, HttpAccept.Json);
|
||||
|
||||
request.HttpRequest.Headers.Add("trakt-api-version", "2");
|
||||
request.HttpRequest.Headers.Add("trakt-api-key", ClientId);
|
||||
|
|
|
@ -45,6 +45,7 @@ namespace NzbDrone.Core.ImportLists.Trakt
|
|||
}
|
||||
|
||||
var generator = GetRequestGenerator();
|
||||
|
||||
return FetchItems(g => g.GetListItems(), true);
|
||||
}
|
||||
|
||||
|
@ -132,7 +133,7 @@ namespace NzbDrone.Core.ImportLists.Trakt
|
|||
var token = response.Resource;
|
||||
Settings.AccessToken = token.AccessToken;
|
||||
Settings.Expires = DateTime.UtcNow.AddSeconds(token.ExpiresIn);
|
||||
Settings.RefreshToken = token.RefreshToken != null ? token.RefreshToken : Settings.RefreshToken;
|
||||
Settings.RefreshToken = token.RefreshToken ?? Settings.RefreshToken;
|
||||
|
||||
if (Definition.Id > 0)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using Newtonsoft.Json;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Serializer;
|
||||
using NzbDrone.Core.ImportLists.Exceptions;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
|
@ -26,20 +26,20 @@ namespace NzbDrone.Core.ImportLists.Trakt
|
|||
return series;
|
||||
}
|
||||
|
||||
var jsonResponse = JsonConvert.DeserializeObject<List<TraktResponse>>(_importResponse.Content);
|
||||
var jsonResponse = STJson.Deserialize<List<TraktResponse>>(_importResponse.Content);
|
||||
|
||||
// no movies were return
|
||||
// no series were return
|
||||
if (jsonResponse == null)
|
||||
{
|
||||
return series;
|
||||
}
|
||||
|
||||
foreach (var movie in jsonResponse)
|
||||
foreach (var show in jsonResponse)
|
||||
{
|
||||
series.AddIfNotNull(new ImportListItemInfo()
|
||||
{
|
||||
Title = movie.Show.Title,
|
||||
TvdbId = movie.Show.Ids.Tvdb.GetValueOrDefault()
|
||||
Title = show.Show.Title,
|
||||
TvdbId = show.Show.Ids.Tvdb.GetValueOrDefault()
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace NzbDrone.Core.ImportLists.Trakt.User
|
|||
break;
|
||||
}
|
||||
|
||||
var request = new ImportListRequest($"{link}", HttpAccept.Json);
|
||||
var request = new ImportListRequest(link, HttpAccept.Json);
|
||||
|
||||
request.HttpRequest.Headers.Add("trakt-api-version", "2");
|
||||
request.HttpRequest.Headers.Add("trakt-api-key", ClientId);
|
||||
|
|
Loading…
Reference in New Issue