public static List <VideoInfo> VideoInfo_SelectPage(VideoSearchInfo search, int pageIndex, int pageSize, out int rowCount) { IVideosService channel = Entity.CreateChannel <IVideosService>(SiteEnum.SiteService.VideoService); VideoInfo_SelectPageRequest request = new VideoInfo_SelectPageRequest() { cloumns = "*", orderBy = search.DefaultOrder, pageIndex = pageIndex, pageSize = pageSize, where = search.ToWhereString() }; var result = channel.VideoInfo_SelectPage(request); (channel as IDisposable).Dispose(); rowCount = result.rowCount; return(result.VideoInfo_SelectPageResult); }
public ActionResult SiteContentListView(string cateId) { int page = Request["page"].ToInt32(1); int pageSize = Request["pagesize"].ToInt32(15); string f_title = Request["f_title"] ?? string.Empty; int rowCount; //查询该分类下的小说内容 VideoSearchInfo search = new VideoSearchInfo(); search.v_c_id = cateId; search.v_titile = f_title; List<VideoInfo> list = VideoServiceClass.VideoInfo_SelectPage(search, page, pageSize, out rowCount); ViewData["list"] = list; ViewData["page"] = page; ViewData["pageSize"] = pageSize; ViewData["rowCount"] = rowCount; return PartialView(); }
//[STAThread] //static void Main(string[] args) //{ // System.Diagnostics.Debug.WriteLine("YouTube Data API: Search"); // System.Diagnostics.Debug.WriteLine("========================"); // try // { // new Search().Run().Wait(); // } // catch (AggregateException ex) // { // foreach (var e in ex.InnerExceptions) // { // System.Diagnostics.Debug.WriteLine("Error: " + e.Message); // } // } // System.Diagnostics.Debug.WriteLine("Press any key to continue..."); //} public async Task <List <VideoSearchInfo> > Run(string searchKeyword) { VideoSearchInfo videoSearchInfo = new VideoSearchInfo(); var youtubeService = new YouTubeService(new BaseClientService.Initializer() { ApiKey = _config["ClientSecrets:ApiKeyYoutubeSearch"], ApplicationName = this.GetType().ToString() }); var searchListRequest = youtubeService.Search.List("snippet"); searchListRequest.Q = searchKeyword; // Replace with your search term. searchListRequest.MaxResults = 50; // Call the search.list method to retrieve results matching the specified query term. var searchListResponse = await searchListRequest.ExecuteAsync(); List <VideoSearchInfo> videoSearchInfos = new List <VideoSearchInfo>(); List <string> channels = new List <string>(); List <string> playlists = new List <string>(); // Add each result to the appropriate list, and then display the lists of // matching videos, channels, and playlists. foreach (var searchResult in searchListResponse.Items) { switch (searchResult.Id.Kind) { case "youtube#video": videoSearchInfos.Add(new VideoSearchInfo { Title = searchResult.Snippet.Title, VideoId = searchResult.Id.VideoId, Description = searchResult.Snippet.Description, PublishedAt = searchResult.Snippet.PublishedAt.ToString(), ThumbnailUrl = searchResult.Snippet.Thumbnails.High.Url, ChannelTitle = searchResult.Snippet.ChannelTitle, ChannelId = searchResult.Snippet.ChannelId, isChannel = false, isPlaylist = false }); //videoSearchInfos.Add(String.Format("VideoTitle: {0} VideoId: ({1}) Videodescription: ({2}) Video published: ({3}) Video ({4})", searchResult.Snippet.Title, searchResult.Id.VideoId, searchResult.Snippet.Description, searchResult.Snippet.PublishedAt)); break; case "youtube#channel": videoSearchInfos.Add(new VideoSearchInfo { Title = searchResult.Snippet.Title, ChannelId = searchResult.Id.ChannelId, ThumbnailUrl = searchResult.Snippet.Thumbnails.High.Url, Description = searchResult.Snippet.Description, isChannel = true, isPlaylist = false }); //channels.Add(String.Format("ChannelTitle: {0} ChannelId: ({1})", searchResult.Snippet.Title, searchResult.Id.ChannelId)); break; case "youtube#playlist": videoSearchInfos.Add(new VideoSearchInfo { Title = searchResult.Snippet.Title, PlaylistId = searchResult.Id.PlaylistId, ThumbnailUrl = searchResult.Snippet.Thumbnails.High.Url, Description = searchResult.Snippet.Description, isChannel = false, isPlaylist = true }); //playlists.Add(String.Format("PlaylistTitle: {0} PlaylistId: ({1})", searchResult.Snippet.Title, searchResult.Id.PlaylistId)); break; } } //System.Diagnostics.Debug.WriteLine(String.Format("Videos:\n{0}\n", string.Join("\n", videos))); //System.Diagnostics.Debug.WriteLine(String.Format("Channels:\n{0}\n", string.Join("\n", channels))); //System.Diagnostics.Debug.WriteLine(String.Format("Playlists:\n{0}\n", string.Join("\n", playlists))); return(videoSearchInfos); }