mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Better handling of current environement
This commit is contained in:
parent
6db91bf3ae
commit
f9e0c23e62
@ -7,19 +7,39 @@ using Microsoft.VisualBasic.FileIO;
|
|||||||
|
|
||||||
namespace Kyoo
|
namespace Kyoo
|
||||||
{
|
{
|
||||||
public class Program
|
public static class Program
|
||||||
{
|
{
|
||||||
public static async Task Main(string[] args)
|
public static async Task Main(string[] args)
|
||||||
{
|
{
|
||||||
if (args.Length > 0)
|
if (args.Length > 0)
|
||||||
FileSystem.CurrentDirectory = args[0];
|
FileSystem.CurrentDirectory = args[0];
|
||||||
Console.WriteLine($"Running as {Environment.UserName} in {FileSystem.CurrentDirectory}.");
|
|
||||||
if (!File.Exists("./appsettings.json"))
|
if (!File.Exists("./appsettings.json"))
|
||||||
File.Copy(Path.Join(AppDomain.CurrentDomain.BaseDirectory, "appsettings.json"), "appsettings.json");
|
File.Copy(Path.Join(AppDomain.CurrentDomain.BaseDirectory, "appsettings.json"), "appsettings.json");
|
||||||
await CreateWebHostBuilder(args).Build().RunAsync();
|
|
||||||
|
|
||||||
|
bool? debug = Environment.GetEnvironmentVariable("ENVIRONEMENT")?.ToLowerInvariant() switch
|
||||||
|
{
|
||||||
|
"d" => true,
|
||||||
|
"dev" => true,
|
||||||
|
"debug" => true,
|
||||||
|
"development" => true,
|
||||||
|
"p" => false,
|
||||||
|
"prod" => false,
|
||||||
|
"production" => false,
|
||||||
|
_ => null
|
||||||
|
};
|
||||||
|
|
||||||
|
if (debug == null)
|
||||||
|
Console.WriteLine($"Invalid ENVIRONEMENT variable. Supported values are \"debug\" and \"prod\". Ignoring...");
|
||||||
|
|
||||||
|
Console.WriteLine($"Running as {Environment.UserName}.");
|
||||||
|
IWebHostBuilder host = CreateWebHostBuilder(args);
|
||||||
|
if (debug != null)
|
||||||
|
host = host.UseEnvironment(debug == true ? "Development" : "Production");
|
||||||
|
await host.Build().RunAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
|
private static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
|
||||||
WebHost.CreateDefaultBuilder(args)
|
WebHost.CreateDefaultBuilder(args)
|
||||||
.UseKestrel(config => { config.AddServerHeader = false; })
|
.UseKestrel(config => { config.AddServerHeader = false; })
|
||||||
.UseUrls("http://*:5000")
|
.UseUrls("http://*:5000")
|
||||||
|
@ -34,7 +34,6 @@ namespace Kyoo
|
|||||||
_loggerFactory = loggerFactory;
|
_loggerFactory = loggerFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to add services to the container.
|
|
||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddSpaStaticFiles(configuration =>
|
services.AddSpaStaticFiles(configuration =>
|
||||||
@ -102,7 +101,7 @@ namespace Kyoo
|
|||||||
o.DefaultScheme = IdentityConstants.ApplicationScheme;
|
o.DefaultScheme = IdentityConstants.ApplicationScheme;
|
||||||
o.DefaultSignInScheme = IdentityConstants.ExternalScheme;
|
o.DefaultSignInScheme = IdentityConstants.ExternalScheme;
|
||||||
})
|
})
|
||||||
.AddIdentityCookies(o => { });
|
.AddIdentityCookies(_ => { });
|
||||||
services.AddAuthentication()
|
services.AddAuthentication()
|
||||||
.AddJwtBearer(options =>
|
.AddJwtBearer(options =>
|
||||||
{
|
{
|
||||||
@ -158,8 +157,7 @@ namespace Kyoo
|
|||||||
services.AddHostedService(provider => (TaskManager)provider.GetService<ITaskManager>());
|
services.AddHostedService(provider => (TaskManager)provider.GetService<ITaskManager>());
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
public static void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
|
||||||
{
|
{
|
||||||
if (env.IsDevelopment())
|
if (env.IsDevelopment())
|
||||||
{
|
{
|
||||||
|
@ -43,44 +43,6 @@ namespace Kyoo.Api
|
|||||||
string mime = subtitle.Codec == "ass" ? "text/x-ssa" : "application/x-subrip";
|
string mime = subtitle.Codec == "ass" ? "text/x-ssa" : "application/x-subrip";
|
||||||
return PhysicalFile(subtitle.Path, mime);
|
return PhysicalFile(subtitle.Path, mime);
|
||||||
}
|
}
|
||||||
|
|
||||||
// [HttpGet("extract/{showSlug}-s{seasonNumber}e{episodeNumber}")]
|
|
||||||
// [Authorize(Policy="Admin")]
|
|
||||||
// public async Task<string> ExtractSubtitle(string showSlug, long seasonNumber, long episodeNumber)
|
|
||||||
// {
|
|
||||||
// Episode episode = _libraryManager.GetEpisode(showSlug, seasonNumber, episodeNumber);
|
|
||||||
// episode.Tracks = null;
|
|
||||||
//
|
|
||||||
// Track[] tracks = await _transcoder.ExtractSubtitles(episode.Path);
|
|
||||||
// foreach (Track track in tracks)
|
|
||||||
// {
|
|
||||||
// track.EpisodeID = episode.ID;
|
|
||||||
// _libraryManager.Register(track);
|
|
||||||
// }
|
|
||||||
// await _libraryManager.SaveChanges();
|
|
||||||
// return "Done. " + tracks.Length + " track(s) extracted.";
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// [HttpGet("extract/{showSlug}")]
|
|
||||||
// [Authorize(Policy="Admin")]
|
|
||||||
// public async Task<string> ExtractSubtitle(string showSlug)
|
|
||||||
// {
|
|
||||||
// IEnumerable<Episode> episodes = _libraryManager.GetShow(showSlug).Episodes;
|
|
||||||
// foreach (Episode episode in episodes)
|
|
||||||
// {
|
|
||||||
// episode.Tracks = null;
|
|
||||||
//
|
|
||||||
// Track[] tracks = await _transcoder.ExtractSubtitles(episode.Path);
|
|
||||||
// foreach (Track track in tracks)
|
|
||||||
// {
|
|
||||||
// track.EpisodeID = episode.ID;
|
|
||||||
// _libraryManager.Register(track);
|
|
||||||
// }
|
|
||||||
// await _libraryManager.SaveChanges();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return "Done.";
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user