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


C# YouTubeRequest.Get方法代码示例

本文整理汇总了C#中YouTubeRequest.Get方法的典型用法代码示例。如果您正苦于以下问题:C# YouTubeRequest.Get方法的具体用法?C# YouTubeRequest.Get怎么用?C# YouTubeRequest.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在YouTubeRequest的用法示例。


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

示例1: GDataResultAggregator

    public GDataResultAggregator(string playlistURL)
    {
      YouTubeRequestSettings settings = new YouTubeRequestSettings(APPNAME, CLIENTID, DEVELKEY);
      YouTubeRequest request = new YouTubeRequest(settings);

      _videoFeed = request.Get<Video>(new Uri(playlistURL));
    }
开发者ID:mumairali,项目名称:youtube-playlist-downloader,代码行数:7,代码来源:GDataResultAggregator.cs

示例2: 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

示例3: 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

示例4: 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

示例5: Details

        //
        // GET: /Candidates/Details/5
        public ViewResult Details(int id)
        {
            Candidate candidate = context.Candidates.Single(x => x.Id == id);

            YouTubeRequest req = new YouTubeRequest(new YouTubeRequestSettings("OpenPac", "AI39si5R4licFRGAWgvNI5G6ANPqGfcuyuTWW55nb7rE49bv5kIyMm7YbGpfvUpCX_5nNBJYXztGiUvhULoBQOoEUVQD8xI-Nw"));

            Uri u = new Uri(string.Format("https://gdata.youtube.com/feeds/api/users/{0}/uploads", candidate.YouTubeId));

            Feed<Video> videos = req.Get<Video>(u);

            List<YouTubeVideo> videoUrls = new List<YouTubeVideo>();

            foreach (Video v in videos.Entries)
            {
                videoUrls.Add(new YouTubeVideo
                {
                    VideoId = v.YouTubeEntry.VideoId,
                    Description = v.Description,
                    Title = v.Title,
                    Rating = v.YouTubeEntry.Rating == null ? 0.0 : v.YouTubeEntry.Rating.Average,
                    Updated = v.YouTubeEntry.Updated,
                    Duration = v.YouTubeEntry.Duration.IntegerValue,
                    YouTubeUrl = v.WatchPage.ToString()
                });
            }

            ViewBag.YouTubeVideos = videoUrls;

            return View(candidate);
        }
开发者ID:felluss,项目名称:open-pac,代码行数:32,代码来源:CandidatesController.cs

