public void ReadAll_PlaylistNull_ThrowsException() { IPlaylistReader sut = new PlaylistReader(); Assert.Throws <ArgumentNullException>(() => { sut.ReadAll(null, "somePlaylist", "someLibraryRoot"); }); }
public void ReadAll_PlayListEmpty_ReturnsNull() { IPlaylistReader sut = new PlaylistReader(); Stream playlistStream = new MemoryStream(); Playlist result = sut.ReadAll(playlistStream, "somePlaylist", "someLibraryRoot"); Assert.Null(result); }
public void ReadAll_PlayListHasOnlyComments_ReturnsNull() { IPlaylistReader sut = new PlaylistReader(); Stream playlistStream = GetTestPlaylistStreamOnlyComments(); Playlist result = sut.ReadAll(playlistStream, "somePlaylist", "someLibraryRoot"); Assert.Null(result); }
public void ReadAll_PlayListHasOnlyFiles_ReturnsFiles() { IPlaylistReader sut = new PlaylistReader(); Stream playlistStream = GetTestPlaylistStreamOnlyFiles(); Playlist result = sut.ReadAll(playlistStream, "somePlaylist", "someLibraryRoot"); Assert.Equal(2, result.Files.Count()); }
private static Playlist ReadPlaylist(string path) { var factory = new PlaylistItemFactory(); var playlist = new Playlist(path); using (var reader = new PlaylistReader(path)) { var itemPath = reader.NextPath(); while (itemPath != null) { var item = factory.FromFile(itemPath); if (item != null) { playlist.Items.Add(item); playlist.RelativePaths = playlist.RelativePaths && reader.WasRelativePath; } itemPath = reader.NextPath(); } } return(playlist); }
/// <summary> /// CUEシートを読み込む。 /// </summary> /// <returns>エラーの発生回数を戻す</returns> private int ReadCueSheet(string path) { PlaylistReader plr = null; switch (Path.GetExtension(path).ToUpperInvariant()) { case ".CUE": plr = new CueSheetReader(mEncoding); break; case ".M3U": case ".M3U8": plr = new M3uReader(); break; default: System.Diagnostics.Debug.Assert(false); break; } bool result = plr.ReadFromFile(path); if (!result) { LoadErrorMessageAdd(string.Format(CultureInfo.InvariantCulture, Properties.Resources.ReadFileFailed + ": {1}{2}", Path.GetExtension(path), path, Environment.NewLine)); return(1); } int errCount = 0; for (int i = 0; i < plr.GetTrackInfoCount(); ++i) { var plti = plr.GetTrackInfo(i); errCount += ReadFileHeader1(plti.path, ReadHeaderMode.OnlyConcreteFile, plti, null); } return(errCount); }
private async void GetPlaylistInfoAsync() { _queryingVideos = true; await Task.Run(delegate { var items = new List <int>(); // Get the youtube playlist indexes foreach (var v in _videos) { items.Add(v.Index); } var reader = new PlaylistReader(this.Input, items.ToArray(), _reverse); VideoInfo video; try { this.PlaylistName = reader.WaitForPlaylist().Name; } catch (TimeoutException ex) { _operationException = ex; _queryingVideos = false; return; } // If '_videos' is empty get all the videos in the playlist. Otherwise // only get those listed in '_videos' if (_videos.Count == 0) { _selectedVideosCount = reader.Playlist.OnlineCount; } else { _selectedVideosCount = _videos.Count; } while ((video = reader.Next()) != null) { // We're done! (I think) if (_videos.Count > 0 && this.Videos.Count == _videos.Count) { break; } if (_cancel) { reader.Stop(); break; } if (_videos.Count == 0 || _videos.Any(x => x.ID == video.ID)) { this.Videos.Add(video); } } }); _queryingVideos = false; }