1
0
mirror of https://github.com/mxpv/podsync.git synced 2024-05-11 05:55:04 +00:00

Handle private YouTube channels #10

This commit is contained in:
Maksym Pavlenko
2017-03-06 15:05:36 -08:00
parent 557b24021f
commit eb3a81aa1b

View File

@@ -13,6 +13,8 @@ namespace Podsync.Services.Rss.Builders
{
public class YouTubeRssBuilder : RssBuilderBase
{
private static readonly Item[] NoVideos = new Item[0];
private readonly IYouTubeClient _youTube;
public YouTubeRssBuilder(IYouTubeClient youTube, IStorageService storageService) : base(storageService)
@@ -59,13 +61,18 @@ namespace Podsync.Services.Rss.Builders
throw new ArgumentException("Invalid channel or playlist id");
}
channel.Items = NoVideos;
// Get video ids from this playlist
var ids = await _youTube.GetPlaylistItemIds(new PlaylistItemsQuery { PlaylistId = channel.Guid, Count = metadata.PageSize });
// Get video descriptions
var videos = await _youTube.GetVideos(new VideoQuery { Ids = ids });
if (ids.Count > 0)
{
// Get video descriptions
var videos = await _youTube.GetVideos(new VideoQuery { Ids = ids });
channel.Items = videos.Select(youtubeVideo => MakeItem(youtubeVideo, metadata)).ToArray();
channel.Items = videos.Select(youtubeVideo => MakeItem(youtubeVideo, metadata)).ToArray();
}
var rss = new Feed
{