public void CreatePlaylistDeezer() { var userId = UserId.Parse("12345"); var playlistId = PlaylistId.Parse("100"); var playlistName = "playlistName"; var accessToken = "accessToken"; var deezerService = DeezerApiBuilder.Create(); var actualPlaylistId = deezerService .SetCreatePlaylist(playlistId) .Build() .CreatePlaylist(accessToken, userId, playlistName); Assert.AreEqual(actualPlaylistId, actualPlaylistId); }
public void AddSongsToPlaylistDeezer() { var playlistId = PlaylistId.Parse("100"); var accessToken = "accessToken"; var songIds = new [] { SongId.Parse("001"), SongId.Parse("002"), SongId.Parse("003") }; var deezerService = DeezerApiBuilder.Create(); deezerService.Build().AddSongsToPlaylist(accessToken, playlistId, songIds); Assert.AreEqual(3, deezerService.SongsAdded); }
public ValueTask <IPlaylist> Create(PlaylistId playlistId) { if (playlistId == QueuePlaylist.Id) { return(new(_queuePlaylist)); } else { var localPlaylist = _localMylistManager.GetPlaylist(playlistId.Id); if (localPlaylist == null) { throw new HohoemaExpception(); } return(new(localPlaylist)); } }
public void GetPlaylistsByUserIdWithUserId() { // arrange var playlistId = PlaylistId.Parse("100"); var userId = UserId.Parse("12345"); var accessToken = "accessToken"; var deezerService = DeezerApiBuilder .Create() .SetPlaylistIdsByUserId(new[] { playlistId }) .Build(); // act var actual = deezerService.GetPlaylistIdsByUserId(accessToken, userId, s => true); // assert Assert.AreEqual(1, actual.Count()); Assert.AreEqual(playlistId, actual.First()); }
public void RaiseMessageWhenAddPlaylistToUser() { var stream = new MemoryEventStream(); var deezerApi = DeezerApiBuilder.Create().SetCreatePlaylist(PlaylistId.Parse("100")).Build(); var songRepository = SongRepositoryBuilder.Create() .SetRandomSongs(1, new[] { new Song(SongId.Parse("100"), "title", "artist") }).Build(); var playlistRepository = PlaylistRepositoryBuilder.Create().Build(); stream.Add(new UserCreated(Identity.Parse("*****@*****.**", "dublow", "12345", "accessToken"))); var publisher = new EventBus(stream); var user = new User(stream, publisher, deezerApi, songRepository, playlistRepository, 1); user.AddPlaylist("playlistName"); Assert.IsTrue(stream.GetEvents().Contains(new PlaylistAdded(UserId.Parse("12345"), PlaylistId.Parse("100"), "playlistName"))); }
public void UseRepositoryWhenPlaylistIsDeleted() { // arrange var userId = UserId.Parse("12345"); var playlistId = PlaylistId.Parse("100"); var playlistName = "playlistName"; var mockedPlaylistRepository = PlaylistRepositoryBuilder.Create(); mockedPlaylistRepository.Playlists.Add((userId, playlistId, playlistName)); var playlistRepository = mockedPlaylistRepository.Build(); var playlistHandler = new PlaylistHandler(playlistRepository); // act playlistHandler.Handle(new PlaylistDeleted(userId, playlistId, playlistName)); // assert Assert.AreEqual(0, mockedPlaylistRepository.Playlists.Count); }
public override int GetHashCode() { unchecked { var hashCode = GameBaseVariantId.GetHashCode(); hashCode = (hashCode * 397) ^ GameVariantId.GetHashCode(); hashCode = (hashCode * 397) ^ (GameVariantResourceId?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ IsMatchOver.GetHashCode(); hashCode = (hashCode * 397) ^ IsTeamGame.GetHashCode(); hashCode = (hashCode * 397) ^ MapId.GetHashCode(); hashCode = (hashCode * 397) ^ MapVariantId.GetHashCode(); hashCode = (hashCode * 397) ^ (MapVariantResourceId?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ PlaylistId.GetHashCode(); hashCode = (hashCode * 397) ^ SeasonId.GetHashCode(); hashCode = (hashCode * 397) ^ TotalDuration.GetHashCode(); return(hashCode); } }
public async ValueTask <PlaylistNextResponseExtractor> GetPlaylistNextResponseAsync( PlaylistId playlistId, VideoId?videoId = null, int index = 0, string?visitorData = null, CancellationToken cancellationToken = default) { const string url = $"https://www.youtube.com/youtubei/v1/next?key={ApiKey}"; var payload = new { playlistId = playlistId.Value, videoId = videoId?.Value, playlistIndex = index, context = new { client = new { clientName = "WEB", clientVersion = "2.20210408.08.00", hl = "en", gl = "US", utcOffsetMinutes = 0, visitorData } } }; using var request = new HttpRequestMessage(HttpMethod.Post, url) { Content = Json.SerializeToHttpContent(payload) }; var raw = await SendHttpRequestAsync(request, cancellationToken); var playlistResponse = PlaylistNextResponseExtractor.Create(raw); if (!playlistResponse.IsPlaylistAvailable()) { throw new PlaylistUnavailableException($"Playlist '{playlistId}' is not available."); } return(playlistResponse); }
/// <summary> /// Gets the metadata associated with the specified playlist. /// </summary> public async ValueTask <Playlist> GetAsync( PlaylistId playlistId, CancellationToken cancellationToken = default) { var playlistExtractor = await GetExtractorForMetadataAsync(playlistId, cancellationToken); var title = playlistExtractor.TryGetPlaylistTitle() ?? throw new YoutubeExplodeException("Could not extract playlist title."); // System playlists have no author var channelId = playlistExtractor.TryGetPlaylistChannelId(); var channelTitle = playlistExtractor.TryGetPlaylistAuthor(); var author = channelId is not null && channelTitle is not null ? new Author(channelId, channelTitle) : null; // System playlists have no description var description = playlistExtractor.TryGetPlaylistDescription() ?? ""; var thumbnails = playlistExtractor .GetPlaylistThumbnails() .Select(t => { var thumbnailUrl = t.TryGetUrl() ?? throw new YoutubeExplodeException("Could not extract thumbnail URL."); var thumbnailWidth = t.TryGetWidth() ?? throw new YoutubeExplodeException("Could not extract thumbnail width."); var thumbnailHeight = t.TryGetHeight() ?? throw new YoutubeExplodeException("Could not extract thumbnail height."); var thumbnailResolution = new Resolution(thumbnailWidth, thumbnailHeight); return(new Thumbnail(thumbnailUrl, thumbnailResolution)); }) .ToArray(); return(new Playlist(playlistId, title, author, description, thumbnails)); }
public void UseRepositoryWhenPlaylistIsAdded() { // arrange var userId = UserId.Parse("12345"); var playlistId = PlaylistId.Parse("100"); var playlistName = "playlistName"; var mockedPlaylistRepository = PlaylistRepositoryBuilder.Create(); var playlistRepository = mockedPlaylistRepository.Build(); var playlistHandler = new PlaylistHandler(playlistRepository); // act playlistHandler.Handle(new PlaylistAdded(userId, playlistId, playlistName)); // assert var(actualUserId, actualPlaylisId, actualPlaylistName) = mockedPlaylistRepository.Playlists.First(); Assert.AreEqual(userId, actualUserId); Assert.AreEqual(playlistId, actualPlaylisId); Assert.AreEqual(playlistName, actualPlaylistName); }
public void NoRaiseMessageWhenAddExistingPlaylistToUser() { var stream = new MemoryEventStream(); var deezerApi = DeezerApiBuilder.Create().Build(); var songRepository = SongRepositoryBuilder.Create().Build(); var playlistRepository = PlaylistRepositoryBuilder.Create().Build(); stream.Add(new UserCreated(Identity.Parse("*****@*****.**", "dublow", "12345", "accessToken"))); stream.Add(new PlaylistAdded(UserId.Parse("12345"), PlaylistId.Parse("100"), "playlistName")); var publisher = new EventBus(stream); var user = new User(stream, publisher, deezerApi, songRepository, playlistRepository, 1); user.AddPlaylist("playlistName"); Assert.IsTrue(stream.GetEvents().Contains(new PlaylistAdded(UserId.Parse("12345"), PlaylistId.Parse("100"), "playlistName"))); Assert.AreEqual(1, stream.GetEvents().OfType <PlaylistAdded>().Count()); }
public override int GetHashCode() { unchecked { var hashCode = (int)GameMode; hashCode = (hashCode * 397) ^ IsMatchComplete.GetHashCode(); hashCode = (hashCode * 397) ^ (MapId?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ MatchDuration.GetHashCode(); hashCode = (hashCode * 397) ^ MatchEndReason.GetHashCode(); hashCode = (hashCode * 397) ^ MatchId.GetHashCode(); hashCode = (hashCode * 397) ^ (MatchStartDate != null ? MatchStartDate.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (int)MatchType; hashCode = (hashCode * 397) ^ (Players?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ PlaylistId.GetHashCode(); hashCode = (hashCode * 397) ^ SeasonId.GetHashCode(); hashCode = (hashCode * 397) ^ (Teams?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ VictoryCondition.GetHashCode(); return(hashCode); } }
public void Receive(VideoPlayRequestMessage message) { _lastPlayedLive = null; async Task <VideoPlayRequestMessageData> ResolvePlay(VideoPlayRequestMessage message) { IPlaylist playlist = null; IPlaylistSortOption sortOption = message.SortOptions; if (message.PlayWithQueue ?? false) { playlist = _queuePlaylist; } else if (message.Playlist != null) { playlist = message.Playlist; } else if (message.PlaylistId == QueuePlaylist.Id.Id && message.PlaylistOrigin == PlaylistItemsSourceOrigin.Local) { playlist = _queuePlaylist; sortOption = QueuePlaylist.DefaultSortOption; } else if (message.PlaylistId != null) { Guard.IsNotNull(message.PlaylistId, nameof(message.PlaylistId)); Guard.IsNotNull(message.PlaylistOrigin, nameof(message.PlaylistOrigin)); var playlistId = new PlaylistId() { Id = message.PlaylistId, Origin = message.PlaylistOrigin.Value }; var factory = _playlistItemsSourceResolver.Resolve(playlistId.Origin); playlist = await factory.Create(playlistId); } if (sortOption is null && message.PlaylistSortOptionsAsString is not null) { var factory = _playlistItemsSourceResolver.Resolve(playlist.PlaylistId.Origin); sortOption = factory.DeserializeSortOptions(message.PlaylistSortOptionsAsString); }
public IEnumerable <DeezerSong> GetSongsByPlaylistId(string accessToken, PlaylistId playlistId) { var uri = String.Format(Endpoints.GetSongsByPlaylist, playlistId.Value, accessToken); TrackDeezer GetT(string url) { Thread.Sleep(2000); return(_request.Get(url, JsonConvert.DeserializeObject <TrackDeezer>)); } var trackItemDeezer = new List <TrackItemDeezer>(); while (!string.IsNullOrEmpty(uri)) { var trackDeezer = GetT(uri); trackItemDeezer.AddRange(trackDeezer.Tracks); uri = trackDeezer.Next; } return(trackItemDeezer.Select(x => new DeezerSong(SongId.Parse(x.Id), x.Title, x.Artist.Name))); }
public bool Equals(MatchStart other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(base.Equals(other) && GameMode == other.GameMode && IsDefaultRuleSet == other.IsDefaultRuleSet && string.Equals(MapId, other.MapId) && MatchId.Equals(other.MatchId) && MatchType == other.MatchType && PlaylistId.Equals(other.PlaylistId) && TeamSize == other.TeamSize); }
public bool Equals(BaseMatch other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(GameBaseVariantId.Equals(other.GameBaseVariantId) && GameVariantId.Equals(other.GameVariantId) && IsMatchOver == other.IsMatchOver && IsTeamGame == other.IsTeamGame && MapId.Equals(other.MapId) && MapVariantId.Equals(other.MapVariantId) && PlaylistId.Equals(other.PlaylistId) && SeasonId.Equals(other.SeasonId) && TotalDuration.Equals(other.TotalDuration)); }
public override int GetHashCode() { unchecked { var hashCode = HighestCsr?.GetHashCode() ?? 0; hashCode = (hashCode * 397) ^ HighestWaveCompleted; hashCode = (hashCode * 397) ^ (LeaderStats?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ PlaylistClassification.GetHashCode(); hashCode = (hashCode * 397) ^ PlaylistId.GetHashCode(); hashCode = (hashCode * 397) ^ TotalCardPlays; hashCode = (hashCode * 397) ^ TotalMatchesCompleted; hashCode = (hashCode * 397) ^ TotalMatchesLost; hashCode = (hashCode * 397) ^ TotalMatchesStarted; hashCode = (hashCode * 397) ^ TotalMatchesWon; hashCode = (hashCode * 397) ^ TotalPointCaptures; hashCode = (hashCode * 397) ^ TotalTimePlayed.GetHashCode(); hashCode = (hashCode * 397) ^ TotalUnitsBuilt; hashCode = (hashCode * 397) ^ TotalUnitsDestroyed; hashCode = (hashCode * 397) ^ TotalUnitsLost; return(hashCode); } }
public void GetSongsByPlaylistIdWithPlaylistId() { // arrange var playlistId = PlaylistId.Parse("100"); var songId = SongId.Parse("001"); var title = "title"; var artist = "artist"; var accessToken = "accessToken"; var deezerService = DeezerApiBuilder .Create() .SetSongsByPlaylistId(new [] { new DeezerSong(songId, title, artist) }) .Build(); // act var actual = deezerService.GetSongsByPlaylistId(accessToken, playlistId); // assert Assert.AreEqual(1, actual.Count()); Assert.AreEqual(songId, actual.First().Id); Assert.AreEqual(title, actual.First().Title); Assert.AreEqual(artist, actual.First().Artist); }
public void UseRepositoryWhenSongIsAdded() { // arrange var userId = UserId.Parse("12345"); var playlistId = PlaylistId.Parse("100"); var songId = SongId.Parse("001"); var title = "title"; var artist = "artist"; var mockedSongRepository = SongRepositoryBuilder.Create(); var songRepository = mockedSongRepository.Build(); var songHandler = new SongHandler(songRepository); // act songHandler.Handle(new SongAdded(userId, playlistId, songId, title, artist)); // assert var(actualUserId, actualPlaylistId, actualSongId, actualTitle, actualArtist) = mockedSongRepository.Songs.First(); Assert.AreEqual(userId, actualUserId); Assert.AreEqual(playlistId, actualPlaylistId); Assert.AreEqual(songId, actualSongId); Assert.AreEqual(title, actualTitle); Assert.AreEqual(artist, actualArtist); }
public override int GetHashCode() { unchecked { var hashCode = (ExperienceProgress != null ? ExperienceProgress.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (int)GameMode; hashCode = (hashCode * 397) ^ LeaderId; hashCode = (hashCode * 397) ^ (MapId?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ MatchId.GetHashCode(); hashCode = (hashCode * 397) ^ (MatchStartDate != null ? MatchStartDate.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (int)MatchType; hashCode = (hashCode * 397) ^ PlayerCompletedMatch.GetHashCode(); hashCode = (hashCode * 397) ^ PlayerIndex; hashCode = (hashCode * 397) ^ PlayerMatchDuration.GetHashCode(); hashCode = (hashCode * 397) ^ (int)PlayerMatchOutcome; hashCode = (hashCode * 397) ^ PlaylistId.GetHashCode(); hashCode = (hashCode * 397) ^ (RatingProgress != null ? RatingProgress.GetHashCode() : 0); hashCode = (hashCode * 397) ^ SeasonId.GetHashCode(); hashCode = (hashCode * 397) ^ TeamId; hashCode = (hashCode * 397) ^ TeamPlayerIndex; hashCode = (hashCode * 397) ^ (Teams?.GetHashCode() ?? 0); return(hashCode); } }
public void Playlist_ID_cannot_be_parsed_from_an_invalid_string(string playlistIdOrUrl) { // Act & assert Assert.Throws <ArgumentException>(() => PlaylistId.Parse(playlistIdOrUrl)); }
public void I_cannot_specify_an_invalid_playlist_url_in_place_of_an_id(string playlistUrl) { // Act & assert Assert.Throws <ArgumentException>(() => new PlaylistId(playlistUrl)); PlaylistId.TryParse(playlistUrl).Should().BeNull(); }
public void Add(UserId userId, PlaylistId playlistId, SongId songId, string title, string artist) { Console.WriteLine( $"UserId:{userId.Value} PlaylistId: {playlistId.Value} SongId: {songId.Value} Title:{title} Artist: {artist}"); }
public override string ToString() { return(PlaylistId.ToString()); // Für bessere Coded UI Test Erkennung }
private async Task DownloadVideo() { YoutubeClient client = new YoutubeClient(); if (downloadedUrl.IndexOf("&list=") > 0) { isList = true; string id = downloadedUrl.Split(new string[] { "&list=" }, StringSplitOptions.RemoveEmptyEntries)[1]; PlaylistId plId = new PlaylistId(id); var videolist = client.Playlists.GetVideosAsync(plId); List <string> playlist = new List <string>(); playlist = (await videolist.BufferAsync()).Select(item => item.Id.Value).ToList(); int count = playlist.Count(); this.progressBar1.Maximum = count; this.progressBar2.Visible = true; Func <int, int, string> appendZero = (fileIndex, totalVideos) => { string append = string.Empty; if (fileIndex < 10) { if (totalVideos > 100) { append = "00"; } else { append = "0"; } } else if (fileIndex < 100) { if (totalVideos > 100) { append = "0"; } } return(append); }; if (count > 0) { int index = 0; lblVideoCount.Text = index + "/" + count; foreach (var vid in playlist) { string zero = appendZero(index + 1, count) + (index + 1); await this.DownloadVideo(vid, "Part" + zero); index++; if (!downloadingVideo) { break; } this.progressBar1.PerformStep(); lblProgress.Text = Convert.ToInt32(this.progressBar1.Value * 100 / count) + "%"; lblVideoCount.Text = index + "/" + count; this.progressBar2.Value = 0; } } } else { this.progressBar2.Visible = false; this.progressBar1.Maximum = 100; var id = new VideoId(downloadedUrl); downloadingVideo = await this.DownloadVideo(id); } if (downloadingVideo) { MessageBox.Show("Succeeded"); } }
public void Delete(UserId userId, PlaylistId isAny, string name) { throw new NotImplementedException(); }
public async ValueTask <IPlaylist> Create(PlaylistId playlistId) { var result = await _seriesProvider.GetSeriesVideosAsync(playlistId.Id); return(new SeriesVideoPlaylist(playlistId, result)); }
public async ValueTask <PlaylistNextResponseExtractor> GetPlaylistNextResponseAsync( PlaylistId playlistId, CancellationToken cancellationToken = default) => await GetPlaylistNextResponseAsync(playlistId, null, 0, null, cancellationToken);
public Playlist(PlaylistId playlistId, string name) { PlaylistId = playlistId; Name = name; Songs = new List <Song>(); }
public PlaylistDeleted(UserId userId, PlaylistId playlistId, string name) { UserId = userId; PlaylistId = playlistId; Name = name; }