Пример #1
0
 static YouTubeVideoService()
 {
     _requestTypes = new VideoRequestType[]
     {
         new MyVideosRequestType(),
         new MyFavoritesRequestType()
     };
 }
Пример #2
0
        public async Task <List <SearchResult> > SearchVideosAsync(string searchTerm, VideoRequestType type, int page)
        {
            var videos = await _youtubeClient.SearchAsync(searchTerm, type, page);

            return(videos.Select(SearchResult.From).ToList());
        }
Пример #3
0
        public async Task <List <YouTubeSearchResult> > SearchAsync(string searchTerm, VideoRequestType type, int page)
        {
            switch (type)
            {
            case VideoRequestType.Channel:
                var channelResults = await new ChannelSearch().GetChannelsPaged(searchTerm, page);
                return(channelResults.Select(YouTubeSearchResult.From).ToList());

            case VideoRequestType.Playlist:
                var playlistResults = await new PlaylistSearch().GetPlaylistsPaged(searchTerm, page);
                return(playlistResults.Select(YouTubeSearchResult.From).ToList());

            default:
                var videoResults = await new VideoSearch().GetVideosPaged(searchTerm, page);
                return(videoResults.Select(YouTubeSearchResult.From).ToList());
            }
        }