mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
New: Avoid cache on IMDb user lists
This commit is contained in:
parent
6d4543f1df
commit
7e5d5fe29e
@ -72,7 +72,7 @@ public override IImportListRequestGenerator GetRequestGenerator()
|
|||||||
|
|
||||||
public override IParseImportListResponse GetParser()
|
public override IParseImportListResponse GetParser()
|
||||||
{
|
{
|
||||||
return new RadarrList2Parser();
|
return new IMDbListParser(Settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using NzbDrone.Common.Extensions;
|
||||||
|
using NzbDrone.Core.ImportLists.ImportListMovies;
|
||||||
|
using NzbDrone.Core.MetadataSource.SkyHook.Resource;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.ImportLists.RadarrList2.IMDbList
|
||||||
|
{
|
||||||
|
public class IMDbListParser : RadarrList2Parser
|
||||||
|
{
|
||||||
|
private readonly IMDbListSettings _settings;
|
||||||
|
|
||||||
|
public IMDbListParser(IMDbListSettings settings)
|
||||||
|
: base()
|
||||||
|
{
|
||||||
|
_settings = settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IList<ImportListMovie> ParseResponse(ImportListResponse importListResponse)
|
||||||
|
{
|
||||||
|
var importResponse = importListResponse;
|
||||||
|
|
||||||
|
var movies = new List<ImportListMovie>();
|
||||||
|
|
||||||
|
if (!PreProcess(importResponse))
|
||||||
|
{
|
||||||
|
return movies;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_settings.ListId.StartsWith("ls", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
//Parse TSV response from IMDB export
|
||||||
|
var row = importResponse.Content.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
|
movies = row.Skip(1).SelectList(m => new ImportListMovie { ImdbId = m.Split(',')[1] });
|
||||||
|
|
||||||
|
return movies;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var jsonResponse = JsonConvert.DeserializeObject<List<MovieResource>>(importResponse.Content);
|
||||||
|
|
||||||
|
if (jsonResponse == null)
|
||||||
|
{
|
||||||
|
return movies;
|
||||||
|
}
|
||||||
|
|
||||||
|
return jsonResponse.SelectList(m => new ImportListMovie { TmdbId = m.TmdbId });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using NzbDrone.Common.Http;
|
using System;
|
||||||
|
using NzbDrone.Common.Http;
|
||||||
|
|
||||||
namespace NzbDrone.Core.ImportLists.RadarrList2.IMDbList
|
namespace NzbDrone.Core.ImportLists.RadarrList2.IMDbList
|
||||||
{
|
{
|
||||||
@ -8,8 +9,15 @@ public class IMDbListRequestGenerator : RadarrList2RequestGeneratorBase
|
|||||||
|
|
||||||
protected override HttpRequest GetHttpRequest()
|
protected override HttpRequest GetHttpRequest()
|
||||||
{
|
{
|
||||||
|
//Use IMDb list Export for user lists to bypass RadarrAPI caching
|
||||||
|
if (Settings.ListId.StartsWith("ls", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return new HttpRequest($"https://www.imdb.com/list/{Settings.ListId}/export", new HttpAccept("*/*"));
|
||||||
|
}
|
||||||
|
|
||||||
return RequestBuilder.Create()
|
return RequestBuilder.Create()
|
||||||
.SetSegment("route", $"list/imdb/{Settings.ListId}")
|
.SetSegment("route", $"list/imdb/{Settings.ListId}")
|
||||||
|
.Accept(HttpAccept.Json)
|
||||||
.Build();
|
.Build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ namespace NzbDrone.Core.ImportLists.RadarrList2
|
|||||||
{
|
{
|
||||||
public class RadarrList2Parser : IParseImportListResponse
|
public class RadarrList2Parser : IParseImportListResponse
|
||||||
{
|
{
|
||||||
public IList<ImportListMovie> ParseResponse(ImportListResponse importListResponse)
|
public virtual IList<ImportListMovie> ParseResponse(ImportListResponse importListResponse)
|
||||||
{
|
{
|
||||||
var importResponse = importListResponse;
|
var importResponse = importListResponse;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common.Http;
|
using NzbDrone.Common.Http;
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ public virtual ImportListPageableRequestChain GetMovies()
|
|||||||
|
|
||||||
var httpRequest = GetHttpRequest();
|
var httpRequest = GetHttpRequest();
|
||||||
|
|
||||||
var request = new ImportListRequest(httpRequest.Url.ToString(), HttpAccept.Json);
|
var request = new ImportListRequest(httpRequest.Url.ToString(), new HttpAccept(httpRequest.Headers.Accept));
|
||||||
|
|
||||||
request.HttpRequest.SuppressHttpError = true;
|
request.HttpRequest.SuppressHttpError = true;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user