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|x64.Build.0 = Debug|x64
|
||||||
{E5EFA4B2-F09D-4C4F-83DD-A436CD60BB77}.Debug|x86.ActiveCfg = Debug|Win32
|
{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}.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.ActiveCfg = Release|x64
|
||||||
{E5EFA4B2-F09D-4C4F-83DD-A436CD60BB77}.Release|x64.Build.0 = Release|x64
|
{E5EFA4B2-F09D-4C4F-83DD-A436CD60BB77}.Release|x64.Build.0 = Release|x64
|
||||||
{E5EFA4B2-F09D-4C4F-83DD-A436CD60BB77}.Release|x86.ActiveCfg = Release|Win32
|
{E5EFA4B2-F09D-4C4F-83DD-A436CD60BB77}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
"build": {
|
"build": {
|
||||||
"builder": "@angular-devkit/build-angular:browser",
|
"builder": "@angular-devkit/build-angular:browser",
|
||||||
"options": {
|
"options": {
|
||||||
"outputPath": "dist/Kyoo",
|
"outputPath": "dist",
|
||||||
"index": "src/index.html",
|
"index": "src/index.html",
|
||||||
"main": "src/main.ts",
|
"main": "src/main.ts",
|
||||||
"polyfills": "src/polyfills.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)
|
if (path == null)
|
||||||
return NotFound();
|
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))
|
if (System.IO.File.Exists(thumb))
|
||||||
return new PhysicalFileResult(thumb, "image/jpg");
|
return new PhysicalFileResult(thumb, "image/jpg");
|
||||||
|
@ -11,8 +11,10 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Kyoo.InternalAPI
|
namespace Kyoo.InternalAPI
|
||||||
{
|
{
|
||||||
public class Crawler : IHostedService
|
public class Crawler : ICrawler
|
||||||
{
|
{
|
||||||
|
private readonly CancellationTokenSource cancellation;
|
||||||
|
|
||||||
private readonly IConfiguration config;
|
private readonly IConfiguration config;
|
||||||
private readonly ILibraryManager libraryManager;
|
private readonly ILibraryManager libraryManager;
|
||||||
private readonly IMetadataProvider metadataProvider;
|
private readonly IMetadataProvider metadataProvider;
|
||||||
@ -24,16 +26,25 @@ namespace Kyoo.InternalAPI
|
|||||||
this.libraryManager = libraryManager;
|
this.libraryManager = libraryManager;
|
||||||
this.metadataProvider = metadataProvider;
|
this.metadataProvider = metadataProvider;
|
||||||
this.transcoder = transcoder;
|
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");
|
Debug.WriteLine("&Crawler started");
|
||||||
string[] paths = config.GetSection("libraryPaths").Get<string[]>();
|
string[] paths = config.GetSection("libraryPaths").Get<string[]>();
|
||||||
|
|
||||||
foreach (string path in paths)
|
foreach (string path in paths)
|
||||||
{
|
{
|
||||||
Scan(path);
|
Scan(path, cancellationToken);
|
||||||
|
|
||||||
|
if(watch)
|
||||||
Watch(path, cancellationToken);
|
Watch(path, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,12 +54,15 @@ namespace Kyoo.InternalAPI
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void Scan(string folderPath)
|
public async void Scan(string folderPath, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
string[] files = Directory.GetFiles(folderPath, "*", SearchOption.AllDirectories);
|
string[] files = Directory.GetFiles(folderPath, "*", SearchOption.AllDirectories);
|
||||||
|
|
||||||
foreach (string file in files)
|
foreach (string file in files)
|
||||||
{
|
{
|
||||||
|
if (cancellationToken.IsCancellationRequested)
|
||||||
|
return;
|
||||||
|
|
||||||
if (IsVideo(file))
|
if (IsVideo(file))
|
||||||
await TryRegisterEpisode(file);
|
await TryRegisterEpisode(file);
|
||||||
}
|
}
|
||||||
@ -217,8 +231,9 @@ namespace Kyoo.InternalAPI
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Task StopAsync(CancellationToken cancellationToken)
|
public Task StopAsync()
|
||||||
{
|
{
|
||||||
|
cancellation.Cancel();
|
||||||
return null;
|
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,6 +661,8 @@ namespace Kyoo.InternalAPI
|
|||||||
cmd.CommandText = "SELECT LAST_INSERT_ROWID()";
|
cmd.CommandText = "SELECT LAST_INSERT_ROWID()";
|
||||||
long showID = (long)cmd.ExecuteScalar();
|
long showID = (long)cmd.ExecuteScalar();
|
||||||
|
|
||||||
|
if (show.Genres != null)
|
||||||
|
{
|
||||||
cmd.CommandText = "INSERT INTO genresLinks (genreID, showID) VALUES($genreID, $showID);";
|
cmd.CommandText = "INSERT INTO genresLinks (genreID, showID) VALUES($genreID, $showID);";
|
||||||
foreach (Genre genre in show.Genres)
|
foreach (Genre genre in show.Genres)
|
||||||
{
|
{
|
||||||
@ -669,6 +671,7 @@ namespace Kyoo.InternalAPI
|
|||||||
cmd.Parameters.AddWithValue("$showID", showID);
|
cmd.Parameters.AddWithValue("$showID", showID);
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(show.studio != null)
|
if(show.studio != null)
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@ namespace Kyoo.InternalAPI.MetadataProvider
|
|||||||
|
|
||||||
public string GetID(string externalIDs)
|
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 '='
|
int startIndex = externalIDs.IndexOf(Provider) + Provider.Length + 1; //The + 1 is for the '='
|
||||||
return externalIDs.Substring(startIndex, externalIDs.IndexOf('|', startIndex) - startIndex);
|
return externalIDs.Substring(startIndex, externalIDs.IndexOf('|', startIndex) - startIndex);
|
||||||
|
@ -74,7 +74,7 @@ namespace Kyoo.InternalAPI
|
|||||||
|
|
||||||
public Episode Merge(IEnumerable<Episode> episodes)
|
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.
|
//For all the following methods, it should use all providers and merge the data.
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
<Company>SDG</Company>
|
<Company>SDG</Company>
|
||||||
<Authors>Anonymus-Raccoon</Authors>
|
<Authors>Anonymus-Raccoon</Authors>
|
||||||
<RepositoryUrl>https://github.com/AnonymusRaccoon/Kyoo</RepositoryUrl>
|
<RepositoryUrl>https://github.com/AnonymusRaccoon/Kyoo</RepositoryUrl>
|
||||||
|
<StartupObject>Kyoo.Program</StartupObject>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using Microsoft.AspNetCore;
|
using Microsoft.AspNetCore;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace Kyoo
|
namespace Kyoo
|
||||||
|
@ -4,7 +4,6 @@ using Microsoft.AspNetCore.Builder;
|
|||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.SpaServices.AngularCli;
|
using Microsoft.AspNetCore.SpaServices.AngularCli;
|
||||||
using Microsoft.AspNetCore.StaticFiles;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Web.Http;
|
using System.Web.Http;
|
||||||
@ -36,7 +35,7 @@ namespace Kyoo
|
|||||||
services.AddSingleton<ITranscoder, Transcoder>();
|
services.AddSingleton<ITranscoder, Transcoder>();
|
||||||
|
|
||||||
//Services used to get informations about files and register them
|
//Services used to get informations about files and register them
|
||||||
services.AddHostedService<Crawler>();
|
services.AddSingleton<ICrawler, Crawler>();
|
||||||
services.AddSingleton<IThumbnailsManager, ThumbnailsManager>();
|
services.AddSingleton<IThumbnailsManager, ThumbnailsManager>();
|
||||||
services.AddSingleton<IMetadataProvider, ProviderManager>();
|
services.AddSingleton<IMetadataProvider, ProviderManager>();
|
||||||
}
|
}
|
||||||
@ -54,7 +53,7 @@ namespace Kyoo
|
|||||||
app.UseHsts();
|
app.UseHsts();
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
//app.UseHttpsRedirection();
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
app.UseSpaStaticFiles();
|
app.UseSpaStaticFiles();
|
||||||
|
|
||||||
|
Binary file not shown.
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"https_port": 44300,
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Warning"
|
"Default": "Warning"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user