mirror of
https://github.com/EpicMorg/atlassian-downloader.git
synced 2025-01-14 12:47:55 +03:00
1.0.0.6
* fixed downloading
This commit is contained in:
parent
63e7059e74
commit
5a7836ec54
@ -3,6 +3,23 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
/*
|
||||
-o, --output-folder "path" --> set output folder
|
||||
-v, --version --> show version
|
||||
-h, --help --> show help
|
||||
-l, --list, --links --> show all links to output
|
||||
-f, -feed, --feed-url, -u, --url --> use json link
|
||||
*/
|
||||
|
||||
namespace EpicMorg.Atlassian.Downloader {
|
||||
class Program {
|
||||
|
||||
/// <param name="intOption">An option whose argument is parsed as an int</param>
|
||||
/// <param name="boolOption">An option whose argument is parsed as a bool</param>
|
||||
/// <param name="fileOption">An option whose argument is parsed as a FileInfo</param>
|
||||
static async Task Main(string[] args) {
|
||||
|
||||
var appTitle = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
|
||||
var appVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
|
||||
@ -46,33 +63,27 @@ Console.Title = $"{appTitle} {appVersion} {appBuildType}";
|
||||
Console.WriteLine($"Download started at {appStartupDate}.");
|
||||
|
||||
var client = new HttpClient();
|
||||
foreach (var feedUrl in feedUrls)
|
||||
{
|
||||
foreach (var feedUrl in feedUrls) {
|
||||
var feedDir = Path.Combine(outputDir, feedUrl[(feedUrl.LastIndexOf('/') + 1)..(feedUrl.LastIndexOf('.'))]);
|
||||
var atlassianJson = await client.GetStringAsync(feedUrl);
|
||||
var callString = "downloads(";
|
||||
var json = atlassianJson[callString.Length..^1];
|
||||
var parsed = JsonSerializer.Deserialize<ResponseArray[]>(json, new JsonSerializerOptions
|
||||
{
|
||||
var parsed = JsonSerializer.Deserialize<ResponseArray[]>(json, new JsonSerializerOptions {
|
||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
||||
});
|
||||
var versions = parsed.GroupBy(a => a.Version).ToDictionary(a => a.Key, a => a.ToArray());
|
||||
|
||||
foreach (var version in versions)
|
||||
{
|
||||
foreach (var version in versions) {
|
||||
var directory = Path.Combine(feedDir, version.Key);
|
||||
if (!Directory.Exists(directory))
|
||||
{
|
||||
if (!Directory.Exists(directory)) {
|
||||
Directory.CreateDirectory(directory);
|
||||
}
|
||||
foreach (var file in version.Value)
|
||||
{
|
||||
foreach (var file in version.Value) {
|
||||
if (file.ZipUrl == null) { continue; }
|
||||
var serverPath = file.ZipUrl.PathAndQuery;
|
||||
var outputFile = Path.Combine(directory, serverPath[(serverPath.LastIndexOf("/") + 1)..]);
|
||||
if (!File.Exists(outputFile))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(file.Md5))
|
||||
{
|
||||
if (!File.Exists(outputFile)) {
|
||||
if (!string.IsNullOrEmpty(file.Md5)) {
|
||||
File.WriteAllText(outputFile + ".md5", file.Md5);
|
||||
}
|
||||
using var outputStream = File.OpenWrite(outputFile);
|
||||
@ -81,9 +92,7 @@ foreach (var feedUrl in feedUrls)
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Console.WriteLine($"[INFO] File \"{file.ZipUrl}\" successfully downloaded to \"{outputFile}\".");
|
||||
Console.ResetColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine($"[WARN] File \"{outputFile}\" already exists. Download from \"{file.ZipUrl}\" skipped.");
|
||||
Console.ResetColor();
|
||||
@ -93,9 +102,10 @@ foreach (var feedUrl in feedUrls)
|
||||
Console.WriteLine($"[SUCCESS] All files from \"{feedUrl}\" successfully downloaded.");
|
||||
}
|
||||
Console.WriteLine($"Download complete at {appStartupDate}.");
|
||||
}
|
||||
}
|
||||
|
||||
public partial class ResponseArray
|
||||
{
|
||||
public partial class ResponseArray {
|
||||
public string Description { get; set; }
|
||||
public string Edition { get; set; }
|
||||
public Uri ZipUrl { get; set; }
|
||||
@ -109,3 +119,5 @@ public partial class ResponseArray
|
||||
public Uri ReleaseNotes { get; set; }
|
||||
public Uri UpgradeNotes { get; set; }
|
||||
}
|
||||
|
||||
}
|
@ -17,15 +17,16 @@
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<RepositoryUrl>https://github.com/EpicMorg/atlassian-downloader</RepositoryUrl>
|
||||
<PackageTags>atlassian, donwloader, epicmorg</PackageTags>
|
||||
<AssemblyVersion>1.0.0.5</AssemblyVersion>
|
||||
<FileVersion>1.0.0.5</FileVersion>
|
||||
<Version>1.0.0.5</Version>
|
||||
<AssemblyVersion>1.0.0.6</AssemblyVersion>
|
||||
<FileVersion>1.0.0.6</FileVersion>
|
||||
<Version>1.0.0.6</Version>
|
||||
<Copyright>EpicMorg 2021</Copyright>
|
||||
<Product>Atlassian Downloader</Product>
|
||||
<IsPackable>true</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.CommandLine.DragonFruit" Version="0.3.0-alpha.20574.7" />
|
||||
<None Include="favicon.png">
|
||||
<Pack>True</Pack>
|
||||
<PackagePath></PackagePath>
|
||||
|
Loading…
x
Reference in New Issue
Block a user