/// <summary> /// Creates an instance of <see cref="YoutubeConverter"/>. /// </summary> public YoutubeConverter(IYoutubeClient youtubeClient, string ffmpegFilePath) { _youtubeClient = youtubeClient.GuardNotNull(nameof(youtubeClient)); ffmpegFilePath.GuardNotNull(nameof(ffmpegFilePath)); _ffmpeg = new FfmpegCli(ffmpegFilePath); }
private static void DownloadAllCaptions(IYoutubeClient client, Video video, string downloadFolder, string videoFileNameBase, IProgress <double> progress) { var closedCaptionTrackInfos = client.GetVideoClosedCaptionTrackInfosAsync(video.Id).Result; DownloadCaptionsForLanguage(client, closedCaptionTrackInfos, "en", downloadFolder, videoFileNameBase, progress); DownloadCaptionsForLanguage(client, closedCaptionTrackInfos, "ko", downloadFolder, videoFileNameBase, progress); }
public HomeViewModel(IYoutubeClient youtubeClient, IMainViewModel parentMainViewModel) { _youtubeClient = youtubeClient; _parentMainViewModel = parentMainViewModel; SearchAndReloadVideoList("Google"); }
/// <summary> /// /// </summary> /// <param name="client">YoutubeClient instance</param> /// <param name="ffmpegExePath">//Path to the ffmpeg.exe file used to mux audio&video stream. It should be located in wwwrooot/ffmpeg.exe</param> public YoutubeClientHelper(IYoutubeClient client, string ffmpegExePath) { this.client = client; converter = new YoutubeConverter(client, ffmpegExePath); }
public void RegisterClient(IYoutubeClient client) { if (!RegisteredClients.Any(c => c.Id == client.Id)) { LOGGER.Info($"Adding youtube client credentials with name '{client.Name}'"); Clients.Add(client); } }
public YoutubeClientHelper(IYoutubeClient client, string installLocation) { this.client = client; string ffmpegExePath = installLocation + "\\ffmpeg.exe"; //Path to the ffmpeg.exe file used to mux audio&video stream. converter = new YoutubeConverter(client, ffmpegExePath); }
public Uri CreateAuthUri(IYoutubeClient client, YoutubeRedirectUri redirectUri, GoogleScope scope) { string scopeString = JoinScopes(scope); string redirectUriString = redirectUri.GetAttribute <EnumMemberAttribute>().Value; string authRequestString = $"https://accounts.google.com/o/oauth2/auth?client_id={client.Id}&redirect_uri={redirectUriString}&scope={scopeString}&response_type=code&approval_prompt=force&access_type=offline"; return(new Uri(authRequestString)); }
public void UnregisterClient(IYoutubeClient client) { if (Clients.Contains(client)) { LOGGER.Info($"Removing youtube client credential with name '{client.Name}'"); Clients.Remove(client); } }
public PlaylistServiceForm(IPlaylistServiceConnectionContainer container, IYoutubeClient client) { LOGGER.Info($"Initializing new instance of PlaylistServiceForm"); Client = client; Container = container; InitializeComponent(); }
/// <summary> /// Creates an instance of <see cref="YoutubeConverter"/>. /// </summary> public YoutubeConverter(IYoutubeClient youtubeClient, string ffmpegFilePath) { _youtubeClient = youtubeClient; _ffmpeg = new FfmpegCli(ffmpegFilePath); // Ensure running on desktop OS if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && !RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { throw new PlatformNotSupportedException("YoutubeExplode.Converter works only on desktop operating systems."); } }
public YoutubeScrapProvider( IYoutubeClient youtube, ILogger <YoutubeScrapProvider> logger, string tempFolder, string outputFolder, string converterFilePath) { this.youtube = youtube; this.logger = logger; this.tempFolder = tempFolder; this.outputFolder = outputFolder; this.converterCli = new Cli(converterFilePath); }
private static void DownloadCaptionsForLanguage(IYoutubeClient client, IReadOnlyList <ClosedCaptionTrackInfo> closedCaptionTrackInfos, string languageCode, string downloadFolder, string videoFileNameBase, IProgress <double> progress) { closedCaptionTrackInfos .SingleOrDefault(info => !info.IsAutoGenerated && info.Language.Code == languageCode) .Do(closedCaptionTrackInfo => { Console.WriteLine(); Console.WriteLine($" 0.00% \t{closedCaptionTrackInfo.Language} captions"); Console.SetCursorPosition(0, Console.CursorTop - 1); client.DownloadClosedCaptionTrackAsync(closedCaptionTrackInfo, Path.Combine(downloadFolder, $"{videoFileNameBase}.{languageCode}.srt"), progress) .Wait(); }); }
public IYoutubeAccount ConnectToAccount(string code, bool mailsAllowed, IYoutubeClient client, YoutubeRedirectUri redirectUri) { LOGGER.Info($"Connecting to account, mails allowed: {mailsAllowed}, redirect uri: {redirectUri}"); var uri = redirectUri.GetAttribute <EnumMemberAttribute>().Value; string content = $"code={code}&client_id={client.Id}&client_secret={client.Secret}&redirect_uri={uri}&grant_type=authorization_code"; var bytes = Encoding.UTF8.GetBytes(content); // Request erstellen WebRequest request = WebRequest.Create("https://www.googleapis.com/oauth2/v4/token"); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; string result = WebService.Communicate(request, bytes); QuotaProblemHandler.ThrowOnQuotaLimitReached(result); IYoutubeAccount account = null; var authResponse = JsonConvert.DeserializeObject <YoutubeAuthResponse>(result); IYoutubeAccountAccess access = new YoutubeAccountAccess(); access.Client = client; access.HasSendMailPrivilegue = mailsAllowed; if (authResponse != null && !string.IsNullOrWhiteSpace(authResponse.access_token)) { access.AccessToken = authResponse.access_token; access.RefreshToken = authResponse.refresh_token; access.TokenType = authResponse.token_type; access.ExpirationDate = DateTime.Now.AddSeconds(authResponse.expires_in); access.ClientId = client.Id; LOGGER.Info($"Connection successful, loading account details"); var accountDetails = GetAccountDetails(access); var acc = accountDetails.items.First(); account = YoutubeAccount.Create(acc.id, acc.snippet.country, acc.snippet.title); account.Access.Add(access); } LOGGER.Info($"Connected to account with id: {account.Id} and title: '{account.Title}'"); return(account); }
private static void DownloadVideo(IYoutubeClient client, Video video, string downloadFolder, string videoFileNameBase, IProgress <double> progress) { var converter = new YoutubeConverter(client, Ffmpeg.DefaultFilePath); var mediaStreamInfoSet = client.GetVideoMediaStreamInfosAsync(video.Id).Result; var videoStreamInfo = mediaStreamInfoSet.Video.OrderByDescending(info => info.VideoQuality).ThenByDescending(info => info.Framerate).First(); var audioStreamInfo = mediaStreamInfoSet.Audio.OrderByDescending(info => info.Bitrate).First(); var extension = videoStreamInfo.Container.GetFileExtension(); converter.DownloadAndProcessMediaStreamsAsync( new MediaStreamInfo[] { videoStreamInfo, audioStreamInfo }, Path.Combine(downloadFolder, videoFileNameBase + $".{extension}"), extension, progress) .Wait(); }
public YoutubeService(IYoutubeClient youtubeClient) { _youtubeClient = youtubeClient; }
/// <summary> /// Creates an instance of <see cref="YoutubeConverter"/>. /// </summary> public YoutubeConverter(IYoutubeClient youtubeClient, string ffmpegFilePath) { _youtubeClient = youtubeClient; _ffmpeg = new FfmpegCli(ffmpegFilePath); }
public YouTubeExplodeScrapper(IYoutubeClient youtubeClient) { _youtubeClient = youtubeClient; }
public void RemoveClient(IYoutubeClient client) { YoutubeClientService.RemoveClient(client); }
public YoutubeService(IYoutubeClient youtubeClient, IConfiguration configuration) { this.youtubeClient = youtubeClient; this.configuration = configuration; }
/// <summary> /// Creates an instance of <see cref="YoutubeConverter"/>. /// </summary> public YoutubeConverter(IYoutubeClient youtubeClient) : this(youtubeClient, Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ffmpeg")) { }
/// <summary> /// Initializes a new instance of the <see cref="YoutubeRepository"/> class. /// </summary> /// <param name="client">injected client.</param> /// <param name="quality">injected quality.</param> public YoutubeRepository(IYoutubeClient client, AudioQuality quality) { this.client = client; this.quality = quality; }