deps updated
This commit is contained in:
parent
c8d726326f
commit
d650dc19e3
@ -2,9 +2,13 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using DTLib.Dtsod;
|
using DTLib.Dtsod;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using DTLib.Extensions;
|
||||||
using VkAudioDownloader;
|
using VkAudioDownloader;
|
||||||
using DTLib.Logging.New;
|
using DTLib.Logging.New;
|
||||||
|
|
||||||
|
Console.InputEncoding = StringConverter.UTF8;
|
||||||
|
Console.OutputEncoding = StringConverter.UTF8;
|
||||||
|
|
||||||
if(!File.Exists("config.dtsod"))
|
if(!File.Exists("config.dtsod"))
|
||||||
{
|
{
|
||||||
File.Copy("config.dtsod.default", "config.dtsod");
|
File.Copy("config.dtsod.default", "config.dtsod");
|
||||||
@ -16,7 +20,7 @@ var config = VkClientConfig.FromDtsod(new DtsodV23(File.ReadAllText("config.dtso
|
|||||||
var logger = new CompositeLogger(new DefaultLogFormat(true),
|
var logger = new CompositeLogger(new DefaultLogFormat(true),
|
||||||
new ConsoleLogger(),
|
new ConsoleLogger(),
|
||||||
new FileLogger("logs", "VkAudioDownloaer"));
|
new FileLogger("logs", "VkAudioDownloaer"));
|
||||||
var _logger = new LoggerContext(logger, "main");
|
var _logger = new ContextLogger(logger, "Main");
|
||||||
_logger.LogDebug("DEBUG LOG ENABLED");
|
_logger.LogDebug("DEBUG LOG ENABLED");
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -29,7 +33,7 @@ try
|
|||||||
var client = new VkClient(config, logger);
|
var client = new VkClient(config, logger);
|
||||||
await client.ConnectAsync();
|
await client.ConnectAsync();
|
||||||
|
|
||||||
// getting audio from vk
|
// getting audio from vk
|
||||||
var audios = client.FindAudio("сталинский костюм").ToArray();
|
var audios = client.FindAudio("сталинский костюм").ToArray();
|
||||||
|
|
||||||
for (var i = 0; i < audios.Length; i++)
|
for (var i = 0; i < audios.Length; i++)
|
||||||
@ -48,5 +52,5 @@ try
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogException(ex);
|
_logger.LogError(ex);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,11 +4,11 @@ namespace VkAudioDownloader.Helpers;
|
|||||||
|
|
||||||
public class FFMPegHelper
|
public class FFMPegHelper
|
||||||
{
|
{
|
||||||
private LoggerContext _logger;
|
private ContextLogger _logger;
|
||||||
private readonly string ffmpeg;
|
private readonly string ffmpeg;
|
||||||
public FFMPegHelper(ILogger logger, string ffmpegDir)
|
public FFMPegHelper(ILogger logger, string ffmpegDir)
|
||||||
{
|
{
|
||||||
_logger = new LoggerContext(logger, nameof(FFMPegHelper));
|
_logger = new ContextLogger(logger, nameof(FFMPegHelper));
|
||||||
ffmpeg=Path.Concat(ffmpegDir,"ffmpeg");
|
ffmpeg=Path.Concat(ffmpegDir,"ffmpeg");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,10 +20,10 @@
|
|||||||
|
|
||||||
<!--external dependencies-->
|
<!--external dependencies-->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CliWrap" Version="3.5.0" />
|
<PackageReference Include="CliWrap" Version="3.6.0" />
|
||||||
<PackageReference Include="VkNet.AudioBypassService" Version="1.7.4" />
|
<PackageReference Include="VkNet.AudioBypassService" Version="1.7.4" />
|
||||||
<PackageReference Include="VkNet" Version="1.72.0" />
|
<PackageReference Include="VkNet" Version="1.72.0" />
|
||||||
<PackageReference Include="DTLib.Dtsod" Version="1.0.1" />
|
<PackageReference Include="DTLib.Dtsod" Version="1.0.2" />
|
||||||
<PackageReference Include="DTLib.Logging" Version="1.0.0" />
|
<PackageReference Include="DTLib.Logging" Version="1.0.5" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -23,14 +23,14 @@ public class VkClient : IDisposable
|
|||||||
{
|
{
|
||||||
public VkApi Api;
|
public VkApi Api;
|
||||||
public VkClientConfig Config;
|
public VkClientConfig Config;
|
||||||
private DTLib.Logging.New.ILogger _logger;
|
private DTLib.Logging.New.ContextLogger _logger;
|
||||||
private HttpHelper _http;
|
private HttpHelper _http;
|
||||||
private FFMPegHelper _ffmpeg;
|
private FFMPegHelper _ffmpeg;
|
||||||
|
|
||||||
public VkClient(VkClientConfig conf, DTLib.Logging.New.ILogger logger)
|
public VkClient(VkClientConfig conf, DTLib.Logging.New.ILogger logger)
|
||||||
{
|
{
|
||||||
Config = conf;
|
Config = conf;
|
||||||
_logger = logger;
|
_logger = new ContextLogger(logger, nameof(VkClient));
|
||||||
_http = new HttpHelper();
|
_http = new HttpHelper();
|
||||||
_ffmpeg = new FFMPegHelper(logger,conf.FFMPegDir);
|
_ffmpeg = new FFMPegHelper(logger,conf.FFMPegDir);
|
||||||
var services = new ServiceCollection()
|
var services = new ServiceCollection()
|
||||||
@ -48,12 +48,12 @@ public class VkClient : IDisposable
|
|||||||
};
|
};
|
||||||
if (Config.Token is not null)
|
if (Config.Token is not null)
|
||||||
{
|
{
|
||||||
_logger.Log(nameof(VkClient),LogSeverity.Info,"authorizing by token");
|
_logger.LogInfo("authorizing by token");
|
||||||
authParams.AccessToken = Config.Token;
|
authParams.AccessToken = Config.Token;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_logger.Log(nameof(VkClient),LogSeverity.Info,"authorizing by login and password");
|
_logger.LogInfo("authorizing by login and password");
|
||||||
authParams.Login = Config.Login;
|
authParams.Login = Config.Login;
|
||||||
authParams.Password = Config.Password;
|
authParams.Password = Config.Password;
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ public class VkClient : IDisposable
|
|||||||
}
|
}
|
||||||
catch (Exception aex)
|
catch (Exception aex)
|
||||||
{
|
{
|
||||||
_logger.LogException(nameof(VkClient),aex);
|
_logger.LogError(aex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,7 +91,7 @@ public class VkClient : IDisposable
|
|||||||
string outFile = Path.Concat(localDir, DTLib.Filesystem.Path.CorrectString($"{audio.Artist}-{audio.Title}.opus"));
|
string outFile = Path.Concat(localDir, DTLib.Filesystem.Path.CorrectString($"{audio.Artist}-{audio.Title}.opus"));
|
||||||
string fragmentDir = $"{outFile}_{DateTime.Now.Ticks}";
|
string fragmentDir = $"{outFile}_{DateTime.Now.Ticks}";
|
||||||
if(File.Exists(outFile))
|
if(File.Exists(outFile))
|
||||||
_logger.LogWarn(nameof(VkClient), $"file {outFile} already exists");
|
_logger.LogWarn( $"file {outFile} already exists");
|
||||||
|
|
||||||
string m3u8 = await _http.GetStringAsync(audio.Url);
|
string m3u8 = await _http.GetStringAsync(audio.Url);
|
||||||
var parser = new M3U8Parser();
|
var parser = new M3U8Parser();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user