Skip to content

Commit

Permalink
修复一些配置问题
Browse files Browse the repository at this point in the history
  • Loading branch information
kaedei committed Jun 22, 2020
1 parent 9a0e27b commit cbff4c5
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 11 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace ResourceMonitor.Models.DandanplayApi
*/

/// <summary>
/// 下载规则详情(部分属性没有用到就没加进来)
/// 下载规则详情
/// </summary>
public class AutoDownloadRule
{
Expand All @@ -35,6 +35,7 @@ public class AutoDownloadRule
public int maxCount { get; set; }
public bool autoStart { get; set; }
public DateTime createdTime { get; set; }
public DateTime startTime { get; set; }
public string subgroupName { get; set; }
public string typeName { get; set; }
public bool chooseNewerIfDuplicate { get; set; }
Expand All @@ -43,7 +44,7 @@ public class AutoDownloadRule

public override string ToString()
{
return $"{nameof(id)}: {id}, {nameof(description)}: {description}, {nameof(keyword)}: {keyword}, {nameof(subgroupId)}: {subgroupId}, {nameof(typeId)}: {typeId}, {nameof(maxCount)}: {maxCount}, {nameof(autoStart)}: {autoStart}, {nameof(createdTime)}: {createdTime}, {nameof(subgroupName)}: {subgroupName}, {nameof(typeName)}: {typeName}, {nameof(chooseNewerIfDuplicate)}: {chooseNewerIfDuplicate}, {nameof(limitFileSize)}: {limitFileSize}, {nameof(version)}: {version}";
return $"{nameof(id)}: {id}, {nameof(description)}: {description}, {nameof(keyword)}: {keyword}, {nameof(subgroupId)}: {subgroupId}, {nameof(typeId)}: {typeId}, {nameof(maxCount)}: {maxCount}, {nameof(autoStart)}: {autoStart}, {nameof(createdTime)}: {createdTime}, {nameof(startTime)}: {startTime}, {nameof(subgroupName)}: {subgroupName}, {nameof(typeName)}: {typeName}, {nameof(chooseNewerIfDuplicate)}: {chooseNewerIfDuplicate}, {nameof(limitFileSize)}: {limitFileSize}, {nameof(version)}: {version}";
}
}
}
3 changes: 2 additions & 1 deletion ResourceMonitor/ResourceMonitor/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public static int Main(string[] args)

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); });
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); })
.UseSerilog();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "index.html",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ namespace ResourceMonitor.Services.Declaration
public interface IDandanplayApi
{
[Post("/api/v2/login")]
Task<LoginResponse> Login(LoginRequest request);
Task<LoginResponse> Login([Body] LoginRequest request);

[Get("/api/v2/login/renew")]
Task<LoginResponse> Renew([Header("Authorization")] string authorization);

[Post("/api/v2/sync/autodownload")]
Task<AutoDownloadRuleListResponse> SyncAutoDownloadRules(AutoDownloadRuleSyncRequest request,
Task<AutoDownloadRuleListResponse> SyncAutoDownloadRules([Body] AutoDownloadRuleSyncRequest request,
[Header("Authorization")] string authorization);
}
}
11 changes: 11 additions & 0 deletions ResourceMonitor/ResourceMonitor/Services/Declaration/IResApi.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Threading.Tasks;
using Refit;

namespace ResourceMonitor.Services.Declaration
{
public interface IResApi
{
[Get("/list")]
Task List(string keyword, int? subgroupId, int? typeId);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using ResourceMonitor.Models.DandanplayApi;
using ResourceMonitor.Services.Declaration;

Expand Down Expand Up @@ -67,5 +69,7 @@ private async Task DownloadRule(AutoDownloadRule rule)

//连接下载器,添加远程任务
}


}
}
18 changes: 13 additions & 5 deletions ResourceMonitor/ResourceMonitor/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,24 @@ public void ConfigureServices(IServiceCollection services)
services.AddHostedService<SyncRulesBackgroundService>();
services.AddHostedService<CheckNewResourcesBackgroundService>();

//User-Agent: dandanplay/resmonitor 1.2.3.4
var userAgent = string.Format(Configuration["Api:UserAgent"],
Assembly.GetExecutingAssembly().GetName().Version.ToString(4));

services.AddRefitClient<IDandanplayApi>()
.ConfigureHttpClient(c =>
{
//User-Agent: dandanplay/resmonitor 1.2.3.4
c.DefaultRequestHeaders.UserAgent.ParseAdd(
string.Format(Configuration["Api:UserAgent"],
Assembly.GetExecutingAssembly().GetName().Version.ToString(4)));
c.DefaultRequestHeaders.UserAgent.ParseAdd(userAgent);
c.BaseAddress = new Uri(Configuration["Api:ApiBaseUrl"]);
});

services.AddRefitClient<IResApi>()
.ConfigureHttpClient(c =>
{
c.DefaultRequestHeaders.UserAgent.ParseAdd(userAgent);
c.BaseAddress = new Uri(Configuration["Api:ResBaseUrl"]);
});

services.AddSingleton<IRulesContainer, RulesContainer>();

services.AddControllers();
Expand All @@ -59,7 +67,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)

app.UseStaticFiles();

app.UseHttpsRedirection();
//app.UseHttpsRedirection();

app.UseRouting();

Expand Down
1 change: 1 addition & 0 deletions ResourceMonitor/ResourceMonitor/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"Api": {
"ApiBaseUrl": "https://api.acplay.net",
"ResBaseUrl": "http://res.acplay.net",
"MagnetBaseUrl": "https://m2t.chinacloudsites.cn",
"UserName": "test",
"Password": "test",
"AppId": "test",
Expand Down

0 comments on commit cbff4c5

Please sign in to comment.