twitch vod downloading done

ffmpeg essentials

fix

Project reorganized

git lfs

ffmpeg removed

ffmpeg added
This commit is contained in:
2024-02-14 02:07:22 +01:00
Unverified
parent 91f9b645bd
commit e3ec5c3a48
264 changed files with 6239 additions and 4014 deletions

View File

@@ -0,0 +1,94 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Http;
using Newtonsoft.Json;
using System.Xml.Serialization;
using System.Reflection.PortableExecutable;
using System.Collections;
namespace VDownload.Services.Utility.HttpClient
{
public interface IHttpClientService
{
Task<T?> SendRequestAsync<T>(HttpRequest request);
Task<string> SendRequestAsync(HttpRequest request);
}
public class HttpClientService : IHttpClientService
{
#region SERVICES
private readonly System.Net.Http.HttpClient _httpClient;
#endregion
#region CONSTRUCTORS
public HttpClientService(System.Net.Http.HttpClient httpClient)
{
_httpClient = httpClient;
}
#endregion
#region PUBLIC METHODS
public async Task<T?> SendRequestAsync<T>(HttpRequest request) => JsonConvert.DeserializeObject<T>(await SendRequestAsync(request));
public async Task<string> SendRequestAsync(HttpRequest request)
{
StringBuilder urlBuilder = new StringBuilder(request.Url);
if (request.Query.Count > 0)
{
Dictionary<string, object> query = request.Query.ToDictionary();
KeyValuePair<string, object> queryElement = query.ElementAt(0);
query.Remove(queryElement.Key);
urlBuilder.Append($"?{queryElement.Key}={queryElement.Value}");
foreach (KeyValuePair<string, object> queryElementLoop in query)
{
urlBuilder.Append($"&{queryElementLoop.Key}={queryElementLoop.Value}");
}
}
HttpMethod method = request.MethodType switch
{
HttpMethodType.GET => HttpMethod.Get,
HttpMethodType.POST => HttpMethod.Post,
HttpMethodType.PUT => HttpMethod.Put,
HttpMethodType.PATCH => HttpMethod.Patch,
HttpMethodType.DELETE => HttpMethod.Delete,
};
HttpRequestMessage httpRequest = new HttpRequestMessage(method, urlBuilder.ToString());
if (request.Body is not null)
{
string json = JsonConvert.SerializeObject(request.Body);
HttpContent content = new StringContent(json);
content.Headers.ContentType.MediaType = "application/json";
httpRequest.Content = content;
}
foreach (KeyValuePair<string, string> header in request.Headers)
{
httpRequest.Headers.Add(header.Key, header.Value);
}
HttpResponseMessage response = await _httpClient.SendAsync(httpRequest);
return await response.Content.ReadAsStringAsync();
}
#endregion
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VDownload.Services.Utility.HttpClient
{
public enum HttpMethodType
{
GET,
POST,
PUT,
PATCH,
DELETE
}
}

View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VDownload.Services.Utility.HttpClient
{
public class HttpRequest
{
#region PROPERTIES
public HttpMethodType MethodType { get; private set; }
public string Url { get; private set; }
public Dictionary<string, string> Headers { get; private set; }
public Dictionary<string, object> Query { get; private set; }
public object? Body { get; set; }
#endregion
#region CONSTRUCTORS
public HttpRequest(HttpMethodType methodType, string url)
{
MethodType = methodType;
Url = url;
Headers = new Dictionary<string, string>();
Query = new Dictionary<string, object>();
}
#endregion
}
}

View File

@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VDownload.Services.Utility.HttpClient
{
public class Token
{
#region PROPERTIES
public string Schema { get; private set; }
public byte[] TokenValue { get; private set; }
#endregion
#region CONSTRUCTORS
public Token(string schema, byte[] tokenValue)
{
Schema = schema;
TokenValue = tokenValue;
}
#endregion
#region PUBLIC METHODS
public override string ToString() => $"{Schema} {Encoding.UTF8.GetString(TokenValue)}";
#endregion
}
}

View File

@@ -0,0 +1,13 @@
<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>
</Project>