当前位置: 首页>>代码示例>>C#>>正文


C# YouTube.YouTubeQuery类代码示例

本文整理汇总了C#中Google.GData.YouTube.YouTubeQuery的典型用法代码示例。如果您正苦于以下问题:C# YouTubeQuery类的具体用法?C# YouTubeQuery怎么用?C# YouTubeQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


YouTubeQuery类属于Google.GData.YouTube命名空间,在下文中一共展示了YouTubeQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetById

 public Video GetById(string id)
 {
     var query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri + "/" + id);
     var res = GetVideos(query);
     var v = res.FirstOrDefault();
     return v;
 }
开发者ID:Chalkable,项目名称:YouTube_Ed_App,代码行数:7,代码来源:YoutubeConnector.cs

示例2: Search

        public IEnumerable<VideoModel> Search(string searchText)
        {
            var modelList = new List<VideoModel>();
            var settings = new YouTubeRequestSettings("YouTunes", "AIzaSyCgNs6G_0w36g6dhAxxBL4nL7wD3C6jmOw");
            var request = new YouTubeRequest(settings);
            var query = new YouTubeQuery("https://gdata.youtube.com/feeds/api/videos") { Query = searchText };

            Feed<Video> feed = null;

            try
            {
                feed = request.Get<Video>(query);

                foreach (var video in feed.Entries)
                {
                    modelList.Add(new VideoModel() { VideoTitle = video.Title, VideoId = video.VideoId });
                }
            }
            catch (GDataRequestException gdre)
            {

            }

            return modelList;
        }
开发者ID:kkoop83,项目名称:YouTunes,代码行数:25,代码来源:YoutubeService.cs

示例3: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            Uri ur = new Uri("http://gdata.youtube.com/feeds/api/videos/fSgGV1llVHM&f=gdata_playlists&c=ytapi-DukaIstvan-MyYouTubeVideosF-d1ogtvf7-0&d=U1YkMvELc_arPNsH4kYosmD9LlbsOl3qUImVMV6ramM");
              YouTubeQuery query = new YouTubeQuery("http://gdata.youtube.com/feeds/api/channels?q=vevo");

              YouTubeFeed videoFeed = service.Query(query);
              YouTubeEntry en = (YouTubeEntry)videoFeed.Entries[0];

              Video video = request.Retrieve<Video>(new Uri("http://gdata.youtube.com/feeds/api/videos/" + en.VideoId));
              Feed<Comment> comments = request.GetComments(video);
            string cm = "";
            foreach (Comment c in comments.Entries)
            {
              cm +=  c.Content + "\n------------------------------------------\n";
            }

              VideoInfo info = new VideoInfo();
              info.Get("yUHNUjEs7rQ");
              //Video v = request.Retrieve<Video>(videoEntryUrl);

              //Feed<Comment> comments = request.GetComments(v);

              //string cm = "";
              //foreach (Comment c in comments.Entries)
              //{
              //  cm += c.Author + c.Content + "------------------------------------------";
              //}
        }
开发者ID:andrewjswan,项目名称:youtube-fm-for-mediaportal,代码行数:28,代码来源:Form1.cs

示例4: RealSearch

        private static IObservable<IReadOnlyList<ISong>> RealSearch(string searchTerm)
        {
            var query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri)
            { 
                OrderBy = "relevance",
                Query = searchTerm,
                SafeSearch = YouTubeQuery.SafeSearchValues.None,
                NumberToRetrieve = RequestLimit
            };

            var settings = new YouTubeRequestSettings("Espera", ApiKey);
            var request = new YouTubeRequest(settings);

            return Observable.FromAsync(async () =>
            {
                Feed<Video> feed = await Task.Run(() => request.Get<Video>(query));
                List<Video> entries = await Task.Run(() => feed.Entries.ToList());

                return (from video in entries
                    let url = video.WatchPage.OriginalString.Replace("&feature=youtube_gdata_player", String.Empty).Replace("https://", "http://")
                    select new YoutubeSong()
                    {
                        Artist = video.Uploader, Title = video.Title, OriginalPath = url
                    }).ToList();
            })
            .Catch<IReadOnlyList<YoutubeSong>, Exception>(ex => Observable.Throw<IReadOnlyList<YoutubeSong>>(new Exception("YoutubeSongFinder search failed", ex)));
        }
