mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Get download counts method
This commit is contained in:
parent
a2ee2eb019
commit
152b23805a
3 changed files with 30 additions and 1 deletions
|
@ -62,7 +62,7 @@ public void WriteElapsedSeconds(string text = null)
|
|||
|
||||
public void WriteElapsedMilliseconds(string text = null)
|
||||
{
|
||||
Write(text, timer.ElapsedMilliseconds + " millisecond.");
|
||||
Write(text, timer.ElapsedMilliseconds + " milliseconds.");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
|
@ -29,6 +29,7 @@ You should have received a copy of the GNU General Public License
|
|||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Cache;
|
||||
using System.Text;
|
||||
|
||||
namespace ShareX.HelpersLib
|
||||
{
|
||||
|
@ -113,6 +114,26 @@ public string GetLatestDownloadURL()
|
|||
return null;
|
||||
}
|
||||
|
||||
public string GetDownloadCounts()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
List<GitHubRelease> releases = GetReleases();
|
||||
|
||||
if (releases != null)
|
||||
{
|
||||
foreach (GitHubRelease release in releases)
|
||||
{
|
||||
if (release.assets.Count > 0)
|
||||
{
|
||||
sb.AppendFormat("{0} ({1}): {2}\r\n", release.name, DateTime.Parse(release.published_at), release.assets.Sum(x => x.download_count));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sb.ToString().Trim();
|
||||
}
|
||||
|
||||
private string GetDownloadURL(GitHubRelease release)
|
||||
{
|
||||
if (release.assets != null && release.assets.Count > 0)
|
||||
|
|
|
@ -417,6 +417,14 @@ public static UpdateChecker CheckUpdate()
|
|||
return updateChecker;
|
||||
}
|
||||
|
||||
public static void CheckDownloadCounts()
|
||||
{
|
||||
GitHubUpdateChecker updateChecker = new GitHubUpdateChecker("ShareX", "ShareX");
|
||||
updateChecker.Proxy = HelpersOptions.CurrentProxy.GetWebProxy();
|
||||
string output = updateChecker.GetDownloadCounts();
|
||||
Debug.WriteLine(output);
|
||||
}
|
||||
|
||||
public static string CheckFilePath(string folder, string filename, TaskSettings taskSettings)
|
||||
{
|
||||
string filepath = Path.Combine(folder, filename);
|
||||
|
|
Loading…
Reference in a new issue