public void Render(Playlist playlist, PlaylistFileType playlistFileType, PlaylistOutput playlistOutput) { var playlistFormatter = _playlistFormatRetriever.GetPlaylistFormatter(playlistFileType); playlistOutput(playlistFormatter.GetHeader(playlist)); for (var playlistIndex = 0; playlistIndex < playlist.Videos.Count; playlistIndex++) { var location = playlist.Videos[playlistIndex].Location; playlistOutput(playlistFormatter.GetPlaylistVideo(location, playlistIndex)); } playlistOutput(playlistFormatter.GetFooter(playlist)); }
private async Task <PlaylistOutput> GetPlayListItemsAsync(PlaylistInput input, CancellationToken token, bool paging) { JObject listJson; PlaylistOutput output = new PlaylistOutput(); do { listJson = JObject.Parse(await GetJsonAsync(input, InputType.Playlist, token)); output.TotalResults = int.Parse(listJson["pageInfo"]["totalResults"].ToString()); input.PageToken = listJson["nextPageToken"].IsNullOrEmpty() != true ? listJson["nextPageToken"].ToString() : null; output.NextPage = input.PageToken; foreach (var item in listJson["items"]) { output.VideosData.Add(SetPlaylistContainsDetails(item["snippet"])); output.TotalResults++; } } while (!listJson["nextPageToken"].IsNullOrEmpty() && !paging); return(output); }
public void Generate(PlaylistOutput output) { var playlistConfiguration = _playlistConfigurationRepository.Find(Settings); var playlist = _playlistBuilder.Build(playlistConfiguration); _playlistRenderer.Render(playlist, Settings.PlaylistFormat, output); }