开发者ID:dbeattie71,项目名称:flashbang,代码行数:27,代码来源:YouTubeFinder.cs

示例5: BBuscador

        protected void BBuscador(String track)
        {
            string spotUrl = String.Format("http://ws.spotify.com/search/1/track?q={0}", track);
            WebClient spotService = new WebClient();
            spotService.Encoding = Encoding.UTF8;
            spotService.DownloadStringCompleted += new DownloadStringCompletedEventHandler(SpotService_DownloadTracksCompleted);
            spotService.DownloadStringAsync(new Uri(spotUrl));

            YouTubeRequest request = new YouTubeRequest(settings);
            YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri);
            query.OrderBy = "relevance";
            query.Query = track;
            query.SafeSearch = YouTubeQuery.SafeSearchValues.None;
            Feed<Video> videoFeed = request.Get<Video>(query);
            if (videoFeed.Entries.Count() > 0)
            {
                video1 = videoFeed.Entries.ElementAt(0);
                literal1.Text = String.Format(embed, video1.VideoId);
                if (videoFeed.Entries.Count() > 1)
                {
                    video1 = videoFeed.Entries.ElementAt(1);
                    literal1.Text += String.Format(embed, video1.VideoId);
                }
            }
        }
开发者ID:mmarinero,项目名称:little-class-projects,代码行数:25,代码来源:Default.aspx.cs

示例6: Skype_MessageStatus

        public void Skype_MessageStatus(IChatMessage message, TChatMessageStatus status) {
            Match output = Regex.Match(message.Body, @"(?:youtube\.\w{2,3}\S+v=|youtu\.be/)([\w-]+)", RegexOptions.IgnoreCase);
            // Use non-breaking space as a marker for when to not show info.
            if (output.Success && !message.Body.Contains(" ")) {
                String youtubeId = output.Groups[1].Value;
                log.Info("Sending request to YouTube...");

                YouTubeQuery ytq = new YouTubeQuery("http://gdata.youtube.com/feeds/api/videos/" + youtubeId);

                Feed<Video> feed = ytr.Get<Video>(ytq);
                Video vid = feed.Entries.ElementAt<Video>(0);
                String title = vid.Title;
                String user = vid.Author;
                String rating = vid.RatingAverage.ToString();

                int seconds = Int32.Parse(vid.Media.Duration.Seconds) % 60;
                int minutes = Int32.Parse(vid.Media.Duration.Seconds) / 60;
                String duration = String.Format(@"{0}:{1:00}", minutes, seconds);

                message.Chat.SendMessage(String.Format(@"YouTube: ""{0}"" (uploaded by: {1}) (avg rating: {2:F2}) (duration: {3})", title, user, rating, duration));
                return;
            }
            
            output = Regex.Match(message.Body, @"^!youtube (.+)", RegexOptions.IgnoreCase);
            if (output.Success) {
                String query = output.Groups[1].Value;

                YouTubeQuery ytq = new YouTubeQuery(YouTubeQuery.DefaultVideoUri);
                ytq.Query = query;
                ytq.SafeSearch = YouTubeQuery.SafeSearchValues.None;
                ytq.NumberToRetrieve = 10;

                Feed<Video> feed = ytr.Get<Video>(ytq);
                int count = feed.Entries.Count<Video>();

                string url;
                if (count > 0) {
                    Video vid = feed.Entries.ElementAt<Video>(random.Next(count));
                    url = vid.WatchPage.ToString();
                } else {
                    url = "No matches found.";
                }

                message.Chat.SendMessage(String.Format(@"YouTube search for ""{0}"": {1}", query, url));
                return;
            }

            output = Regex.Match(message.Body, @"^!youtube", RegexOptions.IgnoreCase);
            if (output.Success) {
                log.Debug("Got a request for a random video.");

                String url = randomCache.Count > 0 ? randomCache.Dequeue() : generateRandomVideos(true);

                message.Chat.SendMessage(String.Format(@"Random YouTube video: {0}", url));

                generateRandomVideos(false);
                return;
            }
        }
