mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Preparing the app for a release.
This commit is contained in:
parent
71403a9888
commit
439ff05c21
2
Kyoo.sln
2
Kyoo.sln
@ -37,7 +37,7 @@ Global
|
||||
{E5EFA4B2-F09D-4C4F-83DD-A436CD60BB77}.Debug|x64.Build.0 = Debug|x64
|
||||
{E5EFA4B2-F09D-4C4F-83DD-A436CD60BB77}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{E5EFA4B2-F09D-4C4F-83DD-A436CD60BB77}.Debug|x86.Build.0 = Debug|Win32
|
||||
{E5EFA4B2-F09D-4C4F-83DD-A436CD60BB77}.Release|Any CPU.ActiveCfg = Release|Win32
|
||||
{E5EFA4B2-F09D-4C4F-83DD-A436CD60BB77}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{E5EFA4B2-F09D-4C4F-83DD-A436CD60BB77}.Release|x64.ActiveCfg = Release|x64
|
||||
{E5EFA4B2-F09D-4C4F-83DD-A436CD60BB77}.Release|x64.Build.0 = Release|x64
|
||||
{E5EFA4B2-F09D-4C4F-83DD-A436CD60BB77}.Release|x86.ActiveCfg = Release|Win32
|
||||
|
@ -17,7 +17,7 @@
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-angular:browser",
|
||||
"options": {
|
||||
"outputPath": "dist/Kyoo",
|
||||
"outputPath": "dist",
|
||||
"index": "src/index.html",
|
||||
"main": "src/main.ts",
|
||||
"polyfills": "src/polyfills.ts",
|
||||
|
29
Kyoo/Controllers/AdminController.cs
Normal file
29
Kyoo/Controllers/AdminController.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using Kyoo.InternalAPI;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Kyoo.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class AdminController : ControllerBase
|
||||
{
|
||||
private readonly ICrawler crawler;
|
||||
|
||||
public AdminController(ICrawler crawler)
|
||||
{
|
||||
this.crawler = crawler;
|
||||
}
|
||||
|
||||
[HttpGet("scan/{watch}")]
|
||||
public IActionResult ScanLibrary(bool watch)
|
||||
{
|
||||
crawler.Start(watch);
|
||||
|
||||
return Ok("Scanning");
|
||||
}
|
||||
}
|
||||
}
|
@ -79,7 +79,8 @@ namespace Kyoo.Controllers
|
||||
if (path == null)
|
||||
return NotFound();
|
||||
|
||||
string thumb = Path.ChangeExtension(path, "jpg");
|
||||
//string thumb = Path.ChangeExtension(path, "jpg");
|
||||
string thumb = path.Replace(Path.GetExtension(path), "-thumb.jpg");
|
||||
|
||||
if (System.IO.File.Exists(thumb))
|
||||
return new PhysicalFileResult(thumb, "image/jpg");
|
||||
|
@ -11,8 +11,10 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Kyoo.InternalAPI
|
||||
{
|
||||
public class Crawler : IHostedService
|
||||
public class Crawler : ICrawler
|
||||
{
|
||||
private readonly CancellationTokenSource cancellation;
|
||||
|
||||
private readonly IConfiguration config;
|
||||
private readonly ILibraryManager libraryManager;
|
||||
private readonly IMetadataProvider metadataProvider;
|
||||
@ -24,31 +26,43 @@ namespace Kyoo.InternalAPI
|
||||
this.libraryManager = libraryManager;
|
||||
this.metadataProvider = metadataProvider;
|
||||
this.transcoder = transcoder;
|
||||
|
||||
cancellation = new CancellationTokenSource();
|
||||
}
|
||||
|
||||
public Task StartAsync(CancellationToken cancellationToken)
|
||||
public Task Start(bool watch)
|
||||
{
|
||||
return StartAsync(watch, cancellation.Token);
|
||||
}
|
||||
|
||||
private Task StartAsync(bool watch, CancellationToken cancellationToken)
|
||||
{
|
||||
Debug.WriteLine("&Crawler started");
|
||||
string[] paths = config.GetSection("libraryPaths").Get<string[]>();
|
||||
|
||||
foreach (string path in paths)
|
||||
{
|
||||
Scan(path);
|
||||
Watch(path, cancellationToken);
|
||||
Scan(path, cancellationToken);
|
||||
|
||||
if(watch)
|
||||
Watch(path, cancellationToken);
|
||||
}
|
||||
|
||||
while (!cancellationToken.IsCancellationRequested) ;
|
||||
while (!cancellationToken.IsCancellationRequested);
|
||||
|
||||
Debug.WriteLine("&Crawler stopped");
|
||||
return null;
|
||||
}
|
||||
|
||||
public async void Scan(string folderPath)
|
||||
public async void Scan(string folderPath, CancellationToken cancellationToken)
|
||||
{
|
||||
string[] files = Directory.GetFiles(folderPath, "*", SearchOption.AllDirectories);
|
||||
|
||||
foreach (string file in files)
|
||||
{
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
return;
|
||||
|
||||
if (IsVideo(file))
|
||||
await TryRegisterEpisode(file);
|
||||
}
|
||||
@ -75,7 +89,7 @@ namespace Kyoo.InternalAPI
|
||||
|
||||
watcher.EnableRaisingEvents = true;
|
||||
|
||||
while (!cancellationToken.IsCancellationRequested) ;
|
||||
while (!cancellationToken.IsCancellationRequested);
|
||||
}
|
||||
}
|
||||
|
||||
@ -217,8 +231,9 @@ namespace Kyoo.InternalAPI
|
||||
}
|
||||
|
||||
|
||||
public Task StopAsync(CancellationToken cancellationToken)
|
||||
public Task StopAsync()
|
||||
{
|
||||
cancellation.Cancel();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
12
Kyoo/InternalAPI/Crawler/ICrawler.cs
Normal file
12
Kyoo/InternalAPI/Crawler/ICrawler.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Kyoo.InternalAPI
|
||||
{
|
||||
public interface ICrawler
|
||||
{
|
||||
Task Start(bool watch);
|
||||
|
||||
Task StopAsync();
|
||||
}
|
||||
}
|
@ -661,13 +661,16 @@ namespace Kyoo.InternalAPI
|
||||
cmd.CommandText = "SELECT LAST_INSERT_ROWID()";
|
||||
long showID = (long)cmd.ExecuteScalar();
|
||||
|
||||
cmd.CommandText = "INSERT INTO genresLinks (genreID, showID) VALUES($genreID, $showID);";
|
||||
foreach (Genre genre in show.Genres)
|
||||
if (show.Genres != null)
|
||||
{
|
||||
long genreID = GetOrCreateGenre(genre);
|
||||
cmd.Parameters.AddWithValue("$genreID", genreID);
|
||||
cmd.Parameters.AddWithValue("$showID", showID);
|
||||
cmd.ExecuteNonQuery();
|
||||
cmd.CommandText = "INSERT INTO genresLinks (genreID, showID) VALUES($genreID, $showID);";
|
||||
foreach (Genre genre in show.Genres)
|
||||
{
|
||||
long genreID = GetOrCreateGenre(genre);
|
||||
cmd.Parameters.AddWithValue("$genreID", genreID);
|
||||
cmd.Parameters.AddWithValue("$showID", showID);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
if(show.studio != null)
|
||||
|
@ -11,7 +11,7 @@ namespace Kyoo.InternalAPI.MetadataProvider
|
||||
|
||||
public string GetID(string externalIDs)
|
||||
{
|
||||
if (externalIDs.Contains(Provider))
|
||||
if (externalIDs?.Contains(Provider) == true)
|
||||
{
|
||||
int startIndex = externalIDs.IndexOf(Provider) + Provider.Length + 1; //The + 1 is for the '='
|
||||
return externalIDs.Substring(startIndex, externalIDs.IndexOf('|', startIndex) - startIndex);
|
||||
|
@ -74,7 +74,7 @@ namespace Kyoo.InternalAPI
|
||||
|
||||
public Episode Merge(IEnumerable<Episode> episodes)
|
||||
{
|
||||
return episodes.FirstOrDefault();
|
||||
return episodes.FirstOrDefault(); //Should do something if the return is null;
|
||||
}
|
||||
|
||||
//For all the following methods, it should use all providers and merge the data.
|
||||
|
@ -13,6 +13,7 @@
|
||||
<Company>SDG</Company>
|
||||
<Authors>Anonymus-Raccoon</Authors>
|
||||
<RepositoryUrl>https://github.com/AnonymusRaccoon/Kyoo</RepositoryUrl>
|
||||
<StartupObject>Kyoo.Program</StartupObject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -1,6 +1,7 @@
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System.IO;
|
||||
|
||||
namespace Kyoo
|
||||
|
@ -4,7 +4,6 @@ using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SpaServices.AngularCli;
|
||||
using Microsoft.AspNetCore.StaticFiles;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.Web.Http;
|
||||
@ -36,7 +35,7 @@ namespace Kyoo
|
||||
services.AddSingleton<ITranscoder, Transcoder>();
|
||||
|
||||
//Services used to get informations about files and register them
|
||||
services.AddHostedService<Crawler>();
|
||||
services.AddSingleton<ICrawler, Crawler>();
|
||||
services.AddSingleton<IThumbnailsManager, ThumbnailsManager>();
|
||||
services.AddSingleton<IMetadataProvider, ProviderManager>();
|
||||
}
|
||||
@ -54,7 +53,7 @@ namespace Kyoo
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
//app.UseHttpsRedirection();
|
||||
app.UseStaticFiles();
|
||||
app.UseSpaStaticFiles();
|
||||
|
||||
|
Binary file not shown.
@ -1,4 +1,5 @@
|
||||
{
|
||||
"https_port": 44300,
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Warning"
|
||||
|
Loading…
x
Reference in New Issue
Block a user