Skip to content

Commit ff9ea86

Browse files
author
Andrii Bondarchuk
committed
Forward cancellation token to youtube requests
1 parent cdacc30 commit ff9ea86

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/FitSyncHub.Functions/Functions/YoutubeRedirectToLiveChatHttpTriggerFunction.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ public async Task<IActionResult> Run(
2727
{
2828
_logger.LogInformation("C# HTTP trigger function processed a request.");
2929

30-
var videoId = await _youTubeLiveService.GetLiveVideoId();
30+
var videoId = await _youTubeLiveService.GetLiveVideoId(cancellationToken);
3131
if (videoId is null)
3232
{
3333
_logger.LogInformation("No live video found, checking for upcoming videos.");
3434
}
3535

36-
videoId ??= await _youTubeLiveService.GetUpcomingVideoId();
36+
videoId ??= await _youTubeLiveService.GetUpcomingVideoId(cancellationToken);
3737
if (videoId == null)
3838
{
3939
_logger.LogInformation("No upcoming video found for the specified channel.");

src/FitSyncHub.Youtube/Services/YouTubeLiveService.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,26 @@ public YouTubeLiveService(YouTubeService youTubeService, IOptions<YoutubeOptions
1515
_channelId = options.Value.ChannelId;
1616
}
1717

18-
public async Task<string?> GetUpcomingVideoId()
18+
public async Task<string?> GetUpcomingVideoId(CancellationToken cancellationToken)
1919
{
2020
var searchRequest = _youtubeService.Search.List("snippet");
2121
searchRequest.ChannelId = _channelId;
2222
searchRequest.EventType = SearchResource.ListRequest.EventTypeEnum.Upcoming;
2323
searchRequest.Type = "video";
2424

25-
var searchResponse = await searchRequest.ExecuteAsync();
25+
var searchResponse = await searchRequest.ExecuteAsync(cancellationToken);
2626

2727
return searchResponse.Items.FirstOrDefault()?.Id.VideoId;
2828
}
2929

30-
public async Task<string?> GetLiveVideoId()
30+
public async Task<string?> GetLiveVideoId(CancellationToken cancellationToken)
3131
{
3232
var searchRequest = _youtubeService.Search.List("snippet");
3333
searchRequest.ChannelId = _channelId;
3434
searchRequest.EventType = SearchResource.ListRequest.EventTypeEnum.Live;
3535
searchRequest.Type = "video";
3636

37-
var searchResponse = await searchRequest.ExecuteAsync();
37+
var searchResponse = await searchRequest.ExecuteAsync(cancellationToken);
3838

3939
return searchResponse.Items.FirstOrDefault()?.Id.VideoId;
4040
}

0 commit comments

Comments
 (0)