开发者ID:shruggles,项目名称:dynamicskypebot,代码行数:59,代码来源:YouTubePlugin.cs

示例7: TimeTest

 public void TimeTest()
 {
     YouTubeQuery target = new YouTubeQuery(); // TODO: Initialize to an appropriate value
     YouTubeQuery.UploadTime expected = new YouTubeQuery.UploadTime(); // TODO: Initialize to an appropriate value
     YouTubeQuery.UploadTime actual;
     target.Time = expected;
     actual = target.Time;
     Assert.AreEqual(expected, actual);
 }
开发者ID:nagyist,项目名称:GoogleAnalytics-MonoMac-Demo,代码行数:9,代码来源:YouTubeQueryTest.cs

示例8: VQTest

 public void VQTest()
 {
     YouTubeQuery target = new YouTubeQuery(); // TODO: Initialize to an appropriate value
     string expected = "secret text string"; // TODO: Initialize to an appropriate value
     string actual;
     target.VQ = expected;
     actual = target.VQ;
     Assert.AreEqual(expected, actual);
 }
开发者ID:yodiz,项目名称:Avega.ContactSynchronizer,代码行数:9,代码来源:YouTubeQueryTest.cs

示例9: SearchForVideo

 // Search for a video given a keyword
 // @return feed of retrieved videos
 public static Feed<Video> SearchForVideo(string keyword)
 {
     YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri);
     query.OrderBy = "relevance";
     query.Query = keyword;
     query.SafeSearch = YouTubeQuery.SafeSearchValues.None;
     query.NumberToRetrieve = 10;
     return request.Get<Video>(query);
 }
开发者ID:kev946,项目名称:You-Audio,代码行数:11,代码来源:YouTube.cs

示例10: PerformSearch

        public void PerformSearch (string searchVal)
        {
            YouTubeQuery query = new YouTubeQuery (YouTubeQuery.DefaultVideoUri);

            //order results by the number of views (most viewed first)
            query.OrderBy = "relevance";

            // perform querying with restricted content included in the results
            // query.SafeSearch could also be set to YouTubeQuery.SafeSearchValues.Moderate
            query.Query = searchVal;
            query.SafeSearch = YouTubeQuery.SafeSearchValues.None;

            this.video_results = yt_request.Get<Video> (query);
        }
开发者ID:allquixotic,项目名称:banshee-gst-sharp-work,代码行数:14,代码来源:YouTubeData.cs

示例11: GetVideos

 private static IEnumerable<Video> GetVideos(YouTubeQuery q)
 {
     YouTubeRequest request = GetRequest();
     Feed<Video> feed = null;
     try
     {
         feed = request.Get<Video>(q);
     }
     catch (GDataRequestException gdre)
     {
         var response = (HttpWebResponse)gdre.Response;
     }
     return feed != null ? feed.Entries : null;
 }
开发者ID:Chalkable,项目名称:YouTube_Ed_App,代码行数:14,代码来源:YoutubeConnector.cs

示例12: AddVideo

        private void AddVideo(YouTubeRequest request, string maxResultsKey, string query, VideoList videoList)
        {
            int maxResults = ConfigService.GetConfig(maxResultsKey, 0);
            if (maxResults > 0)
            {
                YouTubeQuery youtubeQuery = new YouTubeQuery(YouTubeQuery.DefaultVideoUri);
                youtubeQuery.Query = "%22" + query +  "%22";
                youtubeQuery.SafeSearch = YouTubeQuery.SafeSearchValues.Strict;
                youtubeQuery.NumberToRetrieve = maxResults;
                Feed<Video> videos = request.Get<Video>(youtubeQuery);

                YouTubeVideoParser parser = new YouTubeVideoParser();
                parser.Parse(videos, videoList);
            }
        }
