This commit is contained in:
stam 2021-01-13 15:52:47 +03:00
parent 2a98e13a26
commit f333eb5e4c
2 changed files with 33 additions and 4 deletions

View File

@ -4,6 +4,25 @@
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net5.0</TargetFramework>
<ApplicationIcon>favicon.ico</ApplicationIcon> <ApplicationIcon>favicon.ico</ApplicationIcon>
<PackageId>Atlassian Downloader</PackageId>
<Authors>Atlassian Downloader</Authors>
<Description>Atlassian Downloader by EpicMorg, code by kasthack</Description>
<PackageProjectUrl>https://github.com/EpicMorg/atlassian-downloader</PackageProjectUrl>
<PackageIcon>favicon.png</PackageIcon>
<FileVersion>1.0.0.2</FileVersion>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/EpicMorg/atlassian-downloader</RepositoryUrl>
<PackageTags>atlassian, donwloader, epicmorg</PackageTags>
<AssemblyVersion>1.0.0.2</AssemblyVersion>
<Version>1.0.0.2</Version>
<Copyright>EpicMorg 20201</Copyright>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<None Include="favicon.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
</ItemGroup>
</Project> </Project>

View File

@ -1,9 +1,14 @@
using System; using System;
using System.Drawing;
using System.IO; 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;
var appTitle = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
var appVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
var appStartupDate = DateTime.Now;
var outputDir = "output"; var outputDir = "output";
var feedUrls = var feedUrls =
new[] { new[] {
@ -29,7 +34,8 @@ var feedUrls =
"https://my.atlassian.com/download/feeds/current/stash.json" "https://my.atlassian.com/download/feeds/current/stash.json"
}; };
Console.Title = $"{appTitle} {appVersion}";
Console.WriteLine($"Download started at {appStartupDate}.");
var client = new HttpClient(); var client = new HttpClient();
foreach (var feedUrl in feedUrls) foreach (var feedUrl in feedUrls)
@ -64,18 +70,22 @@ foreach (var feedUrl in feedUrls)
using var outputStream = File.OpenWrite(outputFile); using var outputStream = File.OpenWrite(outputFile);
using var request = await client.GetStreamAsync(file.ZipUrl).ConfigureAwait(false); using var request = await client.GetStreamAsync(file.ZipUrl).ConfigureAwait(false);
await request.CopyToAsync(outputStream).ConfigureAwait(false); await request.CopyToAsync(outputStream).ConfigureAwait(false);
Console.WriteLine($"Downloaded {outputFile}"); Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine($"File \"{file.ZipUrl}\" downloaded to \"{outputFile}\".");
Console.ResetColor();
} }
else else
{ {
Console.WriteLine($"File for {file.ZipUrl} already exists"); Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine($"[WARN] File \"{outputFile}\" for \"{file.ZipUrl}\" already exists. Skip.");
Console.ResetColor();
} }
} }
} }
Console.WriteLine($"Downloaded all files from " + Console.WriteLine($"Downloaded all files from " +
$"{feedUrl}"); $"{feedUrl}");
} }
Console.WriteLine("Download complete"); Console.WriteLine("Download complete.");
public partial class ResponseArray public partial class ResponseArray