mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-05 20:42:19 -07:00
test connection by trying to get 1 result from each provided playlist
This commit is contained in:
parent
33f7ab8cd1
commit
85302bded0
2 changed files with 30 additions and 1 deletions
|
@ -57,9 +57,17 @@ namespace NzbDrone.Core.ImportLists.Youtube
|
||||||
failures.AddIfNotNull(TestConnection());
|
failures.AddIfNotNull(TestConnection());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract ValidationFailure TestConnection(YouTubeService service);
|
||||||
|
|
||||||
private ValidationFailure TestConnection()
|
private ValidationFailure TestConnection()
|
||||||
{
|
{
|
||||||
return null;
|
using (var service = new YouTubeService(new BaseClientService.Initializer()
|
||||||
|
{
|
||||||
|
ApiKey = Settings.YoutubeApiKey,
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
return TestConnection(service);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using DryIoc.ImTools;
|
using DryIoc.ImTools;
|
||||||
|
using FluentValidation.Results;
|
||||||
using Google.Apis.YouTube.v3;
|
using Google.Apis.YouTube.v3;
|
||||||
using Google.Apis.YouTube.v3.Data;
|
using Google.Apis.YouTube.v3.Data;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
@ -94,5 +95,25 @@ namespace NzbDrone.Core.ImportLists.Youtube
|
||||||
{
|
{
|
||||||
return (playlistItem.ContentDetails.VideoPublishedAtDateTimeOffset ?? DateTimeOffset.UnixEpoch).DateTime;
|
return (playlistItem.ContentDetails.VideoPublishedAtDateTimeOffset ?? DateTimeOffset.UnixEpoch).DateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override ValidationFailure TestConnection(YouTubeService service)
|
||||||
|
{
|
||||||
|
foreach (var id in Settings.PlaylistIds)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var req = service.PlaylistItems.List("contentDetails,snippet");
|
||||||
|
req.PlaylistId = id;
|
||||||
|
req.MaxResults = 1;
|
||||||
|
req.Execute();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return new ValidationFailure(string.Empty, e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue