public PlatformStreamsDto Map( MaybeResult <IEnumerable <DLiveStreamItemDto>, StreamProviderError> streamSearchResults, int pageSize, int pageOffset ) { return(streamSearchResults.Select(streams => { return new PlatformStreamsDto { StreamPlatformName = StreamPlatform.DLive, Streams = streams.Select(stream => { return new PlatformStreamDto { StreamTitle = stream.title, StreamerName = stream.creator.displayName, StreamThumbnailUrl = stream.thumbnailUrl, StreamerAvatarUrl = stream.creator.avatar, StreamUrl = $"{dliveWebUrl}/{stream.creator.displayName}", IsLive = true, Views = stream.watchingCount, }; }), NextPageToken = streams.Count() == pageSize ? (pageOffset + pageSize).ToString() : string.Empty }; }).GetOrElse(PlatformStreamsDto.Empty(StreamPlatform.DLive))); }
public PlatformStreamsDto Map( MaybeResult <IEnumerable <TwitchStreamDto>, StreamProviderError> twitchStreamResults, int pageSize, int pageOffset ) { return(twitchStreamResults.Select(streams => { var nextPagToken = streams.Count() == pageSize ? (pageOffset + pageSize).ToString() : string.Empty; return new PlatformStreamsDto { StreamPlatformName = StreamPlatform.Twitch, Streams = streams.Select(stream => new PlatformStreamDto { StreamTitle = stream.channel.status, StreamerName = stream.channel.display_name, StreamerAvatarUrl = stream.channel.logo, StreamThumbnailUrl = stream.preview.medium, StreamUrl = stream.channel.url, IsLive = true, Views = stream.viewers, }), NextPageToken = nextPagToken, }; }).GetOrElse(PlatformStreamsDto.Empty(StreamPlatform.Twitch))); }
public static MaybeResult <TwitchChannelDto, StreamProviderError> Select( string channelName, MaybeResult <IEnumerable <TwitchChannelDto>, StreamProviderError> channelSearchResults) { return(channelSearchResults .Select(channels => channels .Where(channel => channel.display_name.Equals(channelName, StringComparison.CurrentCultureIgnoreCase)) .FirstOrDefault())); }
public MaybeResult <PlatformChannelDto, StreamProviderError> Map( MaybeResult <DLiveUserDto, StreamProviderError> userSearchResult) { return(userSearchResult.Select(user => { return new PlatformChannelDto { ChannelName = user.displayName, AvatarUrl = user.avatar, ChannelUrl = $"{dliveWebUrl}/{user.displayName}", StreamPlatformName = StreamPlatform.DLive, }; })); }
public MaybeResult <PlatformChannelDto, StreamProviderError> Map( MaybeResult <TwitchChannelDto, StreamProviderError> twitchChannelResult) { return(twitchChannelResult.Select(channel => { return new PlatformChannelDto { ChannelName = channel.display_name, AvatarUrl = channel.logo, ChannelUrl = channel.url, StreamPlatformName = StreamPlatform.Twitch, }; })); }
public MaybeResult <PlatformStreamsDto, StreamProviderError> Map( YouTubeSearchDto videoSearchResults, MaybeResult <IEnumerable <YouTubeVideoDto>, StreamProviderError> videoDetailResults, MaybeResult <IEnumerable <YouTubeChannelDto>, StreamProviderError> videoChannelResults) { return(videoDetailResults.Chain(videosResult => { return videoChannelResults.Select(channelResults => { var videoDetails = videosResult.ToDictionary(v => v.id, v => v.liveStreamingDetails); var videoChannels = channelResults.ToDictionary(c => c.id, c => c.snippet); return ToStreams(videoSearchResults, videoChannels, videoDetails); }); })); }
public MaybeResult <PlatformChannelDto, StreamProviderError> Map( MaybeResult <IEnumerable <YouTubeChannelDto>, StreamProviderError> channelSnippetResults) { return(channelSnippetResults.Select(channelSnippets => { return channelSnippets.Select(channelSnippet => { return new PlatformChannelDto { ChannelName = channelSnippet.snippet.title, AvatarUrl = [email protected], ChannelUrl = $"{youTubeWebUrl}/channel/{channelSnippet.id}", StreamPlatformName = StreamPlatform.YouTube, }; }) .FirstOrDefault(); })); }