Compare commits
No commits in common. "6a42dbe53eaeadaaf69c3d8950c6f5f7a279e1d3" and "21d0e37bda4202515051a83965fb1803e7720dfd" have entirely different histories.
6a42dbe53e
...
21d0e37bda
@ -1,9 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace OF_DL.Entities;
|
||||
|
||||
public class LatestReleaseAPIResponse
|
||||
{
|
||||
[JsonProperty(PropertyName = "tag_name")]
|
||||
public string TagName { get; set; } = "";
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
using OF_DL.Entities;
|
||||
using Serilog;
|
||||
|
||||
namespace OF_DL.Helpers;
|
||||
|
||||
public static class VersionHelper
|
||||
{
|
||||
public static string? GetLatestReleaseTag()
|
||||
{
|
||||
Log.Debug("Calling GetLatestReleaseTag");
|
||||
try
|
||||
{
|
||||
HttpClient client = new();
|
||||
HttpRequestMessage request = new(HttpMethod.Get, "https://git.ofdl.tools/api/v1/repos/sim0n00ps/OF-DL/releases/latest");
|
||||
using var response = client.Send(request);
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
Log.Debug("GetLatestReleaseTag did not return a Success Status Code");
|
||||
return null;
|
||||
}
|
||||
|
||||
var body = response.Content.ReadAsStringAsync().Result;
|
||||
|
||||
Log.Debug("GetLatestReleaseTag API Response: ");
|
||||
Log.Debug(body);
|
||||
|
||||
var versionCheckResponse = JsonConvert.DeserializeObject<LatestReleaseAPIResponse>(body);
|
||||
|
||||
if (versionCheckResponse == null || versionCheckResponse.TagName == "")
|
||||
{
|
||||
Log.Debug("GetLatestReleaseTag did not return a valid tag name");
|
||||
return null;
|
||||
}
|
||||
|
||||
return versionCheckResponse.TagName;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Exception caught: {0}\n\nStackTrace: {1}", ex.Message, ex.StackTrace);
|
||||
Log.Error("Exception caught: {0}\n\nStackTrace: {1}", ex.Message, ex.StackTrace);
|
||||
if (ex.InnerException != null)
|
||||
{
|
||||
Console.WriteLine("\nInner Exception:");
|
||||
Console.WriteLine("Exception caught: {0}\n\nStackTrace: {1}", ex.InnerException.Message, ex.InnerException.StackTrace);
|
||||
Log.Error("Inner Exception: {0}\n\nStackTrace: {1}", ex.InnerException.Message, ex.InnerException.StackTrace);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.12.0" />
|
||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.3" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Octokit" Version="14.0.0" />
|
||||
<PackageReference Include="protobuf-net" Version="3.2.46" />
|
||||
<PackageReference Include="PuppeteerSharp" Version="20.1.3" />
|
||||
<PackageReference Include="Serilog" Version="4.2.0" />
|
||||
|
@ -9,6 +9,7 @@ using OF_DL.Entities.Streams;
|
||||
using OF_DL.Enumerations;
|
||||
using OF_DL.Enumurations;
|
||||
using OF_DL.Helpers;
|
||||
using Octokit;
|
||||
using Serilog;
|
||||
using Serilog.Core;
|
||||
using Serilog.Events;
|
||||
@ -280,7 +281,7 @@ public class Program
|
||||
DownloadDateSelection = Enum.Parse<DownloadDateSelection>(hoconConfig.GetString("Download.DownloadDateSelection"), true),
|
||||
CustomDate = !string.IsNullOrWhiteSpace(hoconConfig.GetString("Download.CustomDate")) ? DateTime.Parse(hoconConfig.GetString("Download.CustomDate")) : null,
|
||||
ShowScrapeSize = hoconConfig.GetBoolean("Download.ShowScrapeSize"),
|
||||
DownloadVideoResolution = ParseVideoResolution(hoconConfig.GetString("Download.DownloadVideoResolution", "source")),
|
||||
DownloadVideoResolution = ParseVideoResolution(hoconConfig.GetString("Download.DownloadVideoResolution")),
|
||||
|
||||
// File Settings
|
||||
PaidPostFileNameFormat = hoconConfig.GetString("File.PaidPostFileNameFormat"),
|
||||
@ -514,54 +515,14 @@ public class Program
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Only run the version check if not in DEBUG mode
|
||||
#if !DEBUG
|
||||
#if !DEBUG
|
||||
Version localVersion = Assembly.GetEntryAssembly()?.GetName().Version; //Only tested with numeric values.
|
||||
String? latestReleaseTag = VersionHelper.GetLatestReleaseTag();
|
||||
|
||||
if (latestReleaseTag == null)
|
||||
{
|
||||
AnsiConsole.Markup("[yellow]Failed to verify that OF-DL is up-to-date.\n[/]");
|
||||
Log.Error("Failed to get the latest release tag.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Version latestGiteaRelease = new Version(latestReleaseTag.Replace("OFDLV", ""));
|
||||
|
||||
// Compare the Versions
|
||||
int versionComparison = localVersion.CompareTo(latestGiteaRelease);
|
||||
if (versionComparison < 0)
|
||||
{
|
||||
// The version on GitHub is more up to date than this local release.
|
||||
AnsiConsole.Markup("[red]You are running OF-DL version " + $"{localVersion.Major}.{localVersion.Minor}.{localVersion.Build}\n[/]");
|
||||
AnsiConsole.Markup("[red]Please update to the current release, " + $"{latestGiteaRelease.Major}.{latestGiteaRelease.Minor}.{latestGiteaRelease.Build}: [link]https://git.ofdl.tools/sim0n00ps/OF-DL/releases[/]\n[/]");
|
||||
Log.Debug("Detected outdated client running version " + $"{localVersion.Major}.{localVersion.Minor}.{localVersion.Build}");
|
||||
Log.Debug("Latest release version " + $"{latestGiteaRelease.Major}.{latestGiteaRelease.Minor}.{latestGiteaRelease.Build}");
|
||||
}
|
||||
else
|
||||
{
|
||||
// This local version is greater than the release version on GitHub.
|
||||
AnsiConsole.Markup("[green]You are running OF-DL version " + $"{localVersion.Major}.{localVersion.Minor}.{localVersion.Build}\n[/]");
|
||||
AnsiConsole.Markup("[green]Latest Release version: " + $"{latestGiteaRelease.Major}.{latestGiteaRelease.Minor}.{latestGiteaRelease.Build}\n[/]");
|
||||
Log.Debug("Detected client running version " + $"{localVersion.Major}.{localVersion.Minor}.{localVersion.Build}");
|
||||
Log.Debug("Latest release version " + $"{latestGiteaRelease.Major}.{latestGiteaRelease.Minor}.{latestGiteaRelease.Build}");
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
AnsiConsole.Markup("[yellow]Running in Debug/Local mode. Version check skipped.\n[/]");
|
||||
Log.Debug("Running in Debug/Local mode. Version check skipped.");
|
||||
#endif
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
AnsiConsole.Markup("[red]Error checking latest release on GitHub:\n[/]");
|
||||
Console.WriteLine(e);
|
||||
Log.Error("Error checking latest release on GitHub.", e.Message);
|
||||
}
|
||||
|
||||
AnsiConsole.Markup("[red]You are running OF-DL version " + $"{localVersion.Major}.{localVersion.Minor}.{localVersion.Build}\n[/]");
|
||||
#else
|
||||
AnsiConsole.Markup("[yellow]Running in Debug/Local mode. Version check skipped.\n[/]");
|
||||
Log.Debug("Running in Debug/Local mode. Version check skipped.");
|
||||
#endif
|
||||
|
||||
if (File.Exists("auth.json"))
|
||||
{
|
||||
@ -580,7 +541,7 @@ public class Program
|
||||
Log.Debug("Deleting auth.json");
|
||||
File.Delete("auth.json");
|
||||
}
|
||||
|
||||
|
||||
if (cliNonInteractive)
|
||||
{
|
||||
AnsiConsole.MarkupLine($"\n[red]auth.json has invalid JSON syntax. The file can be generated automatically when OF-DL is run in the standard, interactive mode.[/]\n");
|
||||
@ -1685,7 +1646,7 @@ public class Program
|
||||
{
|
||||
archived = await downloadContext.ApiHelper.GetArchived($"/users/{user.Value}/posts", path, downloadContext.DownloadConfig!, ctx);
|
||||
});
|
||||
|
||||
|
||||
int oldArchivedCount = 0;
|
||||
int newArchivedCount = 0;
|
||||
if (archived != null && archived.ArchivedPosts.Count > 0)
|
||||
@ -1818,7 +1779,7 @@ public class Program
|
||||
{
|
||||
posts = await downloadContext.ApiHelper.GetPosts($"/users/{user.Value}/posts", path, downloadContext.DownloadConfig!, paid_post_ids, ctx);
|
||||
});
|
||||
|
||||
|
||||
int oldPostCount = 0;
|
||||
int newPostCount = 0;
|
||||
if (posts == null || posts.Posts.Count <= 0)
|
||||
@ -2340,7 +2301,7 @@ public class Program
|
||||
{
|
||||
streams = await downloadContext.ApiHelper.GetStreams($"/users/{user.Value}/posts/streams", path, downloadContext.DownloadConfig!, paid_post_ids, ctx);
|
||||
});
|
||||
|
||||
|
||||
int oldStreamsCount = 0;
|
||||
int newStreamsCount = 0;
|
||||
if (streams == null || streams.Streams.Count <= 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user