开发者ID:jcurlier,项目名称:theinternetbuzz,代码行数:15,代码来源:YouTubeSearchService.cs

示例13: MainX

        // once you copied your access and refresh tokens
        // then you can run this method directly from now on...
        public void MainX(string args)
        {
            GOAuth2RequestFactory requestFactory = RefreshAuthenticate();
            YouTubeRequestSettings settings = new YouTubeRequestSettings(_app_name, _clientID, _devKey);
            YouTubeRequest request = new YouTubeRequest(settings);

            YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri);
            //order results by the number of views (most viewed first)
            query.OrderBy = "viewCount";
            // search for puppies and include restricted content in the search results
            // query.SafeSearch could also be set to YouTubeQuery.SafeSearchValues.Moderate
            query.Query = args;
            query.SafeSearch = YouTubeQuery.SafeSearchValues.None;
            //Feed<Video> videoFeed = requestFactory.Get<Video>(query);
        }
开发者ID:juress,项目名称:ytmusic,代码行数:17,代码来源:search.cs

示例14: Search

        public IEnumerable<MediaItemViewModel> Search(string query)
        {
            YouTubeQuery youtubeQuery = new YouTubeQuery(YouTubeQuery.DefaultVideoUri);
            //order results by the number of views (most viewed first)
            youtubeQuery.OrderBy = "viewCount";

            // query.SafeSearch could also be set to YouTubeQuery.SafeSearchValues.Moderate
            youtubeQuery.Query = query;
            youtubeQuery.SafeSearch = YouTubeQuery.SafeSearchValues.None;
            youtubeQuery.NumberToRetrieve = 20;

            return this.Request.Get<Video>(youtubeQuery)
                .Entries
                .AsQueryable()
                .Project()
                .To<MediaItemViewModel>();
        }
开发者ID:mauriliofilho,项目名称:Streamus,代码行数:17,代码来源:SearchServices.cs

示例15: RealSearch

        private static IObservable<IReadOnlyList<YoutubeSong>> RealSearch(string searchTerm)
        {
            var query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri)
            {
                OrderBy = "relevance",
                Query = searchTerm,
                SafeSearch = YouTubeQuery.SafeSearchValues.None,
                NumberToRetrieve = RequestLimit
            };

            // NB: I have no idea where this API blocks exactly
            var settings = new YouTubeRequestSettings("Espera", ApiKey);
            var request = new YouTubeRequest(settings);

            return Observable.FromAsync(async () =>
            {
                Feed<Video> feed = await Task.Run(() => request.Get<Video>(query));
                List<Video> entries = await Task.Run(() => feed.Entries.ToList());

                var songs = new List<YoutubeSong>();

                foreach (Video video in entries)
                {
                    var duration = TimeSpan.FromSeconds(Int32.Parse(video.YouTubeEntry.Duration.Seconds));
                    string url = video.WatchPage.OriginalString
                        .Replace("&feature=youtube_gdata_player", String.Empty) // Unnecessary long url
                        .Replace("https://", "http://"); // Secure connections are not always easy to handle when streaming

                    var song = new YoutubeSong(url, duration)
                    {
                        Artist = video.Uploader,
                        Title = video.Title,
                        Description = video.Description,
                        Rating = video.RatingAverage >= 1 ? video.RatingAverage : (double?)null,
                        ThumbnailSource = new Uri(video.Thumbnails[0].Url),
                        Views = video.ViewCount
                    };

                    songs.Add(song);
                }

                return songs;
            })
                // The API gives no clue what can throw, wrap it all up
            .Catch<IReadOnlyList<YoutubeSong>, Exception>(ex => Observable.Throw<IReadOnlyList<YoutubeSong>>(new NetworkSongFinderException("YoutubeSongFinder search failed", ex)));
        }
开发者ID:reactiveui-forks,项目名称:Espera,代码行数:46,代码来源:YoutubeSongFinder.cs


注:本文中的Google.GData.YouTube.YouTubeQuery类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。