mirror of
https://github.com/EpicMorg/atlassian-downloader.git
synced 2025-06-19 08:02:04 +03:00
1.0.0.6
* fixed downloading
This commit is contained in:
parent
63e7059e74
commit
5a7836ec54
@ -3,18 +3,35 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
var appTitle = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
|
/*
|
||||||
var appVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
|
-o, --output-folder "path" --> set output folder
|
||||||
var appStartupDate = DateTime.Now;
|
-v, --version --> show version
|
||||||
var appBuildType = "[Release]";
|
-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;
|
||||||
|
var appStartupDate = DateTime.Now;
|
||||||
|
var appBuildType = "[Release]";
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
appBuildType = "[Debug]";
|
appBuildType = "[Debug]";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
var outputDir = "atlassian";
|
var outputDir = "atlassian";
|
||||||
var feedUrls =
|
var feedUrls =
|
||||||
new[] {
|
new[] {
|
||||||
"https://my.atlassian.com/download/feeds/archived/bamboo.json",
|
"https://my.atlassian.com/download/feeds/archived/bamboo.json",
|
||||||
"https://my.atlassian.com/download/feeds/archived/confluence.json",
|
"https://my.atlassian.com/download/feeds/archived/confluence.json",
|
||||||
"https://my.atlassian.com/download/feeds/archived/crowd.json",
|
"https://my.atlassian.com/download/feeds/archived/crowd.json",
|
||||||
@ -35,77 +52,72 @@ var feedUrls =
|
|||||||
"https://my.atlassian.com/download/feeds/current/jira-servicedesk.json",
|
"https://my.atlassian.com/download/feeds/current/jira-servicedesk.json",
|
||||||
"https://my.atlassian.com/download/feeds/current/jira-software.json",
|
"https://my.atlassian.com/download/feeds/current/jira-software.json",
|
||||||
"https://my.atlassian.com/download/feeds/current/stash.json",
|
"https://my.atlassian.com/download/feeds/current/stash.json",
|
||||||
|
|
||||||
"https://my.atlassian.com/download/feeds/eap/bamboo.json",
|
|
||||||
"https://my.atlassian.com/download/feeds/eap/confluence.json",
|
|
||||||
"https://my.atlassian.com/download/feeds/eap/jira.json",
|
|
||||||
"https://my.atlassian.com/download/feeds/eap/jira-servicedesk.json"
|
|
||||||
};
|
|
||||||
|
|
||||||
Console.Title = $"{appTitle} {appVersion} {appBuildType}";
|
"https://my.atlassian.com/download/feeds/eap/bamboo.json",
|
||||||
Console.WriteLine($"Download started at {appStartupDate}.");
|
"https://my.atlassian.com/download/feeds/eap/confluence.json",
|
||||||
|
"https://my.atlassian.com/download/feeds/eap/jira.json",
|
||||||
|
"https://my.atlassian.com/download/feeds/eap/jira-servicedesk.json"
|
||||||
|
};
|
||||||
|
|
||||||
var client = new HttpClient();
|
Console.Title = $"{appTitle} {appVersion} {appBuildType}";
|
||||||
foreach (var feedUrl in feedUrls)
|
Console.WriteLine($"Download started at {appStartupDate}.");
|
||||||
{
|
|
||||||
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
|
|
||||||
{
|
|
||||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
|
||||||
});
|
|
||||||
var versions = parsed.GroupBy(a => a.Version).ToDictionary(a => a.Key, a => a.ToArray());
|
|
||||||
|
|
||||||
foreach (var version in versions)
|
var client = new HttpClient();
|
||||||
{
|
foreach (var feedUrl in feedUrls) {
|
||||||
var directory = Path.Combine(feedDir, version.Key);
|
var feedDir = Path.Combine(outputDir, feedUrl[(feedUrl.LastIndexOf('/') + 1)..(feedUrl.LastIndexOf('.'))]);
|
||||||
if (!Directory.Exists(directory))
|
var atlassianJson = await client.GetStringAsync(feedUrl);
|
||||||
{
|
var callString = "downloads(";
|
||||||
Directory.CreateDirectory(directory);
|
var json = atlassianJson[callString.Length..^1];
|
||||||
}
|
var parsed = JsonSerializer.Deserialize<ResponseArray[]>(json, new JsonSerializerOptions {
|
||||||
foreach (var file in version.Value)
|
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
||||||
{
|
});
|
||||||
var serverPath = file.ZipUrl.PathAndQuery;
|
var versions = parsed.GroupBy(a => a.Version).ToDictionary(a => a.Key, a => a.ToArray());
|
||||||
var outputFile = Path.Combine(directory, serverPath[(serverPath.LastIndexOf("/") + 1)..]);
|
|
||||||
if (!File.Exists(outputFile))
|
foreach (var version in versions) {
|
||||||
{
|
var directory = Path.Combine(feedDir, version.Key);
|
||||||
if (!string.IsNullOrEmpty(file.Md5))
|
if (!Directory.Exists(directory)) {
|
||||||
{
|
Directory.CreateDirectory(directory);
|
||||||
File.WriteAllText(outputFile + ".md5", file.Md5);
|
}
|
||||||
|
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)) {
|
||||||
|
File.WriteAllText(outputFile + ".md5", file.Md5);
|
||||||
|
}
|
||||||
|
using var outputStream = File.OpenWrite(outputFile);
|
||||||
|
using var request = await client.GetStreamAsync(file.ZipUrl).ConfigureAwait(false);
|
||||||
|
await request.CopyToAsync(outputStream).ConfigureAwait(false);
|
||||||
|
Console.ForegroundColor = ConsoleColor.Green;
|
||||||
|
Console.WriteLine($"[INFO] File \"{file.ZipUrl}\" successfully downloaded to \"{outputFile}\".");
|
||||||
|
Console.ResetColor();
|
||||||
|
} else {
|
||||||
|
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||||
|
Console.WriteLine($"[WARN] File \"{outputFile}\" already exists. Download from \"{file.ZipUrl}\" skipped.");
|
||||||
|
Console.ResetColor();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
using var outputStream = File.OpenWrite(outputFile);
|
Console.WriteLine($"[SUCCESS] All files from \"{feedUrl}\" successfully downloaded.");
|
||||||
using var request = await client.GetStreamAsync(file.ZipUrl).ConfigureAwait(false);
|
|
||||||
await request.CopyToAsync(outputStream).ConfigureAwait(false);
|
|
||||||
Console.ForegroundColor = ConsoleColor.Green;
|
|
||||||
Console.WriteLine($"[INFO] File \"{file.ZipUrl}\" successfully downloaded to \"{outputFile}\".");
|
|
||||||
Console.ResetColor();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
|
||||||
Console.WriteLine($"[WARN] File \"{outputFile}\" already exists. Download from \"{file.ZipUrl}\" skipped.");
|
|
||||||
Console.ResetColor();
|
|
||||||
}
|
}
|
||||||
|
Console.WriteLine($"Download complete at {appStartupDate}.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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 Description { get; set; }
|
public string Edition { get; set; }
|
||||||
public string Edition { get; set; }
|
public Uri ZipUrl { get; set; }
|
||||||
public Uri ZipUrl { get; set; }
|
public object TarUrl { get; set; }
|
||||||
public object TarUrl { get; set; }
|
public string Md5 { get; set; }
|
||||||
public string Md5 { get; set; }
|
public string Size { get; set; }
|
||||||
public string Size { get; set; }
|
public string Released { get; set; }
|
||||||
public string Released { get; set; }
|
public string Type { get; set; }
|
||||||
public string Type { get; set; }
|
public string Platform { get; set; }
|
||||||
public string Platform { get; set; }
|
public string Version { get; set; }
|
||||||
public string Version { get; set; }
|
public Uri ReleaseNotes { get; set; }
|
||||||
public Uri ReleaseNotes { get; set; }
|
public Uri UpgradeNotes { get; set; }
|
||||||
public Uri UpgradeNotes { get; set; }
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<PublishSingleFile>true</PublishSingleFile>
|
<PublishSingleFile>true</PublishSingleFile>
|
||||||
<SelfContained>true</SelfContained>
|
<SelfContained>true</SelfContained>
|
||||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
<PublishTrimmed>true</PublishTrimmed>
|
<PublishTrimmed>true</PublishTrimmed>
|
||||||
@ -17,15 +17,16 @@
|
|||||||
<RepositoryType>git</RepositoryType>
|
<RepositoryType>git</RepositoryType>
|
||||||
<RepositoryUrl>https://github.com/EpicMorg/atlassian-downloader</RepositoryUrl>
|
<RepositoryUrl>https://github.com/EpicMorg/atlassian-downloader</RepositoryUrl>
|
||||||
<PackageTags>atlassian, donwloader, epicmorg</PackageTags>
|
<PackageTags>atlassian, donwloader, epicmorg</PackageTags>
|
||||||
<AssemblyVersion>1.0.0.5</AssemblyVersion>
|
<AssemblyVersion>1.0.0.6</AssemblyVersion>
|
||||||
<FileVersion>1.0.0.5</FileVersion>
|
<FileVersion>1.0.0.6</FileVersion>
|
||||||
<Version>1.0.0.5</Version>
|
<Version>1.0.0.6</Version>
|
||||||
<Copyright>EpicMorg 2021</Copyright>
|
<Copyright>EpicMorg 2021</Copyright>
|
||||||
<Product>Atlassian Downloader</Product>
|
<Product>Atlassian Downloader</Product>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="System.CommandLine.DragonFruit" Version="0.3.0-alpha.20574.7" />
|
||||||
<None Include="favicon.png">
|
<None Include="favicon.png">
|
||||||
<Pack>True</Pack>
|
<Pack>True</Pack>
|
||||||
<PackagePath></PackagePath>
|
<PackagePath></PackagePath>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user