protected override async void OnNavigatedTo(NavigationEventArgs e) { try { if (NetworkInterface.GetIsNetworkAvailable()) { player.Visibility = Visibility.Collapsed; progress.Visibility = Visibility.Visible; string videoId = String.Empty; YoutubeVideo video = e.Parameter as YoutubeVideo; if (video != null && !video.Id.Equals(String.Empty)) { //Get The Video Uri and set it as a player source var url = await YouTube.GetVideoUriAsync(video.Id, YouTubeQuality.Quality480P); player.Source = url.Uri; } player.Visibility = Visibility.Visible; progress.Visibility = Visibility.Collapsed; } else { MessageDialog message = new MessageDialog("You're not connected to Internet!"); await message.ShowAsync(); this.Frame.GoBack(); } } catch { } base.OnNavigatedTo(e); }
public string Generate(DealerViewModel dealer, CarShortViewModel car) { GeneratePowerPointFromImages(dealer, car); if (GenerateVideoFromPowerPoint(dealer, car)) { System.Threading.Thread.Sleep(240000); try { var video = new YoutubeVideo() { }; video.LocalFilePath = (ConfigurationHandler.DealerImages + "/" + dealer.DealerId + "/" + car.Vin + "/NormalSizeImages") + String.Format(@"\{0} {1} {2} {3}.wmv", car.ModelYear, car.Make, car.Model, car.Trim); video.Categories.Add("Autos"); video.Tags.Add(car.ModelYear.ToString()); video.Tags.Add(car.Make); video.Tags.Add(car.Model); video.Tags.Add(dealer.Name); video.Tags.Add("Vehicle"); video.Tags.Add("Auto"); video.Description = car.Description; video.Title = String.Format(@"{0} {1} {2} {3}", car.ModelYear, car.Make, car.Model, car.Trim); video.Latitude = Convert.ToDouble(dealer.Lattitude); video.Longitude = Convert.ToDouble(dealer.Longitude); string videoId; youtube.UploadVideoToYouTube(video, out videoId); return(videoId.Split(':').Last()); } catch (Exception) { } } return(string.Empty); }
public string Add(YoutubeVideo sample) { string status; try { YoutubeVideo videoSample = new YoutubeVideo(); YouTubeDemoModuleDbContext context = new YouTubeDemoModuleDbContext(); videoSample.CreatedBy = sample.CreatedBy; videoSample.CreatedDate = sample.CreatedDate; videoSample.Id = sample.Id; videoSample.ModifiedBy = sample.ModifiedBy; videoSample.ModifiedDate = sample.ModifiedDate; videoSample.ProductId = sample.ProductId; videoSample.VideoTitle = sample.VideoTitle; videoSample.YoutubeId = sample.YoutubeId; context.YouTubeDemo.Add(videoSample); context.SaveChanges(); status = "Success"; } catch (Exception ex) { status = ex.InnerException.Message; } return(status); }
void Start() { videos = new List <vSData>(); videoList = new List <vData>(); thumbs = new Texture2D[maxresults]; youtube = new YoutubeVideo(); }
public async Task <IActionResult> Edit(int id, [Bind("Id,URL,Name")] YoutubeVideo youtubeVideo) { if (id != youtubeVideo.Id) { return(NotFound()); } if (!await _youtubeVideosRepository.ExistAsync(youtubeVideo.Id)) { return(NotFound()); } if (ModelState.IsValid) { try { //_dataContext.Update(youtubeVideo); //await _dataContext.SaveChangesAsync(); await _youtubeVideosRepository.UpdateAsync(youtubeVideo); } catch (DbUpdateConcurrencyException ex) { ModelState.AddModelError(string.Empty, ex.Message); return(View(youtubeVideo)); } TempData["Success"] = "Video updated successfully!"; return(RedirectToAction(nameof(Index))); } return(View(youtubeVideo)); }
public bool RemoveVideo(YoutubeVideo video) { using (var connection = new SQLiteConnection(new SQLitePlatformWinRT(), _sqlpath)) { connection.Delete(video, true); return(true); } //var savedTips = GetAll(); //var savedTip = savedTips.FirstOrDefault(t => t.UniqueId == tip.UniqueId); //if (savedTip != null) //{ // savedTips.Remove(savedTip); //} //else //{ // return false; //} //var jsonTips = JsonConvert.SerializeObject(savedTips); //_roamingSettings.Values["videos"] = jsonTips; //return true; }
private static void UploadVideo() { try { var youtube = new YoutubeWrapper(); var video = new YoutubeVideo() { }; video.LocalFilePath = @"C:\SCBBR53W26C036262\2006 Bentley Continental Fly.wmv"; video.Categories.Add("Autos"); video.Tags.Add("Bentley"); video.Tags.Add("Continental"); video.Tags.Add("Newport Coast Auto"); video.Tags.Add("Vehicle"); video.Tags.Add("Auto"); video.Description = "2006 Bentley Continental Fly"; video.Title = "2006 Bentley Continental Fly"; video.Latitude = 33.648280; video.Longitude = -117.915538; var videoId = string.Empty; youtube.UploadVideoToYouTube(video, out videoId); } catch (Exception ex) { } }
public void Url_ContainsVideoAndInvalidPlaylist_ParseUrl() { var video = new YoutubeVideo(new Uri("https://www.youtube.com/watch?v=ewBulJdtGlM&list=####@"), VideoRefreshFlags.None); Assert.AreEqual("ewBulJdtGlM", video.Id); Assert.Null(video.Playlist); }
public YoutubeToImages() { youtubeVideo = new YoutubeVideo(); youtubeAudio = new YoutubeAudio(); toImages = new ToImages(); cutVideo = new CutVideo(); }
public void Refresh_ValidVideos_Equality() { for (int i = 0; i < _ytIds.Count; i++) { var video = new YoutubeVideo(_ytIds[i]); } }
public YoutubeVideo GetByIdDetached(int id) { YoutubeVideo video = db.Videos.Find(id); db.Entry(video).State = EntityState.Detached; return(video); }
public YT_MediaBtn(Object a_Media, int a_Row, int a_Column) { InitializeComponent(); //Emplacement dans la grille ItemGrid.SetValue(Grid.RowProperty, a_Row); ItemGrid.SetValue(Grid.ColumnProperty, a_Column); if (a_Media is YoutubeVideo) { m_vid = (YoutubeVideo)a_Media; TitleComponent.Text = m_vid.Title; LiveThumbnailComponent.Source = m_vid.Thumbnail; ChannelLogoComponent.Source = m_vid.ChannelImage; ChannelNameComponent.Text = string.Format("{0} views", m_vid.Views); var t_converter = new System.Windows.Media.BrushConverter(); ButtonComponent.Background = (Brush)t_converter.ConvertFromString("#000000"); TimeSpan t_DeltaRelease = DateTime.UtcNow - m_vid.PublicationDate; SinceComponent.Text = t_DeltaRelease.Days > 365 ? String.Format("{0} Ans, {1} Mois", (t_DeltaRelease.Days / 365), (t_DeltaRelease.Days / 31) - (t_DeltaRelease.Days / 365) * 12) : t_DeltaRelease.Days > 31 ? String.Format("{0} Mois, {1} Jours", (t_DeltaRelease.Days / 31), t_DeltaRelease.Days - (t_DeltaRelease.Days / 31) * 31) : t_DeltaRelease.Days > 0 ? String.Format("{0} Jours, {1} Heures", t_DeltaRelease.Days, t_DeltaRelease.Hours) : t_DeltaRelease.Hours > 0 ? String.Format("{0} Heures, {1} Minutes", t_DeltaRelease.Hours, t_DeltaRelease.Minutes) : t_DeltaRelease.Minutes > 0 ? String.Format("{0} Minutes, {1} Secondes", t_DeltaRelease.Minutes, t_DeltaRelease.Seconds) : String.Format("{0} Secondes", t_DeltaRelease.Seconds); Boolean t_isLive = (m_vid.Views == 0 && t_DeltaRelease.TotalSeconds > 60); Boolean t_IsRecent = (t_DeltaRelease.Hours < 2) && (t_DeltaRelease.Days == 0); LiveCircle.Foreground = (Brush)t_converter.ConvertFromString(t_isLive ? (t_IsRecent ? "#e91916" : "#9c7a6f") : "#000000FF"); DateComponent.Text = m_vid.PublicationDate.ToShortDateString(); IsLiveTextComponent.Foreground = (Brush)t_converter.ConvertFromString(t_isLive ? (t_IsRecent ? "#FFF" : "#8f8f8f") : "#000000FF"); } }
public async Task <ActionResult> CompareViewCountAsync(string videoIdGuessed, string videoIdNotGuessed) { if (string.IsNullOrEmpty(videoIdGuessed) || string.IsNullOrEmpty(videoIdNotGuessed)) { return(BadRequest()); } if (videoIdGuessed == videoIdNotGuessed) { return(BadRequest()); } // Try to get Viewcount from database YoutubeVideo video1 = await _context.YoutubeVideos.FindAsync(videoIdGuessed); YoutubeVideo video2 = await _context.YoutubeVideos.FindAsync(videoIdNotGuessed); if (video1 == null || video2 == null) { return(BadRequest()); } List <VideoView> videoViews = new List <VideoView> { new VideoView(video1), new VideoView(video2) }; await AddGuessesStatisticsAsync(videoViews[0].ViewCount, videoViews[1].ViewCount); return(Ok(videoViews)); }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e) { try { if (NetworkInterface.GetIsNetworkAvailable()) { player.Visibility = Visibility.Collapsed; progress.Visibility = Visibility.Visible; string videoId = String.Empty; YoutubeVideo video = e.NavigationParameter as YoutubeVideo; if (video != null && !video.Id.Equals(String.Empty)) { //Get The Video Uri and set it as a player source var url = await YouTube.GetVideoUriAsync(video.Id, YouTubeQuality.Quality1080P); player.Source = url.Uri; } player.Visibility = Visibility.Visible; progress.Visibility = Visibility.Collapsed; } else { MessageDialog message = new MessageDialog("İnternet bağlantınızda sorun var, lütfen internet bağlantınızı kontrol edin ve tekrar deneyin."); await message.ShowAsync(); this.Frame.GoBack(); } } catch { } }
public static void Main1() { while (true) { try { Console.Write("Youtube Url: "); var url = Console.ReadLine(); var video = new YoutubeVideo(new Uri(url), VideoRefreshFlags.None); Console.WriteLine("Refreshing..."); Console.WriteLine(); video.Refresh(); //Console.WriteLine(video.Url); Console.WriteLine("Title: {0}", video.Title); Console.WriteLine("-------------------------"); Console.WriteLine("Description:\n{0}", video.Description); Console.WriteLine("-------------------------"); Console.WriteLine("Length: {0}", video.Length); Console.WriteLine("Views: {0}", video.Views); Console.WriteLine(); } catch (Exception ex) { Console.WriteLine("Error: {0}", ex.Message); } } }
public static void Main(string[] args) { //s_lock = new object(); var video2 = new YoutubeVideo("bBmBPXS7xEA"); var client = new WebClient(); client.DownloadProgressChanged += DownloadProgressChange; client.DownloadFileCompleted += DownloadCompleted; s_startTime = DateTime.Now; s_lastUpdate = DateTime.Now; client.DownloadFileAsync(video2.Formats[0].VideoUrl, CleanFileName(video2.Title) + video2.Formats[0].Extension); Console.ReadLine(); //Console.WriteLine("Downloading & parsing {0} playlist...", "PL4yXuCu4RM9zLDmDPSlBd32vmAL0AKq9O"); //var playlist = new YoutubePlaylist("PL4yXuCu4RM9zLDmDPSlBd32vmAL0AKq9O"); //Console.WriteLine("{0} videos in playlist \"{1}\".", playlist.Count, playlist.Title); //for (int i = 0; i < playlist.Count; i++) //{ // var video = playlist[i]; // video.Refresh(); // Console.WriteLine(); // Console.WriteLine(video.Url); // Console.WriteLine("Title: {0}", video.Title); // Console.WriteLine("Description:\n{0}", video.Description); // Console.WriteLine("Length: {0}", video.Length); // Console.WriteLine("Views: {0}", video.Views); // Console.WriteLine(); // Console.ReadLine(); //} Console.ReadLine(); //-GVo0a3nnyg }
public async Task <BaseResponse <Song> > getYoutubeVideoInfo(string videoId, Song song) { var response = await _client.GetAsync(baseUrl + "videos?id=" + videoId + "&key=" + _youtubeConfig.Key + "&part=contentDetails"); if (response.IsSuccessStatusCode) { var jsonString = await response.Content.ReadAsStringAsync(); YoutubeVideo youtubeVideo = JsonConvert.DeserializeObject <YoutubeVideo>(jsonString); // converts from a XML time span to ms var duration = Convert.ToInt32(System.Xml.XmlConvert.ToTimeSpan(youtubeVideo.items[0].contentDetails.duration).TotalMilliseconds); song.Duration = duration; song.SongType = SongType.Youtube; return(new BaseResponse <Song>(song)); } else { return(new BaseResponse <Song>(message: string.Format("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase))); } throw new NotImplementedException(); }
private static async void VtuberStoppedYoutubeLiveEvent(VtuberEntity vtuber, YoutubeVideo liveVideo) { LogHelper.Info($"Vtuber [{vtuber.OriginalName}] 结束了直播."); foreach (var api in CallbackApis) { await api.CallYoutubeStopLiveAsync(vtuber, liveVideo); } }
public void Create(YoutubeVideo video) { if (video == null && db.Videos.Any(v => v.source == video.source)) { return; } db.Videos.Add(video); }
private static async void VtuberBeginYoutubeLiveEvent(VtuberEntity vtuber, YoutubeVideo liveVideo) { LogHelper.Info($"Vtuber [{vtuber.OriginalName}] 在Youtube开始了直播 {liveVideo.VideoLink} ({liveVideo.Title})"); foreach (var api in CallbackApis) { await api.CallYoutubeBeginLiveAsync(vtuber, liveVideo); } }
public async Task <string> Addition(YoutubeVideo video) { await _eventPublisher.Publish(new VideoAdditionEvent { Video = video }); var result = Add(video); return(result); }
private async Task <bool> UserHasPermissionsOnVideoAsync(YoutubeVideo video) { var user = await _userHelper.GetUserByEmailAsync(User.Identity.Name); return(!User.IsInRole("Manager") && video.User != user ? false : true); }
public void OneTimeSetUp() { string[] args = new string[] { url, path }; Task <string> task = YoutubeVideo.DownloadYoutubeInformation(args); task.Wait(); path = task.Result; }
public async Task Assert_GetVideoByVideoId_videoid_is_invalid() { ActionResult actionResult = await videosController.GetVideoByVideoIdAsync("invalid videoid"); var okResult = actionResult as OkObjectResult; YoutubeVideo video = okResult.Value as YoutubeVideo; Assert.IsNull(video); }
public bool UpdateVideo(YoutubeVideo video) { using (var connection = new SQLiteConnection(new SQLitePlatformWinRT(), _sqlpath)) { connection.Update(video); return(true); } }
private void ListVideo_ItemClick(object sender, ItemClickEventArgs e) { YoutubeVideo video = e.ClickedItem as YoutubeVideo; if (video != null) { Frame.Navigate(typeof(PlayVideoPage), video); } }
public void Delete(YoutubeVideo video) { YoutubeVideo YoutubeVideo = db.Videos.Find(video); if (video != null) { db.Videos.Remove(video); } }
public void Assert_ParseYoutubeVideo_25_results_is_correct() { string jsonData = GetTextFromFile("VideoSearchResponse_25_results.json"); YoutubeVideo yt = parser.ParseYoutubeVideo(jsonData); Assert.IsNotNull(yt.VideoId); Assert.IsNotNull(yt.Title); Assert.IsNotNull(yt.ChannelName); }
public YoutubeJob(YoutubeVideo video, YoutubeAccount account, YoutubeError error, UploadStatus uploadStatus) : this(video, account, uploadStatus) { if (!SimplifyLogging) { LOGGER.Info($"Creating new job with error '{error}'"); } Error = error; }
public async Task <ActionResult> GetVideoByVideoIdAsync(string videoId) { if (string.IsNullOrEmpty(videoId)) { return(BadRequest()); } YoutubeVideo video = await _context.YoutubeVideos.FindAsync(videoId); return(Ok(video)); }
public async Task<Result<YoutubeVideo, string>> GetYoutubeVideoInfo(string videoUrl) { videoUrl = YoutubeHelpers.NormalizeVideoUrl(videoUrl); if(string.IsNullOrEmpty(videoUrl)) return "Invalid Link"; try { var videos = await Task.Run(() => DownloadUrlResolver.GetDownloadUrls(videoUrl)); var video = new YoutubeVideo() { Title = videos.First().Title, Url = videoUrl, }; video.Formats = videos.Select(v => new YTEVideoFormat(video) { FormatCode = v.FormatCode, AudioBitrate = v.AudioBitrate, Resolution = v.Resolution, ContainerExtension = v.VideoExtension, AudioExtension = v.AudioExtension, Container = (MediaContainer)v.VideoType, AudioCodec = (AudioCodec)v.AudioType, AdaptiveType = (AdaptiveType)v.AdaptiveType, DownloadUrl = v.DownloadUrl, IsEncrypted = v.RequiresDecryption, YTEVideoInfo = v, } as VideoFormat).ToList(); return video; } catch(WebException e) { return (e.Response as HttpWebResponse).StatusCode.ToString(); } catch(Exception) { return "Private/Removed Video"; } }
public YTEVideoFormat(YoutubeVideo owner): base(owner) { }
void Start() { Instance = this; }
void Start() { videos = new List<vSData>(); videoList = new List<vData>(); thumbs = new Texture2D[maxresults]; youtube = new YoutubeVideo(); }
void Start() { youtube = gameObject.AddComponent<YoutubeVideo> (); isT = false; }
void Start() { //Instance the YoutubeVideo Object youtube = new YoutubeVideo(); }
void Awake() { Instance = this; }
private void DoChoice(RandomEvent.Choice choice) { int actionValueSkill = 0; int actionValueFollowers = 0; foreach (RandomEvent.ChoiceAction action in choice.Actions) { switch (action.Action) { case RandomEvent.ChoiceAction.ActionType.SkillIncrease: { int increaseValue = (int)action.Values[1]; if (action.Values.Length > 3) switch ((PlayerSkill)action.Values[2]) { case PlayerSkill.Knowledge: increaseValue += Player.Instance.KnowledgeSkills * (int)action.Values[3]; break; case PlayerSkill.Presentation: increaseValue += Player.Instance.PresentationSkills * (int)action.Values[3]; break; case PlayerSkill.Media: increaseValue += Player.Instance.MediaSkills * (int)action.Values[3]; break; default: throw new ArgumentOutOfRangeException(); } if (increaseValue < 0) { this.VisualFeedBack(increaseValue.ToString()).GetComponent<Animator>().SetTrigger("SkillUp"); } else { this.VisualFeedBack("+ " + increaseValue.ToString()).GetComponent<Animator>().SetTrigger("SkillUp"); } actionValueSkill += increaseValue; IncreasePlayerSkill((PlayerSkill)action.Values[0], increaseValue); break; } case RandomEvent.ChoiceAction.ActionType.FollowerIncrease: { int increaseValue = (int)action.Values[0]; if (action.Values.Length > 2) switch ((PlayerSkill)action.Values[1]) { case PlayerSkill.Knowledge: increaseValue += Player.Instance.KnowledgeSkills * (int)action.Values[2]; break; case PlayerSkill.Presentation: increaseValue += Player.Instance.PresentationSkills * (int)action.Values[2]; break; case PlayerSkill.Media: increaseValue += Player.Instance.MediaSkills * (int)action.Values[2]; break; default: throw new ArgumentOutOfRangeException(); } this.VisualFeedBack("+ " + increaseValue.ToString()).GetComponent<Animator>().SetTrigger("FollowerUp"); actionValueFollowers += increaseValue; FollowerManager.Instance.TotalFollowers += increaseValue; break; } case RandomEvent.ChoiceAction.ActionType.Ok: { break; } case RandomEvent.ChoiceAction.ActionType.NewLightbulbNear: { bool respawn = (bool)action.Values[0]; BalloonManager.Instance.SpawnLightbulb(respawn); break; } case RandomEvent.ChoiceAction.ActionType.VisitUrl: { #if (UNITY_IPHONE || UNITY_ANDROID) YoutubeVideo ytv = new YoutubeVideo(); UnityEngine.Handheld.PlayFullScreenMovie(ytv.RequestVideo(this.CurrentRandomEvent.TedUrl, 720)); #else Application.OpenURL(this.CurrentRandomEvent.TedUrl); #endif Player.Instance.KnowledgeSkills++; break; } case RandomEvent.ChoiceAction.ActionType.Tutorial: { this._notificationPanel.SetActive(false); this._temporaryTutorialCanvas.SetActive(true); break; } default: { throw new ArgumentOutOfRangeException(); } } } if (actionValueFollowers < 0 && actionValueSkill < 0) { AudioManager.Instance.PlayNegativeFeedback(); } else if (actionValueFollowers > 0 && actionValueSkill > 0) { AudioManager.Instance.PlayPositiveFeedback(); } this.HideRandomEventsCanvas(); this.NewRandomEvent(choice); this.UpdateToGuiTopcurrentRandomEvent(); }