mirror of
https://github.com/BubbaGumpShrump/AutoTrackR2.git
synced 2025-05-21 08:25:29 +00:00
Point streamlink test to /test
Streamlink tests now throw at the /test api and expect a streamer variable, if nothing then it will succeed. Think the streamer link stuff is mostly done, just need to do the changes on the api.
This commit is contained in:
parent
5994743c73
commit
b448cfec3c
2 changed files with 49 additions and 8 deletions
AutoTrackR2
|
@ -477,20 +477,61 @@ public partial class ConfigPage : UserControl
|
|||
|
||||
private async void TestStreamlinkButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Debug.WriteLine("TestStreamlinkButton_Click: Starting streamlink test");
|
||||
|
||||
if (ConfigManager.StreamlinkEnabled != 1)
|
||||
{
|
||||
Debug.WriteLine("TestStreamlinkButton_Click: Streamlink is not enabled");
|
||||
MessageBox.Show("Streamlink is not enabled. Please enable Streamlink to test.", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Get the duration from the slider
|
||||
int duration = (int)StreamlinkDurationSlider.Value;
|
||||
Debug.WriteLine("TestStreamlinkButton_Click: Configuring HTTP client");
|
||||
// Configure HttpClient with TLS 1.2
|
||||
var handler = new HttpClientHandler
|
||||
{
|
||||
SslProtocols = System.Security.Authentication.SslProtocols.Tls12
|
||||
};
|
||||
|
||||
// Calculate the total duration (30 seconds before + configured duration)
|
||||
int totalDuration = 30 + duration;
|
||||
using (var client = new HttpClient(handler))
|
||||
{
|
||||
// Set headers
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", ConfigManager.ApiKey);
|
||||
client.DefaultRequestHeaders.UserAgent.ParseAdd("AutoTrackR2");
|
||||
|
||||
// Test recording functionality, we're using spacecutlet cause need a good tester.
|
||||
TrackREventDispatcher.OnStreamlinkRecordEvent("spacecutlet");
|
||||
// Create JSON body with version
|
||||
var jsonBody = new { version = "2.10" };
|
||||
var content = new StringContent(JsonSerializer.Serialize(jsonBody), Encoding.UTF8, "application/json");
|
||||
|
||||
// Send POST to test endpoint
|
||||
string baseUrl = Regex.Replace(ConfigManager.ApiUrl ?? "", @"(https?://[^/]+)/?.*", "$1");
|
||||
string endpoint = "test";
|
||||
string fullUrl = $"{baseUrl}/{endpoint}";
|
||||
Debug.WriteLine($"TestStreamlinkButton_Click: Sending request to {fullUrl}");
|
||||
|
||||
var response = await client.PostAsync(fullUrl, content);
|
||||
Debug.WriteLine($"TestStreamlinkButton_Click: Response status code: {response.StatusCode}");
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var responseContent = await response.Content.ReadAsStringAsync();
|
||||
Debug.WriteLine($"TestStreamlinkButton_Click: Response content: {responseContent}");
|
||||
WebHandler.ProcessStreamerResponse(responseContent);
|
||||
MessageBox.Show("Streamlink Test Success.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.WriteLine($"TestStreamlinkButton_Click: Error response: {response.StatusCode} - {response.ReasonPhrase}");
|
||||
MessageBox.Show($"Error: {response.StatusCode} - {response.ReasonPhrase}");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Error testing Streamlink: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
Debug.WriteLine($"TestStreamlinkButton_Click: Exception: {ex.Message}");
|
||||
MessageBox.Show($"Streamlink Test Failure. {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -183,7 +183,7 @@ public static class WebHandler
|
|||
}
|
||||
}
|
||||
|
||||
private static void ProcessStreamerResponse(string responseContent)
|
||||
public static void ProcessStreamerResponse(string responseContent)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue