mirror of
https://github.com/Radarr/Radarr
synced 2025-12-06 08:28:50 +01:00
Fixed: Improve IMDb list logging
This commit is contained in:
parent
9906b95893
commit
bb6713f1d2
3 changed files with 18 additions and 9 deletions
|
|
@ -76,7 +76,7 @@ public override IImportListRequestGenerator GetRequestGenerator()
|
|||
|
||||
public override IParseImportListResponse GetParser()
|
||||
{
|
||||
return new IMDbListParser(Settings);
|
||||
return new IMDbListParser(Settings, _logger);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.ImportLists.ImportListMovies;
|
||||
using NzbDrone.Core.MetadataSource.SkyHook.Resource;
|
||||
|
|
@ -11,10 +12,12 @@ namespace NzbDrone.Core.ImportLists.RadarrList2.IMDbList
|
|||
public class IMDbListParser : RadarrList2Parser
|
||||
{
|
||||
private readonly IMDbListSettings _settings;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public IMDbListParser(IMDbListSettings settings)
|
||||
public IMDbListParser(IMDbListSettings settings, Logger logger)
|
||||
{
|
||||
_settings = settings;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public override IList<ImportListMovie> ParseResponse(ImportListResponse importListResponse)
|
||||
|
|
@ -25,6 +28,7 @@ public override IList<ImportListMovie> ParseResponse(ImportListResponse importLi
|
|||
|
||||
if (!PreProcess(importResponse))
|
||||
{
|
||||
_logger.Debug("IMDb List {0}: Found {1} movies", _settings.ListId, movies.Count);
|
||||
return movies;
|
||||
}
|
||||
|
||||
|
|
@ -34,20 +38,19 @@ public override IList<ImportListMovie> ParseResponse(ImportListResponse importLi
|
|||
var rows = importResponse.Content.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
movies = rows.Skip(1).SelectList(m => m.Split(',')).Where(m => m.Length > 5).SelectList(i => new ImportListMovie { ImdbId = i[1], Title = i[5] });
|
||||
|
||||
return movies;
|
||||
}
|
||||
else
|
||||
{
|
||||
var jsonResponse = JsonConvert.DeserializeObject<List<MovieResource>>(importResponse.Content);
|
||||
|
||||
if (jsonResponse == null)
|
||||
if (jsonResponse != null)
|
||||
{
|
||||
return movies;
|
||||
movies = jsonResponse.SelectList(m => new ImportListMovie { TmdbId = m.TmdbId });
|
||||
}
|
||||
|
||||
return jsonResponse.SelectList(m => new ImportListMovie { TmdbId = m.TmdbId });
|
||||
}
|
||||
|
||||
_logger.Debug("IMDb List {0}: Found {1} movies", _settings.ListId, movies.Count);
|
||||
return movies;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,16 +9,22 @@ public class IMDbListRequestGenerator : RadarrList2RequestGeneratorBase
|
|||
|
||||
protected override HttpRequest GetHttpRequest()
|
||||
{
|
||||
Logger.Info("IMDb List {0}: Importing movies", Settings.ListId);
|
||||
|
||||
// Use IMDb list Export for user lists to bypass RadarrAPI caching
|
||||
if (Settings.ListId.StartsWith("ls", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
throw new Exception("IMDb lists of the form 'ls12345678' are no longer supported. Feel free to remove this list after you review your Clean Library Level.");
|
||||
}
|
||||
|
||||
return RequestBuilder.Create()
|
||||
var request = RequestBuilder.Create()
|
||||
.SetSegment("route", $"list/imdb/{Settings.ListId}")
|
||||
.Accept(HttpAccept.Json)
|
||||
.Build();
|
||||
|
||||
Logger.Trace("IMDb List {0}: Request URL: {1}", Settings.ListId, request.Url);
|
||||
|
||||
return request;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue