twitch vod downloading done
ffmpeg essentials fix Project reorganized git lfs ffmpeg removed ffmpeg added
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
using Newtonsoft.Json;
|
||||
using VDownload.Services.Data.Authentication.Models;
|
||||
|
||||
namespace VDownload.Services.Data.Authentication
|
||||
{
|
||||
public class AuthenticationData
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonProperty("twitch")]
|
||||
public TokenAuthenticationData Twitch { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public AuthenticationData()
|
||||
{
|
||||
Twitch = new TokenAuthenticationData();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VDownload.Services.Data.Configuration;
|
||||
|
||||
namespace VDownload.Services.Data.Authentication
|
||||
{
|
||||
public interface IAuthenticationDataService
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
AuthenticationData Data { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region METHODS
|
||||
|
||||
Task Load();
|
||||
Task Save();
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class AuthenticationDataService : IAuthenticationDataService
|
||||
{
|
||||
#region SERVICES
|
||||
|
||||
protected readonly IConfigurationService _configurationService;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region FIELDS
|
||||
|
||||
protected readonly string _filePath;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PROPERTIES
|
||||
|
||||
public AuthenticationData Data { get; protected set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public AuthenticationDataService(IConfigurationService configurationService)
|
||||
{
|
||||
_configurationService = configurationService;
|
||||
|
||||
string appdataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
||||
string appdataDirectoryName = _configurationService.Common.Path.Appdata.DirectoryName;
|
||||
string appdataAuthenticationFilename = _configurationService.Common.Path.Appdata.AuthenticationFile;
|
||||
_filePath = Path.Combine(appdataPath, appdataDirectoryName, appdataAuthenticationFilename);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public async Task Load()
|
||||
{
|
||||
Data = null;
|
||||
|
||||
if (File.Exists(_filePath))
|
||||
{
|
||||
string content = await File.ReadAllTextAsync(_filePath);
|
||||
Data = JsonConvert.DeserializeObject<AuthenticationData>(content);
|
||||
}
|
||||
|
||||
Data ??= new AuthenticationData();
|
||||
}
|
||||
|
||||
public async Task Save()
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(_filePath));
|
||||
string content = JsonConvert.SerializeObject(Data);
|
||||
await File.WriteAllTextAsync(_filePath, content);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VDownload.Services.Data.Authentication.Models
|
||||
{
|
||||
public class TokenAuthenticationData
|
||||
{
|
||||
[JsonProperty("token")]
|
||||
public byte[]? Token { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\VDownload.Services.Data.Configuration\VDownload.Services.Data.Configuration.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,18 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System.Text.Json.Serialization;
|
||||
using VDownload.Services.Data.Configuration.Models;
|
||||
|
||||
namespace VDownload.Services.Data.Configuration
|
||||
{
|
||||
public class CommonConfiguration
|
||||
{
|
||||
[ConfigurationKeyName("path")]
|
||||
public Models.Path Path { get; set; }
|
||||
|
||||
[ConfigurationKeyName("processing")]
|
||||
public Processing Processing { get; set; }
|
||||
|
||||
[ConfigurationKeyName("string_resources_assembly")]
|
||||
public string StringResourcesAssembly { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VDownload.Sources.Twitch.Configuration;
|
||||
|
||||
namespace VDownload.Services.Data.Configuration
|
||||
{
|
||||
public interface IConfigurationService
|
||||
{
|
||||
CommonConfiguration Common { get; }
|
||||
TwitchConfiguration Twitch { get; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class ConfigurationService : IConfigurationService
|
||||
{
|
||||
#region SERVICES
|
||||
|
||||
protected readonly IConfiguration _configuration;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PROPERTIES
|
||||
|
||||
public CommonConfiguration Common { get; protected set; }
|
||||
public TwitchConfiguration Twitch { get; protected set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public ConfigurationService(IConfiguration configuration)
|
||||
{
|
||||
Common = configuration.GetSection("common").Get<CommonConfiguration>()!;
|
||||
Twitch = configuration.GetSection("twitch").Get<TwitchConfiguration>()!;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VDownload.Services.Data.Configuration.Models
|
||||
{
|
||||
public class Appdata
|
||||
{
|
||||
[ConfigurationKeyName("directory_name")]
|
||||
public string DirectoryName { get; set; }
|
||||
|
||||
[ConfigurationKeyName("authentication_file")]
|
||||
public string AuthenticationFile { get; set; }
|
||||
|
||||
[ConfigurationKeyName("settings_file")]
|
||||
public string SettingsFile { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VDownload.Services.Data.Configuration.Models
|
||||
{
|
||||
public class Muxer
|
||||
{
|
||||
[ConfigurationKeyName("extension")]
|
||||
public string Extension { get; set; }
|
||||
|
||||
[ConfigurationKeyName("video_codecs")]
|
||||
public List<string> VideoCodecs { get; } = new List<string>();
|
||||
|
||||
[ConfigurationKeyName("audio_codecs")]
|
||||
public List<string> AudioCodecs { get; } = new List<string>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VDownload.Services.Data.Configuration.Models
|
||||
{
|
||||
public class Path
|
||||
{
|
||||
[ConfigurationKeyName("appdata")]
|
||||
public Appdata Appdata { get; set; }
|
||||
|
||||
[ConfigurationKeyName("temp")]
|
||||
public Temp Temp { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VDownload.Services.Data.Configuration.Models
|
||||
{
|
||||
public class Processing
|
||||
{
|
||||
[ConfigurationKeyName("muxers")]
|
||||
public List<Muxer> Muxers { get; } = new List<Muxer>();
|
||||
|
||||
[ConfigurationKeyName("processed_filename")]
|
||||
public string ProcessedFilename { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VDownload.Services.Data.Configuration.Models
|
||||
{
|
||||
public class Temp
|
||||
{
|
||||
[ConfigurationKeyName("tasks_directory")]
|
||||
public string TasksDirectory { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\VDownload.Sources\VDownload.Sources.Twitch\VDownload.Sources.Twitch.Configuration\VDownload.Sources.Twitch.Configuration.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,36 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VDownload.Models;
|
||||
using VDownload.Services.Data.Settings.Models;
|
||||
|
||||
namespace VDownload.Services.Data.Settings
|
||||
{
|
||||
public class CommonSettings
|
||||
{
|
||||
[JsonProperty("max_number_of_videos_to_get_from_playlist")]
|
||||
public int MaxNumberOfVideosToGetFromPlaylist { get; set; } = 0;
|
||||
|
||||
[JsonProperty("max_number_of_running_tasks")]
|
||||
public int MaxNumberOfRunningTasks { get; set; } = 5;
|
||||
|
||||
[JsonProperty("temp_directory")]
|
||||
public string TempDirectory { get; set; } = $"{Path.GetTempPath()}\\VDownload";
|
||||
|
||||
[JsonProperty("delete_temp_on_error")]
|
||||
public bool DeleteTempOnError { get; set; } = true;
|
||||
|
||||
[JsonProperty("default_task_settings")]
|
||||
public DefaultTaskSettings DefaultTaskSettings { get; set; } = new DefaultTaskSettings();
|
||||
|
||||
[JsonProperty("notifications")]
|
||||
public Notifications Notifications { get; set; } = new Notifications();
|
||||
|
||||
[JsonProperty("processing")]
|
||||
public Processing Processing { get; set; } = new Processing();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VDownload.Models;
|
||||
|
||||
namespace VDownload.Services.Data.Settings.Models
|
||||
{
|
||||
public class DefaultTaskSettings
|
||||
{
|
||||
[JsonProperty("media_type")]
|
||||
public MediaType MediaType { get; set; } = MediaType.Original;
|
||||
|
||||
[JsonProperty("video_extension")]
|
||||
public VideoExtension VideoExtension { get; set; } = VideoExtension.MP4;
|
||||
|
||||
[JsonProperty("audio_extension")]
|
||||
public AudioExtension AudioExtension { get; set; } = AudioExtension.MP3;
|
||||
|
||||
[JsonProperty("output_directory")]
|
||||
public string OutputDirectory { get; set; } = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
|
||||
|
||||
[JsonProperty("save_last_output_directory")]
|
||||
public bool SaveLastOutputDirectory { get; set; } = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VDownload.Services.Data.Settings.Models
|
||||
{
|
||||
public class Notifications
|
||||
{
|
||||
[JsonProperty("on_successful")]
|
||||
public bool OnSuccessful { get; set; } = true;
|
||||
|
||||
[JsonProperty("on_unsuccessful")]
|
||||
public bool OnUnsuccessful { get; set; } = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VDownload.Models;
|
||||
|
||||
namespace VDownload.Services.Data.Settings.Models
|
||||
{
|
||||
public class Processing
|
||||
{
|
||||
[JsonProperty("ffmpeg_location")]
|
||||
public string FFmpegLocation { get; set; } = $"{AppDomain.CurrentDomain.BaseDirectory}\\FFmpeg";
|
||||
|
||||
[JsonProperty("use_multithreading")]
|
||||
public bool UseMultithreading { get; set; } = true;
|
||||
|
||||
[JsonProperty("use_hardware_acceleration")]
|
||||
public bool UseHardwareAcceleration { get; set; } = true;
|
||||
|
||||
[JsonProperty("speed")]
|
||||
public ProcessingSpeed Speed { get; set; } = ProcessingSpeed.UltraFast;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using Newtonsoft.Json;
|
||||
using VDownload.Sources.Twitch.Settings;
|
||||
|
||||
namespace VDownload.Services.Data.Settings
|
||||
{
|
||||
public class SettingsData
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonProperty("common")]
|
||||
public CommonSettings Common { get; set; }
|
||||
|
||||
[JsonProperty("twitch")]
|
||||
public TwitchSettings Twitch { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
internal SettingsData()
|
||||
{
|
||||
Common = new CommonSettings();
|
||||
Twitch = new TwitchSettings();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VDownload.Services.Data.Configuration;
|
||||
|
||||
namespace VDownload.Services.Data.Settings
|
||||
{
|
||||
public interface ISettingsService
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
SettingsData Data { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region METHODS
|
||||
|
||||
Task Load();
|
||||
Task Save();
|
||||
Task Restore();
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class SettingsService : ISettingsService
|
||||
{
|
||||
#region SERVICES
|
||||
|
||||
protected readonly IConfigurationService _configurationService;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region FIELDS
|
||||
|
||||
protected readonly string _filePath;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PROPERTIES
|
||||
|
||||
public SettingsData Data { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public SettingsService(IConfigurationService configurationService)
|
||||
{
|
||||
_configurationService = configurationService;
|
||||
|
||||
string appdataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
||||
string appdataDirectoryName = _configurationService.Common.Path.Appdata.DirectoryName;
|
||||
string appdataAuthenticationFilename = _configurationService.Common.Path.Appdata.SettingsFile;
|
||||
_filePath = Path.Combine(appdataPath, appdataDirectoryName, appdataAuthenticationFilename);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public async Task Load()
|
||||
{
|
||||
Data = null;
|
||||
|
||||
if (File.Exists(_filePath))
|
||||
{
|
||||
string content = await File.ReadAllTextAsync(_filePath);
|
||||
Data = JsonConvert.DeserializeObject<SettingsData>(content);
|
||||
}
|
||||
|
||||
Data ??= new SettingsData();
|
||||
}
|
||||
|
||||
public async Task Save()
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(_filePath));
|
||||
string content = JsonConvert.SerializeObject(Data);
|
||||
await File.WriteAllTextAsync(_filePath, content);
|
||||
}
|
||||
|
||||
public async Task Restore()
|
||||
{
|
||||
Data = new SettingsData();
|
||||
await Save();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\VDownload.Models\VDownload.Models.csproj" />
|
||||
<ProjectReference Include="..\..\..\VDownload.Sources\VDownload.Sources.Twitch\VDownload.Sources.Twitch.Settings\VDownload.Sources.Twitch.Settings.csproj" />
|
||||
<ProjectReference Include="..\VDownload.Services.Data.Configuration\VDownload.Services.Data.Configuration.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user