@@ -16,19 +16,18 @@ public class Uploader : IUploader
16
16
{
17
17
private static readonly Logger _log = LogManager . GetCurrentClassLogger ( ) ;
18
18
#if DEBUG
19
- const string HeroesProfileApiEndpoint = "https://api.heroesprofile.com/api" ;
20
- const string HeroesProfileMatchParsed = "https://api.heroesprofile.com/openApi/Replay/Parsed/?replayID=" ;
21
- const string HeroesProfileMatchSummary = "https://www.heroesprofile.com/Match/Single/?replayID=" ;
22
- const string HotsAPIApiEndpoint = "http://hotsapi.local/api/v1" ;
19
+ const string HeroesProfileApiEndpoint = "http://127.0.0.1:8000/api" ;
20
+ const string HeroesProfileMatchParsed = "http://127.0.0.1:8000/openApi/Replay/Parsed/?replayID=" ;
21
+ const string HeroesProfileMatchSummary = "http://localhost/Match/Single/?replayID=" ;
22
+
23
+
23
24
24
25
#else
25
26
const string HeroesProfileApiEndpoint = "https://api.heroesprofile.com/api" ;
26
27
const string HeroesProfileMatchParsed = "https://api.heroesprofile.com/openApi/Replay/Parsed/?replayID=" ;
27
28
const string HeroesProfileMatchSummary = "https://www.heroesprofile.com/Match/Single/?replayID=" ;
28
- const string HotsAPIApiEndpoint = "https://hotsapi.net/api/v1" ;
29
29
#endif
30
30
31
- public bool UploadToHotslogs { get ; set ; }
32
31
/// <summary>
33
32
/// New instance of replay uploader
34
33
/// </summary>
@@ -62,23 +61,10 @@ public async Task<UploadStatus> Upload(Replay replay_results, string fingerprint
62
61
try {
63
62
string response ;
64
63
using ( var client = new WebClient ( ) ) {
65
- //var bytes = await client.UploadFileTaskAsync($"{HeroesProfileApiEndpoint}/upload?fingerprint={fingerprint}&data={replay_json}", file);
66
-
67
- var bytes = await client . UploadFileTaskAsync ( $ "{ HeroesProfileApiEndpoint } /upload?fingerprint={ fingerprint } ", file ) ;
64
+ var bytes = await client . UploadFileTaskAsync ( $ "{ HeroesProfileApiEndpoint } /upload/heroesprofile/desktop/?fingerprint={ fingerprint } ", file ) ;
68
65
response = Encoding . UTF8 . GetString ( bytes ) ;
69
66
}
70
67
71
- //Try upload to HotsApi as well
72
- string hotsapiResponse ;
73
- try {
74
- using ( var client = new WebClient ( ) ) {
75
- var bytes = await client . UploadFileTaskAsync ( $ "{ HotsAPIApiEndpoint } /upload?uploadToHotslogs={ UploadToHotslogs } ", file ) ;
76
- hotsapiResponse = Encoding . UTF8 . GetString ( bytes ) ;
77
- }
78
- }
79
- catch {
80
-
81
- }
82
68
dynamic json = JObject . Parse ( response ) ;
83
69
84
70
try {
@@ -195,35 +181,7 @@ public async Task CheckDuplicate(IEnumerable<ReplayFile> replays)
195
181
}
196
182
197
183
/// <summary>
198
- /// Get minimum HotS client build supported by HotsApi
199
- /// </summary>
200
- public async Task < int > GetMinimumBuild ( )
201
- {
202
- //We likely want to track which replays arn't supported by HotsApi so that we don't send them to HotsApi,
203
- //but I would like to change this so that it doesn't prevent replays uploading to our own storage, as we can support any replay build
204
-
205
-
206
- try {
207
- using ( var client = new WebClient ( ) ) {
208
- var response = await client . DownloadStringTaskAsync ( $ "{ HeroesProfileApiEndpoint } /replays/hotsapi-min-build") ;
209
- if ( ! int . TryParse ( response , out int build ) ) {
210
- _log . Warn ( $ "Error parsing minimum build: { response } ") ;
211
- return 0 ;
212
- }
213
- return 0 ;
214
- }
215
- }
216
- catch ( WebException ex ) {
217
- if ( await CheckApiThrottling ( ex . Response ) ) {
218
- return await GetMinimumBuild ( ) ;
219
- }
220
- _log . Warn ( ex , $ "Error getting minimum build") ;
221
- return 0 ;
222
- }
223
- }
224
-
225
- /// <summary>
226
- /// Check if Hotsapi request limit is reached and wait if it is
184
+ /// Check if Heroes Profile API request limit is reached and wait if it is
227
185
/// </summary>
228
186
/// <param name="response">Server response to examine</param>
229
187
private async Task < bool > CheckApiThrottling ( WebResponse response )
0 commit comments