Initial split of the modules

This commit is contained in:
Master Kwoth
2017-09-30 00:46:33 +02:00
parent cdc2c43913
commit 599245b1ca
499 changed files with 469 additions and 256 deletions

View File

@ -0,0 +1,46 @@
using NLog;
using System;
using System.Diagnostics;
using System.Threading.Tasks;
namespace NadekoBot.Services.Impl
{
public class YtdlOperation : IDisposable
{
private readonly Logger _log;
public YtdlOperation()
{
_log = LogManager.GetCurrentClassLogger();
}
public async Task<string> GetDataAsync(string url)
{
using (Process process = new Process()
{
StartInfo = new ProcessStartInfo()
{
FileName = "youtube-dl",
Arguments = $"-f bestaudio -e --get-url --get-id --get-thumbnail --get-duration --no-check-certificate --default-search \"ytsearch:\" \"{url}\"",
UseShellExecute = false,
RedirectStandardError = true,
RedirectStandardOutput = true,
CreateNoWindow = true,
},
})
{
process.Start();
var str = await process.StandardOutput.ReadToEndAsync();
var err = await process.StandardError.ReadToEndAsync();
if(!string.IsNullOrEmpty(err))
_log.Warn(err);
return str;
}
}
public void Dispose()
{
}
}
}