public async Task CheckVideoExistsAsync_Existing_Test()
        {
            string videoId = "Te_dGvF6CcE";

            bool exists = await _client.CheckVideoExistsAsync(videoId);

            Assert.IsTrue(exists);
        }
Exemplo n.º 2
0
        public async Task YoutubeClient_CheckVideoExistsAsync_Existing_Test()
        {
            var  client = new YoutubeClient();
            bool exists = await client.CheckVideoExistsAsync("Te_dGvF6CcE");

            Assert.IsTrue(exists);
        }
Exemplo n.º 3
0
        public async Task YoutubeClient_CheckVideoExistsAsync_NonExisting_Test()
        {
            var  client = new YoutubeClient();
            bool exists = await client.CheckVideoExistsAsync("qld9w0b-1ao");

            Assert.IsFalse(exists);
        }
Exemplo n.º 4
0
        public async Task YoutubeClient_CheckVideoExistsAsync_NonExisting_Test(string videoId)
        {
            var client = new YoutubeClient();

            var exists = await client.CheckVideoExistsAsync(videoId);

            Assert.That(exists, Is.Not.True);
        }
Exemplo n.º 5
0
        public async Task YoutubeClient_CheckVideoExistsAsync_NonExisting_Test()
        {
            string id = (string)TestContext.DataRow["Id"];

            var  client = new YoutubeClient();
            bool exists = await client.CheckVideoExistsAsync(id);

            Assert.IsFalse(exists);
        }
        public async Task YoutubeClient_CheckVideoExistsAsync_Existing_Test()
        {
            var id = (string)TestContext.DataRow["Id"];

            var client = new YoutubeClient();
            var exists = await client.CheckVideoExistsAsync(id);

            Assert.IsTrue(exists);
        }
        public DownloadableFile(string url, AsyncSaveHandler downloadType)
        {
            var videoId = string.Empty;

            if (!YoutubeClient.TryParseVideoId(url, out videoId) | !youtubeClient.CheckVideoExistsAsync(videoId).Result)
            {
                throw new SystemException("In order to download the file, it must come from YouTube");
            }

            this.videoId = videoId;
            DoAsyncSave  = downloadType;
            status       = DownloadStatus.Waiting;
        }
Exemplo n.º 8
0
        internal async Task SendAudioAsyncYTdirect(SocketGuild guild, SocketChannel socketChannel, string song)
        {
            string videoID = ParseYoutubeID(song);

            ytClient = new YoutubeClient();


            //Console.Write("Playing music");
            // Your task: Get a full path to the file if the value of 'path' is only a filename.

            /**if (!File.Exists(song))
             * {
             *  //await guild.TextChannels.SendMessageAsync("File does not exist.");
             *  Console.Write("File does not exist.");
             *  return;
             * }*/
            bool exists = await ytClient.CheckVideoExistsAsync(videoID);

            if (!exists)
            {
                Console.WriteLine("video doesn't exist");
                return;
            }
            try
            {
                IAudioClient client = IsConnected(guild);
                if (client != null)
                {
                    //Console.WriteLine("If in SendAudioAsync");
                    //await Log(LogSeverity.Debug, $"Starting playback of {path} in {guild.Name}");
                    var output = CreateStreamYTDirect(song).StandardOutput.BaseStream;
                    //var output = await YoutubeExplode.Services.Extensions.GetStreamAsync(, song);

                    // You can change the bitrate of the outgoing stream with an additional argument to CreatePCMStream().
                    // If not specified, the default bitrate is 96*1024.
                    stream = client.CreatePCMStream(AudioApplication.Music);
                    await output.CopyToAsync(stream);

                    await stream.FlushAsync().ConfigureAwait(true);
                }
                else
                {
                    Console.WriteLine("joining in audioservice");
                    await JoinAudio(guild, socketChannel as IVoiceChannel);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }


            /**videoInfos = await ytClient.GetVideoInfoAsync(videoID);
             * var streamInfos = videoInfos.AudioStreams.OrderBy(s => s.AudioEncoding).Last();
             * IAudioClient aClient;
             * if (ConnectedChannels.TryGetValue(guild.Id, out aClient))
             * {
             *  string fileExtension = streamInfos.Container.GetFileExtension();
             *  string fileName = $"{videoInfos.Id}.{streamInfos.AudioEncoding}.{fileExtension}";
             *  using (var input = await ytClient.GetMediaStreamAsync(streamInfos))
             *  using (var output = File.Create(fileName))
             *  {
             *      await input.CopyToAsync(output);
             *      stream = aClient.CreatePCMStream(AudioApplication.Music);
             *      await output.FlushAsync().ConfigureAwait(false);
             *  }
             *
             * }
             *
             *
             * /**IAudioClient client;
             * if (ConnectedChannels.TryGetValue(guild.Id, out client))
             * {
             *  //Console.WriteLine("If in SendAudioAsync");
             *  //await Log(LogSeverity.Debug, $"Starting playback of {path} in {guild.Name}");
             *  var output = CreateStream(song).StandardOutput.BaseStream;
             *  //var output = await YoutubeExplode.Services.Extensions.GetStreamAsync(, song);
             *
             *  // You can change the bitrate of the outgoing stream with an additional argument to CreatePCMStream().
             *  // If not specified, the default bitrate is 96*1024.
             *  stream = client.CreatePCMStream(AudioApplication.Music);
             *  await output.CopyToAsync(stream);
             *  await stream.FlushAsync().ConfigureAwait(false);
             * }
             * else
             * {
             *  await JoinAudio(guild, socketChannel as IVoiceChannel);
             * }
             * //Console.WriteLine("end of sendAUdioAsync");
             * Console.WriteLine(client);
             * //return guild.DefaultChannel.SendMessageAsync("Playing music");
             * //throw new NotImplementedException();*/
        }