Skip to content

Commit

Permalink
Merge pull request #39 from granstel/youtube-fixup
Browse files Browse the repository at this point in the history
Youtube fixup
  • Loading branch information
granstel authored Mar 4, 2024
2 parents 8f3192e + 96f0316 commit 29df307
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Dodo1000Bot.Api/Dodo1000Bot.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Version>1.26.0</Version>
<Version>1.26.1</Version>
<UserSecretsId>f449de95-800a-40ef-8716-6e80b7f0977d</UserSecretsId>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion Dodo1000Bot.Api/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"Dodo1000Bot.Api": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:1502;http://localhost:1402",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
Expand Down
2 changes: 1 addition & 1 deletion Dodo1000Bot.Api/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"RefreshEveryTime": "0:10:00"
},
"Youtube": {
"RefreshEveryTime": "0:10:00",
"RefreshEveryTime": "0:15:00",
"ApiKey": "",
"Endpoint": "https://youtube.googleapis.com/youtube/v3/search",
"Channels": [
Expand Down
6 changes: 3 additions & 3 deletions Dodo1000Bot.Services/UnitsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,11 @@ internal async Task CheckUnitsOfBrandAtCountryAndNotify(Brands brand, int countr
_log.LogInformation("unitsList: {unitsList}", unitsList.Serialize());
_log.LogInformation("unitsListSnapshot: {unitsListSnapshot}", unitsListSnapshot.Serialize());

const string formatOfDestinctions = "{0}-{1}";
const string formatOfDistinctions = "{0}-{1}";

var formattedDistinctions = unitsListSnapshot.Select(uls => string.Format(formatOfDestinctions, uls.Name, uls.StartDate));
var formattedDistinctions = unitsListSnapshot.Select(uls => string.Format(formatOfDistinctions, uls.Name, uls.StartDate));
var difference = unitsList.ExceptBy(formattedDistinctions,
ul => string.Format(formatOfDestinctions, ul.Name, ul.StartDate))
ul => string.Format(formatOfDistinctions, ul.Name, ul.StartDate))
.Where(ul => ul.StartDate.Year == DateTime.Today.Date.Year).ToList();

_log.LogInformation("difference: {difference}", difference.Serialize());
Expand Down
8 changes: 6 additions & 2 deletions Dodo1000Bot.Services/YoutubeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,12 @@ public async Task CheckAndNotify(CancellationToken cancellationToken)
var videosSnapshot =
await _snapshotsRepository.Get<Video[]>(snapshotName, cancellationToken);
var videos = await _youTubeClient.SearchVideos(channel, cancellationToken);

var difference = videos.ExceptBy(videosSnapshot.Data.Select(v => v.Id.VideoId), c => c.Id.VideoId);
const string formatOfDistinctions = "{0}-{1}";

var formattedDistinctions = videosSnapshot.Data
.Select(v => string.Format(formatOfDistinctions, v.Id.VideoId, v.Snippet.LiveBroadcastContent));
var difference = videos.ExceptBy(formattedDistinctions,
v => string.Format(formatOfDistinctions, v.Id.VideoId, v.Snippet.LiveBroadcastContent));

foreach (var video in difference)
{
Expand Down

0 comments on commit 29df307

Please sign in to comment.