using NLog; using Sony.Filtr.ApolloAPI; using Sony.Filtr.Buzz; using Sony.Filtr.Contracts.Abstractions; using Sony.Filtr.Core.Buzz; using Sony.Filtr.Core.EditorialPlaylists; using Sony.Filtr.Core.SpotifyUserCountries; using Sony.Filtr.Core.SpotifyWeekly; using Sony.Filtr.Core.TrackPopularity; using Sony.Filtr.Playlists; using Sony.Filtr.Playlists.Spotify; using Sony.Filtr.SpotifyImages; using Sony.Filtr.SpotifyWebAPI; using Sony.Filtr.SpotifyWebAPI.Model; using Sony.Filtr.Tasks.Helpers; using Sony.Filtr.VendorToSpotify; using System; using System.Collections.Generic; using System.Threading.Tasks; namespace Sony.Filtr.Tasks.Tasks { public class UpdatePlaylistInfoWithVendorAPI : UpdatePlaylistInfoTask { private readonly LoggerAdapter _playlistInvalidTracks; public UpdatePlaylistInfoWithVendorAPI(SpotifyWebApi spotifyWebApi, IApolloWebApi apolloWebApi, EditorialPlaylistManager editorialPlaylistManager, SpotifyPlaylistManager spotifyPlaylistManager, SpotifyUserCountryManager spotifyUserCountryManager, BuzzAccountManager buzzAccountManager, IServiceAccountManager serviceAccountManager, SpotifyTrackPopularityManager spotifyTrackPopularityManager, SpotifyImageDownloader spotifyImageHandler, BuzzManager buzzManager, SpotifyPlaylistHistoricTrackListManager historicTrackListManager, IgnoredPlaylistsManager ignoredPlaylistsManager, UpdatePlaylistsHelper updatePlaylistsHelper, SpotifyWeeklyManager spotifyWeeklyManager) : base(spotifyWebApi, apolloWebApi, editorialPlaylistManager, spotifyPlaylistManager, spotifyUserCountryManager, buzzAccountManager, serviceAccountManager, spotifyTrackPopularityManager, spotifyImageHandler, buzzManager, historicTrackListManager, ignoredPlaylistsManager, updatePlaylistsHelper, spotifyWeeklyManager) { _playlistInvalidTracks = LoggerAdapter.GetLogger("PlaylistInvalidTracks"); } protected override async Task<(PlaylistResponse Response, RequestData Data, IEnumerable> RawResponses)> GetPlaylistWithTracksAsync(string playlistId, string fields, string snapshotId) { var vendorPlaylist = await this._apolloWebApi.GetPlaylistByIdWithAllTracksHavingSnapshotIdAsync(playlistId, snapshotId, ApolloCache, fields); await VerifyAndHandlePlaylistInvalidTrack(vendorPlaylist, invalidTracksMessage => _playlistInvalidTracks.Information(() => invalidTracksMessage)); return (vendorPlaylist.ToSpotify(), new RequestData(vendorPlaylist == null ? String.Empty : vendorPlaylist.GetSummary()), vendorPlaylist?.RawResponses); } } }