mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-05 20:42:19 -07:00
cleanup and added api key as a setting, this will probably need documenting how to set this up in the Google Cloud Console
This commit is contained in:
parent
f8fc85c8dd
commit
33f7ab8cd1
4 changed files with 10 additions and 30 deletions
|
@ -13,7 +13,7 @@ using NzbDrone.Core.Parser.Model;
|
|||
namespace NzbDrone.Core.ImportLists.Youtube
|
||||
{
|
||||
public abstract class YoutubeImportListBase<TSettings> : ImportListBase<TSettings>
|
||||
where TSettings : YoutubeSettingsBase<TSettings>, new()
|
||||
where TSettings : YoutubePlaylistSettings, new()
|
||||
{
|
||||
private IHttpClient _httpClient;
|
||||
|
||||
|
@ -36,7 +36,7 @@ namespace NzbDrone.Core.ImportLists.Youtube
|
|||
|
||||
using (var service = new YouTubeService(new BaseClientService.Initializer()
|
||||
{
|
||||
ApiKey = ""
|
||||
ApiKey = Settings.YoutubeApiKey,
|
||||
}))
|
||||
{
|
||||
releases = Fetch(service);
|
||||
|
|
|
@ -32,15 +32,15 @@ namespace NzbDrone.Core.ImportLists.Youtube
|
|||
|
||||
public IList<YoutubeImportListItemInfo> Fetch(YouTubeService service, string playlistId)
|
||||
{
|
||||
// TODO playlist
|
||||
var results = new List<YoutubeImportListItemInfo>();
|
||||
var req = service.PlaylistItems.List("contentDetails,snippet");
|
||||
req.PlaylistId = playlistId;
|
||||
req.MaxResults = 50;
|
||||
|
||||
while (true)
|
||||
var page = 0;
|
||||
var playlist = req.Execute();
|
||||
do
|
||||
{
|
||||
var playlist = req.Execute();
|
||||
page++;
|
||||
req.PageToken = playlist.NextPageToken;
|
||||
|
||||
foreach (var song in playlist.Items)
|
||||
|
@ -61,12 +61,9 @@ namespace NzbDrone.Core.ImportLists.Youtube
|
|||
results.Add(listItem);
|
||||
}
|
||||
|
||||
if (playlist.NextPageToken == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
playlist = req.Execute();
|
||||
}
|
||||
|
||||
while (playlist.NextPageToken != null && page < 10);
|
||||
return results;
|
||||
}
|
||||
|
||||
|
@ -97,10 +94,5 @@ namespace NzbDrone.Core.ImportLists.Youtube
|
|||
{
|
||||
return (playlistItem.ContentDetails.VideoPublishedAtDateTimeOffset ?? DateTimeOffset.UnixEpoch).DateTime;
|
||||
}
|
||||
|
||||
public override object RequestAction(string action, IDictionary<string, string> query)
|
||||
{
|
||||
return base.RequestAction(action, query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,8 @@ namespace NzbDrone.Core.ImportLists.Youtube
|
|||
PlaylistIds = System.Array.Empty<string>();
|
||||
}
|
||||
|
||||
// public override string Scope => "playlist-read-private";
|
||||
[FieldDefinition(1, Label = "Youtube API key", Type = FieldType.Textbox)]
|
||||
public string YoutubeApiKey { get; set; }
|
||||
|
||||
[FieldDefinition(1, Label = "Playlists", Type = FieldType.Textbox)]
|
||||
public IEnumerable<string> PlaylistIds { get; set; }
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
using System;
|
||||
using FluentValidation;
|
||||
using NzbDrone.Core.Annotations;
|
||||
using NzbDrone.Core.Validation;
|
||||
|
||||
namespace NzbDrone.Core.ImportLists.Youtube
|
||||
|
@ -17,17 +15,6 @@ namespace NzbDrone.Core.ImportLists.Youtube
|
|||
|
||||
public string BaseUrl { get; set; }
|
||||
|
||||
public virtual string Scope => "";
|
||||
|
||||
[FieldDefinition(0, Label = "Access Token", Type = FieldType.Textbox, Hidden = HiddenType.Hidden)]
|
||||
public string AccessToken { get; set; }
|
||||
|
||||
[FieldDefinition(0, Label = "Refresh Token", Type = FieldType.Textbox, Hidden = HiddenType.Hidden)]
|
||||
public string RefreshToken { get; set; }
|
||||
|
||||
[FieldDefinition(0, Label = "Expires", Type = FieldType.Textbox, Hidden = HiddenType.Hidden)]
|
||||
public DateTime Expires { get; set; }
|
||||
|
||||
public NzbDroneValidationResult Validate()
|
||||
{
|
||||
return new NzbDroneValidationResult(Validator.Validate((TSettings)this));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue