本文整理汇总了C#中YouTubeRequest.Retrieve方法的典型用法代码示例。如果您正苦于以下问题:C# YouTubeRequest.Retrieve方法的具体用法?C# YouTubeRequest.Retrieve怎么用?C# YouTubeRequest.Retrieve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YouTubeRequest
的用法示例。
在下文中一共展示了YouTubeRequest.Retrieve方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetById
public VideoEntry GetById(string videoId)
{
var request = new YouTubeRequest(_settings);
var video =
request.Retrieve<Video>(new Uri(String.Format("http://gdata.youtube.com/feeds/api/videos/{0}", videoId)));
return _videoEntryFactory.Build(video);
}
示例2: LoadPlaylist
private static void LoadPlaylist(YouTubeRequest request, Playlist playlistItem)
{
Debug.WriteLine(String.Format("[{2}] Title: {1}\tId: {0}", playlistItem.Id, playlistItem.Title, playlistItem.CountHint));
Playlist playlist = request.Retrieve<Playlist>(new Uri(playlistItem.Self));
if (playlistItem.CountHint == playlist.PlaylistsEntry.Feed.Entries.Count())
Debug.WriteLine("All Entries retrieved");
else
Debug.WriteLine(String.Format("{0} entry(ies) retrieved", playlist.PlaylistsEntry.Feed.Entries.Count()));
foreach (var playlistEntryItem in playlist.PlaylistsEntry.Feed.Entries)
{
Video video = request.Retrieve<Video>(new Uri(playlistEntryItem.SelfUri.ToString()));
Debug.WriteLine(String.Format("{0}\t| {1}", video.VideoId, video.Title));
//PrintVideoEntry(video);
}
}
示例3: GetTitle
public VideoTitleParseResult GetTitle(string id)
{
var settings = new YouTubeRequestSettings("VocaDB", null);
var request = new YouTubeRequest(settings);
var videoEntryUrl = new Uri(string.Format("http://gdata.youtube.com/feeds/api/videos/{0}", id));
try {
var video = request.Retrieve<Video>(videoEntryUrl);
var thumbUrl = video.Thumbnails.Count > 0 ? video.Thumbnails[0].Url : string.Empty;
return VideoTitleParseResult.CreateSuccess(video.Title, video.Author, thumbUrl);
} catch (Exception x) {
return VideoTitleParseResult.CreateError(x.Message);
}
}
示例4: GetVideo
public override VideoResponse GetVideo(VideoRequest videoRequest)
{
Uri videoUrl = new Uri("http://gdata.youtube.com/feeds/api/videos/" + videoRequest.VideoId);
try
{
var request = new YouTubeRequest(new YouTubeRequestSettings(Application, ApiKey));
var video = request.Retrieve<Video>(videoUrl);
return new VideoResponse() { Video = video };
}
catch (Exception e)
{
return new VideoResponse() { Video = null };
}
}
示例5: Main
static void Main(string[] args)
{
Uri youTubeLink = new Uri("http://www.youtube.com/watch?v=ItqQ2EZziB8");
var parameters = System.Web.HttpUtility.ParseQueryString(youTubeLink.Query);
var videoId = parameters["v"];
Uri youTubeApi = new Uri(string.Format("http://gdata.youtube.com/feeds/api/videos/{0}", videoId));
YouTubeRequestSettings settings = new YouTubeRequestSettings(null, null);
YouTubeRequest request = new YouTubeRequest(settings);
var result = request.Retrieve<Video>(youTubeApi);
Console.WriteLine(result.Title);
Console.WriteLine(result.Description);
Console.WriteLine(result.ViewCount);
Console.ReadLine();
}
示例6: GetYouTubeVideo
public static Google.YouTube.Video GetYouTubeVideo(string id = "")
{
try {
// Initiate video object
Google.YouTube.Video video = new Google.YouTube.Video();
// Initiate YouTube request object
YouTubeRequestSettings settings = new YouTubeRequestSettings("curtmfg", "AI39si6iCFZ_NutrvZe04i9_m7gFhgmPK1e7LF6-yHMAwB-GDO3vC3eD0R-5lberMQLdglNjH3IWUMe3tJXe9qrFe44n2jAUyg");
YouTubeRequest req = new YouTubeRequest(settings);
req.Proxy = null;
// Create the URI and make request to YouTube
Uri video_url = new Uri("http://gdata.youtube.com/feeds/api/videos/" + id);
video = req.Retrieve<Google.YouTube.Video>(video_url);
return video;
} catch (Exception) {
return new Google.YouTube.Video();
}
}
示例7: postComment
private void postComment(object sender, RoutedEventArgs e)
{
YouTubeRequest req = new YouTubeRequest(new YouTubeRequestSettings(MainWindow.APP_NAME, MainWindow.DEV_KEY, MainWindow.mProgramProperties.Username, MainWindow.mProgramProperties.Password));
Uri videoEntryUrl = new Uri(string.Format("{0}/{1}", Google.GData.YouTube.YouTubeQuery.DefaultVideoUri, videoId));
Google.YouTube.Video newVideo = req.Retrieve<Google.YouTube.Video>(videoEntryUrl);
Comment c = new Comment();
c.Content = commentTxtBox.Text.ToString();
try
{
req.AddComment(newVideo, c);
}
catch (Google.GData.Client.GDataRequestException ex)
{
MessageBox.Show("You have post too many comments! Try again later!");
return;
}
this.commentTxtBox.Text = "";
}
示例8: Remove
public void Remove(string uploader, string videoID)
{
YouTubeRequestSettings settings = new YouTubeRequestSettings("ControlTower", knt_devkey, knt_hadi, knt_hsifresi);
bool s = true;
string vidid = "";
try
{
YouTubeRequest request = new YouTubeRequest(settings);
Uri uri = new Uri(String.Format("http://gdata.YouTube.com/feeds/api/users/{0}/uploads/{1}", uploader, videoID));
Video a = request.Retrieve<Video>(uri);
request.Delete(a);
vidid = a.VideoId;
}
catch
{
s = false;
}
if (s)
AppendText(richTextBox1, Color.Chocolate, " Silindi: " + videoID + " " + DateTime.Now.ToString());
}
示例9: getstuff
private void getstuff(string videoid)
{
int tempvidswatched = RipLeech.Properties.Settings.Default.videoswatched;
RipLeech.Properties.Settings.Default.videoswatched = tempvidswatched + 1;
RipLeech.Properties.Settings.Default.Save();
webBrowser1.Navigate("http://youtube.com/v/" + videoid + "&vq=hd720");
YouTubeRequest request = new YouTubeRequest(settings);
try
{
Uri videoEntryUrl = new Uri("http://gdata.youtube.com/feeds/api/videos/" + videoid);
Video video = request.Retrieve<Video>(videoEntryUrl);
Feed<Video> relatedVideos = request.GetRelatedVideos(video);
printVideoFeed(relatedVideos);
printVideoEntry(video);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
示例10: YouTubeGetTest
/////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/// <summary>runs a test on the YouTube factory object</summary>
//////////////////////////////////////////////////////////////////////
[Test] public void YouTubeGetTest()
{
Tracing.TraceMsg("Entering YouTubeGetTest");
YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytClient, this.ytDevKey, this.ytUser, this.ytPwd);
settings.PageSize = 15;
YouTubeRequest f = new YouTubeRequest(settings);
Feed<Video> feed = f.GetStandardFeed(YouTubeQuery.MostPopular);
foreach (Video v in feed.Entries)
{
// remove the etag to force a refresh
v.YouTubeEntry.Etag = null;
Video refresh = f.Retrieve(v);
Assert.AreEqual(refresh.VideoId, v.VideoId, "The ID values should be equal");
}
}
示例11: VideoSubmit
public ActionResult VideoSubmit(string video, string videoType, string personType,
string footageType, string band, string song, string contestID)
{
if (string.IsNullOrWhiteSpace(video))
{
Response.Redirect("~/videosubmission.aspx?statustype=I");
return new EmptyResult();
}
VideoRequest vir = new VideoRequest();
vir.RequestURL = video;
string vidKey = string.Empty;
vir.RequestURL = vir.RequestURL.Replace("https", "http");
if (vir.RequestURL.Contains("http://youtu.be/"))
{
vir.VideoKey = vir.RequestURL.Replace("http://youtu.be/", string.Empty);
}
else if (vir.RequestURL.Contains("http://www.youtube.com/watch?"))
{
NameValueCollection nvcKey = System.Web.HttpUtility.ParseQueryString(vir.RequestURL.Replace("http://www.youtube.com/watch?", string.Empty));
vir.VideoKey = nvcKey["v"];
vidKey = nvcKey["v"];
}
else
{
// invalid
vir.StatusType = 'I';
Response.Redirect("~/videosubmission.aspx?statustype=I");
return new EmptyResult();
}
if (string.IsNullOrWhiteSpace(videoType) ||
string.IsNullOrWhiteSpace(personType) ||
string.IsNullOrWhiteSpace(footageType) ||
string.IsNullOrWhiteSpace(band) ||
string.IsNullOrWhiteSpace(song))
{
// invalid
vir.StatusType = 'P';
Response.Redirect("~/videosubmission.aspx?statustype=P");
return new EmptyResult();
}
try
{
//IDictionaryEnumerator enumerator = HttpContext.Current.Cache.GetEnumerator();
//while (enumerator.MoveNext())
//{
// HttpContext.Current.Cache.Remove(enumerator.Key.ToString());
//}
//Artists allartsis = new Artists();
//allartsis.RemoveCache();
//if (gvwRequestedVideos.SelectedDataKey != null)
//{
// vidreq = new VideoRequest(Convert.ToInt32(gvwRequestedVideos.SelectedDataKey.Value));
// vidreq.StatusType = 'A';
// vidreq.Update();
//}
BootBaronLib.AppSpec.DasKlub.BOL.Video vid = new BootBaronLib.AppSpec.DasKlub.BOL.Video("YT", vidKey);
vid.ProviderCode = "YT";
Google.YouTube.Video video2;
video2 = new Google.YouTube.Video();
try
{
YouTubeRequestSettings yousettings = new YouTubeRequestSettings("You Manager", devkey, username, password);
YouTubeRequest yourequest;
Uri Url;
yourequest = new YouTubeRequest(yousettings);
Url = new Uri("http://gdata.youtube.com/feeds/api/videos/" + vidKey);
video2 = yourequest.Retrieve<Google.YouTube.Video>(Url);
vid.Duration = (float)Convert.ToDouble(video2.YouTubeEntry.Duration.Seconds);
vid.ProviderUserKey = video2.Uploader;
vid.PublishDate = video2.YouTubeEntry.Published;
}
catch (GDataRequestException)
{
vid.IsEnabled = false;
vid.Update();
//litVideo.Text = string.Empty;
// return;
// invalid
vir.StatusType = 'I';
Response.Redirect("~/videosubmission.aspx?statustype=I");
//.........这里部分代码省略.........
示例12: GetVideoInfo
public override DownloadInfo GetVideoInfo(bool saveDialog, String savePath)
{
//DownloadInfo info = null;
YouTubeRequestSettings settings = new YouTubeRequestSettings(Settings.Default.youtubeAppName, Settings.Default.youtubeDevKey);
YouTubeRequest request = new YouTubeRequest(settings);
Uri videoEntryUrl = new Uri(urlPageVideo);
Video video = request.Retrieve<Video>(videoEntryUrl);
String videoInfo = printVideoEntry(video);
String urlVideoFile = video.Contents[0].Url;
//DownloadPageToFile(urlVideoFile, @"D:\Video\Youtube\Test\test");
WebClient webClient = new WebClient();
byte[] buffer = webClient.DownloadData(urlVideoFile);
byte[] fileType = new byte[3];
byte[] header = new byte[5];
byte[] compressedData = new byte[buffer.Length - 8];
for (int index = 0; index < 3; index++)
fileType[index] = buffer[index];
for (int index = 3; index < 8; index++)
header[index-3] = buffer[index];
for (int index = 8; index < buffer.Length; index++)
compressedData[index-8] = buffer[index];
MemoryStream ms = new MemoryStream(compressedData);
DeflateStream zipStream = new DeflateStream(ms, CompressionMode.Decompress);
byte[] tempBufer = new byte[256];
FileStream fichier = new FileStream(savePath + "test.swf",
FileMode.Create, FileAccess.Write, FileShare.None,
tempBufer.Length, false);
fichier.Write(fileType, 0, fileType.Length);
fichier.Write(header, 0, header.Length);
fichier.Flush();
int offset = 0;
int totalCount = 0;
int bytesRead;
while ((bytesRead = zipStream.Read(tempBufer, 0, tempBufer.Length)) != 0)
{
fichier.Write(tempBufer, 0, tempBufer.Length);
offset += bytesRead;
totalCount += bytesRead;
}
zipStream.Close();
ms.Close();
fichier.Close();
/*long videoFileSize = 0;
String titreVideo = null;
if (urlVideoFile != null)
{
videoFileSize = getVideoFileSizeAndType(urlVideoFile);
if (videoFileSize > 0)
{
titreVideo = video.Title;
if (titreVideo != null)
{
info = new DownloadInfo(urlVideoFile, titreVideo, videoFileSize, savePath, this.fileType, manager.managerMV, manager, this);
if (saveDialog)
{
info = LaunchSaveDlg(info);
}
}
}
}*/
return null;
}
示例13: btnSubmit_Click
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
var allartsis = new Artists();
allartsis.RemoveCache();
if (gvwRequestedVideos.SelectedDataKey != null)
{
vidreq = new VideoRequest(Convert.ToInt32(gvwRequestedVideos.SelectedDataKey.Value))
{
StatusType = 'A'
};
vidreq.Update();
}
vid = new Video("YT", txtVideoKey.Text)
{
Duration = (float) Convert.ToDouble(txtDuration.Text),
Intro = (float) Convert.ToDouble(txtSecondsIn.Text),
LengthFromStart = (float) Convert.ToDouble(txtElasedEnd.Text),
ProviderCode = ddlVideoProvider.SelectedValue,
ProviderUserKey = txtUserName.Text,
VolumeLevel = Convert.ToInt32(ddlVolumeLevel.SelectedValue),
IsEnabled = chkEnabled.Checked,
EnableTrim = chkEnabled.Checked
};
// vid.IsHidden = chkHidden.Checked;
/// publish date
var yousettings = new YouTubeRequestSettings("Das Klub", devkey);
var yourequest = new YouTubeRequest(yousettings);
var Url = new Uri("http://gdata.youtube.com/feeds/api/videos/" + vid.ProviderKey);
var video = new Google.YouTube.Video();
video = yourequest.Retrieve<Google.YouTube.Video>(Url);
vid.PublishDate = video.YouTubeEntry.Published;
if (vid.VideoID == 0)
{
vid.Create();
}
else
vid.Update();
// if there is a contest, add it now since there is an id
if (ddlContest.SelectedValue != unknownValue)
{
//TODO: check if it already is in the contest
ContestVideo.DeleteVideoFromAllContests(vid.VideoID);
var cv = new ContestVideo();
cv.ContestID = Convert.ToInt32(ddlContest.SelectedValue);
cv.VideoID = vid.VideoID;
cv.Create();
}
else
{
// TODO: JUST REMOVE FROM CURRENT CONTEST, NOT ALL
ContestVideo.DeleteVideoFromAllContests(vid.VideoID);
}
// vid type
if (!string.IsNullOrWhiteSpace(ddlVideoType.SelectedValue)
&& ddlVideoType.SelectedValue != selectText)
{
propTyp = new PropertyType(SiteEnums.PropertyTypeCode.VIDTP);
mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
mp.RemoveCache();
MultiPropertyVideo.AddMultiPropertyVideo(
Convert.ToInt32(
ddlVideoType.SelectedValue), vid.VideoID);
}
// human
if (!string.IsNullOrWhiteSpace(ddlHumanType.SelectedValue)
&& ddlHumanType.SelectedValue != selectText)
{
propTyp = new PropertyType(SiteEnums.PropertyTypeCode.HUMAN);
mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
mp.RemoveCache();
MultiPropertyVideo.AddMultiPropertyVideo(
Convert.ToInt32(
ddlHumanType.SelectedValue), vid.VideoID);
}
// footage
if (!string.IsNullOrWhiteSpace(ddlFootageType.SelectedValue)
&& ddlFootageType.SelectedValue != selectText)
{
propTyp = new PropertyType(SiteEnums.PropertyTypeCode.FOOTG);
mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
mp.RemoveCache();
MultiPropertyVideo.AddMultiPropertyVideo(
Convert.ToInt32(
//.........这里部分代码省略.........
示例14: LoadVideo
private void LoadVideo(string videoKey)
{
ClearInput();
try
{
vid = new Video("YT", videoKey);
litVideo.Text =
string.Format(
@"<iframe width=""425"" height=""349"" src=""http://www.youtube.com/embed/{0}"" frameborder=""0"" allowfullscreen></iframe>",
vid.ProviderKey);
txtSecondsIn.Text = vid.Intro.ToString();
txtElasedEnd.Text = vid.LengthFromStart.ToString();
ddlVideoProvider.SelectedValue = vid.ProviderCode;
chkEnabled.Checked = vid.IsEnabled;
ddlVolumeLevel.SelectedValue = vid.VolumeLevel.ToString();
lblVideoID.Text = vid.VideoID.ToString();
if (vid.VolumeLevel == 0)
{
ddlVolumeLevel.SelectedValue = "5";
chkEnabled.Checked = true;
}
var video = new Google.YouTube.Video();
try
{
var yousettings = new YouTubeRequestSettings("Das Klub", devkey);
var yourequest = new YouTubeRequest(yousettings);
var url = new Uri("http://gdata.youtube.com/feeds/api/videos/" + videoKey);
video = yourequest.Retrieve<Google.YouTube.Video>(url);
txtDuration.Text = video.YouTubeEntry.Duration.Seconds;
}
catch (GDataRequestException)
{
vid.IsEnabled = false;
vid.Update();
litVideo.Text = string.Empty;
return;
}
if (vid.LengthFromStart == 0)
{
txtElasedEnd.Text = video.YouTubeEntry.Duration.Seconds;
}
if (vid.LengthFromStart == 0)
{
txtDuration.Text = video.YouTubeEntry.Duration.Seconds;
}
txtUserName.Text = video.Uploader;
lblVideoID.Text = vid.VideoID.ToString();
txtVideoKey.Text = video.VideoId;
// vid type
propTyp = new PropertyType(SiteEnums.PropertyTypeCode.VIDTP);
mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
mps = new MultiProperties(propTyp.PropertyTypeID);
mps.Sort(delegate(MultiProperty p1, MultiProperty p2) { return p1.Name.CompareTo(p2.Name); });
ddlVideoType.DataSource = mps;
ddlVideoType.DataTextField = "name";
ddlVideoType.DataValueField = "multiPropertyID";
ddlVideoType.DataBind();
ddlVideoType.Items.Insert(0, new ListItem(selectText));
if (mp.MultiPropertyID != 0)
ddlVideoType.SelectedValue = mp.MultiPropertyID.ToString();
// human
propTyp = new PropertyType(SiteEnums.PropertyTypeCode.HUMAN);
mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
mps = new MultiProperties(propTyp.PropertyTypeID);
mps.Sort(delegate(MultiProperty p1, MultiProperty p2) { return p1.Name.CompareTo(p2.Name); });
ddlHumanType.DataSource = mps;
ddlHumanType.DataTextField = "name";
ddlHumanType.DataValueField = "multiPropertyID";
ddlHumanType.DataBind();
ddlHumanType.Items.Insert(0, new ListItem(selectText));
if (mp.MultiPropertyID != 0)
ddlHumanType.SelectedValue = mp.MultiPropertyID.ToString();
// footage
propTyp = new PropertyType(SiteEnums.PropertyTypeCode.FOOTG);
mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
mps = new MultiProperties(propTyp.PropertyTypeID);
mps.Sort(delegate(MultiProperty p1, MultiProperty p2) { return p1.Name.CompareTo(p2.Name); });
ddlFootageType.DataSource = mps;
ddlFootageType.DataTextField = "name";
ddlFootageType.DataValueField = "multiPropertyID";
ddlFootageType.DataBind();
ddlFootageType.Items.Insert(0, new ListItem(selectText));
if (mp.MultiPropertyID != 0)
ddlFootageType.SelectedValue = mp.MultiPropertyID.ToString();
// contest
//.........这里部分代码省略.........
示例15: getChannelVideos
private string[] getChannelVideos(int type,string channelUserName,string devKey,string userName, string pass)
{
List<string> videos = new List<string>();
YouTubeRequestSettings settings = new YouTubeRequestSettings("Contentor", devKey, userName, pass);
YouTubeRequest request = new YouTubeRequest(settings);
try
{
int toplam = 0;
string q;
using (WebClient asd = new WebClient())
{
asd.Encoding = Encoding.UTF8;
q = asd.DownloadString("http://gdata.youtube.com/feeds/api/users/" + channelUserName + "/uploads?v=2&alt=jsonc&max-results=0");
}
string[] adet1 = q.Split(new string[] { "totalItems\":" }, StringSplitOptions.None);
string[] adet2 = adet1[1].Split(',');
string adet3 = adet2[0];
int index = 1;
for (int i = 1; i <= Convert.ToInt16(adet3) / 50; i++)
{
Uri uri = new Uri("http://gdata.youtube.com/feeds/api/users/" + channelUserName + "/uploads?&max-results=50&start-index=" + index);
Feed<Video> videoFeed = request.Get<Video>(uri);
foreach (Video entry in videoFeed.Entries)
{
videos.Add(entry.VideoId);
}
index += 50;
}
toplam = ((Convert.ToInt16(adet3) / 50) * 50) + 1;
Uri uri2 = new Uri("http://gdata.youtube.com/feeds/api/users/" + channelUserName + "/uploads?&max-results=50&start-index=" + toplam);
Feed<Video> videoFeed2 = request.Get<Video>(uri2);
foreach (Video entry in videoFeed2.Entries)
{
videos.Add(entry.VideoId);
}
}
catch
{
MessageBox.Show("Sayfa Adında Sorun Var!");
}
if (type == 1)
{
List<string> checkedVideos = new List<string>();
foreach (string s in videos)
{
Uri videoEntryUrl = new Uri("http://gdata.youtube.com/feeds/api/videos/"+s);
Video video = request.Retrieve<Video>(videoEntryUrl);
if (video.Media != null && video.Media.Rating != null)
{
checkedVideos.Add(s+" restricted: "+video.Media.Rating.Country);
}
if (video.IsDraft)
{
string stateName = video.Status.Name;
checkedVideos.Add(s + " not live: "+stateName);
/*if (stateName == "processing")
{
checkedVideos.Add(s + " processing: " + video.Media.Rating.Country);
}
else if (stateName == "rejected")
{
checkedVideos.Add(s+" rejected: "+video.Status.Value);
}
else if (stateName == "failed")
{
checkedVideos.Add(s+" failed uploading: "+ video.Status.Value);
}*/
}
}
return checkedVideos.ToArray();
}
else
return videos.ToArray();
}