added vknet as submodule
This commit is contained in:
parent
2028bf5967
commit
f3b620756d
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -1,3 +1,9 @@
|
||||
[submodule "DTLib"]
|
||||
path = DTLib
|
||||
url = https://github.com/Timerix22/DTLib.git
|
||||
[submodule "vknet"]
|
||||
path = vknet
|
||||
url = https://github.com/Timerix22/vknet
|
||||
[submodule "VkNet.AudioBypass"]
|
||||
path = VkNet.AudioBypass
|
||||
url = https://github.com/Timerix22/VkNet.AudioBypass
|
||||
|
||||
@ -2,5 +2,8 @@
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/DTLib" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/VkNet.AudioBypass" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/vknet" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@ -1,13 +1,11 @@
|
||||
// See https://aka.ms/new-console-template for more information
|
||||
|
||||
using DTLib.Dtsod;
|
||||
using VkAudioDownloader;
|
||||
|
||||
|
||||
var client = new VkClient(new VkClientConfig()
|
||||
{
|
||||
AppId = 51473647,
|
||||
Login = "aaa",
|
||||
Password = "aaa"
|
||||
});
|
||||
var client = new VkClient(VkClientConfig.FromDtsod(new DtsodV23(File.ReadAllText("config.dtsod"))));
|
||||
client.Connect();
|
||||
Console.WriteLine(client.Api.Token);
|
||||
var audios = client.FindAudio("моя оборона");
|
||||
foreach (var a in audios)
|
||||
{
|
||||
Console.WriteLine(a.Title);
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>10</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
3
VkAudioDownloader.CLI/config.dtsod.default
Normal file
3
VkAudioDownloader.CLI/config.dtsod.default
Normal file
@ -0,0 +1,3 @@
|
||||
app_id: 0ul;
|
||||
login: " ";
|
||||
password: " ";
|
||||
@ -8,6 +8,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DTLib", "DTLib\DTLib\DTLib.
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DTLib.Dtsod", "DTLib\DTLib.Dtsod\DTLib.Dtsod.csproj", "{F6FA6507-8A20-43F8-9D88-4CB2F049780D}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VkNet", "vknet\VkNet\VkNet.csproj", "{123A7020-4C9B-4F7D-A27A-3002A7B21D4C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VkNet.Generators", "vknet\VkNet.Generators\VkNet.Generators.csproj", "{BD698045-3408-40C1-AEEF-865219710EE2}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VkNet.AudioBypassService", "VkNet.AudioBypass\VkNet.AudioBypassService\VkNet.AudioBypassService.csproj", "{5650A6DD-602D-49FF-A0B0-DB59BD63EACE}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -30,5 +36,17 @@ Global
|
||||
{F6FA6507-8A20-43F8-9D88-4CB2F049780D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F6FA6507-8A20-43F8-9D88-4CB2F049780D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F6FA6507-8A20-43F8-9D88-4CB2F049780D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{123A7020-4C9B-4F7D-A27A-3002A7B21D4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{123A7020-4C9B-4F7D-A27A-3002A7B21D4C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{123A7020-4C9B-4F7D-A27A-3002A7B21D4C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{123A7020-4C9B-4F7D-A27A-3002A7B21D4C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BD698045-3408-40C1-AEEF-865219710EE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BD698045-3408-40C1-AEEF-865219710EE2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BD698045-3408-40C1-AEEF-865219710EE2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BD698045-3408-40C1-AEEF-865219710EE2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{5650A6DD-602D-49FF-A0B0-DB59BD63EACE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5650A6DD-602D-49FF-A0B0-DB59BD63EACE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5650A6DD-602D-49FF-A0B0-DB59BD63EACE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5650A6DD-602D-49FF-A0B0-DB59BD63EACE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
@ -2,17 +2,18 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>10</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DTLib\DTLib.Dtsod\DTLib.Dtsod.csproj" />
|
||||
<ProjectReference Include="..\DTLib\DTLib\DTLib.csproj" />
|
||||
<ProjectReference Include="..\VkNet.AudioBypass\VkNet.AudioBypassService\VkNet.AudioBypassService.csproj" />
|
||||
<!--ProjectReference Include="..\vknet\VkNet.Generators\VkNet.Generators.csproj" />
|
||||
<ProjectReference Include="..\vknet\VkNet\VkNet.csproj" /!-->
|
||||
<PackageReference Include="VkNet" Version="1.72.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DTLib\DTLib.Dtsod\DTLib.Dtsod.csproj" />
|
||||
<ProjectReference Include="..\DTLib\DTLib\DTLib.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -2,9 +2,15 @@
|
||||
global using DTLib.Extensions;
|
||||
using DTLib.Logging;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using VkNet;
|
||||
using VkNet.Enums.Filters;
|
||||
using VkNet.Model;
|
||||
using VkNet.Model.RequestParams;
|
||||
using VkNet.Utils;
|
||||
using VkNet.Model.Attachments;
|
||||
using VkNet.AudioBypassService;
|
||||
using VkNet.AudioBypassService.Extensions;
|
||||
|
||||
namespace VkAudioDownloader;
|
||||
|
||||
@ -20,19 +26,48 @@ public class VkClient : IDisposable
|
||||
Config = conf;
|
||||
var services = new ServiceCollection();
|
||||
//services.AddSingleton<LoggerService>();
|
||||
services.AddAudioBypass();
|
||||
Api = new VkApi(services);
|
||||
|
||||
}
|
||||
|
||||
public void Connect()
|
||||
{
|
||||
Api.Authorize(new ApiAuthParams
|
||||
var authParams = new ApiAuthParams
|
||||
{
|
||||
ApplicationId = Config.AppId,
|
||||
Login = Config.Login,
|
||||
Password = Config.Password,
|
||||
Settings = Settings.Audio
|
||||
};
|
||||
if (Config.Token is not null)
|
||||
{
|
||||
Console.WriteLine("authorizing by token");
|
||||
authParams.AccessToken = Config.Token;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("authorizing by login and password");
|
||||
authParams.Login = Config.Login;
|
||||
authParams.Password = Config.Password;
|
||||
}
|
||||
Api.Authorize(authParams);
|
||||
}
|
||||
|
||||
public VkCollection<Audio> FindAudio(string query, int maxRezults=10) =>
|
||||
Api.Audio.Search(new AudioSearchParams()
|
||||
{
|
||||
Query = query,
|
||||
Count = maxRezults,
|
||||
});
|
||||
|
||||
public Stream DownloadAudio(Audio audio)
|
||||
{
|
||||
HttpClient http = new HttpClient();
|
||||
var stream = http.GetStreamAsync(audio.Url).GetAwaiter().GetResult();
|
||||
return stream;
|
||||
}
|
||||
public void DownloadAudio(Audio audio, TimeSpan lengthLimit)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private bool Disposed = false;
|
||||
|
||||
@ -4,28 +4,36 @@ namespace VkAudioDownloader;
|
||||
|
||||
public class VkClientConfig
|
||||
{
|
||||
/// account password
|
||||
public string Password;
|
||||
/// account login (email/phone number)
|
||||
public string Login;
|
||||
/// vk app id from https://vk.com/apps?act=manage
|
||||
public ulong AppId;
|
||||
|
||||
|
||||
public static VkClientConfig FromDtsod(DtsodV23 dtsod) =>
|
||||
new VkClientConfig
|
||||
/// account password
|
||||
public string? Password;
|
||||
/// account login (email/phone number)
|
||||
public string? Login;
|
||||
/// can be used instead of login and password
|
||||
public string? Token;
|
||||
public static VkClientConfig FromDtsod(DtsodV23 dtsod)
|
||||
{
|
||||
var config = new VkClientConfig
|
||||
{
|
||||
Password = dtsod["password"],
|
||||
Login = dtsod["login"],
|
||||
AppId = dtsod["app_id"]
|
||||
};
|
||||
if (dtsod.TryGetValue("login", out var login))
|
||||
config.Login = login;
|
||||
if (dtsod.TryGetValue("password", out var password))
|
||||
config.Password = password;
|
||||
if (dtsod.TryGetValue("token", out var token))
|
||||
config.Token = token;
|
||||
return config;
|
||||
}
|
||||
|
||||
public DtsodV23 ToDtsod() =>
|
||||
new DtsodV23
|
||||
{
|
||||
{ "password", Password },
|
||||
{ "login", Login },
|
||||
{ "app_id", AppId }
|
||||
{ "app_id", AppId },
|
||||
{ "password", Password ?? null },
|
||||
{ "login", Login ?? null },
|
||||
{ "token", Token ?? null }
|
||||
};
|
||||
|
||||
}
|
||||
1
VkNet.AudioBypass
Submodule
1
VkNet.AudioBypass
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 54bc3198977726bb4a401401001a15a12f326cc7
|
||||
1
vknet
Submodule
1
vknet
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 5989ed812a93dec5d44f60bc50d119a5a46047a1
|
||||
Loading…
Reference in New Issue
Block a user