示例6: AddVideo

        private void AddVideo(YouTubeRequest request, string urlTemplate, string maxResultsKey, VideoList videoList)
        {
            int maxResults = ConfigService.GetConfig(maxResultsKey, 0);
            if (maxResults > 0)
            {
                string url = string.Format(urlTemplate, maxResults);
                Feed<Video> videos = request.Get<Video>(new Uri(url));

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

示例7: Guncelle

        private void Guncelle()
        {
            using (OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=hesap.mdb"))
            {
                conn.Open();
                OleDbCommand komut = new OleDbCommand();
                komut.Connection = conn;
                komut.CommandText = "Select * from hesap"; // sorgu / komut cumlemi yazıyorum.
                komut.ExecuteNonQuery(); // insert , updateiçin gerekli satir sayisi donduruyoruz.
                OleDbDataReader dr = komut.ExecuteReader(); // datareader olusturup komut sorgulayıp veritabaninda okuma işlemini tanıtıyoruz
                while (dr.Read()) // datareader ile okuyoruz.
                {
                    string hadi = dr["hadi"].ToString();
                    string kadi = dr["kadi"].ToString();
                    string q;
                    using (WebClient asd = new WebClient())
                    {
                        asd.Encoding = Encoding.UTF8;
                        q = asd.DownloadString("http://gdata.youtube.com/feeds/api/users/" + kadi + "/uploads?v=2&alt=jsonc&max-results=0");
                    }
                    string[] adet1 = q.Split(new string[] { "totalItems\":" }, StringSplitOptions.None);
                    string[] adet2 = adet1[1].Split(',');
                    listView1.Items.Add(new ListViewItem(new string[] { hadi, "Adet: "+adet2[0] }));
                }
                dr.Close();
                komut.ExecuteNonQuery(); // insert , updateiçin gerekli satir sayisi donduruyoruz.
                dr = komut.ExecuteReader(); // datareader olusturup komut sorgulayıp veritabaninda okuma işlemini tanıtıyoruz
                while (dr.Read()) // datareader ile okuyoruz.
                {
                    string kadi = dr["hadi"].ToString(); // veritabanimdaki "kadi" alanımdaki veriyi alip kadi değişkenine atıyorum(yukarıda string olusturmustum)
                    string sifre = dr["hsifresi"].ToString(); // aynı durum söz konusu
                    string devkey = dr["devkey"].ToString();
                    Random a = new Random();
                    string id = a.Next(100000, 999999).ToString();
                    YouTubeRequestSettings settings = new YouTubeRequestSettings(id, devkey, kadi,sifre);
                    YouTubeRequest request = new YouTubeRequest(settings);

                    string feedUrl = "https://gdata.youtube.com/feeds/api/users/default/uploads";

                    Feed<Video> videoFeed = request.Get<Video>(new Uri(feedUrl));
                    foreach (Video entry in videoFeed.Entries)
                    {
                        string vid_thumb ="http://img.youtube.com/vi/"+entry.VideoId+"/0.jpg";
                        int izlenme = entry.ViewCount;
                        if(izlenme == -1)
                            izlenme = 0;
                        listView1.Items.Add(new ListViewItem(new string[] { kadi,entry.YouTubeEntry.Title.Text,izlenme.ToString()  }));
                    }
                }
            }
        }
开发者ID:voyl,项目名称:myprojects,代码行数:51,代码来源:Form1.cs

示例8: 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

示例9: GetListOfSubscriptions

        internal List<KeyValuePair<string, List<Video>>> GetListOfSubscriptions(Settings i_settings)
        {
            List<KeyValuePair<string, List<Video>>> resObj = new  List<KeyValuePair<string, List<Video>>> ();

            YouTubeRequestSettings settings = new YouTubeRequestSettings(
                  i_settings.appName
                , i_settings.devKey
                , i_settings.username
                , i_settings.password);

            YouTubeRequest request = new YouTubeRequest(settings);
            Feed<Subscription> feedOfSubcr = request.GetSubscriptionsFeed(i_settings.userShort);

            string[] stringSeparators = new string[] { "Activity of:" };

            foreach (Subscription subItem in feedOfSubcr.Entries)
            {
                string keyStr = subItem.ToString().Split(stringSeparators, StringSplitOptions.None)[1].Trim();
                List<Video> listOfVideos = new List<Video>();

                string userName = subItem.UserName;
                string url = string.Format(i_settings.urlFormatter, userName);

                Feed<Video> videoFeed = request.Get<Video>(new Uri(url));

                int depth = 0;
                foreach (Video entry in videoFeed.Entries)
                {
                    //strBuilder.AppendLine("    " + entry.Title);
                    listOfVideos.Add(entry);
                    depth++;
                    if (depth >= i_settings.feedDepth)
                    {
                        break;
                    }
                }

                if (listOfVideos.Count > 0)
                {
                    KeyValuePair<string, List<Video>> subscriptionO = new KeyValuePair<string, List<Video>>(keyStr, listOfVideos);
                    resObj.Add(subscriptionO);
                }

            }

            return resObj;
        }
开发者ID:maxshlain,项目名称:ytpodcaster_00,代码行数:47,代码来源:SubscriptionsFetcher.cs

示例10: 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

示例11: GetCurtVideos

        public static Feed<Google.YouTube.Video> GetCurtVideos()
        {
            try {
                YouTubeRequestSettings settings = new YouTubeRequestSettings("eLocal", "AI39si6iCFZ_NutrvZe04i9_m7gFhgmPK1e7LF6-yHMAwB-GDO3vC3eD0R-5lberMQLdglNjH3IWUMe3tJXe9qrFe44n2jAUyg");
                YouTubeRequest req = new YouTubeRequest(settings);

                YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri);
                query.Author = "curtmfg";
                query.Formats.Add(YouTubeQuery.VideoFormat.Embeddable);
                query.OrderBy = "viewCount";

                // We need to load the feed data for the CURTMfg Youtube Channel
                Feed<Google.YouTube.Video> video_feed = req.Get<Google.YouTube.Video>(query);
                return video_feed;
            } catch (Exception) {
                return null;
            }
        }
开发者ID:ninnemana,项目名称:elocal,代码行数:18,代码来源:Media.cs

示例12: Search

        public override List<Result> Search(string pKeyWords)
        {
            string youtubeApplicationName = ConfigurationManager.AppSettings["youtube-application-name"];
            string youtubeDeveloperKey = ConfigurationManager.AppSettings["youtube-developer-key"];

            if (string.IsNullOrWhiteSpace(youtubeApplicationName) || string.IsNullOrWhiteSpace(youtubeDeveloperKey))
                throw new Exception("App was unable to find Youtube credentials on the current settings file. Please add youtube-application-name and youtube-developer-key to the appSettings section.");

            YouTubeRequestSettings requestSettings = new YouTubeRequestSettings(youtubeApplicationName, youtubeDeveloperKey);
            requestSettings.AutoPaging = false;

            YouTubeRequest youtubeRequest = new YouTubeRequest(requestSettings);

            YouTubeQuery youtubeQuery = new YouTubeQuery(YouTubeQuery.DefaultVideoUri)
            {
                OrderBy = "viewCount",
                Query = pKeyWords,
                NumberToRetrieve = this.MaxResultSearch
            };

            Feed<Video> youtubeVideos = youtubeRequest.Get<Video>(youtubeQuery);

            List<Result> domainResults = new List<Result>();

            foreach (Video video in youtubeVideos.Entries)
            {
                domainResults.Add(
                    new Result()
                    {
                        CreatedDate = video.Updated,
                        Type = SourceType.YouTube,
                        Text = string.Format("{0} {1}", video.Description, video.Keywords),
                        Title = video.Title,
                        URL = video.WatchPage.OriginalString
                    }
                );
            }

            return domainResults;
        }
开发者ID:andrecalil,项目名称:TrendSearch,代码行数:40,代码来源:YouTubeSource.cs

示例13: CreateVideoFeed

    private void CreateVideoFeed(string s)
    {
        YouTubeRequestSettings settings = new YouTubeRequestSettings("most_viewed", YouTubeDeveloperKey);
        YouTubeRequest request = new YouTubeRequest(settings);

        //Link to the feed we wish to read from
        string feedUrl = String.Format("http://gdata.youtube.com/feeds/api/videos?q=" + s);

        dtVideoData.Columns.Add("Title");
       
        dtVideoData.Columns.Add("DateUploaded");


        dtVideoData.Columns.Add("VideoID");
        dtVideoData.Columns.Add("Duration");

        DataRow drVideoData;

        Feed<Video> videoFeed = request.Get<Video>(new Uri(feedUrl));

        //Iterate through each video entry and store details in DataTable
        foreach (Video videoEntry in videoFeed.Entries)
        {
            drVideoData = dtVideoData.NewRow();

            drVideoData["Title"] = videoEntry.Title;
           
            drVideoData["DateUploaded"] = videoEntry.Updated.ToShortDateString();


            drVideoData["VideoID"] = videoEntry.YouTubeEntry.VideoId;
            drVideoData["Duration"] = videoEntry.YouTubeEntry.Duration.Seconds.ToString();

            dtVideoData.Rows.Add(drVideoData);
        }

        RadGrid1.DataSource = dtVideoData;
        RadGrid1.DataBind();

    }
开发者ID:vaibhavgeek,项目名称:friendyoke,代码行数:40,代码来源:video-galla.ascx.cs

示例14: youTubeSearch

        private void youTubeSearch(string searchTerm)
        {
            YouTubeRequestSettings settings =
            new YouTubeRequestSettings("SmartHome", developerKeyV2);
            YouTubeRequest request = new YouTubeRequest(settings);

            YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri);

            //For Categories
            //AtomCategory category1 = new AtomCategory("News", YouTubeNameTable.KeywordSchema);
            //query.Categories.Add(new QueryCategory(category1);

            //For Playlist
            // YouTubeQuery query = new YouTubeQuery(YouTubeQuery.BaseUserUri);
            // Feed<Google.YouTube.Playlist> userPlayList = request.GetPlaylistsFeed("[email protected]");
            // foreach (Google.YouTube.Playlist p in userPlayList.Entries)
            // {
            //     Feed<PlayListMember> list = request.GetPlaylist(p);
            //     foreach (Google.YouTube.Video entry in list.Entries)
              //      {
              //          System.Windows.MessageBox.Show(entry.Title);
              //      }
              //  }

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

            // search for puppies and include restricted content in the search results
            // query.SafeSearch could also be set to YouTubeQuery.SafeSearchValues.Moderate
            query.Query = searchTerm;
            query.SafeSearch = YouTubeQuery.SafeSearchValues.None;

            Feed<Google.YouTube.Video> videoFeed = request.Get<Google.YouTube.Video>(query);

            foreach (Google.YouTube.Video entry in videoFeed.Entries)
            {
            //System.Windows.MessageBox.Show(entry.Title);
            }
        }
开发者ID:hirec,项目名称:SmartHomeV2,代码行数:40,代码来源:YouTube_ContentVM.cs

示例15: button10_Click

        private void button10_Click(object sender, EventArgs e)
        {
            label38.Text = "Search Results:";
            try
            {
                string searchupd = "http://nicoding.com/api.php?app=ripleech&updtrend=search&term=" + textBox7.Text;
                HttpWebRequest searchreq = (HttpWebRequest)WebRequest.Create(searchupd);
                WebResponse searchres = searchreq.GetResponse();
                System.IO.StreamReader sr = new System.IO.StreamReader(searchres.GetResponseStream(), System.Text.Encoding.GetEncoding("windows-1252"));
                string pluginsavail = sr.ReadToEnd();
            }
            catch { }
            listView1.Items.Clear();
            YouTubeRequest request = new YouTubeRequest(settings);
            YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri);

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

            // search for puppies and include restricted content in the search results
            // query.SafeSearch could also be set to YouTubeQuery.SafeSearchValues.Moderate
            query.Query = textBox7.Text;
            query.SafeSearch = YouTubeQuery.SafeSearchValues.None;

            Feed<Video> videoFeed = request.Get<Video>(query);
            printVideoFeed(videoFeed);
        }
开发者ID:Gigawiz,项目名称:RipLeech,代码行数:27,代码来源:metro.cs


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