This commit is contained in:
2024-02-28 01:22:13 +01:00
Unverified
parent e3ec5c3a48
commit 74eb899e31
51 changed files with 562 additions and 608 deletions

View File

@@ -0,0 +1,45 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VDownload.Sources.Twitch.Api.Helix.GetUsers.Response
{
public class Data
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("login")]
public string Login { get; set; }
[JsonProperty("display_name")]
public string DisplayName { get; set; }
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("broadcaster_type")]
public string BroadcasterType { get; set; }
[JsonProperty("description")]
public string Description { get; set; }
[JsonProperty("profile_image_url")]
public string ProfileImageUrl { get; set; }
[JsonProperty("offline_image_url")]
public string OfflineImageUrl { get; set; }
[JsonProperty("view_count")]
public int ViewCount { get; set; }
[JsonProperty("email")]
public string Email { get; set; }
[JsonProperty("created_at")]
public DateTime CreatedAt { get; set; }
}
}

View File

@@ -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.Sources.Twitch.Api.Helix.GetUsers.Response
{
public class GetUsersResponse
{
[JsonProperty("data")]
public List<Data> Data { get; } = new List<Data>();
}
}

View File

@@ -1,6 +1,7 @@
using VDownload.Services.Data.Configuration;
using VDownload.Services.Utility.HttpClient;
using VDownload.Sources.Twitch.Api.GQL.GetVideoToken.Response;
using VDownload.Sources.Twitch.Api.Helix.GetUsers.Response;
using VDownload.Sources.Twitch.Api.Helix.GetVideos.Response;
using VDownload.Sources.Twitch.Search.Models.GetVideoToken.Request;
@@ -10,7 +11,9 @@ namespace VDownload.Sources.Twitch.Api
{
Task<string> AuthValidate(byte[] token);
Task<GetVideoTokenResponse> GQLGetVideoToken(string id);
Task<GetVideosResponse> HelixGetVideos(string id, byte[] token);
Task<GetUsersResponse> HelixGetUser(string login, byte[] token);
Task<GetVideosResponse> HelixGetVideo(string id, byte[] token);
Task<GetVideosResponse> HelixGetUserVideos(string user_id, byte[] token, int count, string? cursor = null);
Task<string> UsherGetVideoPlaylist(string id, string videoToken, string videoTokenSignature);
}
@@ -49,12 +52,47 @@ namespace VDownload.Sources.Twitch.Api
return await _httpClientService.SendRequestAsync(request);
}
public async Task<GetVideosResponse> HelixGetVideos(string id, byte[] token)
public async Task<GetUsersResponse> HelixGetUser(string login, byte[] token)
{
Token tokenData = new Token(_configurationService.Twitch.Api.Helix.TokenSchema, token);
HttpRequest request = new HttpRequest(HttpMethodType.GET, _configurationService.Twitch.Api.Helix.Endpoints.GetUsers);
request.Query.Add("login", login);
request.Headers.Add("Authorization", $"{tokenData}");
request.Headers.Add("Client-Id", _configurationService.Twitch.Api.Helix.ClientId);
return await _httpClientService.SendRequestAsync<GetUsersResponse>(request);
}
public async Task<GetVideosResponse> HelixGetVideo(string id, byte[] token)
{
Token tokenData = new Token(_configurationService.Twitch.Api.Helix.TokenSchema, token);
HttpRequest request = new HttpRequest(HttpMethodType.GET, _configurationService.Twitch.Api.Helix.Endpoints.GetVideos);
request.Query.Add("id", id);
request.Headers.Add("Authorization", tokenData.ToString());
request.Headers.Add("Client-Id", _configurationService.Twitch.Api.Helix.ClientId);
return await _httpClientService.SendRequestAsync<GetVideosResponse>(request);
}
public async Task<GetVideosResponse> HelixGetUserVideos(string user_id, byte[] token, int count, string? cursor = null)
{
Token tokenData = new Token(_configurationService.Twitch.Api.Helix.TokenSchema, token);
HttpRequest request = new HttpRequest(HttpMethodType.GET, _configurationService.Twitch.Api.Helix.Endpoints.GetVideos);
request.Query.Add("user_id", user_id);
request.Query.Add("first", count);
if (cursor is not null)
{
request.Query.Add("after", cursor);
}
request.Headers.Add("Authorization", tokenData.ToString());
request.Headers.Add("Client-Id", _configurationService.Twitch.Api.Helix.ClientId);