Only fetching channel IDs from DB instead all of channel

This commit is contained in:
hak8or 2018-02-20 00:13:06 -05:00
parent a3a3c3a780
commit d2b9a8b40c
1 changed files with 6 additions and 2 deletions

View File

@ -37,6 +37,7 @@ namespace YTManager.Tasks {
}).ToList();
}
// Gets some info about a youtube channel.
public static async Task<Models.Channel> Get_YTChannel(string channelID) {
// YT API access key
var youtubeService = new YouTubeService(new Google.Apis.Services.BaseClientService.Initializer()
@ -68,10 +69,13 @@ namespace YTManager.Tasks {
ops.UseNpgsql(dbstr);
// Get all the channels from the db.
var channels = await (new MediaDB(ops.Options)).Channels.ToListAsync();
var channel_ids = await
(new MediaDB(ops.Options))
.Channels.Select(ch => ch.YoutubeID)
.ToListAsync();
// For each channel, do an update.
channels.ForEach(async ch => await ChannelUpdate(dbstr, ch.YoutubeID));
channel_ids.ForEach(async id => await ChannelUpdate(dbstr, id));
}
// Update videos for just one channel.