/// <summary> /// Fetch a list of videos from youtube /// </summary> /// <returns></returns> protected async Task FetchData() { _httpClient.BaseAddress = new System.Uri("https://www.googleapis.com/youtube/v3/"); if (autoRegionCode) { string tempregionCode = await JSRuntime.Current.InvokeAsync <string>("myFunction.local"); if (tempregionCode.Contains("-")) { regionCode = tempregionCode.Split('-')[1]; } } text = await _httpClient.GetStringAsync(GenerateUrl()); try { model = Json.Deserialize <YouTubeModel>(text); } catch (Exception ex) { err = ex.ToString(); } }
/// <summary> /// Load ViewModel items asynchronous /// </summary> public async Task LoadData(bool isNetworkAvailable) { var loadTasks = new Task[] { FacebookModel.LoadItems(isNetworkAvailable), YouTubeModel.LoadItems(isNetworkAvailable), ArmiaWBinguModel.LoadItems(isNetworkAvailable), }; await Task.WhenAll(loadTasks); }
//Returns filepath string (Shared by both models) public static string GetPath(YouTubeModel model) { //Decrypts Video if necessary if (model.Video.RequiresDecryption) DownloadUrlResolver.DecryptDownloadUrl(model.Video); //Remove illegal characters from video.Title string title = model.Video.Title; string cleanTitle = CleanFileName(title); //Set FilePath property string path = Path.Combine(model.FolderPath, cleanTitle); return path; }
private async Task PerformYouTubeSearchAsync(YouTubeModel model) { var youtubeService = new YouTubeService(new BaseClientService.Initializer() { ApiKey = "AIzaSyCTnrb4UFBFj3NknsqAKem6Chf1fbLdhT0", ApplicationName = this.GetType().ToString() }); var searchListRequest = youtubeService.Search.List("snippet"); searchListRequest.Q = model.Keywords; // Replace with your search term. searchListRequest.MaxResults = 10; // Call the search.list method to retrieve results matching the specified query term. var searchListResponse = await searchListRequest.ExecuteAsync(); // 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": model.Videos.Add(String.Format("{0} ({1})", searchResult.Snippet.Title, searchResult.Id.VideoId)); break; case "youtube#channel": model.Channels.Add(String.Format("{0} ({1})", searchResult.Snippet.Title, searchResult.Id.ChannelId)); break; case "youtube#playlist": model.Playlists.Add(String.Format("{0} ({1})", searchResult.Snippet.Title, searchResult.Id.PlaylistId)); break; } } }
//Returns VideoInfo List (Shared by both audio and video models) public static IEnumerable<VideoInfo> GetVideoInfos(YouTubeModel model) { //Get the available video formats. IEnumerable<VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(model.Link); return videoInfos; }
public IActionResult Revelation(YouTubeModel model) { model.link = "https://youtu.be/P5m567jUWrA1"; model.embed = "<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/P5m567jUWrA1\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>"; return(View("Index", model)); }
public async Task <ActionResult> Index(YouTubeModel model) { await PerformYouTubeSearchAsync(model); return(View("SearchResults", model)); }