Skip to content

Commit

Permalink
#1833 add wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
qdraw committed Dec 1, 2024
1 parent 1fb64de commit a47e20c
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 12 deletions.
27 changes: 16 additions & 11 deletions starsky/starsky.foundation.video/GetDependencies/FFMpegDownload.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Text.Json;
using starsky.foundation.http.Interfaces;
using starsky.foundation.platform.Architecture;
using starsky.foundation.platform.Interfaces;
using starsky.foundation.platform.JsonConverter;
using starsky.foundation.platform.Models;
Expand Down Expand Up @@ -34,9 +35,9 @@ public FfMpegDownload(IHttpClientHelper httpClientHelper, AppSettings appSetting
_logger = logger;
}

public async Task<bool> DownloadFFMpeg()
public async Task<bool> DownloadFfMpeg()
{
if ( _appSettings.ExiftoolSkipDownloadOnStartup == true || _appSettings is
if ( _appSettings.FfmpegSkipDownloadOnStartup == true || _appSettings is
{ AddSwaggerExport: true, AddSwaggerExportExitAfter: true } )
{
var name = _appSettings.FfmpegSkipDownloadOnStartup == true
Expand All @@ -48,29 +49,33 @@ public async Task<bool> DownloadFFMpeg()

CreateDirectoryDependenciesFolderIfNotExists();

var currentArchitecture = CurrentArchitecture.GetCurrentRuntimeIdentifier();

var index = await DownloadIndex();
await GetUrlFromIndex(index);
var data = GetUrlFromIndex(index, currentArchitecture);

return true;
}

private async Task<BinaryIndex?> GetUrlFromIndex(FfmpegBinariesIndex? index)
private BinaryIndex? GetUrlFromIndex(FfmpegBinariesIndex? index,
string currentArchitecture)
{
return index?.Binaries.Find(p => p.Architecture == "win64");
return index?.Binaries.Find(p => p.Architecture == currentArchitecture);
}

private async Task<FfmpegBinariesIndex?> DownloadIndex()
private async Task<FfmpegBinariesContainer> DownloadIndex()
{
var result = await _httpClientHelper.ReadString(_ffMpegApiIndex);
if ( result.Key )
var result = new FfmpegBinariesContainer(null, false, null);
var apiResult = await _httpClientHelper.ReadString(_ffMpegApiIndex);
if ( apiResult.Key )
{
return JsonSerializer.Deserialize<FfmpegBinariesIndex>(result.Value,
DefaultJsonSerializer.CamelCase);
return ;
}

result = await _httpClientHelper.ReadString(_ffMpegApiIndexMirror);
apiResult = await _httpClientHelper.ReadString(_ffMpegApiIndexMirror);
if ( result.Key )
{
result.
return JsonSerializer.Deserialize<FfmpegBinariesIndex>(result.Value,
DefaultJsonSerializer.CamelCase);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ public class BinaryIndex

public class FfmpegBinariesIndex
{
public bool Success { get; set; } = true;
public List<BinaryIndex> Binaries { get; set; }
}

public class FfmpegBinariesContainer {

public FfmpegBinariesContainer(Uri? indexUrl, bool success, FfmpegBinariesIndex? data)
{
Data = data;
IndexUrl = indexUrl;
Success = success;
}

public bool Success { get; set; }
public Uri? IndexUrl { get; set; }
public FfmpegBinariesIndex? Data { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.ComponentModel.DataAnnotations;

namespace starsky.foundation.video.GetDependencies;

public class OperationSystemPlatforms
{
public enum OsPlatformAndArchitecture
{
Unknown,
[Display(Name = "win-x86")]
WinX86,
[Display(Name = "win-x64")]
WinX64,
[Display(Name = "win-arm64")]
WinArm64,
[Display(Name = "linux-x64")]
LinuxX64,
[Display(Name = "linux-arm")]
LinuxArm,
[Display(Name = "linux-arm64")]
LinuxArm64,
[Display(Name = "osx-x64")]
OsxX64,
[Display(Name = "osx-arm64")]
OsxArm64
}
}

0 comments on commit a47e20c

Please sign in to comment.