From 79a2cd810b74a5b550c871073657fbd28ff8c3c4 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Mon, 16 Aug 2021 15:12:48 +0200 Subject: [PATCH 01/38] Fixing regexs for windows --- Kyoo.Transcoder | 2 +- Kyoo.WebApp/Kyoo.WebApp.csproj | 2 +- Kyoo/Kyoo.csproj | 2 +- Kyoo/settings.json | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Kyoo.Transcoder b/Kyoo.Transcoder index 75b49dcd..3315700b 160000 --- a/Kyoo.Transcoder +++ b/Kyoo.Transcoder @@ -1 +1 @@ -Subproject commit 75b49dcd25aed20eda7454faa4bc016a12c51680 +Subproject commit 3315700b84e8aaa8cd66edcd35257ec06bff5efc diff --git a/Kyoo.WebApp/Kyoo.WebApp.csproj b/Kyoo.WebApp/Kyoo.WebApp.csproj index c8c5fe64..e4a4158e 100644 --- a/Kyoo.WebApp/Kyoo.WebApp.csproj +++ b/Kyoo.WebApp/Kyoo.WebApp.csproj @@ -65,6 +65,6 @@ - + diff --git a/Kyoo/Kyoo.csproj b/Kyoo/Kyoo.csproj index e76cf005..28ac7ff0 100644 --- a/Kyoo/Kyoo.csproj +++ b/Kyoo/Kyoo.csproj @@ -35,7 +35,7 @@ - + diff --git a/Kyoo/settings.json b/Kyoo/settings.json index a3d90396..de2d784e 100644 --- a/Kyoo/settings.json +++ b/Kyoo/settings.json @@ -45,12 +45,12 @@ "scan": "24:00:00" } }, - + "media": { "regex": [ - "^\\/?(?.+)?\\/(?.+?)(?: \\((?\\d+)\\))?\\/\\k(?: \\(\\d+\\))? S(?\\d+)E(?\\d+)\\..*$", - "^\\/?(?.+)?\\/(?.+?)(?: \\((?\\d+)\\))?\\/\\k(?: \\(\\d+\\))? (?\\d+)\\..*$", - "^\\/?(?.+)?\\/(?.+?)(?: \\((?\\d+)\\))?\\/\\k(?: \\(\\d+\\))?\\..*$" + "^[\\/\\\\]*(?.+)?[\\/\\\\]+(?.+?)(?: \\((?\\d+)\\))?[\\/\\\\]+\\k(?: \\(\\d+\\))? S(?\\d+)E(?\\d+)\\..*$", + "^[\\/\\\\]*(?.+)?[\\/\\\\]+(?.+?)(?: \\((?\\d+)\\))?[\\/\\\\]+\\k(?: \\(\\d+\\))? (?\\d+)\\..*$", + "^[\\/\\\\]*(?.+)?[\\/\\\\]+(?.+?)(?: \\((?\\d+)\\))?[\\/\\\\]+\\k(?: \\(\\d+\\))?\\..*$" ], "subtitleRegex": [ "^(?.+)\\.(?\\w{1,3})\\.(?default\\.)?(?forced\\.)?.*$" From 18c98fb4f172e321465ae88b9bb068d707879468 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Mon, 16 Aug 2021 15:53:59 +0200 Subject: [PATCH 02/38] Normalizing / and \ on windows --- Kyoo/Controllers/Transcoder.cs | 46 +++++++++++++++++++++------------- Kyoo/Tasks/Crawler.cs | 2 +- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/Kyoo/Controllers/Transcoder.cs b/Kyoo/Controllers/Transcoder.cs index a8adc9d1..379c1827 100644 --- a/Kyoo/Controllers/Transcoder.cs +++ b/Kyoo/Controllers/Transcoder.cs @@ -22,29 +22,40 @@ namespace Kyoo.Controllers private const string TranscoderPath = "transcoder"; [DllImport(TranscoderPath, CallingConvention = CallingConvention.Cdecl)] - public static extern int init(); + private static extern int init(); - [DllImport(TranscoderPath, CallingConvention = CallingConvention.Cdecl)] - public static extern int transmux(string path, string outpath, out float playableDuration); - - [DllImport(TranscoderPath, CallingConvention = CallingConvention.Cdecl)] - public static extern int transcode(string path, string outpath, out float playableDuration); + public static int Init() => init(); - [DllImport(TranscoderPath, CallingConvention = CallingConvention.Cdecl)] + [DllImport(TranscoderPath, CallingConvention = CallingConvention.Cdecl, + CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)] + private static extern int transmux(string path, string outpath, out float playableDuration); + + public static int Transmux(string path, string outPath, out float playableDuration) + { + path = path.Replace('\\', '/'); + outPath = outPath.Replace('\\', '/'); + return transmux(path, outPath, out playableDuration); + } + + [DllImport(TranscoderPath, CallingConvention = CallingConvention.Cdecl, + CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)] private static extern IntPtr extract_infos(string path, string outpath, - out int length, - out int trackCount, + out uint length, + out uint trackCount, bool reextracct); - + [DllImport(TranscoderPath, CallingConvention = CallingConvention.Cdecl)] - private static extern void free(IntPtr ptr); - - + private static extern void free_streams(IntPtr streams, uint count); + + public static Track[] ExtractInfos(string path, string outPath, bool reextract) { + path = path.Replace('\\', '/'); + outPath = outPath.Replace('\\', '/'); + int size = Marshal.SizeOf(); - IntPtr ptr = extract_infos(path, outPath, out int arrayLength, out int trackCount, reextract); + IntPtr ptr = extract_infos(path, outPath, out uint arrayLength, out uint trackCount, reextract); IntPtr streamsPtr = ptr; Track[] tracks; @@ -68,7 +79,7 @@ namespace Kyoo.Controllers tracks = Array.Empty(); if (ptr != IntPtr.Zero) - free(ptr); // free_streams is not necessary since the Marshal free the unmanaged pointers. + free_streams(ptr, trackCount); return tracks; } } @@ -83,7 +94,7 @@ namespace Kyoo.Controllers _options = options; _library = library; - if (TranscoderAPI.init() != Marshal.SizeOf()) + if (TranscoderAPI.Init() != Marshal.SizeOf()) throw new BadTranscoderException(); } @@ -122,8 +133,7 @@ namespace Kyoo.Controllers Task.Factory.StartNew(() => { - string cleanManifest = manifest.Replace('\\', '/'); - transmuxFailed = TranscoderAPI.transmux(episode.Path, cleanManifest, out playableDuration) != 0; + transmuxFailed = TranscoderAPI.Transmux(episode.Path, manifest, out playableDuration) != 0; }, TaskCreationOptions.LongRunning); while (playableDuration < 10 || !File.Exists(manifest) && !transmuxFailed) await Task.Delay(10); diff --git a/Kyoo/Tasks/Crawler.cs b/Kyoo/Tasks/Crawler.cs index cc2762c4..6e94a97f 100644 --- a/Kyoo/Tasks/Crawler.cs +++ b/Kyoo/Tasks/Crawler.cs @@ -146,7 +146,7 @@ namespace Kyoo.Tasks string[] subtitles = files .Where(FileExtensions.IsSubtitle) - .Where(x => !x.Contains("/Extra/")) + .Where(x => !x.Contains("Extra")) .Where(x => tracks.All(y => y.Path != x)) .ToArray(); percent = 0; From d6c720319e990c54ec0bdb6aa68398172edebdaa Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Thu, 19 Aug 2021 17:31:50 +0200 Subject: [PATCH 03/38] Fixing the transcoder on windows --- Kyoo.Transcoder | 2 +- Kyoo.WebApp/Kyoo.WebApp.csproj | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Kyoo.Transcoder b/Kyoo.Transcoder index 3315700b..48782f89 160000 --- a/Kyoo.Transcoder +++ b/Kyoo.Transcoder @@ -1 +1 @@ -Subproject commit 3315700b84e8aaa8cd66edcd35257ec06bff5efc +Subproject commit 48782f895a40f28eda5e861fcaa624c0eab54076 diff --git a/Kyoo.WebApp/Kyoo.WebApp.csproj b/Kyoo.WebApp/Kyoo.WebApp.csproj index e4a4158e..5c99d8f0 100644 --- a/Kyoo.WebApp/Kyoo.WebApp.csproj +++ b/Kyoo.WebApp/Kyoo.WebApp.csproj @@ -35,6 +35,11 @@ + + + + + From 01875697480362d45b6335b328ffd49ecddfef6d Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Thu, 19 Aug 2021 17:57:07 +0200 Subject: [PATCH 04/38] Authentication: Using absolute paths for redirect uris --- Kyoo.Authentication/AuthenticationModule.cs | 10 +++++++++- Kyoo.Authentication/Kyoo.Authentication.csproj | 2 +- Kyoo.WebApp/Front | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Kyoo.Authentication/AuthenticationModule.cs b/Kyoo.Authentication/AuthenticationModule.cs index 61f3d929..805b01cd 100644 --- a/Kyoo.Authentication/AuthenticationModule.cs +++ b/Kyoo.Authentication/AuthenticationModule.cs @@ -110,6 +110,14 @@ namespace Kyoo.Authentication CertificateOption certificateOptions = new(); _configuration.GetSection(CertificateOption.Path).Bind(certificateOptions); + clients.AddRange(IdentityContext.GetClients()); + foreach (Client client in clients) + { + client.RedirectUris = client.RedirectUris + .Select(x => x.StartsWith("/") ? publicUrl + x : x) + .ToArray(); + } + services.AddIdentityServer(options => { options.IssuerUri = publicUrl; @@ -120,7 +128,7 @@ namespace Kyoo.Authentication .AddInMemoryIdentityResources(IdentityContext.GetIdentityResources()) .AddInMemoryApiScopes(IdentityContext.GetScopes()) .AddInMemoryApiResources(IdentityContext.GetApis()) - .AddInMemoryClients(IdentityContext.GetClients().Concat(clients)) + .AddInMemoryClients(clients) .AddProfileService() .AddSigninKeys(certificateOptions); diff --git a/Kyoo.Authentication/Kyoo.Authentication.csproj b/Kyoo.Authentication/Kyoo.Authentication.csproj index 080795b2..313f57ce 100644 --- a/Kyoo.Authentication/Kyoo.Authentication.csproj +++ b/Kyoo.Authentication/Kyoo.Authentication.csproj @@ -22,7 +22,7 @@ - + login/%(RecursiveDir)%(Filename)%(Extension) Always diff --git a/Kyoo.WebApp/Front b/Kyoo.WebApp/Front index dca10903..e2941691 160000 --- a/Kyoo.WebApp/Front +++ b/Kyoo.WebApp/Front @@ -1 +1 @@ -Subproject commit dca10903ff54a8999732695b5c2a0a5c94f85200 +Subproject commit e2941691f3f57523f2094a036bf10017195f1b58 From 42469bfa67cc2e5b1cf0ccabf4a4fe1de24a8f3b Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Fri, 20 Aug 2021 19:33:03 +0200 Subject: [PATCH 05/38] WindowsTrait: Creating a custom host for windows with a notification icon. Starting to create a inno setup installer --- Kyoo.WindowsHost/Kyoo.WindowsHost.csproj | 22 ++++ Kyoo.WindowsHost/Program.cs | 28 +++++ Kyoo.WindowsHost/SystemTrait.cs | 135 +++++++++++++++++++++++ Kyoo.WindowsHost/kyoo.ico | Bin 0 -> 15406 bytes Kyoo.sln | 10 ++ Kyoo/CoreModule.cs | 5 +- Kyoo/Kyoo.csproj | 3 +- Kyoo/Program.cs | 56 ++++++++-- deployment/kyoo-windows.iss | 39 +++++++ 9 files changed, 282 insertions(+), 16 deletions(-) create mode 100644 Kyoo.WindowsHost/Kyoo.WindowsHost.csproj create mode 100644 Kyoo.WindowsHost/Program.cs create mode 100644 Kyoo.WindowsHost/SystemTrait.cs create mode 100644 Kyoo.WindowsHost/kyoo.ico create mode 100644 deployment/kyoo-windows.iss diff --git a/Kyoo.WindowsHost/Kyoo.WindowsHost.csproj b/Kyoo.WindowsHost/Kyoo.WindowsHost.csproj new file mode 100644 index 00000000..fe167974 --- /dev/null +++ b/Kyoo.WindowsHost/Kyoo.WindowsHost.csproj @@ -0,0 +1,22 @@ + + + + WinExe + net5.0-windows + enable + true + Kyoo.Host.Windows + + + + + + + + + + PreserveNewest + + + + \ No newline at end of file diff --git a/Kyoo.WindowsHost/Program.cs b/Kyoo.WindowsHost/Program.cs new file mode 100644 index 00000000..ace92e24 --- /dev/null +++ b/Kyoo.WindowsHost/Program.cs @@ -0,0 +1,28 @@ +using System.Threading.Tasks; +using Autofac; +using Microsoft.Extensions.Hosting; + +namespace Kyoo.Host.Windows +{ + public static class Program + { + /// + /// The main entry point for the application that overrides the default host (). + /// It adds a system trait for windows and since the host is build as a windows executable instead of a console + /// app, the console is not showed. + /// + public static async Task Main(string[] args) + { + Kyoo.Program.SetupDataDir(args); + + IHost host = Kyoo.Program.CreateWebHostBuilder(args) + .ConfigureContainer(builder => + { + builder.RegisterType().As().SingleInstance(); + }) + .Build(); + + await Kyoo.Program.StartWithHost(host); + } + } +} \ No newline at end of file diff --git a/Kyoo.WindowsHost/SystemTrait.cs b/Kyoo.WindowsHost/SystemTrait.cs new file mode 100644 index 00000000..22009ab1 --- /dev/null +++ b/Kyoo.WindowsHost/SystemTrait.cs @@ -0,0 +1,135 @@ +using System; +using System.Diagnostics; +using System.Drawing; +using System.IO; +using System.Threading; +using System.Windows.Forms; +using Autofac; +using Kyoo.Models.Options; +using Microsoft.Extensions.Options; + +namespace Kyoo.Host.Windows +{ + /// + /// A singleton that add an notification icon on the window's toolbar. + /// + public sealed class SystemTrait : IStartable, IDisposable + { + /// + /// The options containing the . + /// + private readonly IOptions _options; + + /// + /// The thread where the trait is running. + /// + private Thread? _thread; + + + /// + /// Create a new . + /// + /// The options to use. + public SystemTrait(IOptions options) + { + _options = options; + } + + /// + public void Start() + { + _thread = new Thread(() => InternalSystemTrait.Run(_options)) + { + IsBackground = true + }; + _thread.Start(); + } + + /// + public void Dispose() + { + // TODO not sure that the trait is ended and that it does shutdown but the only way to shutdown the + // app anyway is via the Trait's Exit or a Signal so it's fine. + _thread?.Join(); + _thread = null; + } + + /// + /// The internal class for . It should be invoked via + /// . + /// + private class InternalSystemTrait : ApplicationContext + { + /// + /// The options containing the . + /// + private readonly IOptions _options; + + /// + /// The Icon that is displayed in the window's bar. + /// + private readonly NotifyIcon _icon; + + /// + /// Create a new . Used only by . + /// + /// The option containing the public url. + private InternalSystemTrait(IOptions options) + { + _options = options; + + Application.ApplicationExit += (_, _) => Dispose(); + + _icon = new NotifyIcon(); + _icon.Text = "Kyoo"; + _icon.Icon = new Icon(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "kyoo.ico")); + _icon.Visible = true; + _icon.MouseClick += (_, e) => + { + if (e.Button != MouseButtons.Left) + return; + _StartBrowser(); + }; + + _icon.ContextMenuStrip = new ContextMenuStrip(); + _icon.ContextMenuStrip.Items.AddRange(new ToolStripItem[] + { + new ToolStripMenuItem("Exit", null, (_, _) => { Environment.Exit(0); }) + }); + } + + /// + /// Run the trait in the current thread, this method does not return while the trait is running. + /// + /// The options to pass to . + public static void Run(IOptions options) + { + using InternalSystemTrait trait = new(options); + Application.Run(trait); + } + + /// + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + _icon.Visible = false; + _icon.Dispose(); + } + + /// + /// Open kyoo's page in the user's default browser. + /// + private void _StartBrowser() + { + Process browser = new() + { + StartInfo = new ProcessStartInfo(_options.Value.PublicUrl.ToString()) + { + UseShellExecute = true + } + }; + browser.Start(); + } + } + } +} \ No newline at end of file diff --git a/Kyoo.WindowsHost/kyoo.ico b/Kyoo.WindowsHost/kyoo.ico new file mode 100644 index 0000000000000000000000000000000000000000..61e160247cb9651a48c86119ecae4e3a7d0558cc GIT binary patch literal 15406 zcmeHO378bswLVqV)%(78Pfzc&GR!_bOV83X;DRWEI&n7|*PuxhiMw&0F(m3!K@>0u zYFt4CjRqA#Anr>@TzSemphn}4pdd`2_urZs0A`n-Kr=xz7wIkm(_0&)7}qR^qlY&u(keIY^u3v zo5AAyn<`6dbb9BDR5s;SYFY6YYJTGp8ofM@_jlBj_I?=er~F~|v|PpJrh7T&jdQ|b z=0KootJ?VZ7jpf=k124%^<*uq!21rsJn%bl75t+%0~dMSTu{-?rp7s(43~4VUf{e4iC!m%o@6TsaH{?r|@0_1p@xT{v)0kn;Y+ASJQP|kT{$TO$*rDbUwSH!}9vd-)>a` zBRA^I?g#LE9Z&#Z)@x0ZKkjyOp!@_jG|XYOW**B8kM-&6Cv8-`74J#Km%U02OWvZ2 zX$Mewx0tUxwn6>neRfx$(^K@BVlC?>+mJVv>hX7~-B+DK*;$>`zIv(LwPH5qR#s3q zi}f9kljHYG3mtb@tvuZ7Z-s zw>L5WpTloFhid~39qOW7Zcw&?hghQK^(M-`7p2zTlKL&0?`at>e!Dx z%WqQIWzc;oIFKYQM_Q2CCAg4F%{I@yqEbQ*76|m=Du4Fk1Q54i+-ba1IMv% z1nn+1IZ`Y;%Yh=6-RV_wH2qsjB+kJ+Jp%6x1KP+OY@pC-WmNuPIc1hNQ`4H9hL(4# z>7ey)>gn0ney#P7J%C{^If}kh4igs!%h+Ca78`1M*i<==4Mp8wDByr`SO%RugT5Ex zit#D9oeEC5lxiON1vS4pi?Y2>Qg-bkYU{m$4qcz2*IB<04%_?p4)mXPnm8V*Wq0P6 zZ0Wp@Egg5TrRqX9yUW;&`C$^!$y<#&Ws|{Pv_?r^ynyPLJW0)Oy-zJGzo5oHucgN4 z@1)@`w|<-ch5TaA7X2p*E7_O1fNfoOvMKinTWfFNV5pu8t$Ga+i#{JR>$iIR^&5?q z)83b|uYN$;m0wb3Sud5{GMi%K&Zg3F#ru#QYShg1_VJI~ja-EOQ;|{*)t$=D_M6zy zzL0ITGdWt20{ZHd4QGd%XwYhANthNNxic7;MpXbFNIk>62C88 z(-aT{ge?)i;Ew)Q4&N6Wp;Pz*+SnJP|8ywI(IE%3H**;qvJ2Q!dpG)T+upzMKLQn} zvb|{v>)V&GKJ#GSo;Wpcch_uG4W4yap0D9|#XR{PFcugI901e;g2Q0T;e*z{@b`r7 zi=AfpJ$_Cmt2kKsBQ`b9WlO`|T$ntNi$W3jU}aoTJcb=jH?ukS2R5}n#P+IRaUfWm z510*kyQ=G-BZ`!VTW zEeGt-f4}|*`%gy8IM{p^yM|3>OY0mqG(X9@)|b%tOKiw3f*!8tXre>wyTonV-aq_O z=)jQooAr5*N#AGH>-rQ~?t|>>$nU=&wtS-K94!a*_mBCP^tdp-Da`*g7yEsjDok>; z_7L`Duh9HoDf>3-nqOjl%Mv!WFJNcG^&E?5x!CLEbiY3==1@LvGvtLmvFmlhHx~VW zq?6@8;Y>7-LZL}iT-<|xMauz;#l90j|Iu)gLp49(g8E}I|0=jB65&*;oI@2SvN7`q zt#4cX47S(bqH(Zf?&V0yC{7g=aMWejWR5}ZkXg-JbaGxNOMN;;-m23nFUd0flytfl z^7*PM8Z8%{qvZgt{~+dHL18t!n}5OXj%&G~vYQjh8gPhnByk9v>gKZA{6}`-Jmjgp zh%GhKVHc;dui_^hOdZHxPcrYZ*thyErj2fs{vGV6FX6YJgq>c9asN+zt^~f>a=4-C zzX1J53R-a9ngQKD&d!#J9I8HrlZ8V$5QMlyFi zi1X5o94tPG{pqo6tbdf%wx`(HF_FD>C$J}6lD7x4+jJGvHdE!C&6K#{Yx0j;Pxg|B z;Jb{&SmWfq&z8dzTK`zDoD8KoTz(w8GS`B`e4MwQW@E!6THi{`GFIANWMkWGHdXyR zZ*Z6Ab+)3fpl{*J?yKeS!1n&rIPXOhwd^Z9mMxXn zv08l}%ayZOs+^UVhTfBxYwp^j%iQ^?uKJhn%8}N$$y@rO6zzV5hD=>ZO)syf_O;Ja z$I8=b*z#h^KK-rxPq}Pd;P$c4n`F1Yo^AeiRz11A64_~)_z<$YL(PLpA? z+hO~_;dHFfo9r)2I?EE0bWf5gG*?a?b)zmfVZ3SVT}PWHJlRO&ANNzoss`#Jr8ukXzKQc}_u2#Z|9#^+u{#P-;PKQIk=9{3}015gG015NY4bvToowKF=+ z-W&H2IywY64mcPPeecdr;r6#_f`jOHuYHRjv;e6Ah|m9S|4SMuML*TR$-w`CI0;yO zCk^vbJ3C{UYinA>ImG%9_rLE=a29+;Jj8}rsf%njF9Px6JYfce9O9Ypqb!1x;4bXA zlg#E2e1tU40p*BsBp`aU^einBK5~Aajs^wfFg^S)E0xPuG8t&XCT8YtdZ-0^YHu+uvR)L5*bQeT?KT| zL2k$~Xs?7_5cp@e?flW%ry|yBGbrpf>DVKH*rywD0-TpW6Ea9T#0eDTSX6rQs8L;U5m#tG)0ajD_xa{U3?C6Mqx*?FQ#C&TJ741}?A|5Nj}Q zGwID+WS!+p(wR4s&a{E_=6A{NenO7MCn(LCW2vpV12N=s%?1;R_`C2=k$WhyQQ$-i zMXond<>MB_5badG#!1zm0^$lB_`Ze8UxzIb@_ehd3xA<=!99kUpNRX#>=q6^~8^xd`jy#~7azz~BeC9zlxXFtQ|vlfS!}Qj_Ya zdO?<&mW`m6RYy{DZ#Ols?xr@JPukbE&~W6e&U@BG%rdaQa_qui=)b^f(D)~jt4z9_ z91c~oGj${z%g<%~kaO9H7_zbCgsq0e!5<14B%AA5*r$cy{0O)|fVp)aa3?9o>10X& zhWtmIPo7W=82eUVXU1!Rp+xMJDts~GjP3$Ety~Djio1T)%$C{QdILstbJj(J_kOLCFyUn zEWazOrWKN{XQnL_o8?x&{LUZ(8oze0w;QFhgPlwI)#@{GTwgWo=aE?FJW zV$-wtc|I7FZZG^1F9!c2k5`Mu`D(|rz2i2-&hKSQ?ryfU+`^V2KV@sMiESn;+fZ zEk2meUherW^e^U59CN3izlURqEc(n_j);0Y?aekv7BIFrh+ z&d{hCwtsZ~_pjf6{vvK&gnWKH(a6Et)3o@VtyAO<<|9u0I6JDY=5TBTrx05a@qGdD zPSRoFn8Thga2NJ@V`H{iDkp!f%f7H#Zhd`=)biR^sd3pxsrvV?P_pMiV%BE#HzKpqp#&+ z)GSP6Q~Mtf|6k0`svEcX-WD1uGTrh=rsN&LG)%6)2tqeqt{j4%7ifKpcnxBKIzAvhb64lwmu6-24== zRV`m7@--q~CG=VBb|79{!qKt=I8=Wc>K3lS+z(25^f3e4jJkwAP zmyBjl_4#bi+=Q4PV!Un7vY~!<-coW|-X7`x+Tv;XSZ|K6l4R2|xaUi;UC#%%yMf;T zX96REE}$J~0!jcOgBXXwwhMoeYZP{WFy~Q>oI|<*H7e;0M=D3NxBgN#H{TEbPlNvy z4kyNNkuS_89tRg=tkV7nM^nStR|D>Cw`%cHL&uYd(Jn$v_6F2x9Fg}r<9$xEW2;Fu zZc!w86Lj|l@Hy~TI8lGZbt(vs1I_?W0YnW;4oCny#+-J`KcVHT26HAh)T#uLizwk( zaT^D!#CL6%VQIGnUlA|#`rHJhpaUxp7(PS3~hn#^N!X$A2J@7E>?frOXI_A>P zI8e~a1r9fICcut!?qCP1hYHS8`KFA-GcwL$d$-*)YmmPyzpBu1-A7*FsWDZrG#EFt7 zj+b_#Cg>RUSD(u+O2k=9nR5E1t+j4iv3-zGZ9~h?Lv%E zg-q(#K9lYvhhAA>(n)_(CFyzOXPyVoMc5B-#Qu09{F55+7jsFpUG%>ze~}x63|N;% z{vbzCNcBR*=9t3Oyp|d ziNj~qy#W8}W(o$+rf^uS3DNezU*u~C=Knx$R_h0KV~JD)hZ;^{PuB!?c1>kl+wE+@ zdNwr+o4OQs<^|+VpMwlb+0^!XcGdn0dCk$tB^C8^$2u3|Ihczp!59cz2b-tGsgbYh z^CGwAgbZd?5qYLQNtVBafAuE0-E-luUynT7ulwomnSa`4m=}--T*#KT``BB12^Xdgz}yRA-q^I- zw-V??@D>nxWnu3`o>S!7q5C}YRDCY+M}F=rRZ%v8{|A`&uOde_Urr`(lhdeq=x@8~ zU*zkte36R`UtSC)*GYdPZLfS*(G5{_4Na5!^3a%!j{Yt^9r07sB_g&gc$%F|f4 z_k;gb@c$L1QWqf4C~T`}JMkB1My=k$Y2#?5gbT_K)N+o|p(8k%s^X%82&bcQPNge2 zhMcpn`aCvgX0zPa>i0H3Jt7Pe;Y)@0CUm*D$N94bXFI1U>d3~(G{DryMDd_he~ zUgRZVck-|~$cxK)J?4vEr)&d01NWzNI{8{epM>2RiMT-*a+Fz|@tXVT|DC@C`ziQ) zVLv0VZw1K)_SgT2y}2upD;~?SAqQx>PZ!3yC>q0<4B=qu$!x8;gO%oGY-oG}`O}-( zQ*#;W5n*3553<_0l&y6$P*ZRg$BJ4wT3Eyd-T;SeRt{NAeK^}~h5g(DpXEzoZ(wUa z1&@ymLdTd(0@ z-I-iiK7!*Z*pX;4)?+b;(#Ns2dM5b441GTaJAVWF>c?q$SbOy~Y_6OFAN3k`550)} z<)^bRIg&m8>b%Py>~mS1n>|+R2Cv2Vfy1c2iMo{~;64|eW`Xy;z^%Z~@VyZjgqe73aDW>@od7>{!~Qa%QDypB^L@J}Ai)~e~OYk3Ji z&ZF$gUeAH1b2xy#z*BYt^0+6kqxf7+25Ze!HkVwSH-!(&8y#g^jn?o6v(^1qi^cq= z$)KO7*XgbVvlD@%1~3X&!F_MBrk(hs-j(6Ia~%A`vBS{sMC7)g!alkf^*;Brv+X9F z1AYd3au6rNwH!>Ir0HMd-}b1M1NOIqf6Zw2Co}8|Rh;Q1Vn5~=w0~E7@FO--SSVmaAqv*WY3UG za8A4z{wDmG_J=SI_p>8&BYTI8=Rg|gf$}SnzkiT*SL&4CvTb6si zxeI@Bj!I$u#v?VTM?MyHELWhO2R=b|9>xLn70r*qpPvQ2-=T3=o1S6074`=?cvIUP z)FDq~^N`c?reG#-v<9~6Jq=$f(bGSZ$|inDLuYvk!08H_iN7Eg!d83AS#M%z@7(N7?&QXw+({=%VE`^wu?0|HMbs z^q2Rk`PI3UdHOUey{VX@KXy^1TlmF$nkRo}yz{5s^LJv834}NXe>0TIvbXqX)ZJak zrXdp%Kbgu(`Baw5G~}hyoAXlHP21$kDVvn~TR+k@PJ2hGx@d*2Xw)lGxZ*h}oOw)+ zjk#AYy5M%Iyz^0Ne0Djtu6&m|dY_=&svhcmdn65CHIy1(3*Zd@o#;OW-zVvIaiKTJ z0e^zM!76r#I@nQgC|km#SsxtDa$rne@{h_(zC*?JYdLz-M@rfF6>9yjU(`4DJf=3E zbB~%mX0opFxXb0L)6SrZt4^f4M<-CrD^F7Es&}Yk%_~yw?YVN-+rLqUtvFtjA-Coq zoBspzN9^t5e*(fbGyANTyvOS3^VmIKdmVwz4tsEu!4lda8^WJTdjBV+dOjwD|9#0d z^i3sx#1ggk!dYt9gd2_BlP)!%GyPP%xh_Gd2bJb(J_r|`q`g{XBxofSJ!=j5~)H@IB(cb#6( zTXvV{Wuw)(NHN$Rlys&!r08cO&UUwKk584O2T#yd|9reU?CMkXKe}U#wddiS_1eW1 zmY&5y)NOdcFNgYpOQHL@lw19j)Vcc4sH=Dda?FvtR$oe;YYs;&u||`lUxuA$`>x-1 z;*b3+kGM@fs?|#A^G?)hnN;O#qt*PbIp|wvNyZ*AC*#xfp@PfE;XRFv_T$0-XoNYA zBztV6u3$u$u6kUHI{eo)`V*&@884a_xAr{l_w_7BZ9ihPqUPa%wPR@5nv1Dx&25n5 z8Lc*@W6d(uWjrKz^-hF*r)n~YI{tmPo%kbulJ~-Y4O!XvRoAIabw8$>nqi1Fr}2LoVJ%mw?Kf%oC*4-69B-j!#F|g;F;dTLJ@sHsih5n~ z|1hHvA3Pju^|19LXxQ3IsJ-_=)Kk2T>k28i_Rmt+nguj$-Ie%TC*@uj`L=zv?ffy> zJ~e>9sEzX&)Xh$V+H2A&&!9eUwrsUdl9Ta^m8QBM>T<2ask5^Lv3@7&u2JKX+fSQ; zxbmp~ve7Z?!kP@j*B*g-n9EUOuQR0ej$SxhxYf%sC`|#7C&$6Jqq@; z8{9_&O_ba1|1a%sEC%ymci@lffzL4xp8;zTkGKopMg58JU6F%;-x`US2I}1R*FNCY z9h;VKku^IXhpo*0%}PTNGq3rp51)gS#n@!t@$}cn>{kvzbasS`#-x~OTtAYOp D&GxeA literal 0 HcmV?d00001 diff --git a/Kyoo.sln b/Kyoo.sln index 701d760b..6ab7d6d9 100644 --- a/Kyoo.sln +++ b/Kyoo.sln @@ -19,6 +19,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kyoo.Tests", "tests\Kyoo.Te EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kyoo.WebApp", "Kyoo.WebApp\Kyoo.WebApp.csproj", "{2374D500-1ADB-4752-85DB-8BB0DDF5A8E8}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kyoo.WindowsHost", "Kyoo.WindowsHost\Kyoo.WindowsHost.csproj", "{98851001-40DD-46A6-94B3-2F8D90722076}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -65,5 +67,13 @@ Global {2374D500-1ADB-4752-85DB-8BB0DDF5A8E8}.Debug|Any CPU.Build.0 = Debug|Any CPU {2374D500-1ADB-4752-85DB-8BB0DDF5A8E8}.Release|Any CPU.ActiveCfg = Release|Any CPU {2374D500-1ADB-4752-85DB-8BB0DDF5A8E8}.Release|Any CPU.Build.0 = Release|Any CPU + {4FF1ECD9-6EEF-4440-B037-A661D78FB04D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4FF1ECD9-6EEF-4440-B037-A661D78FB04D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4FF1ECD9-6EEF-4440-B037-A661D78FB04D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4FF1ECD9-6EEF-4440-B037-A661D78FB04D}.Release|Any CPU.Build.0 = Release|Any CPU + {98851001-40DD-46A6-94B3-2F8D90722076}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {98851001-40DD-46A6-94B3-2F8D90722076}.Debug|Any CPU.Build.0 = Debug|Any CPU + {98851001-40DD-46A6-94B3-2F8D90722076}.Release|Any CPU.ActiveCfg = Release|Any CPU + {98851001-40DD-46A6-94B3-2F8D90722076}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/Kyoo/CoreModule.cs b/Kyoo/CoreModule.cs index b6445b3d..2d1e35e8 100644 --- a/Kyoo/CoreModule.cs +++ b/Kyoo/CoreModule.cs @@ -70,10 +70,11 @@ namespace Kyoo builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().As().SingleInstance(); + builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().SingleInstance(); @@ -135,8 +136,6 @@ namespace Kyoo }); services.AddHttpClient(); - - services.AddHostedService(x => x.GetService() as TaskManager); } /// diff --git a/Kyoo/Kyoo.csproj b/Kyoo/Kyoo.csproj index 28ac7ff0..d4a573f9 100644 --- a/Kyoo/Kyoo.csproj +++ b/Kyoo/Kyoo.csproj @@ -44,7 +44,8 @@ - + diff --git a/Kyoo/Program.cs b/Kyoo/Program.cs index e9f21a0b..f905b8ba 100644 --- a/Kyoo/Program.cs +++ b/Kyoo/Program.cs @@ -7,6 +7,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; +using SEnvironment = System.Environment; namespace Kyoo { @@ -28,20 +29,23 @@ namespace Kyoo #else private const string Environment = "Production"; #endif - + /// /// Main function of the program /// /// Command line arguments - public static async Task Main(string[] args) + public static Task Main(string[] args) + { + SetupDataDir(args); + return StartWithHost(CreateWebHostBuilder(args).Build()); + } + + /// + /// Start the given host and log failing exceptions. + /// + /// The host to start. + public static async Task StartWithHost(IHost host) { - if (!File.Exists(JsonConfigPath)) - File.Copy(Path.Join(AppDomain.CurrentDomain.BaseDirectory, JsonConfigPath), JsonConfigPath); - - IHost host = CreateWebHostBuilder(args) - .UseEnvironment(Environment) - .Build(); - try { host.Services.GetRequiredService>() @@ -65,6 +69,7 @@ namespace Kyoo return builder.SetBasePath(System.Environment.CurrentDirectory) .AddJsonFile(JsonConfigPath, false, true) .AddEnvironmentVariables() + .AddEnvironmentVariables("KYOO_") .AddCommandLine(args); } @@ -73,7 +78,7 @@ namespace Kyoo /// /// The host context that contains the configuration /// The logger builder to configure. - private static void _ConfigureLogging(HostBuilderContext context, ILoggingBuilder builder) + public static void ConfigureLogging(HostBuilderContext context, ILoggingBuilder builder) { builder.AddConfiguration(context.Configuration.GetSection("logging")) .AddSimpleConsole(x => @@ -89,18 +94,19 @@ namespace Kyoo /// /// Command line parameters that can be handled by kestrel /// - /// An action to configure the logging. If it is null, will be used. + /// An action to configure the logging. If it is null, will be used. /// /// A new web host instance public static IHostBuilder CreateWebHostBuilder(string[] args, Action loggingConfiguration = null) { IConfiguration configuration = SetupConfig(new ConfigurationBuilder(), args).Build(); - loggingConfiguration ??= _ConfigureLogging; + loggingConfiguration ??= ConfigureLogging; return new HostBuilder() .UseServiceProviderFactory(new AutofacServiceProviderFactory()) .UseContentRoot(AppDomain.CurrentDomain.BaseDirectory) + .UseEnvironment(Environment) .ConfigureAppConfiguration(x => SetupConfig(x, args)) .ConfigureLogging(loggingConfiguration) .ConfigureServices(x => x.AddRouting()) @@ -113,6 +119,32 @@ namespace Kyoo ); } + /// + /// Parse the data directory from environment variables and command line arguments, create it if necessary. + /// Set the current directory to said data folder and place a default configuration file if it does not already + /// exists. + /// + /// The command line arguments + public static void SetupDataDir(string[] args) + { + IConfiguration parsed = new ConfigurationBuilder() + .AddEnvironmentVariables() + .AddEnvironmentVariables("KYOO_") + .AddCommandLine(args) + .Build(); + + string path = parsed.GetValue("data_dir"); + if (path == null) + path = Path.Combine(SEnvironment.GetFolderPath(SEnvironment.SpecialFolder.LocalApplicationData), "Kyoo"); + + if (!Directory.Exists(path)) + Directory.CreateDirectory(path); + SEnvironment.CurrentDirectory = path; + + if (!File.Exists(JsonConfigPath)) + File.Copy(Path.Join(AppDomain.CurrentDomain.BaseDirectory, JsonConfigPath), JsonConfigPath); + } + /// /// An useless class only used to have a logger in the main. /// diff --git a/deployment/kyoo-windows.iss b/deployment/kyoo-windows.iss new file mode 100644 index 00000000..99d9d426 --- /dev/null +++ b/deployment/kyoo-windows.iss @@ -0,0 +1,39 @@ +[Setup] +AppId={{31A61284-7939-46BC-B584-D2279A6EEEE8} +AppName=Kyoo +AppVersion=1.0 +AppPublisher=SDG +AppPublisherURL=https://github.com/AnonymusRaccoon/Kyoo +AppSupportURL=https://github.com/AnonymusRaccoon/Kyoo +AppUpdatesURL=https://github.com/AnonymusRaccoon/Kyoo +DefaultDirName={commonpf}\Kyoo +DisableProgramGroupPage=yes +LicenseFile={#kyoo}\LICENSE +OutputBaseFilename=kyoo-windows +SetupIconFile={#kyoo}\wwwroot\favicon.ico +Compression=lzma +SolidCompression=yes +WizardStyle=modern +AppCopyright=GPL-3.0 + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" + +[Tasks] +Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked +Name: "startupShortcut"; Description: "Create shortcut in Startup folder (Starts when you log into Windows)"; GroupDescription: "Start automatically"; Flags: exclusive +Name: "none"; Description: "Do not start automatically"; GroupDescription: "Start automatically"; Flags: exclusive unchecked + +[Files] +Source: "{#kyoo}\Kyoo.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "{#kyoo}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs + +[UninstallDelete] +Type: filesandordirs; Name: "{commonappdata}\Kyoo" + +[Icons] +Name: "{autoprograms}\Kyoo"; Filename: "{app}\Kyoo.exe" +Name: "{autodesktop}\Kyoo"; Filename: "{app}\Kyoo.exe"; Tasks: desktopicon + +[Run] +Filename: "{app}\Kyoo.exe"; Description: "{cm:LaunchProgram,Kyoo}"; Flags: nowait postinstall skipifsilent \ No newline at end of file From 334a265e192755d95e8c1815ba9d345ec267366e Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Fri, 20 Aug 2021 22:26:23 +0200 Subject: [PATCH 06/38] Host: Using serilog instead of microsoft logging and adding file logs --- Kyoo.WindowsHost/SystemTrait.cs | 3 +- Kyoo/CoreModule.cs | 2 + Kyoo/Kyoo.csproj | 8 +++- Kyoo/PluginsStartup.cs | 12 ++---- Kyoo/Program.cs | 70 +++++++++++++++++++++++---------- Kyoo/settings.json | 14 ++++--- 6 files changed, 70 insertions(+), 39 deletions(-) diff --git a/Kyoo.WindowsHost/SystemTrait.cs b/Kyoo.WindowsHost/SystemTrait.cs index 22009ab1..b0b7bbbf 100644 --- a/Kyoo.WindowsHost/SystemTrait.cs +++ b/Kyoo.WindowsHost/SystemTrait.cs @@ -78,6 +78,7 @@ namespace Kyoo.Host.Windows { _options = options; + AppDomain.CurrentDomain.ProcessExit += (_, _) => Dispose(); Application.ApplicationExit += (_, _) => Dispose(); _icon = new NotifyIcon(); @@ -111,8 +112,8 @@ namespace Kyoo.Host.Windows /// protected override void Dispose(bool disposing) { - base.Dispose(disposing); _icon.Visible = false; + base.Dispose(disposing); _icon.Dispose(); } diff --git a/Kyoo/CoreModule.cs b/Kyoo/CoreModule.cs index 2d1e35e8..470ad3bd 100644 --- a/Kyoo/CoreModule.cs +++ b/Kyoo/CoreModule.cs @@ -17,6 +17,7 @@ using Microsoft.AspNetCore.StaticFiles; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; +using Serilog; using IMetadataProvider = Kyoo.Abstractions.Controllers.IMetadataProvider; namespace Kyoo @@ -151,6 +152,7 @@ namespace Kyoo app.UseHsts(); } }, SA.Before), + SA.New(app => app.UseSerilogRequestLogging(), SA.Before), SA.New(app => app.UseResponseCompression(), SA.Routing + 1), SA.New(app => app.UseRouting(), SA.Routing), SA.New(app => app.UseEndpoints(x => x.MapControllers()), SA.Endpoint) diff --git a/Kyoo/Kyoo.csproj b/Kyoo/Kyoo.csproj index d4a573f9..c7c358cc 100644 --- a/Kyoo/Kyoo.csproj +++ b/Kyoo/Kyoo.csproj @@ -24,6 +24,11 @@ + + + + + @@ -44,8 +49,7 @@ - + diff --git a/Kyoo/PluginsStartup.cs b/Kyoo/PluginsStartup.cs index 4bcd362f..c5545842 100644 --- a/Kyoo/PluginsStartup.cs +++ b/Kyoo/PluginsStartup.cs @@ -131,19 +131,13 @@ namespace Kyoo /// This is meant to be used from . /// /// The context of the web host. - /// - /// The method used to configure the logger factory used by the plugin manager and plugins during startup. + /// + /// The logger factory used to log while the application is setting itself up. /// /// A new . public static PluginsStartup FromWebHost(WebHostBuilderContext host, - Action loggingConfiguration) + ILoggerFactory logger) { - HostBuilderContext genericHost = new(new Dictionary()) - { - Configuration = host.Configuration, - HostingEnvironment = host.HostingEnvironment - }; - ILoggerFactory logger = LoggerFactory.Create(builder => loggingConfiguration(genericHost, builder)); HostServiceProvider hostProvider = new(host.HostingEnvironment, host.Configuration, logger); PluginManager plugins = new( hostProvider, diff --git a/Kyoo/Program.cs b/Kyoo/Program.cs index f905b8ba..b74da994 100644 --- a/Kyoo/Program.cs +++ b/Kyoo/Program.cs @@ -2,11 +2,15 @@ using System; using System.IO; using System.Threading.Tasks; using Autofac.Extensions.DependencyInjection; +using JetBrains.Annotations; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; +using Serilog; +using Serilog.Templates; +using Serilog.Templates.Themes; using SEnvironment = System.Environment; namespace Kyoo @@ -30,6 +34,19 @@ namespace Kyoo private const string Environment = "Production"; #endif + /// + /// Initialize the bootstrap logger to use it anywhere. This is done here so it is called before any method, + /// even if the is not used and this binary is used as a dll. + /// + static Program() + { + LoggerConfiguration config = new(); + _ConfigureLogging(null, config); + Log.Logger = config.CreateBootstrapLogger().ForContext(); + + AppDomain.CurrentDomain.ProcessExit += (_, _) => Log.CloseAndFlush(); + } + /// /// Main function of the program /// @@ -67,6 +84,7 @@ namespace Kyoo private static IConfigurationBuilder SetupConfig(IConfigurationBuilder builder, string[] args) { return builder.SetBasePath(System.Environment.CurrentDirectory) + .AddJsonFile(Path.Join(AppDomain.CurrentDomain.BaseDirectory, JsonConfigPath), false, true) .AddJsonFile(JsonConfigPath, false, true) .AddEnvironmentVariables() .AddEnvironmentVariables("KYOO_") @@ -78,44 +96,54 @@ namespace Kyoo /// /// The host context that contains the configuration /// The logger builder to configure. - public static void ConfigureLogging(HostBuilderContext context, ILoggingBuilder builder) + private static void _ConfigureLogging([CanBeNull] HostBuilderContext context, LoggerConfiguration builder) { - builder.AddConfiguration(context.Configuration.GetSection("logging")) - .AddSimpleConsole(x => + if (context != null) + { + try { - x.TimestampFormat = "[hh:mm:ss] "; - }) - .AddDebug() - .AddEventSourceLogger(); + builder.ReadFrom.Configuration(context.Configuration, "logging"); + } + catch (Exception ex) + { + Log.Fatal(ex, "Could not read serilog configuration"); + } + } + + const string template = + "[{@t:HH:mm:ss} {@l:u3} {Substring(SourceContext, LastIndexOf(SourceContext, '.') + 1), 15} ({@i:10})] " + + "{@m}{#if not EndsWith(@m, '\n')}\n{#end}{@x}"; + + builder + .WriteTo.Console(new ExpressionTemplate(template, theme: TemplateTheme.Code)) + .WriteTo.Debug() + .WriteTo.RollingFile(new ExpressionTemplate(template), "logs/log-{Date}.log") + .Enrich.WithThreadId() + .Enrich.FromLogContext(); } /// /// Create a a web host /// /// Command line parameters that can be handled by kestrel - /// - /// An action to configure the logging. If it is null, will be used. - /// /// A new web host instance - public static IHostBuilder CreateWebHostBuilder(string[] args, - Action loggingConfiguration = null) + public static IHostBuilder CreateWebHostBuilder(string[] args) { IConfiguration configuration = SetupConfig(new ConfigurationBuilder(), args).Build(); - loggingConfiguration ??= ConfigureLogging; return new HostBuilder() .UseServiceProviderFactory(new AutofacServiceProviderFactory()) .UseContentRoot(AppDomain.CurrentDomain.BaseDirectory) .UseEnvironment(Environment) .ConfigureAppConfiguration(x => SetupConfig(x, args)) - .ConfigureLogging(loggingConfiguration) + .UseSerilog(_ConfigureLogging) .ConfigureServices(x => x.AddRouting()) .ConfigureWebHost(x => x .UseKestrel(options => { options.AddServerHeader = false; }) .UseIIS() .UseIISIntegration() .UseUrls(configuration.GetValue("basics:url")) - .UseStartup(host => PluginsStartup.FromWebHost(host, loggingConfiguration)) + .UseStartup(host => PluginsStartup.FromWebHost(host, new LoggerFactory().AddSerilog())) ); } @@ -140,14 +168,14 @@ namespace Kyoo if (!Directory.Exists(path)) Directory.CreateDirectory(path); SEnvironment.CurrentDirectory = path; - + if (!File.Exists(JsonConfigPath)) File.Copy(Path.Join(AppDomain.CurrentDomain.BaseDirectory, JsonConfigPath), JsonConfigPath); } - - /// - /// An useless class only used to have a logger in the main. - /// - private class Application {} } + + /// + /// An useless class only used to have a logger in the main. + /// + internal class Application {} } diff --git a/Kyoo/settings.json b/Kyoo/settings.json index de2d784e..299f0e5c 100644 --- a/Kyoo/settings.json +++ b/Kyoo/settings.json @@ -30,12 +30,14 @@ }, "logging": { - "logLevel": { - "default": "Warning", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information", - "Microsoft.EntityFrameworkCore": "None", - "Kyoo": "Trace" + "MinimumLevel": { + "Default": "Warning", + "Override": { + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information", + "Microsoft.EntityFrameworkCore": "Fatal", + "Kyoo": "Verbose" + } } }, From f661457617ff0f80c875e41a9ad6797effa92315 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sun, 22 Aug 2021 13:51:55 +0200 Subject: [PATCH 07/38] Host: Cleaning up logs and finishing the windows's trait --- Kyoo.WindowsHost/SystemTrait.cs | 3 +++ Kyoo/Kyoo.csproj | 1 - Kyoo/Program.cs | 11 ++++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Kyoo.WindowsHost/SystemTrait.cs b/Kyoo.WindowsHost/SystemTrait.cs index b0b7bbbf..121360b7 100644 --- a/Kyoo.WindowsHost/SystemTrait.cs +++ b/Kyoo.WindowsHost/SystemTrait.cs @@ -95,6 +95,9 @@ namespace Kyoo.Host.Windows _icon.ContextMenuStrip = new ContextMenuStrip(); _icon.ContextMenuStrip.Items.AddRange(new ToolStripItem[] { + new ToolStripMenuItem("Open browser", null, (_, _) => { _StartBrowser(); }), + new ToolStripMenuItem("Open logs", null, (_, _) => { Process.Start("explorer.exe", Environment.CurrentDirectory); }), + new ToolStripSeparator(), new ToolStripMenuItem("Exit", null, (_, _) => { Environment.Exit(0); }) }); } diff --git a/Kyoo/Kyoo.csproj b/Kyoo/Kyoo.csproj index c7c358cc..0ccab98e 100644 --- a/Kyoo/Kyoo.csproj +++ b/Kyoo/Kyoo.csproj @@ -28,7 +28,6 @@ - diff --git a/Kyoo/Program.cs b/Kyoo/Program.cs index b74da994..c7fbe06a 100644 --- a/Kyoo/Program.cs +++ b/Kyoo/Program.cs @@ -111,13 +111,18 @@ namespace Kyoo } const string template = - "[{@t:HH:mm:ss} {@l:u3} {Substring(SourceContext, LastIndexOf(SourceContext, '.') + 1), 15} ({@i:10})] " - + "{@m}{#if not EndsWith(@m, '\n')}\n{#end}{@x}"; + "[{@t:HH:mm:ss} {@l:u3} {Substring(SourceContext, LastIndexOf(SourceContext, '.') + 1), 15} " + + "({@i:0000000000})] {@m}{#if not EndsWith(@m, '\n')}\n{#end}{@x}"; builder .WriteTo.Console(new ExpressionTemplate(template, theme: TemplateTheme.Code)) .WriteTo.Debug() - .WriteTo.RollingFile(new ExpressionTemplate(template), "logs/log-{Date}.log") + .WriteTo.File( + path: "logs/log-.log", + formatter: new ExpressionTemplate(template), + rollingInterval: RollingInterval.Day, + rollOnFileSizeLimit: true + ) .Enrich.WithThreadId() .Enrich.FromLogContext(); } From daedd60f3de278bed6d90e860deff08248b5a4ad Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sun, 22 Aug 2021 17:20:23 +0200 Subject: [PATCH 08/38] Windows: Creating an installer with a custom data directory path --- .github/workflows/analysis.yml | 2 +- .github/workflows/build.yml | 29 ++++++++++++++++--- .github/workflows/docker.yml | 3 +- Kyoo.WindowsHost/Kyoo.WindowsHost.csproj | 1 - Kyoo.WindowsHost/Program.cs | 6 ++++ Kyoo.WindowsHost/SystemTrait.cs | 2 +- Kyoo/Kyoo.csproj | 4 +++ Kyoo/Program.cs | 6 ++-- deployment/kyoo-windows.iss | 37 ++++++++++++++++++++---- deployment/kyoo.service | 2 +- 10 files changed, 74 insertions(+), 18 deletions(-) diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index fc1679cb..ab5ed716 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -1,5 +1,5 @@ name: Analysis -on: [push, pull_request] +on: [push, pull_request, workflow_dispatch] jobs: analysis: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bd06596b..3d4429e5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,5 @@ name: Build -on: [push, pull_request] +on: [push, pull_request, workflow_dispatch] jobs: build: @@ -43,13 +43,16 @@ jobs: if: matrix.artifact == 'windows' uses: ilammy/msvc-dev-cmd@v1 - name: Build the app + shell: bash env: INCLUDE: ${{env.INCLUDE}};C:\Program Files\FFmpeg\include LIB: ${{env.LIB}};C:\Program Files\FFmpeg\lib LIBPATH: ${{env.LIBPATH}};C:\Program Files\FFmpeg\lib CFLAGS: -I/usr/local/include LDFLAGS: -L/usr/local/lib - run: dotnet publish -r ${{matrix.runtime}} -c Release -o dist Kyoo + run: | + project=$([ "${{runner.os}}" == "Windows" ] && echo Kyoo.WindowsHost || echo Kyoo) + dotnet publish -r ${{matrix.runtime}} -c Release -o dist $project - name: Compression output shell: bash run: | @@ -71,7 +74,7 @@ jobs: *.tar.gz release: - name: Create debian, rpm & arch releases + name: Create windows, debian, rpm & arch releases runs-on: ubuntu-latest needs: build if: github.ref == 'refs/heads/master' @@ -80,12 +83,26 @@ jobs: version: v0.0.1 #${{ github.ref }} steps: - uses: actions/checkout@v1 - - uses: actions/download-artifact@v2 + - name: Download linux build + uses: actions/download-artifact@v2 with: name: kyoo_linux path: artifact - name: Unzip the published files. run: mkdir dist && tar -C dist -xzf artifact/kyoo_linux.tar.gz + - name: Download windows build + uses: actions/download-artifact@v2 + with: + name: kyoo_windows + path: artifact + - name: Unzip windows files + run: mkdir dist_win && 7z e artifact/kyoo_windows.zip -o dist_win + - name: Install Inno Setup + run: | + curl -L https://jrsoftware.org/download.php/is.exe > innosetup.exe + ./innosetup.exe /VERYSILENT /SUPPRESSMSGBOXES /Log=log.txt || (cat log.txt && exit 1) + - name: Create windows installer + run: iscc -Dkyoo=$(realpath dist_win) -O./ -Fkyoo-windows deployment/kyoo-windows.iss - name: Create the package structure run: | sudo mkdir -p pkg/usr/lib/ @@ -119,6 +136,10 @@ jobs: with: pkgdir: deployment namcapDisable: true + - uses: actions/upload-artifact@v2 + with: + name: kyoo_windows + path: ./*.exe - uses: actions/upload-artifact@v2 with: name: kyoo_rpm diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index e61395ff..c68715f0 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,6 +1,5 @@ name: Docker - -on: [push, pull_request] +on: [push, pull_request, workflow_dispatch] jobs: build: diff --git a/Kyoo.WindowsHost/Kyoo.WindowsHost.csproj b/Kyoo.WindowsHost/Kyoo.WindowsHost.csproj index fe167974..eeb412ca 100644 --- a/Kyoo.WindowsHost/Kyoo.WindowsHost.csproj +++ b/Kyoo.WindowsHost/Kyoo.WindowsHost.csproj @@ -3,7 +3,6 @@ WinExe net5.0-windows - enable true Kyoo.Host.Windows diff --git a/Kyoo.WindowsHost/Program.cs b/Kyoo.WindowsHost/Program.cs index ace92e24..73c1cedc 100644 --- a/Kyoo.WindowsHost/Program.cs +++ b/Kyoo.WindowsHost/Program.cs @@ -1,6 +1,8 @@ +using System; using System.Threading.Tasks; using Autofac; using Microsoft.Extensions.Hosting; +using Microsoft.Win32; namespace Kyoo.Host.Windows { @@ -13,6 +15,10 @@ namespace Kyoo.Host.Windows /// public static async Task Main(string[] args) { + object dataDir = Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\SDG\Kyoo\Settings", "DataDir", null) + ?? Registry.GetValue(@"HKEY_CURRENT_USER\Software\SDG\Kyoo\Settings", "DataDir", null); + if (dataDir is string data) + Environment.SetEnvironmentVariable("KYOO_DATA_DIR", data); Kyoo.Program.SetupDataDir(args); IHost host = Kyoo.Program.CreateWebHostBuilder(args) diff --git a/Kyoo.WindowsHost/SystemTrait.cs b/Kyoo.WindowsHost/SystemTrait.cs index 121360b7..5201f239 100644 --- a/Kyoo.WindowsHost/SystemTrait.cs +++ b/Kyoo.WindowsHost/SystemTrait.cs @@ -23,7 +23,7 @@ namespace Kyoo.Host.Windows /// /// The thread where the trait is running. /// - private Thread? _thread; + private Thread _thread; /// diff --git a/Kyoo/Kyoo.csproj b/Kyoo/Kyoo.csproj index 0ccab98e..4fc74690 100644 --- a/Kyoo/Kyoo.csproj +++ b/Kyoo/Kyoo.csproj @@ -59,4 +59,8 @@ false + + + + diff --git a/Kyoo/Program.cs b/Kyoo/Program.cs index c7fbe06a..b2844b39 100644 --- a/Kyoo/Program.cs +++ b/Kyoo/Program.cs @@ -65,13 +65,13 @@ namespace Kyoo { try { - host.Services.GetRequiredService>() - .LogInformation("Running as {Name}", System.Environment.UserName); + Log.Information("Running as {Name}", System.Environment.UserName); + Log.Information("Data directory: {DataDirectory}", System.Environment.CurrentDirectory); await host.RunAsync(); } catch (Exception ex) { - host.Services.GetRequiredService>().LogCritical(ex, "Unhandled exception"); + Log.Fatal(ex, "Unhandled exception"); } } diff --git a/deployment/kyoo-windows.iss b/deployment/kyoo-windows.iss index 99d9d426..720ea594 100644 --- a/deployment/kyoo-windows.iss +++ b/deployment/kyoo-windows.iss @@ -9,12 +9,12 @@ AppUpdatesURL=https://github.com/AnonymusRaccoon/Kyoo DefaultDirName={commonpf}\Kyoo DisableProgramGroupPage=yes LicenseFile={#kyoo}\LICENSE -OutputBaseFilename=kyoo-windows SetupIconFile={#kyoo}\wwwroot\favicon.ico Compression=lzma SolidCompression=yes WizardStyle=modern AppCopyright=GPL-3.0 +ArchitecturesInstallIn64BitMode=x64 arm64 ia64 [Languages] Name: "english"; MessagesFile: "compiler:Default.isl" @@ -26,14 +26,41 @@ Name: "none"; Description: "Do not start automatically"; GroupDescription: "Star [Files] Source: "{#kyoo}\Kyoo.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "{#kyoo}\Kyoo.WindowsHost.exe"; DestDir: "{app}"; Flags: ignoreversion Source: "{#kyoo}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs +[Registry] +Root: HKA; Subkey: "Software\SDG"; Flags: uninsdeletekeyifempty +Root: HKA; Subkey: "Software\SDG\Kyoo"; Flags: uninsdeletekey +Root: HKA; Subkey: "Software\SDG\Kyoo\Settings"; ValueType: string; ValueName: "DataDir"; ValueData: "{code:GetDataDir}" + [UninstallDelete] -Type: filesandordirs; Name: "{commonappdata}\Kyoo" +Type: filesandordirs; Name: "{code:GetDataDir}" [Icons] -Name: "{autoprograms}\Kyoo"; Filename: "{app}\Kyoo.exe" -Name: "{autodesktop}\Kyoo"; Filename: "{app}\Kyoo.exe"; Tasks: desktopicon +Name: "{autoprograms}\Kyoo"; Filename: "{app}\Kyoo.WindowsHost.exe" +Name: "{autoprograms}\Kyoo (Console)"; Filename: "{app}\Kyoo.exe" +Name: "{autodesktop}\Kyoo"; Filename: "{app}\Kyoo.WindowsHost.exe"; Tasks: desktopicon [Run] -Filename: "{app}\Kyoo.exe"; Description: "{cm:LaunchProgram,Kyoo}"; Flags: nowait postinstall skipifsilent \ No newline at end of file +Filename: "{app}\Kyoo.WindowsHost.exe"; Description: "{cm:LaunchProgram,Kyoo}"; Flags: nowait postinstall skipifsilent + +[Code] +var + DataDirPage: TInputDirWizardPage; + +procedure InitializeWizard; +begin + DataDirPage := CreateInputDirPage(wpSelectDir, + 'Choose Data Location', 'Choose the folder in which to install the Kyoo data', + 'The installer will set the following folder for Kyoo. To install in a different folder, click Browse and select another folder.' + + 'Please make sure the folder exists and is accessible. Do not choose the server install folder. Click Next to continue.', + False, ''); + DataDirPage.Add(''); + DataDirPage.Values[0] := GetPreviousData('DataDir', 'C:\ProgramData\Kyoo'); +end; + +function GetDataDir(Param: String): String; +begin + Result := DataDirPage.Values[0]; +end; \ No newline at end of file diff --git a/deployment/kyoo.service b/deployment/kyoo.service index 277c26ca..88b91542 100644 --- a/deployment/kyoo.service +++ b/deployment/kyoo.service @@ -5,7 +5,7 @@ After=network.target [Service] User=kyoo -WorkingDirectory=/var/lib/kyoo +Environment=KYOO_DATA_DIR=/var/lib/kyoo ExecStart=/usr/lib/kyoo/Kyoo Restart=on-abort TimeoutSec=20 From 3b85962dfdda6f428749e77d429136f09e68b1cf Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sun, 22 Aug 2021 20:26:52 +0200 Subject: [PATCH 09/38] Build: Skipping WindowsHost build on non-windows devices --- Kyoo.Transcoder | 2 +- Kyoo.WindowsHost/Kyoo.WindowsHost.csproj | 23 ++++++------------- .../Kyoo.WindowsHost.linux.target | 12 ++++++++++ Kyoo.WindowsHost/Kyoo.WindowsHost.target | 23 +++++++++++++++++++ Kyoo.WindowsHost/Program.cs | 2 +- Kyoo.WindowsHost/SystemTrait.cs | 2 +- Kyoo/Kyoo.csproj | 18 +++++++++------ 7 files changed, 56 insertions(+), 26 deletions(-) create mode 100644 Kyoo.WindowsHost/Kyoo.WindowsHost.linux.target create mode 100644 Kyoo.WindowsHost/Kyoo.WindowsHost.target diff --git a/Kyoo.Transcoder b/Kyoo.Transcoder index 48782f89..7bae8def 160000 --- a/Kyoo.Transcoder +++ b/Kyoo.Transcoder @@ -1 +1 @@ -Subproject commit 48782f895a40f28eda5e861fcaa624c0eab54076 +Subproject commit 7bae8def39ace7bab481efea4825c4802e9e1f31 diff --git a/Kyoo.WindowsHost/Kyoo.WindowsHost.csproj b/Kyoo.WindowsHost/Kyoo.WindowsHost.csproj index eeb412ca..35a4a4b8 100644 --- a/Kyoo.WindowsHost/Kyoo.WindowsHost.csproj +++ b/Kyoo.WindowsHost/Kyoo.WindowsHost.csproj @@ -1,21 +1,12 @@ - - + - WinExe - net5.0-windows - true - Kyoo.Host.Windows + true - + + + + - + - - - - - PreserveNewest - - - \ No newline at end of file diff --git a/Kyoo.WindowsHost/Kyoo.WindowsHost.linux.target b/Kyoo.WindowsHost/Kyoo.WindowsHost.linux.target new file mode 100644 index 00000000..2cccfbd3 --- /dev/null +++ b/Kyoo.WindowsHost/Kyoo.WindowsHost.linux.target @@ -0,0 +1,12 @@ + + + + + net5.0 + NU1503 + + + + + + \ No newline at end of file diff --git a/Kyoo.WindowsHost/Kyoo.WindowsHost.target b/Kyoo.WindowsHost/Kyoo.WindowsHost.target new file mode 100644 index 00000000..70bd90b0 --- /dev/null +++ b/Kyoo.WindowsHost/Kyoo.WindowsHost.target @@ -0,0 +1,23 @@ + + + + + WinExe + net5.0-windows + true + Kyoo.WindowsHost + + + + + + + + + + PreserveNewest + + + \ No newline at end of file diff --git a/Kyoo.WindowsHost/Program.cs b/Kyoo.WindowsHost/Program.cs index 73c1cedc..46e0d427 100644 --- a/Kyoo.WindowsHost/Program.cs +++ b/Kyoo.WindowsHost/Program.cs @@ -4,7 +4,7 @@ using Autofac; using Microsoft.Extensions.Hosting; using Microsoft.Win32; -namespace Kyoo.Host.Windows +namespace Kyoo.WindowsHost { public static class Program { diff --git a/Kyoo.WindowsHost/SystemTrait.cs b/Kyoo.WindowsHost/SystemTrait.cs index 5201f239..6e120682 100644 --- a/Kyoo.WindowsHost/SystemTrait.cs +++ b/Kyoo.WindowsHost/SystemTrait.cs @@ -8,7 +8,7 @@ using Autofac; using Kyoo.Models.Options; using Microsoft.Extensions.Options; -namespace Kyoo.Host.Windows +namespace Kyoo.WindowsHost { /// /// A singleton that add an notification icon on the window's toolbar. diff --git a/Kyoo/Kyoo.csproj b/Kyoo/Kyoo.csproj index 4fc74690..69f37d87 100644 --- a/Kyoo/Kyoo.csproj +++ b/Kyoo/Kyoo.csproj @@ -18,9 +18,13 @@ - transcoder.dll - libtranscoder.dylib - libtranscoder.so + transcoder.dll + libtranscoder.dylib + libtranscoder.so + + $(TranscoderRoot)buildWin + $(TranscoderRoot)buildOSX + $(TranscoderRoot)build @@ -48,13 +52,13 @@ - - - + + + - + PreserveNewest false From 4ae0a98336f297dc464fb554e22d5b1b831e3524 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sun, 22 Aug 2021 20:41:00 +0200 Subject: [PATCH 10/38] Build: Fixing clean, restore and pack state for the skipped windows host --- .github/workflows/build.yml | 1 + Kyoo.WindowsHost/Kyoo.WindowsHost.linux.target | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3d4429e5..0ae25ce0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,6 +37,7 @@ jobs: else # sudo add-apt-repository -y "deb http://azure.archive.ubuntu.com/ubuntu groovy main multiverse restricted universe" # sudo apt-get update -y + sudo apt-get update sudo apt-get install -y libavutil-dev libavcodec-dev libavformat-dev fi - name: Enabling windows compilations tools diff --git a/Kyoo.WindowsHost/Kyoo.WindowsHost.linux.target b/Kyoo.WindowsHost/Kyoo.WindowsHost.linux.target index 2cccfbd3..888c2ed7 100644 --- a/Kyoo.WindowsHost/Kyoo.WindowsHost.linux.target +++ b/Kyoo.WindowsHost/Kyoo.WindowsHost.linux.target @@ -1,12 +1,20 @@  + + net5.0 NU1503 + + + + + + \ No newline at end of file From d5e1d4f00336cc4c1fdd6475a3852c29795ffa9b Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sun, 22 Aug 2021 20:47:58 +0200 Subject: [PATCH 11/38] Build: Fixing transcoder path --- Kyoo/Kyoo.csproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Kyoo/Kyoo.csproj b/Kyoo/Kyoo.csproj index 69f37d87..8c9aa0d5 100644 --- a/Kyoo/Kyoo.csproj +++ b/Kyoo/Kyoo.csproj @@ -53,12 +53,12 @@ - - + + - + PreserveNewest false From 4daa1eb28d5eef42483e37eae7ff75fe88db078c Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Mon, 23 Aug 2021 21:09:49 +0200 Subject: [PATCH 12/38] Application: Allowing the app to be restarted --- .github/workflows/build.yml | 5 +- Kyoo.Abstractions/Controllers/IApplication.cs | 24 ++ .../Kyoo.WindowsHost.linux.target | 1 + Kyoo.WindowsHost/Kyoo.WindowsHost.target | 2 +- Kyoo.WindowsHost/Program.cs | 24 +- Kyoo.WindowsHost/SystemTrait.cs | 46 +++- Kyoo/Application.cs | 244 ++++++++++++++++++ Kyoo/Kyoo.csproj | 6 +- Kyoo/Program.cs | 159 +----------- deployment/PKGBUILD | 4 +- deployment/PKGBUILD.github | 2 +- deployment/kyoo.install | 11 - deployment/kyoo.service | 2 +- deployment/kyoo.spec | 16 +- deployment/postinst | 15 -- 15 files changed, 322 insertions(+), 239 deletions(-) create mode 100644 Kyoo.Abstractions/Controllers/IApplication.cs create mode 100644 Kyoo/Application.cs delete mode 100644 deployment/kyoo.install delete mode 100644 deployment/postinst diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0ae25ce0..91c6d42c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -107,25 +107,22 @@ jobs: - name: Create the package structure run: | sudo mkdir -p pkg/usr/lib/ - sudo mkdir -p pkg/DEBIAN sudo cp -r --no-preserve ownership dist pkg/usr/lib/kyoo sudo install -Dm 644 deployment/kyoo.service -t pkg/usr/lib/systemd/system/ sudo install -Dm 644 deployment/kyoo.sysusers pkg/usr/lib/sysusers.d/kyoo.conf sudo install -Dm 644 deployment/kyoo.tmpfiles pkg/usr/lib/tmpfiles.d/kyoo.conf - sudo install -Dm 755 deployment/postinst -t pkg/DEBIAN/ - uses: jiro4989/build-deb-action@v2 with: package: kyoo package_root: pkg maintainer: Zoe Roux version: ${{env.version}} - depends: "postgresql, libavutil-dev, libavcodec-dev, libavformat-dev" + depends: "libavutil-dev, libavcodec-dev, libavformat-dev" arch: amd64 desc: ${{env.description}} - name: Build rpm package run: | mkdir out - sudo rm -rf pkg/DEBIAN rpmbuild -bb --buildroot $(pwd)/out --build-in-place --define "_rpmdir $(pwd)/rpm" deployment/kyoo.spec - name: Prepare arch package run: | diff --git a/Kyoo.Abstractions/Controllers/IApplication.cs b/Kyoo.Abstractions/Controllers/IApplication.cs new file mode 100644 index 00000000..95e01454 --- /dev/null +++ b/Kyoo.Abstractions/Controllers/IApplication.cs @@ -0,0 +1,24 @@ +namespace Kyoo.Abstractions.Controllers +{ + /// + /// An interface that allow one to interact with the host and shutdown or restart the app. + /// + public interface IApplication + { + /// + /// Shutdown the process and stop gracefully. + /// + void Shutdown(); + + /// + /// Restart Kyoo from scratch, reload plugins, configurations and restart the web server. + /// + void Restart(); + + /// + /// Get the data directory + /// + /// Retrieve the data directory where runtime data should be stored + string GetDataDirectory(); + } +} \ No newline at end of file diff --git a/Kyoo.WindowsHost/Kyoo.WindowsHost.linux.target b/Kyoo.WindowsHost/Kyoo.WindowsHost.linux.target index 888c2ed7..490cbebe 100644 --- a/Kyoo.WindowsHost/Kyoo.WindowsHost.linux.target +++ b/Kyoo.WindowsHost/Kyoo.WindowsHost.linux.target @@ -17,4 +17,5 @@ + \ No newline at end of file diff --git a/Kyoo.WindowsHost/Kyoo.WindowsHost.target b/Kyoo.WindowsHost/Kyoo.WindowsHost.target index 70bd90b0..c945d8ad 100644 --- a/Kyoo.WindowsHost/Kyoo.WindowsHost.target +++ b/Kyoo.WindowsHost/Kyoo.WindowsHost.target @@ -11,7 +11,7 @@ - + diff --git a/Kyoo.WindowsHost/Program.cs b/Kyoo.WindowsHost/Program.cs index 46e0d427..c3ea68b4 100644 --- a/Kyoo.WindowsHost/Program.cs +++ b/Kyoo.WindowsHost/Program.cs @@ -1,8 +1,5 @@ -using System; using System.Threading.Tasks; using Autofac; -using Microsoft.Extensions.Hosting; -using Microsoft.Win32; namespace Kyoo.WindowsHost { @@ -13,22 +10,13 @@ namespace Kyoo.WindowsHost /// It adds a system trait for windows and since the host is build as a windows executable instead of a console /// app, the console is not showed. /// - public static async Task Main(string[] args) + public static Task Main(string[] args) { - object dataDir = Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\SDG\Kyoo\Settings", "DataDir", null) - ?? Registry.GetValue(@"HKEY_CURRENT_USER\Software\SDG\Kyoo\Settings", "DataDir", null); - if (dataDir is string data) - Environment.SetEnvironmentVariable("KYOO_DATA_DIR", data); - Kyoo.Program.SetupDataDir(args); - - IHost host = Kyoo.Program.CreateWebHostBuilder(args) - .ConfigureContainer(builder => - { - builder.RegisterType().As().SingleInstance(); - }) - .Build(); - - await Kyoo.Program.StartWithHost(host); + Application application = new(); + return application.Start(args, builder => + { + builder.RegisterType().As().SingleInstance(); + }); } } } \ No newline at end of file diff --git a/Kyoo.WindowsHost/SystemTrait.cs b/Kyoo.WindowsHost/SystemTrait.cs index 6e120682..96525f7d 100644 --- a/Kyoo.WindowsHost/SystemTrait.cs +++ b/Kyoo.WindowsHost/SystemTrait.cs @@ -5,6 +5,7 @@ using System.IO; using System.Threading; using System.Windows.Forms; using Autofac; +using Kyoo.Abstractions.Controllers; using Kyoo.Models.Options; using Microsoft.Extensions.Options; @@ -15,6 +16,11 @@ namespace Kyoo.WindowsHost /// public sealed class SystemTrait : IStartable, IDisposable { + /// + /// The application running Kyoo. + /// + private readonly IApplication _application; + /// /// The options containing the . /// @@ -29,16 +35,18 @@ namespace Kyoo.WindowsHost /// /// Create a new . /// + /// The application running Kyoo. /// The options to use. - public SystemTrait(IOptions options) + public SystemTrait(IApplication application, IOptions options) { + _application = application; _options = options; } /// public void Start() { - _thread = new Thread(() => InternalSystemTrait.Run(_options)) + _thread = new Thread(() => InternalSystemTrait.Run(_application, _options)) { IsBackground = true }; @@ -48,8 +56,7 @@ namespace Kyoo.WindowsHost /// public void Dispose() { - // TODO not sure that the trait is ended and that it does shutdown but the only way to shutdown the - // app anyway is via the Trait's Exit or a Signal so it's fine. + System.Windows.Forms.Application.Exit(); _thread?.Join(); _thread = null; } @@ -61,6 +68,11 @@ namespace Kyoo.WindowsHost private class InternalSystemTrait : ApplicationContext { /// + /// The application running Kyoo. + /// + private readonly IApplication _application; + + /// /// The options containing the . /// private readonly IOptions _options; @@ -73,13 +85,15 @@ namespace Kyoo.WindowsHost /// /// Create a new . Used only by . /// + /// The application running Kyoo. /// The option containing the public url. - private InternalSystemTrait(IOptions options) + private InternalSystemTrait(IApplication application, IOptions options) { + _application = application; _options = options; AppDomain.CurrentDomain.ProcessExit += (_, _) => Dispose(); - Application.ApplicationExit += (_, _) => Dispose(); + System.Windows.Forms.Application.ApplicationExit += (_, _) => Dispose(); _icon = new NotifyIcon(); _icon.Text = "Kyoo"; @@ -96,20 +110,21 @@ namespace Kyoo.WindowsHost _icon.ContextMenuStrip.Items.AddRange(new ToolStripItem[] { new ToolStripMenuItem("Open browser", null, (_, _) => { _StartBrowser(); }), - new ToolStripMenuItem("Open logs", null, (_, _) => { Process.Start("explorer.exe", Environment.CurrentDirectory); }), + new ToolStripMenuItem("Open logs", null, (_, _) => { _OpenLogs(); }), new ToolStripSeparator(), - new ToolStripMenuItem("Exit", null, (_, _) => { Environment.Exit(0); }) + new ToolStripMenuItem("Exit", null, (_, _) => { _application.Shutdown(); }) }); } /// /// Run the trait in the current thread, this method does not return while the trait is running. /// + /// The application running Kyoo. /// The options to pass to . - public static void Run(IOptions options) + public static void Run(IApplication application, IOptions options) { - using InternalSystemTrait trait = new(options); - Application.Run(trait); + using InternalSystemTrait trait = new(application, options); + System.Windows.Forms.Application.Run(trait); } /// @@ -134,6 +149,15 @@ namespace Kyoo.WindowsHost }; browser.Start(); } + + /// + /// Open the log directory in windows's explorer. + /// + private void _OpenLogs() + { + string logDir = Path.Combine(_application.GetDataDirectory(), "logs"); + Process.Start("explorer.exe", logDir); + } } } } \ No newline at end of file diff --git a/Kyoo/Application.cs b/Kyoo/Application.cs new file mode 100644 index 00000000..4cc1004d --- /dev/null +++ b/Kyoo/Application.cs @@ -0,0 +1,244 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Threading; +using System.Threading.Tasks; +using Autofac; +using Autofac.Extensions.DependencyInjection; +using JetBrains.Annotations; +using Kyoo.Abstractions.Controllers; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Microsoft.Win32; +using Serilog; +using Serilog.Templates; +using Serilog.Templates.Themes; +using ILogger = Serilog.ILogger; + +namespace Kyoo +{ + public class Application : IApplication + { + /// + /// The path to the data directory. + /// + private string _dataDir; + + /// + /// Should the application restart after a shutdown? + /// + private bool _shouldRestart; + + /// + /// The cancellation token source used to allow the app to be shutdown or restarted. + /// + private CancellationTokenSource _tokenSource; + + /// + /// Start the application with the given console args. + /// This is generally called from the Main entrypoint of Kyoo. + /// + /// The console arguments to use for kyoo. + /// A task representing the whole process + public Task Start(string[] args) + { + return Start(args, _ => { }); + } + + /// + /// Start the application with the given console args. + /// This is generally called from the Main entrypoint of Kyoo. + /// + /// The console arguments to use for kyoo. + /// A custom action to configure the container before the start + /// A task representing the whole process + public async Task Start(string[] args, Action configure) + { + _dataDir = _SetupDataDir(args); + + LoggerConfiguration config = new(); + _ConfigureLogging(config, null); + Log.Logger = config.CreateBootstrapLogger() + .ForContext(); + + AppDomain.CurrentDomain.ProcessExit += (_, _) => Log.CloseAndFlush(); + AppDomain.CurrentDomain.UnhandledException += (_, ex) + => Log.Fatal(ex.ExceptionObject as Exception, "Unhandled exception"); + + do + { + IHost host = _CreateWebHostBuilder(args) + .ConfigureContainer(configure) + .Build(); + Log.Logger = host.Services.GetRequiredService().ForContext(); + + _tokenSource = new CancellationTokenSource(); + await _StartWithHost(host, _tokenSource.Token); + } + while (_shouldRestart); + } + + /// + public void Shutdown() + { + _shouldRestart = false; + _tokenSource.Cancel(); + } + + /// + public void Restart() + { + _shouldRestart = true; + _tokenSource.Cancel(); + } + + /// + public string GetDataDirectory() + { + return _dataDir; + } + + /// + /// Parse the data directory from environment variables and command line arguments, create it if necessary. + /// Set the current directory to said data folder and place a default configuration file if it does not already + /// exists. + /// + /// The command line arguments + /// The current data directory. + private static string _SetupDataDir(string[] args) + { + Dictionary registry = new(); + + if (OperatingSystem.IsWindows()) + { + object dataDir = Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\SDG\Kyoo\Settings", "DataDir", null) + ?? Registry.GetValue(@"HKEY_CURRENT_USER\Software\SDG\Kyoo\Settings", "DataDir", null); + if (dataDir is string data) + registry.Add("DataDir", data); + } + + IConfiguration parsed = new ConfigurationBuilder() + .AddInMemoryCollection(registry) + .AddEnvironmentVariables() + .AddEnvironmentVariables("KYOO_") + .AddCommandLine(args) + .Build(); + + string path = parsed.GetValue("datadir") + ?? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Kyoo"); + + if (!Directory.Exists(path)) + Directory.CreateDirectory(path); + Environment.CurrentDirectory = path; + + if (!File.Exists(Program.JsonConfigPath)) + File.Copy(Path.Join(AppDomain.CurrentDomain.BaseDirectory, Program.JsonConfigPath), + Program.JsonConfigPath); + + return path; + } + + /// + /// Start the given host and log failing exceptions. + /// + /// The host to start. + /// A token to allow one to stop the host. + private async Task _StartWithHost(IHost host, CancellationToken cancellationToken) + { + try + { + Log.Information("Running as {Name}", Environment.UserName); + Log.Information("Data directory: {DataDirectory}", GetDataDirectory()); + await host.RunAsync(cancellationToken); + } + catch (Exception ex) + { + Log.Fatal(ex, "Unhandled exception"); + } + } + + /// + /// Create a a web host + /// + /// Command line parameters that can be handled by kestrel + /// A new web host instance + private IHostBuilder _CreateWebHostBuilder(string[] args) + { + IConfiguration configuration = _SetupConfig(new ConfigurationBuilder(), args).Build(); + + return new HostBuilder() + .UseServiceProviderFactory(new AutofacServiceProviderFactory()) + .UseContentRoot(AppDomain.CurrentDomain.BaseDirectory) + .UseEnvironment(Program.Environment) + .ConfigureAppConfiguration(x => _SetupConfig(x, args)) + .UseSerilog((host, builder) => _ConfigureLogging(builder, host.Configuration)) + .ConfigureServices(x => x.AddRouting()) + .ConfigureContainer(x => + { + x.RegisterInstance(this).As().SingleInstance().ExternallyOwned(); + }) + .ConfigureWebHost(x => x + .UseKestrel(options => { options.AddServerHeader = false; }) + .UseIIS() + .UseIISIntegration() + .UseUrls(configuration.GetValue("basics:url")) + .UseStartup(host => PluginsStartup.FromWebHost(host, new LoggerFactory().AddSerilog())) + ); + } + + /// + /// Register settings.json, environment variables and command lines arguments as configuration. + /// + /// The configuration builder to use + /// The command line arguments + /// The modified configuration builder + private IConfigurationBuilder _SetupConfig(IConfigurationBuilder builder, string[] args) + { + return builder.SetBasePath(GetDataDirectory()) + .AddJsonFile(Path.Join(AppDomain.CurrentDomain.BaseDirectory, Program.JsonConfigPath), false, true) + .AddJsonFile(Program.JsonConfigPath, false, true) + .AddEnvironmentVariables() + .AddEnvironmentVariables("KYOO_") + .AddCommandLine(args); + } + + /// + /// Configure the logging. + /// + /// The logger builder to configure. + /// The configuration to read settings from. + private void _ConfigureLogging(LoggerConfiguration builder, [CanBeNull] IConfiguration configuration) + { + if (configuration != null) + { + try + { + builder.ReadFrom.Configuration(configuration, "logging"); + } + catch (Exception ex) + { + Log.Fatal(ex, "Could not read serilog configuration"); + } + } + + const string template = + "[{@t:HH:mm:ss} {@l:u3} {Substring(SourceContext, LastIndexOf(SourceContext, '.') + 1), 15} " + + "({@i:0000000000})] {@m}{#if not EndsWith(@m, '\n')}\n{#end}{@x}"; + + builder + .WriteTo.Console(new ExpressionTemplate(template, theme: TemplateTheme.Code)) + .WriteTo.Debug() + .WriteTo.File( + path: Path.Combine(GetDataDirectory(), "logs", "log-.log"), + formatter: new ExpressionTemplate(template), + rollingInterval: RollingInterval.Day, + rollOnFileSizeLimit: true + ) + .Enrich.WithThreadId() + .Enrich.FromLogContext(); + } + } +} \ No newline at end of file diff --git a/Kyoo/Kyoo.csproj b/Kyoo/Kyoo.csproj index 8c9aa0d5..b53ac5ae 100644 --- a/Kyoo/Kyoo.csproj +++ b/Kyoo/Kyoo.csproj @@ -21,10 +21,6 @@ transcoder.dll libtranscoder.dylib libtranscoder.so - - $(TranscoderRoot)buildWin - $(TranscoderRoot)buildOSX - $(TranscoderRoot)build @@ -52,7 +48,7 @@ - + diff --git a/Kyoo/Program.cs b/Kyoo/Program.cs index b2844b39..a2c3689a 100644 --- a/Kyoo/Program.cs +++ b/Kyoo/Program.cs @@ -1,17 +1,5 @@ -using System; -using System.IO; using System.Threading.Tasks; -using Autofac.Extensions.DependencyInjection; -using JetBrains.Annotations; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using Serilog; -using Serilog.Templates; -using Serilog.Templates.Themes; -using SEnvironment = System.Environment; namespace Kyoo { @@ -29,158 +17,19 @@ namespace Kyoo /// The string representation of the environment used in . /// #if DEBUG - private const string Environment = "Development"; + public const string Environment = "Development"; #else - private const string Environment = "Production"; + public const string Environment = "Production"; #endif - /// - /// Initialize the bootstrap logger to use it anywhere. This is done here so it is called before any method, - /// even if the is not used and this binary is used as a dll. - /// - static Program() - { - LoggerConfiguration config = new(); - _ConfigureLogging(null, config); - Log.Logger = config.CreateBootstrapLogger().ForContext(); - - AppDomain.CurrentDomain.ProcessExit += (_, _) => Log.CloseAndFlush(); - } - /// /// Main function of the program /// /// Command line arguments public static Task Main(string[] args) { - SetupDataDir(args); - return StartWithHost(CreateWebHostBuilder(args).Build()); - } - - /// - /// Start the given host and log failing exceptions. - /// - /// The host to start. - public static async Task StartWithHost(IHost host) - { - try - { - Log.Information("Running as {Name}", System.Environment.UserName); - Log.Information("Data directory: {DataDirectory}", System.Environment.CurrentDirectory); - await host.RunAsync(); - } - catch (Exception ex) - { - Log.Fatal(ex, "Unhandled exception"); - } - } - - /// - /// Register settings.json, environment variables and command lines arguments as configuration. - /// - /// The configuration builder to use - /// The command line arguments - /// The modified configuration builder - private static IConfigurationBuilder SetupConfig(IConfigurationBuilder builder, string[] args) - { - return builder.SetBasePath(System.Environment.CurrentDirectory) - .AddJsonFile(Path.Join(AppDomain.CurrentDomain.BaseDirectory, JsonConfigPath), false, true) - .AddJsonFile(JsonConfigPath, false, true) - .AddEnvironmentVariables() - .AddEnvironmentVariables("KYOO_") - .AddCommandLine(args); - } - - /// - /// Configure the logging. - /// - /// The host context that contains the configuration - /// The logger builder to configure. - private static void _ConfigureLogging([CanBeNull] HostBuilderContext context, LoggerConfiguration builder) - { - if (context != null) - { - try - { - builder.ReadFrom.Configuration(context.Configuration, "logging"); - } - catch (Exception ex) - { - Log.Fatal(ex, "Could not read serilog configuration"); - } - } - - const string template = - "[{@t:HH:mm:ss} {@l:u3} {Substring(SourceContext, LastIndexOf(SourceContext, '.') + 1), 15} " - + "({@i:0000000000})] {@m}{#if not EndsWith(@m, '\n')}\n{#end}{@x}"; - - builder - .WriteTo.Console(new ExpressionTemplate(template, theme: TemplateTheme.Code)) - .WriteTo.Debug() - .WriteTo.File( - path: "logs/log-.log", - formatter: new ExpressionTemplate(template), - rollingInterval: RollingInterval.Day, - rollOnFileSizeLimit: true - ) - .Enrich.WithThreadId() - .Enrich.FromLogContext(); - } - - /// - /// Create a a web host - /// - /// Command line parameters that can be handled by kestrel - /// A new web host instance - public static IHostBuilder CreateWebHostBuilder(string[] args) - { - IConfiguration configuration = SetupConfig(new ConfigurationBuilder(), args).Build(); - - return new HostBuilder() - .UseServiceProviderFactory(new AutofacServiceProviderFactory()) - .UseContentRoot(AppDomain.CurrentDomain.BaseDirectory) - .UseEnvironment(Environment) - .ConfigureAppConfiguration(x => SetupConfig(x, args)) - .UseSerilog(_ConfigureLogging) - .ConfigureServices(x => x.AddRouting()) - .ConfigureWebHost(x => x - .UseKestrel(options => { options.AddServerHeader = false; }) - .UseIIS() - .UseIISIntegration() - .UseUrls(configuration.GetValue("basics:url")) - .UseStartup(host => PluginsStartup.FromWebHost(host, new LoggerFactory().AddSerilog())) - ); - } - - /// - /// Parse the data directory from environment variables and command line arguments, create it if necessary. - /// Set the current directory to said data folder and place a default configuration file if it does not already - /// exists. - /// - /// The command line arguments - public static void SetupDataDir(string[] args) - { - IConfiguration parsed = new ConfigurationBuilder() - .AddEnvironmentVariables() - .AddEnvironmentVariables("KYOO_") - .AddCommandLine(args) - .Build(); - - string path = parsed.GetValue("data_dir"); - if (path == null) - path = Path.Combine(SEnvironment.GetFolderPath(SEnvironment.SpecialFolder.LocalApplicationData), "Kyoo"); - - if (!Directory.Exists(path)) - Directory.CreateDirectory(path); - SEnvironment.CurrentDirectory = path; - - if (!File.Exists(JsonConfigPath)) - File.Copy(Path.Join(AppDomain.CurrentDomain.BaseDirectory, JsonConfigPath), JsonConfigPath); + Application application = new(); + return application.Start(args); } } - - /// - /// An useless class only used to have a logger in the main. - /// - internal class Application {} } diff --git a/deployment/PKGBUILD b/deployment/PKGBUILD index 005865a1..e1763fd2 100644 --- a/deployment/PKGBUILD +++ b/deployment/PKGBUILD @@ -8,7 +8,7 @@ arch=("i686" "x86_64" "armv6h") url="https://github.com/AnonymusRaccoon/Kyoo" license=("GPLv3") groups=() -depends=("dotnet-runtime>=5" "aspnet-runtime>=5" "postgresql" "ffmpeg") +depends=("dotnet-runtime>=5" "aspnet-runtime>=5" "ffmpeg") makedepends=("dotnet-sdk>=5" "cmake" "gcc" "make" "npm" "git") install="kyoo.install" source=("git+https://github.com/AnonymusRaccoon/Kyoo" #tag=v${pkgver} @@ -30,7 +30,7 @@ build() { # cd "Kyoo-$pkgver" cd "Kyoo" export DOTNET_CLI_TELEMETRY_OPTOUT=1 - dotnet publish -c Release -o "$srcdir/output" Kyoo + dotnet publish -c Release -o "$srcdir/output" Kyoo } package() { diff --git a/deployment/PKGBUILD.github b/deployment/PKGBUILD.github index 1fbdaa3d..fa5403a1 100644 --- a/deployment/PKGBUILD.github +++ b/deployment/PKGBUILD.github @@ -8,7 +8,7 @@ arch=("i686" "x86_64" "armv6h") url="https://github.com/AnonymusRaccoon/Kyoo" license=("GPLv3") groups=() -depends=("postgresql" "ffmpeg") +depends=("ffmpeg") makedepends=() install="kyoo.install" # The output folder is needed but we can't use directory in the source array. diff --git a/deployment/kyoo.install b/deployment/kyoo.install deleted file mode 100644 index 080047de..00000000 --- a/deployment/kyoo.install +++ /dev/null @@ -1,11 +0,0 @@ -post_install() { - sudo -u postgres psql <<- "EOF" - DO $$ - BEGIN - CREATE ROLE kyoo WITH CREATEDB LOGIN PASSWORD 'kyooPassword'; - EXCEPTION WHEN DUPLICATE_OBJECT THEN - RAISE NOTICE 'not creating role kyoo -- it already exists'; - END - $$; - EOF -} \ No newline at end of file diff --git a/deployment/kyoo.service b/deployment/kyoo.service index 88b91542..a53b1967 100644 --- a/deployment/kyoo.service +++ b/deployment/kyoo.service @@ -5,7 +5,7 @@ After=network.target [Service] User=kyoo -Environment=KYOO_DATA_DIR=/var/lib/kyoo +Environment=KYOO_DATADIR=/var/lib/kyoo ExecStart=/usr/lib/kyoo/Kyoo Restart=on-abort TimeoutSec=20 diff --git a/deployment/kyoo.spec b/deployment/kyoo.spec index 6cf1c4a2..b59e907e 100644 --- a/deployment/kyoo.spec +++ b/deployment/kyoo.spec @@ -7,7 +7,7 @@ Summary: A media browser URL: https://github.com/AnonymusRaccoon/Kyoo License: GPL-3.0 BuildArch: x86_64 -Requires: postgresql-server ffmpeg-devel +Requires: ffmpeg-devel AutoReqProv: no %description @@ -24,17 +24,3 @@ rm -rf %{buildroot} /usr/lib/systemd/system/* /usr/lib/sysusers.d/kyoo.conf /usr/lib/tmpfiles.d/kyoo.conf - -%post -sudo postgresql-setup --initdb 2> /dev/null || true -sudo systemctl start postgresql -sudo -u postgres psql << "EOF" -DO $$ -BEGIN - CREATE ROLE kyoo WITH CREATEDB LOGIN PASSWORD 'kyooPassword'; - EXCEPTION WHEN DUPLICATE_OBJECT THEN - RAISE NOTICE 'not creating role kyoo -- it already exists'; -END -$$; -EOF - diff --git a/deployment/postinst b/deployment/postinst deleted file mode 100644 index cdf42470..00000000 --- a/deployment/postinst +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -set -e - -sudo -u postgres psql << "EOF" -DO $$ -BEGIN - CREATE ROLE kyoo WITH CREATEDB LOGIN PASSWORD 'kyooPassword'; - EXCEPTION WHEN DUPLICATE_OBJECT THEN - RAISE NOTICE 'not creating role kyoo -- it already exists'; -END -$$; -EOF - -systemd-sysusers -systemd-tmpfiles --create From 22a2cf6145bcbbc450f8829349873de12834b9fa Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Tue, 24 Aug 2021 13:32:34 +0200 Subject: [PATCH 13/38] Build: Fixing windows host publish --- Kyoo.WindowsHost/Kyoo.WindowsHost.target | 2 +- Kyoo/Kyoo.csproj | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Kyoo.WindowsHost/Kyoo.WindowsHost.target b/Kyoo.WindowsHost/Kyoo.WindowsHost.target index c945d8ad..53891dde 100644 --- a/Kyoo.WindowsHost/Kyoo.WindowsHost.target +++ b/Kyoo.WindowsHost/Kyoo.WindowsHost.target @@ -11,7 +11,7 @@ - + diff --git a/Kyoo/Kyoo.csproj b/Kyoo/Kyoo.csproj index b53ac5ae..75612c0c 100644 --- a/Kyoo/Kyoo.csproj +++ b/Kyoo/Kyoo.csproj @@ -10,6 +10,11 @@ Kyoo.Program default + + + $(SelfContainedValue) + $(RuntimeIdentifierValue) + true From ada55f73d75048cde17ae95e105e0876535584a4 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Tue, 24 Aug 2021 14:04:07 +0200 Subject: [PATCH 14/38] Build: Reverting transcoder exec order (it probably don't matter but the github runner does not compile --- Kyoo/Kyoo.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kyoo/Kyoo.csproj b/Kyoo/Kyoo.csproj index 75612c0c..380d440b 100644 --- a/Kyoo/Kyoo.csproj +++ b/Kyoo/Kyoo.csproj @@ -54,8 +54,8 @@ - - + + From e90a322f1967be92c85c7e191a48cb2fdcf3afd4 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Tue, 24 Aug 2021 20:37:56 +0200 Subject: [PATCH 15/38] CI: building the app in the cmd for windows instead of bash --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 91c6d42c..8bec4450 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,17 +43,17 @@ jobs: - name: Enabling windows compilations tools if: matrix.artifact == 'windows' uses: ilammy/msvc-dev-cmd@v1 - - name: Build the app + - name: Select the project to build shell: bash + run: echo "PROJECT=$([ "${{runner.os}}" == "Windows" ] && echo Kyoo.WindowsHost || echo Kyoo)" >> $GITHUB_ENV + - name: Build the app env: INCLUDE: ${{env.INCLUDE}};C:\Program Files\FFmpeg\include LIB: ${{env.LIB}};C:\Program Files\FFmpeg\lib LIBPATH: ${{env.LIBPATH}};C:\Program Files\FFmpeg\lib CFLAGS: -I/usr/local/include LDFLAGS: -L/usr/local/lib - run: | - project=$([ "${{runner.os}}" == "Windows" ] && echo Kyoo.WindowsHost || echo Kyoo) - dotnet publish -r ${{matrix.runtime}} -c Release -o dist $project + run: dotnet publish -r ${{matrix.runtime}} -c Release -o dist ${{env.PROJECT}} - name: Compression output shell: bash run: | From 01620f92f7c24adb6faeec38002b5737e708ec77 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Wed, 25 Aug 2021 10:35:47 +0200 Subject: [PATCH 16/38] CI: Building packets on the PR (for test only) --- .github/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8bec4450..4103e613 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -78,7 +78,6 @@ jobs: name: Create windows, debian, rpm & arch releases runs-on: ubuntu-latest needs: build - if: github.ref == 'refs/heads/master' env: description: "A media browser" version: v0.0.1 #${{ github.ref }} From adce8f2e7bccc25751836489d82198f2536a73fb Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Wed, 25 Aug 2021 11:25:03 +0200 Subject: [PATCH 17/38] =?UTF-8?q?=C3=83CI:=20Fixing=20windows=20unzip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4103e613..3b965c9e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -96,7 +96,7 @@ jobs: name: kyoo_windows path: artifact - name: Unzip windows files - run: mkdir dist_win && 7z e artifact/kyoo_windows.zip -o dist_win + run: mkdir dist_win && 7z x artifact/kyoo_windows.zip -odist_win - name: Install Inno Setup run: | curl -L https://jrsoftware.org/download.php/is.exe > innosetup.exe From 736f8293c97634a59daff7b11b8b122eedaf3193 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Wed, 25 Aug 2021 12:15:16 +0200 Subject: [PATCH 18/38] CI: running windows installer on a windows server --- .github/workflows/build.yml | 45 +++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3b965c9e..eee3325c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -73,9 +73,33 @@ jobs: path: | *.zip *.tar.gz - + + windows_release: + name: Create windows release + runs-on: windows-latest + needs: build + steps: + - uses: actions/checkout@v1 + - name: Download windows build + uses: actions/download-artifact@v2 + with: + name: kyoo_windows + path: artifact + - name: Unzip windows files + run: mkdir dist_win && 7z x artifact/kyoo_windows.zip -odist_win + - name: Install Inno Setup + run: | + curl -L https://jrsoftware.org/download.php/is.exe > innosetup.exe + ./innosetup.exe /VERYSILENT /SUPPRESSMSGBOXES /Log=log.txt || (cat log.txt && exit 1) + - name: Create windows installer + run: iscc -Dkyoo=$(realpath dist_win) -O./ -Fkyoo-windows deployment/kyoo-windows.iss + - uses: actions/upload-artifact@v2 + with: + name: kyoo_windows + path: ./*.exe + release: - name: Create windows, debian, rpm & arch releases + name: Create debian, rpm & arch releases runs-on: ubuntu-latest needs: build env: @@ -90,19 +114,6 @@ jobs: path: artifact - name: Unzip the published files. run: mkdir dist && tar -C dist -xzf artifact/kyoo_linux.tar.gz - - name: Download windows build - uses: actions/download-artifact@v2 - with: - name: kyoo_windows - path: artifact - - name: Unzip windows files - run: mkdir dist_win && 7z x artifact/kyoo_windows.zip -odist_win - - name: Install Inno Setup - run: | - curl -L https://jrsoftware.org/download.php/is.exe > innosetup.exe - ./innosetup.exe /VERYSILENT /SUPPRESSMSGBOXES /Log=log.txt || (cat log.txt && exit 1) - - name: Create windows installer - run: iscc -Dkyoo=$(realpath dist_win) -O./ -Fkyoo-windows deployment/kyoo-windows.iss - name: Create the package structure run: | sudo mkdir -p pkg/usr/lib/ @@ -133,10 +144,6 @@ jobs: with: pkgdir: deployment namcapDisable: true - - uses: actions/upload-artifact@v2 - with: - name: kyoo_windows - path: ./*.exe - uses: actions/upload-artifact@v2 with: name: kyoo_rpm From 88f22d3bfa573d9509cbec4bc2e9915923ad446b Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Wed, 25 Aug 2021 16:09:31 +0200 Subject: [PATCH 19/38] Build: cleaning up the webapp publish step --- Kyoo.WebApp/Front | 2 +- Kyoo.WebApp/Kyoo.WebApp.csproj | 36 ++++++++++++++++------------------ 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/Kyoo.WebApp/Front b/Kyoo.WebApp/Front index e2941691..71aab50c 160000 --- a/Kyoo.WebApp/Front +++ b/Kyoo.WebApp/Front @@ -1 +1 @@ -Subproject commit e2941691f3f57523f2094a036bf10017195f1b58 +Subproject commit 71aab50cdef2bb3d2013648f9b253e1becf4fc74 diff --git a/Kyoo.WebApp/Kyoo.WebApp.csproj b/Kyoo.WebApp/Kyoo.WebApp.csproj index 5c99d8f0..7c1196eb 100644 --- a/Kyoo.WebApp/Kyoo.WebApp.csproj +++ b/Kyoo.WebApp/Kyoo.WebApp.csproj @@ -1,4 +1,6 @@ - + + + net5.0 true @@ -33,22 +35,19 @@ - + - - - + + + - + @@ -58,18 +57,17 @@ - - - - - - - - - + + + + + + RunWebpack; + $(BuildDependsOn) + + From 3e2fd2218cc4da3bf55b1117a7eb9c3970355ade Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Fri, 27 Aug 2021 13:50:25 +0200 Subject: [PATCH 20/38] Build: retrying the CI with a new package-lock --- Kyoo.WebApp/Front | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kyoo.WebApp/Front b/Kyoo.WebApp/Front index 71aab50c..ac41fcab 160000 --- a/Kyoo.WebApp/Front +++ b/Kyoo.WebApp/Front @@ -1 +1 @@ -Subproject commit 71aab50cdef2bb3d2013648f9b253e1becf4fc74 +Subproject commit ac41fcab3a8847c765e2f834aa17675955993dbb From cd3caf5df235a7be005c709a064adbdd0a811c66 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Fri, 27 Aug 2021 17:01:05 +0200 Subject: [PATCH 21/38] WebApp: Updating angular --- Kyoo.WebApp/Front | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kyoo.WebApp/Front b/Kyoo.WebApp/Front index ac41fcab..ef7b2252 160000 --- a/Kyoo.WebApp/Front +++ b/Kyoo.WebApp/Front @@ -1 +1 @@ -Subproject commit ac41fcab3a8847c765e2f834aa17675955993dbb +Subproject commit ef7b22523d9f7f55a4b385ab1565f421c2212dae From 2797792ad8ecbc3c24c885a31f72edb61f27a21b Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sat, 28 Aug 2021 10:52:50 +0200 Subject: [PATCH 22/38] Build: Adding a real error message for kyoo's missing transcoder --- Kyoo/Kyoo.csproj | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Kyoo/Kyoo.csproj b/Kyoo/Kyoo.csproj index 380d440b..b564772d 100644 --- a/Kyoo/Kyoo.csproj +++ b/Kyoo/Kyoo.csproj @@ -54,8 +54,16 @@ - - + + + + + + + From 88320dfa4c7fa1ffb5396a0f6923c4b9ac864a70 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sat, 28 Aug 2021 12:10:07 +0200 Subject: [PATCH 23/38] Building: WebPack is now running only once when publishing the windows host --- Kyoo.WebApp/Kyoo.WebApp.csproj | 2 +- Kyoo/Kyoo.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Kyoo.WebApp/Kyoo.WebApp.csproj b/Kyoo.WebApp/Kyoo.WebApp.csproj index 7c1196eb..3f38a706 100644 --- a/Kyoo.WebApp/Kyoo.WebApp.csproj +++ b/Kyoo.WebApp/Kyoo.WebApp.csproj @@ -35,7 +35,7 @@ - + diff --git a/Kyoo/Kyoo.csproj b/Kyoo/Kyoo.csproj index b564772d..5ce67120 100644 --- a/Kyoo/Kyoo.csproj +++ b/Kyoo/Kyoo.csproj @@ -50,7 +50,7 @@ - + From e307e7d53ae8b72320d9b9edf81590968bba0070 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sat, 28 Aug 2021 12:31:31 +0200 Subject: [PATCH 24/38] =?UTF-8?q?=C3=83CI:=20Deleting=20DEBIAN=20files=20b?= =?UTF-8?q?efore=20rpm=20build?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eee3325c..dfc301ed 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -88,6 +88,7 @@ jobs: - name: Unzip windows files run: mkdir dist_win && 7z x artifact/kyoo_windows.zip -odist_win - name: Install Inno Setup + shell: bash run: | curl -L https://jrsoftware.org/download.php/is.exe > innosetup.exe ./innosetup.exe /VERYSILENT /SUPPRESSMSGBOXES /Log=log.txt || (cat log.txt && exit 1) @@ -121,7 +122,8 @@ jobs: sudo install -Dm 644 deployment/kyoo.service -t pkg/usr/lib/systemd/system/ sudo install -Dm 644 deployment/kyoo.sysusers pkg/usr/lib/sysusers.d/kyoo.conf sudo install -Dm 644 deployment/kyoo.tmpfiles pkg/usr/lib/tmpfiles.d/kyoo.conf - - uses: jiro4989/build-deb-action@v2 + - name: Build debian package + uses: jiro4989/build-deb-action@v2 with: package: kyoo package_root: pkg @@ -133,6 +135,7 @@ jobs: - name: Build rpm package run: | mkdir out + sudo rm -rf pkg/DEBIAN rpmbuild -bb --buildroot $(pwd)/out --build-in-place --define "_rpmdir $(pwd)/rpm" deployment/kyoo.spec - name: Prepare arch package run: | From 6add043ec25e70d1ee5c6943b7ecb50af54b981d Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sat, 28 Aug 2021 12:55:22 +0200 Subject: [PATCH 25/38] CI: Removing install script of PKGBUILD --- deployment/PKGBUILD | 1 - deployment/PKGBUILD.github | 1 - 2 files changed, 2 deletions(-) diff --git a/deployment/PKGBUILD b/deployment/PKGBUILD index e1763fd2..ecd32404 100644 --- a/deployment/PKGBUILD +++ b/deployment/PKGBUILD @@ -10,7 +10,6 @@ license=("GPLv3") groups=() depends=("dotnet-runtime>=5" "aspnet-runtime>=5" "ffmpeg") makedepends=("dotnet-sdk>=5" "cmake" "gcc" "make" "npm" "git") -install="kyoo.install" source=("git+https://github.com/AnonymusRaccoon/Kyoo" #tag=v${pkgver} "kyoo.service" "kyoo.sysusers" diff --git a/deployment/PKGBUILD.github b/deployment/PKGBUILD.github index fa5403a1..e464dfc8 100644 --- a/deployment/PKGBUILD.github +++ b/deployment/PKGBUILD.github @@ -10,7 +10,6 @@ license=("GPLv3") groups=() depends=("ffmpeg") makedepends=() -install="kyoo.install" # The output folder is needed but we can't use directory in the source array. source=() sha256sums=() From 996b5206a8a6fb26b08546d01cc8374af0010029 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sat, 28 Aug 2021 13:53:40 +0200 Subject: [PATCH 26/38] CI: Using cmd as windows shell instead of bash --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dfc301ed..d0cf1093 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -88,7 +88,7 @@ jobs: - name: Unzip windows files run: mkdir dist_win && 7z x artifact/kyoo_windows.zip -odist_win - name: Install Inno Setup - shell: bash + shell: cmd run: | curl -L https://jrsoftware.org/download.php/is.exe > innosetup.exe ./innosetup.exe /VERYSILENT /SUPPRESSMSGBOXES /Log=log.txt || (cat log.txt && exit 1) From db74c80679e330a488929bc88f4c0878590cb454 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sat, 28 Aug 2021 19:58:14 +0200 Subject: [PATCH 27/38] CI: Removing ./ for windows --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d0cf1093..dc55ff2d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -91,7 +91,7 @@ jobs: shell: cmd run: | curl -L https://jrsoftware.org/download.php/is.exe > innosetup.exe - ./innosetup.exe /VERYSILENT /SUPPRESSMSGBOXES /Log=log.txt || (cat log.txt && exit 1) + innosetup.exe /VERYSILENT /SUPPRESSMSGBOXES /Log=log.txt || (cat log.txt && exit 1) - name: Create windows installer run: iscc -Dkyoo=$(realpath dist_win) -O./ -Fkyoo-windows deployment/kyoo-windows.iss - uses: actions/upload-artifact@v2 From 6d9d04e1cf7c8d8fa44a109d9edffa9a44cf383e Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sat, 28 Aug 2021 20:21:35 +0200 Subject: [PATCH 28/38] CI: Using bash instead of powershell to create the windows installer --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dc55ff2d..4fb9d19b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -93,6 +93,7 @@ jobs: curl -L https://jrsoftware.org/download.php/is.exe > innosetup.exe innosetup.exe /VERYSILENT /SUPPRESSMSGBOXES /Log=log.txt || (cat log.txt && exit 1) - name: Create windows installer + shell: bash run: iscc -Dkyoo=$(realpath dist_win) -O./ -Fkyoo-windows deployment/kyoo-windows.iss - uses: actions/upload-artifact@v2 with: From 63c583dc9239bcb5763e86f145fb9355ef9b6f4d Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sun, 29 Aug 2021 13:53:34 +0200 Subject: [PATCH 29/38] CI: Fixing windows startup and cleaning the output zip --- .github/workflows/build.yml | 4 ++-- deployment/kyoo-windows.iss | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4fb9d19b..7fbb5b0d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -97,8 +97,8 @@ jobs: run: iscc -Dkyoo=$(realpath dist_win) -O./ -Fkyoo-windows deployment/kyoo-windows.iss - uses: actions/upload-artifact@v2 with: - name: kyoo_windows - path: ./*.exe + name: kyoo_windows_installer + path: ./kyoo-windows.exe release: name: Create debian, rpm & arch releases diff --git a/deployment/kyoo-windows.iss b/deployment/kyoo-windows.iss index 720ea594..34744576 100644 --- a/deployment/kyoo-windows.iss +++ b/deployment/kyoo-windows.iss @@ -41,6 +41,7 @@ Type: filesandordirs; Name: "{code:GetDataDir}" Name: "{autoprograms}\Kyoo"; Filename: "{app}\Kyoo.WindowsHost.exe" Name: "{autoprograms}\Kyoo (Console)"; Filename: "{app}\Kyoo.exe" Name: "{autodesktop}\Kyoo"; Filename: "{app}\Kyoo.WindowsHost.exe"; Tasks: desktopicon +Name: "{autostartup}\Kyoo"; Filename: "{app}\Kyoo.WindowsHost.exe"; Tasks: startupShortcut [Run] Filename: "{app}\Kyoo.WindowsHost.exe"; Description: "{cm:LaunchProgram,Kyoo}"; Flags: nowait postinstall skipifsilent From acf87b26194a672cbf521167ea69d6ed05f3d182 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Mon, 30 Aug 2021 13:09:12 +0200 Subject: [PATCH 30/38] Build: Cleaning up the build process but breaking windows publish --- Kyoo.Abstractions/Kyoo.Abstractions.csproj | 1 - Kyoo.WebApp/Kyoo.WebApp.csproj | 14 ++++++++++---- Kyoo.WindowsHost/Kyoo.WindowsHost.target | 4 ++-- Kyoo/Kyoo.csproj | 7 +------ 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Kyoo.Abstractions/Kyoo.Abstractions.csproj b/Kyoo.Abstractions/Kyoo.Abstractions.csproj index 9831afb3..2c7ac85d 100644 --- a/Kyoo.Abstractions/Kyoo.Abstractions.csproj +++ b/Kyoo.Abstractions/Kyoo.Abstractions.csproj @@ -2,7 +2,6 @@ net5.0 - true Kyoo.Abstractions Zoe Roux Base package to create plugins for Kyoo. diff --git a/Kyoo.WebApp/Kyoo.WebApp.csproj b/Kyoo.WebApp/Kyoo.WebApp.csproj index 3f38a706..2e7cd80e 100644 --- a/Kyoo.WebApp/Kyoo.WebApp.csproj +++ b/Kyoo.WebApp/Kyoo.WebApp.csproj @@ -8,6 +8,7 @@ false $(DefaultItemExcludes);$(SpaRoot)node_modules/** Front/ + $(SpaRoot)node_modules/.install-stamp false @@ -35,16 +36,20 @@ - + - - - + + + + + + + @@ -66,6 +71,7 @@ + NpmInstall; RunWebpack; $(BuildDependsOn) diff --git a/Kyoo.WindowsHost/Kyoo.WindowsHost.target b/Kyoo.WindowsHost/Kyoo.WindowsHost.target index 53891dde..c10e4fa0 100644 --- a/Kyoo.WindowsHost/Kyoo.WindowsHost.target +++ b/Kyoo.WindowsHost/Kyoo.WindowsHost.target @@ -11,7 +11,7 @@ - + @@ -20,4 +20,4 @@ PreserveNewest - \ No newline at end of file + diff --git a/Kyoo/Kyoo.csproj b/Kyoo/Kyoo.csproj index 5ce67120..b3b31fcf 100644 --- a/Kyoo/Kyoo.csproj +++ b/Kyoo/Kyoo.csproj @@ -11,11 +11,6 @@ default - - $(SelfContainedValue) - $(RuntimeIdentifierValue) - - true true @@ -50,7 +45,7 @@ - + From e338fc6b3740756faf432fecdfb1dd01e1caa3c8 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Mon, 30 Aug 2021 13:43:54 +0200 Subject: [PATCH 31/38] Host: Moving the default host to a subproject, Kyoo is now a library without host --- .github/workflows/build.yml | 2 +- Kyoo.Abstractions/Controllers/IApplication.cs | 7 +++ Kyoo.Host.Console/Kyoo.Host.Console.csproj | 16 +++++++ {Kyoo => Kyoo.Host.Console}/Program.cs | 13 ++---- .../Kyoo.Host.WindowsTrait.csproj | 4 +- .../Kyoo.Host.WindowsTrait.linux.target | 0 .../Kyoo.Host.WindowsTrait.target | 0 .../Program.cs | 15 +++++-- .../SystemTrait.cs | 2 +- .../kyoo.ico | Bin Kyoo.sln | 8 +++- Kyoo/Application.cs | 41 ++++++++++++++---- Kyoo/Controllers/ConfigurationManager.cs | 11 ++++- Kyoo/Kyoo.csproj | 9 ++-- 14 files changed, 94 insertions(+), 34 deletions(-) create mode 100644 Kyoo.Host.Console/Kyoo.Host.Console.csproj rename {Kyoo => Kyoo.Host.Console}/Program.cs (63%) rename Kyoo.WindowsHost/Kyoo.WindowsHost.csproj => Kyoo.Host.WindowsTrait/Kyoo.Host.WindowsTrait.csproj (52%) rename Kyoo.WindowsHost/Kyoo.WindowsHost.linux.target => Kyoo.Host.WindowsTrait/Kyoo.Host.WindowsTrait.linux.target (100%) rename Kyoo.WindowsHost/Kyoo.WindowsHost.target => Kyoo.Host.WindowsTrait/Kyoo.Host.WindowsTrait.target (100%) rename {Kyoo.WindowsHost => Kyoo.Host.WindowsTrait}/Program.cs (60%) rename {Kyoo.WindowsHost => Kyoo.Host.WindowsTrait}/SystemTrait.cs (99%) rename {Kyoo.WindowsHost => Kyoo.Host.WindowsTrait}/kyoo.ico (100%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a0b5c9e6..e0e25260 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,7 +44,7 @@ jobs: uses: ilammy/msvc-dev-cmd@v1 - name: Select the project to build shell: bash - run: echo "PROJECT=$([ "${{runner.os}}" == "Windows" ] && echo Kyoo.WindowsHost || echo Kyoo)" >> $GITHUB_ENV + run: echo "PROJECT=$([ "${{runner.os}}" == "Windows" ] && echo Kyoo.Host.WindowsTrait || echo Kyoo.Host.Console)" >> $GITHUB_ENV - name: Build the app env: INCLUDE: ${{env.INCLUDE}};C:\Program Files\FFmpeg\include diff --git a/Kyoo.Abstractions/Controllers/IApplication.cs b/Kyoo.Abstractions/Controllers/IApplication.cs index 95e01454..8e72280e 100644 --- a/Kyoo.Abstractions/Controllers/IApplication.cs +++ b/Kyoo.Abstractions/Controllers/IApplication.cs @@ -20,5 +20,12 @@ /// /// Retrieve the data directory where runtime data should be stored string GetDataDirectory(); + + /// + /// Retrieve the path of the json configuration file + /// (relative to the data directory, see ). + /// + /// The configuration file name. + string GetConfigFile(); } } \ No newline at end of file diff --git a/Kyoo.Host.Console/Kyoo.Host.Console.csproj b/Kyoo.Host.Console/Kyoo.Host.Console.csproj new file mode 100644 index 00000000..e7b396be --- /dev/null +++ b/Kyoo.Host.Console/Kyoo.Host.Console.csproj @@ -0,0 +1,16 @@ + + + Exe + net5.0 + Kyoo.Host.Console.Program + + SDG + Zoe Roux + https://github.com/AnonymusRaccoon/Kyoo + default + + + + + + diff --git a/Kyoo/Program.cs b/Kyoo.Host.Console/Program.cs similarity index 63% rename from Kyoo/Program.cs rename to Kyoo.Host.Console/Program.cs index a2c3689a..b6699fcf 100644 --- a/Kyoo/Program.cs +++ b/Kyoo.Host.Console/Program.cs @@ -1,25 +1,20 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; -namespace Kyoo +namespace Kyoo.Host.Console { /// /// Program entrypoint. /// public static class Program { - /// - /// The path of the json configuration of the application. - /// - public const string JsonConfigPath = "./settings.json"; - /// /// The string representation of the environment used in . /// #if DEBUG - public const string Environment = "Development"; + private const string Environment = "Development"; #else - public const string Environment = "Production"; + private const string Environment = "Production"; #endif /// @@ -28,7 +23,7 @@ namespace Kyoo /// Command line arguments public static Task Main(string[] args) { - Application application = new(); + Application application = new(Environment); return application.Start(args); } } diff --git a/Kyoo.WindowsHost/Kyoo.WindowsHost.csproj b/Kyoo.Host.WindowsTrait/Kyoo.Host.WindowsTrait.csproj similarity index 52% rename from Kyoo.WindowsHost/Kyoo.WindowsHost.csproj rename to Kyoo.Host.WindowsTrait/Kyoo.Host.WindowsTrait.csproj index 35a4a4b8..41ab83db 100644 --- a/Kyoo.WindowsHost/Kyoo.WindowsHost.csproj +++ b/Kyoo.Host.WindowsTrait/Kyoo.Host.WindowsTrait.csproj @@ -3,8 +3,8 @@ true - - + + diff --git a/Kyoo.WindowsHost/Kyoo.WindowsHost.linux.target b/Kyoo.Host.WindowsTrait/Kyoo.Host.WindowsTrait.linux.target similarity index 100% rename from Kyoo.WindowsHost/Kyoo.WindowsHost.linux.target rename to Kyoo.Host.WindowsTrait/Kyoo.Host.WindowsTrait.linux.target diff --git a/Kyoo.WindowsHost/Kyoo.WindowsHost.target b/Kyoo.Host.WindowsTrait/Kyoo.Host.WindowsTrait.target similarity index 100% rename from Kyoo.WindowsHost/Kyoo.WindowsHost.target rename to Kyoo.Host.WindowsTrait/Kyoo.Host.WindowsTrait.target diff --git a/Kyoo.WindowsHost/Program.cs b/Kyoo.Host.WindowsTrait/Program.cs similarity index 60% rename from Kyoo.WindowsHost/Program.cs rename to Kyoo.Host.WindowsTrait/Program.cs index c3ea68b4..9b4936ba 100644 --- a/Kyoo.WindowsHost/Program.cs +++ b/Kyoo.Host.WindowsTrait/Program.cs @@ -1,18 +1,27 @@ using System.Threading.Tasks; using Autofac; -namespace Kyoo.WindowsHost +namespace Kyoo.Host.WindowsTrait { public static class Program { /// - /// The main entry point for the application that overrides the default host (). + /// The string representation of the environment used in IWebHostEnvironment. + /// +#if DEBUG + private const string Environment = "Development"; +#else + private const string Environment = "Production"; +#endif + + /// + /// The main entry point for the application that overrides the default host. /// It adds a system trait for windows and since the host is build as a windows executable instead of a console /// app, the console is not showed. /// public static Task Main(string[] args) { - Application application = new(); + Application application = new(Environment); return application.Start(args, builder => { builder.RegisterType().As().SingleInstance(); diff --git a/Kyoo.WindowsHost/SystemTrait.cs b/Kyoo.Host.WindowsTrait/SystemTrait.cs similarity index 99% rename from Kyoo.WindowsHost/SystemTrait.cs rename to Kyoo.Host.WindowsTrait/SystemTrait.cs index 96525f7d..86037c1d 100644 --- a/Kyoo.WindowsHost/SystemTrait.cs +++ b/Kyoo.Host.WindowsTrait/SystemTrait.cs @@ -9,7 +9,7 @@ using Kyoo.Abstractions.Controllers; using Kyoo.Models.Options; using Microsoft.Extensions.Options; -namespace Kyoo.WindowsHost +namespace Kyoo.Host.WindowsTrait { /// /// A singleton that add an notification icon on the window's toolbar. diff --git a/Kyoo.WindowsHost/kyoo.ico b/Kyoo.Host.WindowsTrait/kyoo.ico similarity index 100% rename from Kyoo.WindowsHost/kyoo.ico rename to Kyoo.Host.WindowsTrait/kyoo.ico diff --git a/Kyoo.sln b/Kyoo.sln index 6ab7d6d9..cbb05a6c 100644 --- a/Kyoo.sln +++ b/Kyoo.sln @@ -19,7 +19,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kyoo.Tests", "tests\Kyoo.Te EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kyoo.WebApp", "Kyoo.WebApp\Kyoo.WebApp.csproj", "{2374D500-1ADB-4752-85DB-8BB0DDF5A8E8}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kyoo.WindowsHost", "Kyoo.WindowsHost\Kyoo.WindowsHost.csproj", "{98851001-40DD-46A6-94B3-2F8D90722076}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kyoo.Host.WindowsTrait", "Kyoo.Host.WindowsTrait\Kyoo.Host.WindowsTrait.csproj", "{98851001-40DD-46A6-94B3-2F8D90722076}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kyoo.Host.Console", "Kyoo.Host.Console\Kyoo.Host.Console.csproj", "{D8658BEA-8949-45AC-BEBB-A4FFC4F800F5}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -75,5 +77,9 @@ Global {98851001-40DD-46A6-94B3-2F8D90722076}.Debug|Any CPU.Build.0 = Debug|Any CPU {98851001-40DD-46A6-94B3-2F8D90722076}.Release|Any CPU.ActiveCfg = Release|Any CPU {98851001-40DD-46A6-94B3-2F8D90722076}.Release|Any CPU.Build.0 = Release|Any CPU + {D8658BEA-8949-45AC-BEBB-A4FFC4F800F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D8658BEA-8949-45AC-BEBB-A4FFC4F800F5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D8658BEA-8949-45AC-BEBB-A4FFC4F800F5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D8658BEA-8949-45AC-BEBB-A4FFC4F800F5}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/Kyoo/Application.cs b/Kyoo/Application.cs index 4cc1004d..b51192f3 100644 --- a/Kyoo/Application.cs +++ b/Kyoo/Application.cs @@ -37,6 +37,22 @@ namespace Kyoo /// private CancellationTokenSource _tokenSource; + /// + /// The environment in witch Kyoo will run (ether "Production" or "Development"). + /// + private readonly string _environment; + + + /// + /// Create a new that will use the specified environment. + /// + /// The environment to run in. + public Application(string environment) + { + _environment = environment; + } + + /// /// Start the application with the given console args. /// This is generally called from the Main entrypoint of Kyoo. @@ -100,7 +116,14 @@ namespace Kyoo { return _dataDir; } - + + + /// + public string GetConfigFile() + { + return "./settings.json"; + } + /// /// Parse the data directory from environment variables and command line arguments, create it if necessary. /// Set the current directory to said data folder and place a default configuration file if it does not already @@ -108,7 +131,7 @@ namespace Kyoo /// /// The command line arguments /// The current data directory. - private static string _SetupDataDir(string[] args) + private string _SetupDataDir(string[] args) { Dictionary registry = new(); @@ -134,9 +157,9 @@ namespace Kyoo Directory.CreateDirectory(path); Environment.CurrentDirectory = path; - if (!File.Exists(Program.JsonConfigPath)) - File.Copy(Path.Join(AppDomain.CurrentDomain.BaseDirectory, Program.JsonConfigPath), - Program.JsonConfigPath); + if (!File.Exists(GetConfigFile())) + File.Copy(Path.Join(AppDomain.CurrentDomain.BaseDirectory, GetConfigFile()), + GetConfigFile()); return path; } @@ -159,7 +182,7 @@ namespace Kyoo Log.Fatal(ex, "Unhandled exception"); } } - + /// /// Create a a web host /// @@ -172,7 +195,7 @@ namespace Kyoo return new HostBuilder() .UseServiceProviderFactory(new AutofacServiceProviderFactory()) .UseContentRoot(AppDomain.CurrentDomain.BaseDirectory) - .UseEnvironment(Program.Environment) + .UseEnvironment(_environment) .ConfigureAppConfiguration(x => _SetupConfig(x, args)) .UseSerilog((host, builder) => _ConfigureLogging(builder, host.Configuration)) .ConfigureServices(x => x.AddRouting()) @@ -198,8 +221,8 @@ namespace Kyoo private IConfigurationBuilder _SetupConfig(IConfigurationBuilder builder, string[] args) { return builder.SetBasePath(GetDataDirectory()) - .AddJsonFile(Path.Join(AppDomain.CurrentDomain.BaseDirectory, Program.JsonConfigPath), false, true) - .AddJsonFile(Program.JsonConfigPath, false, true) + .AddJsonFile(Path.Join(AppDomain.CurrentDomain.BaseDirectory, GetConfigFile()), false, true) + .AddJsonFile(GetConfigFile(), false, true) .AddEnvironmentVariables() .AddEnvironmentVariables("KYOO_") .AddCommandLine(args); diff --git a/Kyoo/Controllers/ConfigurationManager.cs b/Kyoo/Controllers/ConfigurationManager.cs index c6476551..d43129de 100644 --- a/Kyoo/Controllers/ConfigurationManager.cs +++ b/Kyoo/Controllers/ConfigurationManager.cs @@ -21,6 +21,11 @@ namespace Kyoo.Controllers /// private readonly IConfiguration _configuration; + /// + /// The application running Kyoo, it is used to retrieve the configuration file. + /// + private readonly IApplication _application; + /// /// The strongly typed list of options /// @@ -31,9 +36,11 @@ namespace Kyoo.Controllers /// /// The configuration to use. /// The strongly typed option list. - public ConfigurationManager(IConfiguration configuration, IEnumerable references) + /// The application running Kyoo, it is used to retrieve the configuration file. + public ConfigurationManager(IConfiguration configuration, IEnumerable references, IApplication application) { _configuration = configuration; + _application = application; _references = references.ToDictionary(x => x.Path, x => x.Type, StringComparer.OrdinalIgnoreCase); } @@ -131,7 +138,7 @@ namespace Kyoo.Controllers IDictionary configDic = config; configDic[path] = value; JObject obj = JObject.FromObject(config); - await using StreamWriter writer = new(Program.JsonConfigPath); + await using StreamWriter writer = new(_application.GetConfigFile()); await writer.WriteAsync(obj.ToString()); } diff --git a/Kyoo/Kyoo.csproj b/Kyoo/Kyoo.csproj index b3b31fcf..0e37a4f9 100644 --- a/Kyoo/Kyoo.csproj +++ b/Kyoo/Kyoo.csproj @@ -1,4 +1,4 @@ - + net5.0 @@ -7,7 +7,6 @@ SDG Zoe Roux https://github.com/AnonymusRaccoon/Kyoo - Kyoo.Program default @@ -55,10 +54,7 @@ - + @@ -70,5 +66,6 @@ + From 3d14902a0b84462ec79900ac88beb5b9937c3e94 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Mon, 30 Aug 2021 13:46:01 +0200 Subject: [PATCH 32/38] Build: Removing npm install step when skipping the web app --- Kyoo.WebApp/Kyoo.WebApp.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kyoo.WebApp/Kyoo.WebApp.csproj b/Kyoo.WebApp/Kyoo.WebApp.csproj index 2e7cd80e..c5f22695 100644 --- a/Kyoo.WebApp/Kyoo.WebApp.csproj +++ b/Kyoo.WebApp/Kyoo.WebApp.csproj @@ -36,7 +36,7 @@ - + From 75346d8f7aede649ef87e14a5cd49b2a1e4ff03f Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Tue, 31 Aug 2021 20:45:42 +0200 Subject: [PATCH 33/38] Host: Fixing windows host console presence, renaming Kyoo to Kyoo.Core --- .github/workflows/build.yml | 3 +-- Kyoo.Abstractions/Controllers/IRepository.cs | 1 + .../Models/ConfigurationReference.cs | 1 + Kyoo.Abstractions/Models/Page.cs | 1 + Kyoo.Abstractions/Models/Resources/Genre.cs | 1 + .../Models/Resources/Provider.cs | 1 + Kyoo.Abstractions/Models/Resources/Studio.cs | 1 + Kyoo.Abstractions/Module.cs | 1 + .../Utility/EnumerableExtensions.cs | 2 +- Kyoo.Abstractions/Utility/Merger.cs | 2 +- Kyoo.Abstractions/Utility/MethodOfUtils.cs | 2 +- Kyoo.Abstractions/Utility/TaskUtils.cs | 2 +- Kyoo.Abstractions/Utility/Utility.cs | 2 +- .../Models/DTO/RegisterRequest.cs | 1 + {Kyoo => Kyoo.Core}/.gitignore | 0 {Kyoo => Kyoo.Core}/Application.cs | 2 +- .../Controllers/ConfigurationManager.cs | 4 +-- .../FileSystems/FileSystemComposite.cs | 4 +-- .../Controllers/FileSystems/HttpFileSystem.cs | 2 +- .../FileSystems/LocalFileSystem.cs | 4 +-- .../Controllers/LibraryManager.cs | 3 ++- .../PassthroughPermissionValidator.cs | 2 +- .../Controllers/PluginManager.cs | 4 +-- .../Controllers/ProviderComposite.cs | 3 ++- .../Controllers/RegexIdentifier.cs | 7 ++--- .../Repositories/CollectionRepository.cs | 2 +- .../Repositories/EpisodeRepository.cs | 3 ++- .../Repositories/GenreRepository.cs | 2 +- .../Repositories/LibraryItemRepository.cs | 2 +- .../Repositories/LibraryRepository.cs | 3 ++- .../Repositories/LocalRepository.cs | 5 ++-- .../Repositories/PeopleRepository.cs | 3 ++- .../Repositories/ProviderRepository.cs | 2 +- .../Repositories/SeasonRepository.cs | 2 +- .../Repositories/ShowRepository.cs | 3 ++- .../Repositories/StudioRepository.cs | 2 +- .../Repositories/TrackRepository.cs | 2 +- .../Repositories/UserRepository.cs | 2 +- .../Controllers/TaskManager.cs | 4 +-- .../Controllers/ThumbnailsManager.cs | 2 +- {Kyoo => Kyoo.Core}/Controllers/Transcoder.cs | 12 ++++----- {Kyoo => Kyoo.Core}/CoreModule.cs | 10 +++---- {Kyoo => Kyoo.Core}/Helper.cs | 2 +- .../Kyoo.csproj => Kyoo.Core/Kyoo.Core.csproj | 0 {Kyoo => Kyoo.Core}/Models/FileExtensions.cs | 2 +- .../Models/Options/BasicOptions.cs | 2 +- .../Models/Options/MediaOptions.cs | 2 +- .../Models/Options/TaskOptions.cs | 2 +- {Kyoo => Kyoo.Core}/Models/Stream.cs | 2 +- {Kyoo => Kyoo.Core}/PluginsStartup.cs | 9 ++++--- {Kyoo => Kyoo.Core}/Tasks/Crawler.cs | 4 +-- {Kyoo => Kyoo.Core}/Tasks/ExtractMetadata.cs | 0 {Kyoo => Kyoo.Core}/Tasks/Housekeeping.cs | 2 +- .../Tasks/MetadataProviderLoader.cs | 2 +- .../Tasks/PluginInitializer.cs | 2 +- {Kyoo => Kyoo.Core}/Tasks/ReScan.cs | 0 {Kyoo => Kyoo.Core}/Tasks/RegisterEpisode.cs | 2 +- {Kyoo => Kyoo.Core}/Tasks/RegisterSubtitle.cs | 2 +- {Kyoo => Kyoo.Core}/Views/CollectionApi.cs | 4 +-- {Kyoo => Kyoo.Core}/Views/ConfigurationApi.cs | 2 +- {Kyoo => Kyoo.Core}/Views/EpisodeApi.cs | 4 +-- {Kyoo => Kyoo.Core}/Views/GenreApi.cs | 4 +-- {Kyoo => Kyoo.Core}/Views/Helper/ApiHelper.cs | 2 +- {Kyoo => Kyoo.Core}/Views/Helper/CrudApi.cs | 2 +- .../Views/Helper/JsonSerializer.cs | 3 ++- .../Views/Helper/ResourceViewAttribute.cs | 3 ++- {Kyoo => Kyoo.Core}/Views/LibraryApi.cs | 4 +-- {Kyoo => Kyoo.Core}/Views/LibraryItemApi.cs | 4 +-- {Kyoo => Kyoo.Core}/Views/PeopleApi.cs | 4 +-- {Kyoo => Kyoo.Core}/Views/ProviderApi.cs | 4 +-- {Kyoo => Kyoo.Core}/Views/SearchApi.cs | 2 +- {Kyoo => Kyoo.Core}/Views/SeasonApi.cs | 4 +-- {Kyoo => Kyoo.Core}/Views/ShowApi.cs | 4 +-- {Kyoo => Kyoo.Core}/Views/StudioApi.cs | 4 +-- {Kyoo => Kyoo.Core}/Views/SubtitleApi.cs | 2 +- {Kyoo => Kyoo.Core}/Views/TaskApi.cs | 2 +- {Kyoo => Kyoo.Core}/Views/TrackApi.cs | 4 +-- {Kyoo => Kyoo.Core}/Views/VideoApi.cs | 4 +-- {Kyoo => Kyoo.Core}/Views/WatchApi.cs | 2 +- {Kyoo => Kyoo.Core}/settings.json | 0 Kyoo.Database/Extensions.cs | 2 +- Kyoo.Host.Console/Kyoo.Host.Console.csproj | 11 +++++++- Kyoo.Host.Console/Program.cs | 1 + .../Kyoo.Host.WindowsTrait.target | 3 ++- Kyoo.Host.WindowsTrait/Program.cs | 1 + Kyoo.Host.WindowsTrait/SystemTrait.cs | 2 +- Kyoo.Postgresql/PostgresContext.cs | 1 + Kyoo.SqLite/SqLiteContext.cs | 1 + .../Convertors/CollectionConvertors.cs | 1 + Kyoo.TheMovieDb/Convertors/MovieConvertors.cs | 1 + .../Convertors/PeopleConvertors.cs | 1 + Kyoo.TheMovieDb/Convertors/ShowConvertors.cs | 1 + .../Convertors/StudioConvertors.cs | 1 + Kyoo.TheTvdb/Convertors.cs | 1 + Kyoo.WebApp/Kyoo.WebApp.csproj | 3 ++- Kyoo.sln | 2 +- deployment/PKGBUILD | 2 +- deployment/kyoo-windows.iss | 14 +++++----- deployment/kyoo.service | 2 +- .../Database/RepositoryActivator.cs | 2 +- .../Database/SpecificTests/LibraryTests.cs | 1 + .../Database/SpecificTests/ShowTests.cs | 1 + .../Kyoo.Tests/Identifier/IdentifierTests.cs | 4 +-- tests/Kyoo.Tests/Identifier/ProviderTests.cs | 2 +- tests/Kyoo.Tests/Kyoo.Tests.csproj | 2 +- tests/Kyoo.Tests/Utility/EnumerableTests.cs | 1 + tests/Kyoo.Tests/Utility/MergerTests.cs | 1 + tests/Kyoo.Tests/Utility/TaskTests.cs | 1 + tests/Kyoo.Tests/Utility/UtilityTests.cs | 27 ++++++++++--------- 109 files changed, 179 insertions(+), 134 deletions(-) rename {Kyoo => Kyoo.Core}/.gitignore (100%) rename {Kyoo => Kyoo.Core}/Application.cs (99%) rename {Kyoo => Kyoo.Core}/Controllers/ConfigurationManager.cs (99%) rename {Kyoo => Kyoo.Core}/Controllers/FileSystems/FileSystemComposite.cs (99%) rename {Kyoo => Kyoo.Core}/Controllers/FileSystems/HttpFileSystem.cs (99%) rename {Kyoo => Kyoo.Core}/Controllers/FileSystems/LocalFileSystem.cs (98%) rename {Kyoo => Kyoo.Core}/Controllers/LibraryManager.cs (99%) rename {Kyoo => Kyoo.Core}/Controllers/PassthroughPermissionValidator.cs (96%) rename {Kyoo => Kyoo.Core}/Controllers/PluginManager.cs (98%) rename {Kyoo => Kyoo.Core}/Controllers/ProviderComposite.cs (98%) rename {Kyoo => Kyoo.Core}/Controllers/RegexIdentifier.cs (97%) rename {Kyoo => Kyoo.Core}/Controllers/Repositories/CollectionRepository.cs (98%) rename {Kyoo => Kyoo.Core}/Controllers/Repositories/EpisodeRepository.cs (99%) rename {Kyoo => Kyoo.Core}/Controllers/Repositories/GenreRepository.cs (98%) rename {Kyoo => Kyoo.Core}/Controllers/Repositories/LibraryItemRepository.cs (99%) rename {Kyoo => Kyoo.Core}/Controllers/Repositories/LibraryRepository.cs (98%) rename {Kyoo => Kyoo.Core}/Controllers/Repositories/LocalRepository.cs (99%) rename {Kyoo => Kyoo.Core}/Controllers/Repositories/PeopleRepository.cs (99%) rename {Kyoo => Kyoo.Core}/Controllers/Repositories/ProviderRepository.cs (98%) rename {Kyoo => Kyoo.Core}/Controllers/Repositories/SeasonRepository.cs (99%) rename {Kyoo => Kyoo.Core}/Controllers/Repositories/ShowRepository.cs (99%) rename {Kyoo => Kyoo.Core}/Controllers/Repositories/StudioRepository.cs (98%) rename {Kyoo => Kyoo.Core}/Controllers/Repositories/TrackRepository.cs (98%) rename {Kyoo => Kyoo.Core}/Controllers/Repositories/UserRepository.cs (98%) rename {Kyoo => Kyoo.Core}/Controllers/TaskManager.cs (99%) rename {Kyoo => Kyoo.Core}/Controllers/ThumbnailsManager.cs (99%) rename {Kyoo => Kyoo.Core}/Controllers/Transcoder.cs (92%) rename {Kyoo => Kyoo.Core}/CoreModule.cs (97%) rename {Kyoo => Kyoo.Core}/Helper.cs (97%) rename Kyoo/Kyoo.csproj => Kyoo.Core/Kyoo.Core.csproj (100%) rename {Kyoo => Kyoo.Core}/Models/FileExtensions.cs (98%) rename {Kyoo => Kyoo.Core}/Models/Options/BasicOptions.cs (98%) rename {Kyoo => Kyoo.Core}/Models/Options/MediaOptions.cs (92%) rename {Kyoo => Kyoo.Core}/Models/Options/TaskOptions.cs (94%) rename {Kyoo => Kyoo.Core}/Models/Stream.cs (97%) rename {Kyoo => Kyoo.Core}/PluginsStartup.cs (98%) rename {Kyoo => Kyoo.Core}/Tasks/Crawler.cs (98%) rename {Kyoo => Kyoo.Core}/Tasks/ExtractMetadata.cs (100%) rename {Kyoo => Kyoo.Core}/Tasks/Housekeeping.cs (99%) rename {Kyoo => Kyoo.Core}/Tasks/MetadataProviderLoader.cs (98%) rename {Kyoo => Kyoo.Core}/Tasks/PluginInitializer.cs (98%) rename {Kyoo => Kyoo.Core}/Tasks/ReScan.cs (100%) rename {Kyoo => Kyoo.Core}/Tasks/RegisterEpisode.cs (99%) rename {Kyoo => Kyoo.Core}/Tasks/RegisterSubtitle.cs (98%) rename {Kyoo => Kyoo.Core}/Views/CollectionApi.cs (98%) rename {Kyoo => Kyoo.Core}/Views/ConfigurationApi.cs (99%) rename {Kyoo => Kyoo.Core}/Views/EpisodeApi.cs (99%) rename {Kyoo => Kyoo.Core}/Views/GenreApi.cs (97%) rename {Kyoo => Kyoo.Core}/Views/Helper/ApiHelper.cs (99%) rename {Kyoo => Kyoo.Core}/Views/Helper/CrudApi.cs (99%) rename {Kyoo => Kyoo.Core}/Views/Helper/JsonSerializer.cs (99%) rename {Kyoo => Kyoo.Core}/Views/Helper/ResourceViewAttribute.cs (98%) rename {Kyoo => Kyoo.Core}/Views/LibraryApi.cs (99%) rename {Kyoo => Kyoo.Core}/Views/LibraryItemApi.cs (96%) rename {Kyoo => Kyoo.Core}/Views/PeopleApi.cs (98%) rename {Kyoo => Kyoo.Core}/Views/ProviderApi.cs (96%) rename {Kyoo => Kyoo.Core}/Views/SearchApi.cs (99%) rename {Kyoo => Kyoo.Core}/Views/SeasonApi.cs (98%) rename {Kyoo => Kyoo.Core}/Views/ShowApi.cs (99%) rename {Kyoo => Kyoo.Core}/Views/StudioApi.cs (97%) rename {Kyoo => Kyoo.Core}/Views/SubtitleApi.cs (99%) rename {Kyoo => Kyoo.Core}/Views/TaskApi.cs (97%) rename {Kyoo => Kyoo.Core}/Views/TrackApi.cs (95%) rename {Kyoo => Kyoo.Core}/Views/VideoApi.cs (98%) rename {Kyoo => Kyoo.Core}/Views/WatchApi.cs (97%) rename {Kyoo => Kyoo.Core}/settings.json (100%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e0e25260..c6f063b7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ jobs: fail-fast: false matrix: include: - - os: ubuntu-latest #ubuntu-16.04 # We are using an old version of ubuntu to have an old libc version (forward compatibility exist but not backward) + - os: ubuntu-latest runtime: linux-x64 artifact: linux - os: windows-latest @@ -35,7 +35,6 @@ jobs: elif [[ "${{runner.os}}" == "macOS" ]]; then brew install ffmpeg else - # sudo add-apt-repository -y "deb http://azure.archive.ubuntu.com/ubuntu groovy main multiverse restricted universe" sudo apt-get update sudo apt-get install -y libavutil-dev libavcodec-dev libavformat-dev fi diff --git a/Kyoo.Abstractions/Controllers/IRepository.cs b/Kyoo.Abstractions/Controllers/IRepository.cs index 3a7dee05..45c866ba 100644 --- a/Kyoo.Abstractions/Controllers/IRepository.cs +++ b/Kyoo.Abstractions/Controllers/IRepository.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using JetBrains.Annotations; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Exceptions; +using Kyoo.Utils; namespace Kyoo.Abstractions.Controllers { diff --git a/Kyoo.Abstractions/Models/ConfigurationReference.cs b/Kyoo.Abstractions/Models/ConfigurationReference.cs index 8b1064dd..676367e3 100644 --- a/Kyoo.Abstractions/Models/ConfigurationReference.cs +++ b/Kyoo.Abstractions/Models/ConfigurationReference.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Reflection; using JetBrains.Annotations; +using Kyoo.Utils; namespace Kyoo.Abstractions.Models { diff --git a/Kyoo.Abstractions/Models/Page.cs b/Kyoo.Abstractions/Models/Page.cs index eb8898d2..5dc37abb 100644 --- a/Kyoo.Abstractions/Models/Page.cs +++ b/Kyoo.Abstractions/Models/Page.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Kyoo.Utils; namespace Kyoo.Abstractions.Models { diff --git a/Kyoo.Abstractions/Models/Resources/Genre.cs b/Kyoo.Abstractions/Models/Resources/Genre.cs index b346381f..0cf2d9b3 100644 --- a/Kyoo.Abstractions/Models/Resources/Genre.cs +++ b/Kyoo.Abstractions/Models/Resources/Genre.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using Kyoo.Abstractions.Models.Attributes; +using Kyoo.Utils; namespace Kyoo.Abstractions.Models { diff --git a/Kyoo.Abstractions/Models/Resources/Provider.cs b/Kyoo.Abstractions/Models/Resources/Provider.cs index 61726100..d1a34223 100644 --- a/Kyoo.Abstractions/Models/Resources/Provider.cs +++ b/Kyoo.Abstractions/Models/Resources/Provider.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models.Attributes; +using Kyoo.Utils; namespace Kyoo.Abstractions.Models { diff --git a/Kyoo.Abstractions/Models/Resources/Studio.cs b/Kyoo.Abstractions/Models/Resources/Studio.cs index f0e14567..fbc4934b 100644 --- a/Kyoo.Abstractions/Models/Resources/Studio.cs +++ b/Kyoo.Abstractions/Models/Resources/Studio.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using Kyoo.Abstractions.Models.Attributes; +using Kyoo.Utils; namespace Kyoo.Abstractions.Models { diff --git a/Kyoo.Abstractions/Module.cs b/Kyoo.Abstractions/Module.cs index f4594387..dcc5bc18 100644 --- a/Kyoo.Abstractions/Module.cs +++ b/Kyoo.Abstractions/Module.cs @@ -1,6 +1,7 @@ using Autofac; using Autofac.Builder; using Kyoo.Abstractions.Controllers; +using Kyoo.Utils; using Microsoft.Extensions.Configuration; namespace Kyoo.Abstractions diff --git a/Kyoo.Abstractions/Utility/EnumerableExtensions.cs b/Kyoo.Abstractions/Utility/EnumerableExtensions.cs index 93f1b52e..9bd81157 100644 --- a/Kyoo.Abstractions/Utility/EnumerableExtensions.cs +++ b/Kyoo.Abstractions/Utility/EnumerableExtensions.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using JetBrains.Annotations; -namespace Kyoo +namespace Kyoo.Utils { /// /// A set of extensions class for enumerable. diff --git a/Kyoo.Abstractions/Utility/Merger.cs b/Kyoo.Abstractions/Utility/Merger.cs index c59f47a1..fe00a924 100644 --- a/Kyoo.Abstractions/Utility/Merger.cs +++ b/Kyoo.Abstractions/Utility/Merger.cs @@ -8,7 +8,7 @@ using JetBrains.Annotations; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Attributes; -namespace Kyoo +namespace Kyoo.Utils { /// /// A class containing helper methods to merge objects. diff --git a/Kyoo.Abstractions/Utility/MethodOfUtils.cs b/Kyoo.Abstractions/Utility/MethodOfUtils.cs index 5d051f69..30a1ce4c 100644 --- a/Kyoo.Abstractions/Utility/MethodOfUtils.cs +++ b/Kyoo.Abstractions/Utility/MethodOfUtils.cs @@ -1,7 +1,7 @@ using System; using System.Reflection; -namespace Kyoo +namespace Kyoo.Utils { /// /// Static class containing MethodOf calls. diff --git a/Kyoo.Abstractions/Utility/TaskUtils.cs b/Kyoo.Abstractions/Utility/TaskUtils.cs index a0d04b03..91413f2c 100644 --- a/Kyoo.Abstractions/Utility/TaskUtils.cs +++ b/Kyoo.Abstractions/Utility/TaskUtils.cs @@ -2,7 +2,7 @@ using System; using System.Threading.Tasks; using JetBrains.Annotations; -namespace Kyoo +namespace Kyoo.Utils { /// /// A class containing helper method for tasks. diff --git a/Kyoo.Abstractions/Utility/Utility.cs b/Kyoo.Abstractions/Utility/Utility.cs index ab4fc92d..d1bb91b1 100644 --- a/Kyoo.Abstractions/Utility/Utility.cs +++ b/Kyoo.Abstractions/Utility/Utility.cs @@ -9,7 +9,7 @@ using System.Text; using System.Text.RegularExpressions; using JetBrains.Annotations; -namespace Kyoo +namespace Kyoo.Utils { /// /// A set of utility functions that can be used everywhere. diff --git a/Kyoo.Authentication/Models/DTO/RegisterRequest.cs b/Kyoo.Authentication/Models/DTO/RegisterRequest.cs index e10967fd..1e505bb7 100644 --- a/Kyoo.Authentication/Models/DTO/RegisterRequest.cs +++ b/Kyoo.Authentication/Models/DTO/RegisterRequest.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using Kyoo.Abstractions.Models; +using Kyoo.Utils; namespace Kyoo.Authentication.Models.DTO { diff --git a/Kyoo/.gitignore b/Kyoo.Core/.gitignore similarity index 100% rename from Kyoo/.gitignore rename to Kyoo.Core/.gitignore diff --git a/Kyoo/Application.cs b/Kyoo.Core/Application.cs similarity index 99% rename from Kyoo/Application.cs rename to Kyoo.Core/Application.cs index b51192f3..2101aeb6 100644 --- a/Kyoo/Application.cs +++ b/Kyoo.Core/Application.cs @@ -18,7 +18,7 @@ using Serilog.Templates; using Serilog.Templates.Themes; using ILogger = Serilog.ILogger; -namespace Kyoo +namespace Kyoo.Core { public class Application : IApplication { diff --git a/Kyoo/Controllers/ConfigurationManager.cs b/Kyoo.Core/Controllers/ConfigurationManager.cs similarity index 99% rename from Kyoo/Controllers/ConfigurationManager.cs rename to Kyoo.Core/Controllers/ConfigurationManager.cs index d43129de..7f5432f1 100644 --- a/Kyoo/Controllers/ConfigurationManager.cs +++ b/Kyoo.Core/Controllers/ConfigurationManager.cs @@ -8,11 +8,11 @@ using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Exceptions; -using Kyoo.Api; +using Kyoo.Core.Api; using Microsoft.Extensions.Configuration; using Newtonsoft.Json.Linq; -namespace Kyoo.Controllers +namespace Kyoo.Core.Controllers { public class ConfigurationManager : IConfigurationManager { diff --git a/Kyoo/Controllers/FileSystems/FileSystemComposite.cs b/Kyoo.Core/Controllers/FileSystems/FileSystemComposite.cs similarity index 99% rename from Kyoo/Controllers/FileSystems/FileSystemComposite.cs rename to Kyoo.Core/Controllers/FileSystems/FileSystemComposite.cs index bab7167d..4a715602 100644 --- a/Kyoo/Controllers/FileSystems/FileSystemComposite.cs +++ b/Kyoo.Core/Controllers/FileSystems/FileSystemComposite.cs @@ -9,11 +9,11 @@ using JetBrains.Annotations; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models.Attributes; using Kyoo.Abstractions.Models; -using Kyoo.Models.Options; +using Kyoo.Core.Models.Options; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; -namespace Kyoo.Controllers +namespace Kyoo.Core.Controllers { /// /// A composite that merge every available diff --git a/Kyoo/Controllers/FileSystems/HttpFileSystem.cs b/Kyoo.Core/Controllers/FileSystems/HttpFileSystem.cs similarity index 99% rename from Kyoo/Controllers/FileSystems/HttpFileSystem.cs rename to Kyoo.Core/Controllers/FileSystems/HttpFileSystem.cs index 8bd3d62f..0b5618fa 100644 --- a/Kyoo/Controllers/FileSystems/HttpFileSystem.cs +++ b/Kyoo.Core/Controllers/FileSystems/HttpFileSystem.cs @@ -9,7 +9,7 @@ using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Attributes; using Microsoft.AspNetCore.Mvc; -namespace Kyoo.Controllers +namespace Kyoo.Core.Controllers { /// /// A for http/https links. diff --git a/Kyoo/Controllers/FileSystems/LocalFileSystem.cs b/Kyoo.Core/Controllers/FileSystems/LocalFileSystem.cs similarity index 98% rename from Kyoo/Controllers/FileSystems/LocalFileSystem.cs rename to Kyoo.Core/Controllers/FileSystems/LocalFileSystem.cs index 3c4da8a0..3c75717f 100644 --- a/Kyoo/Controllers/FileSystems/LocalFileSystem.cs +++ b/Kyoo.Core/Controllers/FileSystems/LocalFileSystem.cs @@ -5,12 +5,12 @@ using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Attributes; -using Kyoo.Models.Options; +using Kyoo.Core.Models.Options; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.StaticFiles; using Microsoft.Extensions.Options; -namespace Kyoo.Controllers +namespace Kyoo.Core.Controllers { /// /// A for the local filesystem (using System.IO). diff --git a/Kyoo/Controllers/LibraryManager.cs b/Kyoo.Core/Controllers/LibraryManager.cs similarity index 99% rename from Kyoo/Controllers/LibraryManager.cs rename to Kyoo.Core/Controllers/LibraryManager.cs index 2b396ed5..e7759f0a 100644 --- a/Kyoo/Controllers/LibraryManager.cs +++ b/Kyoo.Core/Controllers/LibraryManager.cs @@ -6,8 +6,9 @@ using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Exceptions; +using Kyoo.Utils; -namespace Kyoo.Controllers +namespace Kyoo.Core.Controllers { public class LibraryManager : ILibraryManager { diff --git a/Kyoo/Controllers/PassthroughPermissionValidator.cs b/Kyoo.Core/Controllers/PassthroughPermissionValidator.cs similarity index 96% rename from Kyoo/Controllers/PassthroughPermissionValidator.cs rename to Kyoo.Core/Controllers/PassthroughPermissionValidator.cs index 5b623008..914835bf 100644 --- a/Kyoo/Controllers/PassthroughPermissionValidator.cs +++ b/Kyoo.Core/Controllers/PassthroughPermissionValidator.cs @@ -2,7 +2,7 @@ using Kyoo.Abstractions.Models.Permissions; using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.Extensions.Logging; -namespace Kyoo.Controllers +namespace Kyoo.Core.Controllers { /// /// A permission validator that always validate permissions. This effectively disable the permission system. diff --git a/Kyoo/Controllers/PluginManager.cs b/Kyoo.Core/Controllers/PluginManager.cs similarity index 98% rename from Kyoo/Controllers/PluginManager.cs rename to Kyoo.Core/Controllers/PluginManager.cs index 3b60e83f..37dc173d 100644 --- a/Kyoo/Controllers/PluginManager.cs +++ b/Kyoo.Core/Controllers/PluginManager.cs @@ -5,12 +5,12 @@ using System.Linq; using System.Reflection; using System.Runtime.Loader; using Kyoo.Abstractions.Controllers; -using Kyoo.Models.Options; +using Kyoo.Core.Models.Options; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -namespace Kyoo.Controllers +namespace Kyoo.Core.Controllers { /// /// An implementation of . diff --git a/Kyoo/Controllers/ProviderComposite.cs b/Kyoo.Core/Controllers/ProviderComposite.cs similarity index 98% rename from Kyoo/Controllers/ProviderComposite.cs rename to Kyoo.Core/Controllers/ProviderComposite.cs index dd9ecb41..1032b022 100644 --- a/Kyoo/Controllers/ProviderComposite.cs +++ b/Kyoo.Core/Controllers/ProviderComposite.cs @@ -4,9 +4,10 @@ using System.Linq; using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; +using Kyoo.Utils; using Microsoft.Extensions.Logging; -namespace Kyoo.Controllers +namespace Kyoo.Core.Controllers { /// /// A metadata provider composite that merge results from all available providers. diff --git a/Kyoo/Controllers/RegexIdentifier.cs b/Kyoo.Core/Controllers/RegexIdentifier.cs similarity index 97% rename from Kyoo/Controllers/RegexIdentifier.cs rename to Kyoo.Core/Controllers/RegexIdentifier.cs index 41a6e0d8..1032d4bb 100644 --- a/Kyoo/Controllers/RegexIdentifier.cs +++ b/Kyoo.Core/Controllers/RegexIdentifier.cs @@ -7,11 +7,12 @@ using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Exceptions; -using Kyoo.Models.Options; -using Kyoo.Models.Watch; +using Kyoo.Core.Models.Options; +using Kyoo.Core.Models.Watch; +using Kyoo.Utils; using Microsoft.Extensions.Options; -namespace Kyoo.Controllers +namespace Kyoo.Core.Controllers { /// /// An identifier that use a regex to extract basics metadata. diff --git a/Kyoo/Controllers/Repositories/CollectionRepository.cs b/Kyoo.Core/Controllers/Repositories/CollectionRepository.cs similarity index 98% rename from Kyoo/Controllers/Repositories/CollectionRepository.cs rename to Kyoo.Core/Controllers/Repositories/CollectionRepository.cs index cdb0740a..f6d1e220 100644 --- a/Kyoo/Controllers/Repositories/CollectionRepository.cs +++ b/Kyoo.Core/Controllers/Repositories/CollectionRepository.cs @@ -8,7 +8,7 @@ using Kyoo.Abstractions.Models; using Kyoo.Database; using Microsoft.EntityFrameworkCore; -namespace Kyoo.Controllers +namespace Kyoo.Core.Controllers { /// /// A local repository to handle collections diff --git a/Kyoo/Controllers/Repositories/EpisodeRepository.cs b/Kyoo.Core/Controllers/Repositories/EpisodeRepository.cs similarity index 99% rename from Kyoo/Controllers/Repositories/EpisodeRepository.cs rename to Kyoo.Core/Controllers/Repositories/EpisodeRepository.cs index d31e97cc..f19acdb2 100644 --- a/Kyoo/Controllers/Repositories/EpisodeRepository.cs +++ b/Kyoo.Core/Controllers/Repositories/EpisodeRepository.cs @@ -7,9 +7,10 @@ using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Exceptions; using Kyoo.Database; +using Kyoo.Utils; using Microsoft.EntityFrameworkCore; -namespace Kyoo.Controllers +namespace Kyoo.Core.Controllers { /// /// A local repository to handle episodes. diff --git a/Kyoo/Controllers/Repositories/GenreRepository.cs b/Kyoo.Core/Controllers/Repositories/GenreRepository.cs similarity index 98% rename from Kyoo/Controllers/Repositories/GenreRepository.cs rename to Kyoo.Core/Controllers/Repositories/GenreRepository.cs index b791f627..f72b13e7 100644 --- a/Kyoo/Controllers/Repositories/GenreRepository.cs +++ b/Kyoo.Core/Controllers/Repositories/GenreRepository.cs @@ -8,7 +8,7 @@ using Kyoo.Abstractions.Models; using Kyoo.Database; using Microsoft.EntityFrameworkCore; -namespace Kyoo.Controllers +namespace Kyoo.Core.Controllers { /// /// A local repository for genres. diff --git a/Kyoo/Controllers/Repositories/LibraryItemRepository.cs b/Kyoo.Core/Controllers/Repositories/LibraryItemRepository.cs similarity index 99% rename from Kyoo/Controllers/Repositories/LibraryItemRepository.cs rename to Kyoo.Core/Controllers/Repositories/LibraryItemRepository.cs index 172c7ab6..ba075c09 100644 --- a/Kyoo/Controllers/Repositories/LibraryItemRepository.cs +++ b/Kyoo.Core/Controllers/Repositories/LibraryItemRepository.cs @@ -9,7 +9,7 @@ using Kyoo.Abstractions.Models.Exceptions; using Kyoo.Database; using Microsoft.EntityFrameworkCore; -namespace Kyoo.Controllers +namespace Kyoo.Core.Controllers { /// /// A local repository to handle library items. diff --git a/Kyoo/Controllers/Repositories/LibraryRepository.cs b/Kyoo.Core/Controllers/Repositories/LibraryRepository.cs similarity index 98% rename from Kyoo/Controllers/Repositories/LibraryRepository.cs rename to Kyoo.Core/Controllers/Repositories/LibraryRepository.cs index e532d4e0..1e835114 100644 --- a/Kyoo/Controllers/Repositories/LibraryRepository.cs +++ b/Kyoo.Core/Controllers/Repositories/LibraryRepository.cs @@ -6,9 +6,10 @@ using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; using Kyoo.Database; +using Kyoo.Utils; using Microsoft.EntityFrameworkCore; -namespace Kyoo.Controllers +namespace Kyoo.Core.Controllers { /// /// A local repository to handle libraries. diff --git a/Kyoo/Controllers/Repositories/LocalRepository.cs b/Kyoo.Core/Controllers/Repositories/LocalRepository.cs similarity index 99% rename from Kyoo/Controllers/Repositories/LocalRepository.cs rename to Kyoo.Core/Controllers/Repositories/LocalRepository.cs index 14d4cb40..55c6e259 100644 --- a/Kyoo/Controllers/Repositories/LocalRepository.cs +++ b/Kyoo.Core/Controllers/Repositories/LocalRepository.cs @@ -8,10 +8,11 @@ using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Attributes; using Kyoo.Abstractions.Models.Exceptions; -using Kyoo.Api; +using Kyoo.Utils; +using Kyoo.Core.Api; using Microsoft.EntityFrameworkCore; -namespace Kyoo.Controllers +namespace Kyoo.Core.Controllers { /// /// A base class to create repositories using Entity Framework. diff --git a/Kyoo/Controllers/Repositories/PeopleRepository.cs b/Kyoo.Core/Controllers/Repositories/PeopleRepository.cs similarity index 99% rename from Kyoo/Controllers/Repositories/PeopleRepository.cs rename to Kyoo.Core/Controllers/Repositories/PeopleRepository.cs index 10ca820b..9b8eb38f 100644 --- a/Kyoo/Controllers/Repositories/PeopleRepository.cs +++ b/Kyoo.Core/Controllers/Repositories/PeopleRepository.cs @@ -7,9 +7,10 @@ using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Exceptions; using Kyoo.Database; +using Kyoo.Utils; using Microsoft.EntityFrameworkCore; -namespace Kyoo.Controllers +namespace Kyoo.Core.Controllers { /// /// A local repository to handle people. diff --git a/Kyoo/Controllers/Repositories/ProviderRepository.cs b/Kyoo.Core/Controllers/Repositories/ProviderRepository.cs similarity index 98% rename from Kyoo/Controllers/Repositories/ProviderRepository.cs rename to Kyoo.Core/Controllers/Repositories/ProviderRepository.cs index a1f00608..321b11d3 100644 --- a/Kyoo/Controllers/Repositories/ProviderRepository.cs +++ b/Kyoo.Core/Controllers/Repositories/ProviderRepository.cs @@ -8,7 +8,7 @@ using Kyoo.Abstractions.Models; using Kyoo.Database; using Microsoft.EntityFrameworkCore; -namespace Kyoo.Controllers +namespace Kyoo.Core.Controllers { /// /// A local repository to handle providers. diff --git a/Kyoo/Controllers/Repositories/SeasonRepository.cs b/Kyoo.Core/Controllers/Repositories/SeasonRepository.cs similarity index 99% rename from Kyoo/Controllers/Repositories/SeasonRepository.cs rename to Kyoo.Core/Controllers/Repositories/SeasonRepository.cs index f63f37e2..1a22fe15 100644 --- a/Kyoo/Controllers/Repositories/SeasonRepository.cs +++ b/Kyoo.Core/Controllers/Repositories/SeasonRepository.cs @@ -9,7 +9,7 @@ using Kyoo.Abstractions.Models.Exceptions; using Kyoo.Database; using Microsoft.EntityFrameworkCore; -namespace Kyoo.Controllers +namespace Kyoo.Core.Controllers { /// /// A local repository to handle seasons. diff --git a/Kyoo/Controllers/Repositories/ShowRepository.cs b/Kyoo.Core/Controllers/Repositories/ShowRepository.cs similarity index 99% rename from Kyoo/Controllers/Repositories/ShowRepository.cs rename to Kyoo.Core/Controllers/Repositories/ShowRepository.cs index 1605eab6..dca498c7 100644 --- a/Kyoo/Controllers/Repositories/ShowRepository.cs +++ b/Kyoo.Core/Controllers/Repositories/ShowRepository.cs @@ -5,10 +5,11 @@ using System.Linq.Expressions; using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; +using Kyoo.Utils; using Kyoo.Database; using Microsoft.EntityFrameworkCore; -namespace Kyoo.Controllers +namespace Kyoo.Core.Controllers { /// /// A local repository to handle shows diff --git a/Kyoo/Controllers/Repositories/StudioRepository.cs b/Kyoo.Core/Controllers/Repositories/StudioRepository.cs similarity index 98% rename from Kyoo/Controllers/Repositories/StudioRepository.cs rename to Kyoo.Core/Controllers/Repositories/StudioRepository.cs index 42b98b44..185e4420 100644 --- a/Kyoo/Controllers/Repositories/StudioRepository.cs +++ b/Kyoo.Core/Controllers/Repositories/StudioRepository.cs @@ -8,7 +8,7 @@ using Kyoo.Abstractions.Models; using Kyoo.Database; using Microsoft.EntityFrameworkCore; -namespace Kyoo.Controllers +namespace Kyoo.Core.Controllers { /// /// A local repository to handle studios diff --git a/Kyoo/Controllers/Repositories/TrackRepository.cs b/Kyoo.Core/Controllers/Repositories/TrackRepository.cs similarity index 98% rename from Kyoo/Controllers/Repositories/TrackRepository.cs rename to Kyoo.Core/Controllers/Repositories/TrackRepository.cs index b7c29c47..c6b7889c 100644 --- a/Kyoo/Controllers/Repositories/TrackRepository.cs +++ b/Kyoo.Core/Controllers/Repositories/TrackRepository.cs @@ -7,7 +7,7 @@ using Kyoo.Abstractions.Models; using Kyoo.Database; using Microsoft.EntityFrameworkCore; -namespace Kyoo.Controllers +namespace Kyoo.Core.Controllers { /// /// A local repository to handle tracks. diff --git a/Kyoo/Controllers/Repositories/UserRepository.cs b/Kyoo.Core/Controllers/Repositories/UserRepository.cs similarity index 98% rename from Kyoo/Controllers/Repositories/UserRepository.cs rename to Kyoo.Core/Controllers/Repositories/UserRepository.cs index 896b8480..1b267ab6 100644 --- a/Kyoo/Controllers/Repositories/UserRepository.cs +++ b/Kyoo.Core/Controllers/Repositories/UserRepository.cs @@ -8,7 +8,7 @@ using Kyoo.Abstractions.Models; using Kyoo.Database; using Microsoft.EntityFrameworkCore; -namespace Kyoo.Controllers +namespace Kyoo.Core.Controllers { /// /// A repository for users. diff --git a/Kyoo/Controllers/TaskManager.cs b/Kyoo.Core/Controllers/TaskManager.cs similarity index 99% rename from Kyoo/Controllers/TaskManager.cs rename to Kyoo.Core/Controllers/TaskManager.cs index df89f290..af1d24e6 100644 --- a/Kyoo/Controllers/TaskManager.cs +++ b/Kyoo.Core/Controllers/TaskManager.cs @@ -10,12 +10,12 @@ using JetBrains.Annotations; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models.Attributes; using Kyoo.Abstractions.Models.Exceptions; -using Kyoo.Models.Options; +using Kyoo.Core.Models.Options; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -namespace Kyoo.Controllers +namespace Kyoo.Core.Controllers { /// /// A service to handle long running tasks and a background runner. diff --git a/Kyoo/Controllers/ThumbnailsManager.cs b/Kyoo.Core/Controllers/ThumbnailsManager.cs similarity index 99% rename from Kyoo/Controllers/ThumbnailsManager.cs rename to Kyoo.Core/Controllers/ThumbnailsManager.cs index 274b655f..d82db69f 100644 --- a/Kyoo/Controllers/ThumbnailsManager.cs +++ b/Kyoo.Core/Controllers/ThumbnailsManager.cs @@ -7,7 +7,7 @@ using Kyoo.Abstractions.Models; using Microsoft.AspNetCore.StaticFiles; using Microsoft.Extensions.Logging; -namespace Kyoo.Controllers +namespace Kyoo.Core.Controllers { /// /// Download images and retrieve the path of those images for a resource. diff --git a/Kyoo/Controllers/Transcoder.cs b/Kyoo.Core/Controllers/Transcoder.cs similarity index 92% rename from Kyoo/Controllers/Transcoder.cs rename to Kyoo.Core/Controllers/Transcoder.cs index 379c1827..1f2f8d08 100644 --- a/Kyoo/Controllers/Transcoder.cs +++ b/Kyoo.Core/Controllers/Transcoder.cs @@ -4,14 +4,14 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; -using Kyoo.Models.Options; +using Kyoo.Core.Models.Options; using Microsoft.Extensions.Options; -using Stream = Kyoo.Models.Watch.Stream; +using Stream = Kyoo.Core.Models.Watch.Stream; // We use threads so tasks are not always awaited. #pragma warning disable 4014 -namespace Kyoo.Controllers +namespace Kyoo.Core.Controllers { public class BadTranscoderException : Exception {} @@ -54,7 +54,7 @@ namespace Kyoo.Controllers path = path.Replace('\\', '/'); outPath = outPath.Replace('\\', '/'); - int size = Marshal.SizeOf(); + int size = Marshal.SizeOf(); IntPtr ptr = extract_infos(path, outPath, out uint arrayLength, out uint trackCount, reextract); IntPtr streamsPtr = ptr; Track[] tracks; @@ -66,7 +66,7 @@ namespace Kyoo.Controllers int j = 0; for (int i = 0; i < arrayLength; i++) { - Stream stream = Marshal.PtrToStructure(streamsPtr); + Models.Watch.Stream stream = Marshal.PtrToStructure(streamsPtr); if (stream!.Type != StreamType.Unknown) { tracks[j] = stream.ToTrack(); @@ -94,7 +94,7 @@ namespace Kyoo.Controllers _options = options; _library = library; - if (TranscoderAPI.Init() != Marshal.SizeOf()) + if (TranscoderAPI.Init() != Marshal.SizeOf()) throw new BadTranscoderException(); } diff --git a/Kyoo/CoreModule.cs b/Kyoo.Core/CoreModule.cs similarity index 97% rename from Kyoo/CoreModule.cs rename to Kyoo.Core/CoreModule.cs index 470ad3bd..ef0961cc 100644 --- a/Kyoo/CoreModule.cs +++ b/Kyoo.Core/CoreModule.cs @@ -7,11 +7,11 @@ using Autofac.Extras.AttributeMetadata; using Kyoo.Abstractions; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models.Permissions; -using Kyoo.Api; -using Kyoo.Controllers; +using Kyoo.Core.Api; +using Kyoo.Core.Controllers; +using Kyoo.Core.Models.Options; +using Kyoo.Core.Tasks; using Kyoo.Database; -using Kyoo.Models.Options; -using Kyoo.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.StaticFiles; using Microsoft.Extensions.Configuration; @@ -20,7 +20,7 @@ using Microsoft.Extensions.Hosting; using Serilog; using IMetadataProvider = Kyoo.Abstractions.Controllers.IMetadataProvider; -namespace Kyoo +namespace Kyoo.Core { /// /// The core module containing default implementations diff --git a/Kyoo/Helper.cs b/Kyoo.Core/Helper.cs similarity index 97% rename from Kyoo/Helper.cs rename to Kyoo.Core/Helper.cs index ad8a6dfb..570e22d6 100644 --- a/Kyoo/Helper.cs +++ b/Kyoo.Core/Helper.cs @@ -2,7 +2,7 @@ using System.Net.Http; using System.Threading.Tasks; using Newtonsoft.Json; -namespace Kyoo +namespace Kyoo.Core { public static class Helper { diff --git a/Kyoo/Kyoo.csproj b/Kyoo.Core/Kyoo.Core.csproj similarity index 100% rename from Kyoo/Kyoo.csproj rename to Kyoo.Core/Kyoo.Core.csproj diff --git a/Kyoo/Models/FileExtensions.cs b/Kyoo.Core/Models/FileExtensions.cs similarity index 98% rename from Kyoo/Models/FileExtensions.cs rename to Kyoo.Core/Models/FileExtensions.cs index 5b29fe08..26e520d1 100644 --- a/Kyoo/Models/FileExtensions.cs +++ b/Kyoo.Core/Models/FileExtensions.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.IO; -namespace Kyoo.Models.Watch +namespace Kyoo.Core.Models.Watch { /// /// A static class allowing one to identify files extensions. diff --git a/Kyoo/Models/Options/BasicOptions.cs b/Kyoo.Core/Models/Options/BasicOptions.cs similarity index 98% rename from Kyoo/Models/Options/BasicOptions.cs rename to Kyoo.Core/Models/Options/BasicOptions.cs index ca018fd4..5bb108f8 100644 --- a/Kyoo/Models/Options/BasicOptions.cs +++ b/Kyoo.Core/Models/Options/BasicOptions.cs @@ -1,7 +1,7 @@ using Kyoo.Abstractions.Models; using System; -namespace Kyoo.Models.Options +namespace Kyoo.Core.Models.Options { /// /// The typed list of basic/global options for Kyoo diff --git a/Kyoo/Models/Options/MediaOptions.cs b/Kyoo.Core/Models/Options/MediaOptions.cs similarity index 92% rename from Kyoo/Models/Options/MediaOptions.cs rename to Kyoo.Core/Models/Options/MediaOptions.cs index 4b02e4db..3133e8d2 100644 --- a/Kyoo/Models/Options/MediaOptions.cs +++ b/Kyoo.Core/Models/Options/MediaOptions.cs @@ -1,4 +1,4 @@ -namespace Kyoo.Models.Options +namespace Kyoo.Core.Models.Options { /// /// Options for media registering. diff --git a/Kyoo/Models/Options/TaskOptions.cs b/Kyoo.Core/Models/Options/TaskOptions.cs similarity index 94% rename from Kyoo/Models/Options/TaskOptions.cs rename to Kyoo.Core/Models/Options/TaskOptions.cs index 922a9ff4..89b77687 100644 --- a/Kyoo/Models/Options/TaskOptions.cs +++ b/Kyoo.Core/Models/Options/TaskOptions.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using JetBrains.Annotations; -namespace Kyoo.Models.Options +namespace Kyoo.Core.Models.Options { /// /// Options related to tasks diff --git a/Kyoo/Models/Stream.cs b/Kyoo.Core/Models/Stream.cs similarity index 97% rename from Kyoo/Models/Stream.cs rename to Kyoo.Core/Models/Stream.cs index 6d2b4a3c..2980adae 100644 --- a/Kyoo/Models/Stream.cs +++ b/Kyoo.Core/Models/Stream.cs @@ -2,7 +2,7 @@ using System.Runtime.InteropServices; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Attributes; -namespace Kyoo.Models.Watch +namespace Kyoo.Core.Models.Watch { /// /// The unmanaged stream that the transcoder will return. diff --git a/Kyoo/PluginsStartup.cs b/Kyoo.Core/PluginsStartup.cs similarity index 98% rename from Kyoo/PluginsStartup.cs rename to Kyoo.Core/PluginsStartup.cs index c5545842..470c9a4f 100644 --- a/Kyoo/PluginsStartup.cs +++ b/Kyoo.Core/PluginsStartup.cs @@ -5,13 +5,14 @@ using Autofac; using Kyoo.Abstractions; using Kyoo.Abstractions.Controllers; using Kyoo.Authentication; -using Kyoo.Controllers; -using Kyoo.Models.Options; +using Kyoo.Core.Controllers; +using Kyoo.Core.Models.Options; +using Kyoo.Core.Tasks; using Kyoo.Postgresql; using Kyoo.SqLite; -using Kyoo.Tasks; using Kyoo.TheMovieDb; using Kyoo.TheTvdb; +using Kyoo.Utils; using Kyoo.WebApp; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -21,7 +22,7 @@ using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -namespace Kyoo +namespace Kyoo.Core { /// /// The Startup class is used to configure the AspNet's webhost. diff --git a/Kyoo/Tasks/Crawler.cs b/Kyoo.Core/Tasks/Crawler.cs similarity index 98% rename from Kyoo/Tasks/Crawler.cs rename to Kyoo.Core/Tasks/Crawler.cs index 6e94a97f..3633fbb3 100644 --- a/Kyoo/Tasks/Crawler.cs +++ b/Kyoo.Core/Tasks/Crawler.cs @@ -7,10 +7,10 @@ using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Attributes; -using Kyoo.Models.Watch; +using Kyoo.Core.Models.Watch; using Microsoft.Extensions.Logging; -namespace Kyoo.Tasks +namespace Kyoo.Core.Tasks { /// /// A task to add new video files. diff --git a/Kyoo/Tasks/ExtractMetadata.cs b/Kyoo.Core/Tasks/ExtractMetadata.cs similarity index 100% rename from Kyoo/Tasks/ExtractMetadata.cs rename to Kyoo.Core/Tasks/ExtractMetadata.cs diff --git a/Kyoo/Tasks/Housekeeping.cs b/Kyoo.Core/Tasks/Housekeeping.cs similarity index 99% rename from Kyoo/Tasks/Housekeeping.cs rename to Kyoo.Core/Tasks/Housekeeping.cs index 1724b0e7..38d1c9f4 100644 --- a/Kyoo/Tasks/Housekeeping.cs +++ b/Kyoo.Core/Tasks/Housekeeping.cs @@ -6,7 +6,7 @@ using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Attributes; using Microsoft.Extensions.Logging; -namespace Kyoo.Tasks +namespace Kyoo.Core.Tasks { /// /// A task to remove orphaned episode and series. diff --git a/Kyoo/Tasks/MetadataProviderLoader.cs b/Kyoo.Core/Tasks/MetadataProviderLoader.cs similarity index 98% rename from Kyoo/Tasks/MetadataProviderLoader.cs rename to Kyoo.Core/Tasks/MetadataProviderLoader.cs index 3c9163c4..cfe398ae 100644 --- a/Kyoo/Tasks/MetadataProviderLoader.cs +++ b/Kyoo.Core/Tasks/MetadataProviderLoader.cs @@ -6,7 +6,7 @@ using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models.Attributes; using Kyoo.Abstractions.Models.Exceptions; -namespace Kyoo.Tasks +namespace Kyoo.Core.Tasks { /// /// A task that download metadata providers images. diff --git a/Kyoo/Tasks/PluginInitializer.cs b/Kyoo.Core/Tasks/PluginInitializer.cs similarity index 98% rename from Kyoo/Tasks/PluginInitializer.cs rename to Kyoo.Core/Tasks/PluginInitializer.cs index 7f9e5171..a5b36b6d 100644 --- a/Kyoo/Tasks/PluginInitializer.cs +++ b/Kyoo.Core/Tasks/PluginInitializer.cs @@ -5,7 +5,7 @@ using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models.Attributes; -namespace Kyoo.Tasks +namespace Kyoo.Core.Tasks { /// /// A task run on Kyoo's startup to initialize plugins diff --git a/Kyoo/Tasks/ReScan.cs b/Kyoo.Core/Tasks/ReScan.cs similarity index 100% rename from Kyoo/Tasks/ReScan.cs rename to Kyoo.Core/Tasks/ReScan.cs diff --git a/Kyoo/Tasks/RegisterEpisode.cs b/Kyoo.Core/Tasks/RegisterEpisode.cs similarity index 99% rename from Kyoo/Tasks/RegisterEpisode.cs rename to Kyoo.Core/Tasks/RegisterEpisode.cs index 851d658d..d713a9d1 100644 --- a/Kyoo/Tasks/RegisterEpisode.cs +++ b/Kyoo.Core/Tasks/RegisterEpisode.cs @@ -7,7 +7,7 @@ using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Attributes; using Kyoo.Abstractions.Models.Exceptions; -namespace Kyoo.Tasks +namespace Kyoo.Core.Tasks { /// /// A task to register a new episode diff --git a/Kyoo/Tasks/RegisterSubtitle.cs b/Kyoo.Core/Tasks/RegisterSubtitle.cs similarity index 98% rename from Kyoo/Tasks/RegisterSubtitle.cs rename to Kyoo.Core/Tasks/RegisterSubtitle.cs index 2ace1f0b..3b931ab7 100644 --- a/Kyoo/Tasks/RegisterSubtitle.cs +++ b/Kyoo.Core/Tasks/RegisterSubtitle.cs @@ -6,7 +6,7 @@ using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Attributes; using Kyoo.Abstractions.Models.Exceptions; -namespace Kyoo.Tasks +namespace Kyoo.Core.Tasks { /// /// A task to register a new episode diff --git a/Kyoo/Views/CollectionApi.cs b/Kyoo.Core/Views/CollectionApi.cs similarity index 98% rename from Kyoo/Views/CollectionApi.cs rename to Kyoo.Core/Views/CollectionApi.cs index b6cada95..56af8b0a 100644 --- a/Kyoo/Views/CollectionApi.cs +++ b/Kyoo.Core/Views/CollectionApi.cs @@ -7,10 +7,10 @@ using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Exceptions; using Kyoo.Abstractions.Models.Permissions; -using Kyoo.Models.Options; +using Kyoo.Core.Models.Options; using Microsoft.Extensions.Options; -namespace Kyoo.Api +namespace Kyoo.Core.Api { [Route("api/collection")] [Route("api/collections")] diff --git a/Kyoo/Views/ConfigurationApi.cs b/Kyoo.Core/Views/ConfigurationApi.cs similarity index 99% rename from Kyoo/Views/ConfigurationApi.cs rename to Kyoo.Core/Views/ConfigurationApi.cs index 1abef5bf..0b20df11 100644 --- a/Kyoo/Views/ConfigurationApi.cs +++ b/Kyoo.Core/Views/ConfigurationApi.cs @@ -5,7 +5,7 @@ using Kyoo.Abstractions.Models.Exceptions; using Kyoo.Abstractions.Models.Permissions; using Microsoft.AspNetCore.Mvc; -namespace Kyoo.Api +namespace Kyoo.Core.Api { /// /// An API to retrieve or edit configuration settings diff --git a/Kyoo/Views/EpisodeApi.cs b/Kyoo.Core/Views/EpisodeApi.cs similarity index 99% rename from Kyoo/Views/EpisodeApi.cs rename to Kyoo.Core/Views/EpisodeApi.cs index f225c0b7..c4fdf566 100644 --- a/Kyoo/Views/EpisodeApi.cs +++ b/Kyoo.Core/Views/EpisodeApi.cs @@ -7,10 +7,10 @@ using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Exceptions; using Kyoo.Abstractions.Models.Permissions; -using Kyoo.Models.Options; +using Kyoo.Core.Models.Options; using Microsoft.Extensions.Options; -namespace Kyoo.Api +namespace Kyoo.Core.Api { [Route("api/episode")] [Route("api/episodes")] diff --git a/Kyoo/Views/GenreApi.cs b/Kyoo.Core/Views/GenreApi.cs similarity index 97% rename from Kyoo/Views/GenreApi.cs rename to Kyoo.Core/Views/GenreApi.cs index 3076fca2..d6e6a678 100644 --- a/Kyoo/Views/GenreApi.cs +++ b/Kyoo.Core/Views/GenreApi.cs @@ -5,11 +5,11 @@ using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Permissions; -using Kyoo.Models.Options; +using Kyoo.Core.Models.Options; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; -namespace Kyoo.Api +namespace Kyoo.Core.Api { [Route("api/genre")] [Route("api/genres")] diff --git a/Kyoo/Views/Helper/ApiHelper.cs b/Kyoo.Core/Views/Helper/ApiHelper.cs similarity index 99% rename from Kyoo/Views/Helper/ApiHelper.cs rename to Kyoo.Core/Views/Helper/ApiHelper.cs index f2650942..31e545c6 100644 --- a/Kyoo/Views/Helper/ApiHelper.cs +++ b/Kyoo.Core/Views/Helper/ApiHelper.cs @@ -6,7 +6,7 @@ using System.Linq.Expressions; using System.Reflection; using Kyoo.Abstractions.Models; -namespace Kyoo.Api +namespace Kyoo.Core.Api { public static class ApiHelper { diff --git a/Kyoo/Views/Helper/CrudApi.cs b/Kyoo.Core/Views/Helper/CrudApi.cs similarity index 99% rename from Kyoo/Views/Helper/CrudApi.cs rename to Kyoo.Core/Views/Helper/CrudApi.cs index eba42b1d..ab1eef72 100644 --- a/Kyoo/Views/Helper/CrudApi.cs +++ b/Kyoo.Core/Views/Helper/CrudApi.cs @@ -8,7 +8,7 @@ using Kyoo.Abstractions.Models.Exceptions; using Kyoo.Abstractions.Models.Permissions; using Microsoft.AspNetCore.Mvc; -namespace Kyoo.Api +namespace Kyoo.Core.Api { [ApiController] [ResourceView] diff --git a/Kyoo/Views/Helper/JsonSerializer.cs b/Kyoo.Core/Views/Helper/JsonSerializer.cs similarity index 99% rename from Kyoo/Views/Helper/JsonSerializer.cs rename to Kyoo.Core/Views/Helper/JsonSerializer.cs index c5b91b03..96d6d6ea 100644 --- a/Kyoo/Views/Helper/JsonSerializer.cs +++ b/Kyoo.Core/Views/Helper/JsonSerializer.cs @@ -6,11 +6,12 @@ using System.Reflection; using System.Text.RegularExpressions; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Attributes; +using Kyoo.Utils; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Serialization; -namespace Kyoo.Api +namespace Kyoo.Core.Api { public class JsonPropertyIgnorer : CamelCasePropertyNamesContractResolver { diff --git a/Kyoo/Views/Helper/ResourceViewAttribute.cs b/Kyoo.Core/Views/Helper/ResourceViewAttribute.cs similarity index 98% rename from Kyoo/Views/Helper/ResourceViewAttribute.cs rename to Kyoo.Core/Views/Helper/ResourceViewAttribute.cs index 386dc60c..ad4d9055 100644 --- a/Kyoo/Views/Helper/ResourceViewAttribute.cs +++ b/Kyoo.Core/Views/Helper/ResourceViewAttribute.cs @@ -6,12 +6,13 @@ using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Attributes; +using Kyoo.Utils; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Controllers; using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.Extensions.DependencyInjection; -namespace Kyoo.Api +namespace Kyoo.Core.Api { public class ResourceViewAttribute : ActionFilterAttribute { diff --git a/Kyoo/Views/LibraryApi.cs b/Kyoo.Core/Views/LibraryApi.cs similarity index 99% rename from Kyoo/Views/LibraryApi.cs rename to Kyoo.Core/Views/LibraryApi.cs index 69203926..60991589 100644 --- a/Kyoo/Views/LibraryApi.cs +++ b/Kyoo.Core/Views/LibraryApi.cs @@ -6,10 +6,10 @@ using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Permissions; -using Kyoo.Models.Options; +using Kyoo.Core.Models.Options; using Microsoft.Extensions.Options; -namespace Kyoo.Api +namespace Kyoo.Core.Api { [Route("api/library")] [Route("api/libraries")] diff --git a/Kyoo/Views/LibraryItemApi.cs b/Kyoo.Core/Views/LibraryItemApi.cs similarity index 96% rename from Kyoo/Views/LibraryItemApi.cs rename to Kyoo.Core/Views/LibraryItemApi.cs index 0c801a5c..207eae9c 100644 --- a/Kyoo/Views/LibraryItemApi.cs +++ b/Kyoo.Core/Views/LibraryItemApi.cs @@ -6,11 +6,11 @@ using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Exceptions; using Kyoo.Abstractions.Models.Permissions; -using Kyoo.Models.Options; +using Kyoo.Core.Models.Options; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; -namespace Kyoo.Api +namespace Kyoo.Core.Api { [Route("api/item")] [Route("api/items")] diff --git a/Kyoo/Views/PeopleApi.cs b/Kyoo.Core/Views/PeopleApi.cs similarity index 98% rename from Kyoo/Views/PeopleApi.cs rename to Kyoo.Core/Views/PeopleApi.cs index 06ce4df7..5135aa86 100644 --- a/Kyoo/Views/PeopleApi.cs +++ b/Kyoo.Core/Views/PeopleApi.cs @@ -5,11 +5,11 @@ using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Exceptions; using Kyoo.Abstractions.Models.Permissions; -using Kyoo.Models.Options; +using Kyoo.Core.Models.Options; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; -namespace Kyoo.Api +namespace Kyoo.Core.Api { [Route("api/people")] [ApiController] diff --git a/Kyoo/Views/ProviderApi.cs b/Kyoo.Core/Views/ProviderApi.cs similarity index 96% rename from Kyoo/Views/ProviderApi.cs rename to Kyoo.Core/Views/ProviderApi.cs index 04f999a1..431fefed 100644 --- a/Kyoo/Views/ProviderApi.cs +++ b/Kyoo.Core/Views/ProviderApi.cs @@ -2,11 +2,11 @@ using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Permissions; -using Kyoo.Models.Options; +using Kyoo.Core.Models.Options; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; -namespace Kyoo.Api +namespace Kyoo.Core.Api { [Route("api/provider")] [Route("api/providers")] diff --git a/Kyoo/Views/SearchApi.cs b/Kyoo.Core/Views/SearchApi.cs similarity index 99% rename from Kyoo/Views/SearchApi.cs rename to Kyoo.Core/Views/SearchApi.cs index 5abe1467..a6e17c91 100644 --- a/Kyoo/Views/SearchApi.cs +++ b/Kyoo.Core/Views/SearchApi.cs @@ -5,7 +5,7 @@ using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Permissions; using Microsoft.AspNetCore.Mvc; -namespace Kyoo.Api +namespace Kyoo.Core.Api { [Route("api/search/{query}")] [ApiController] diff --git a/Kyoo/Views/SeasonApi.cs b/Kyoo.Core/Views/SeasonApi.cs similarity index 98% rename from Kyoo/Views/SeasonApi.cs rename to Kyoo.Core/Views/SeasonApi.cs index 6979b47b..f7be874a 100644 --- a/Kyoo/Views/SeasonApi.cs +++ b/Kyoo.Core/Views/SeasonApi.cs @@ -6,10 +6,10 @@ using System.Linq; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Permissions; -using Kyoo.Models.Options; +using Kyoo.Core.Models.Options; using Microsoft.Extensions.Options; -namespace Kyoo.Api +namespace Kyoo.Core.Api { [Route("api/season")] [Route("api/seasons")] diff --git a/Kyoo/Views/ShowApi.cs b/Kyoo.Core/Views/ShowApi.cs similarity index 99% rename from Kyoo/Views/ShowApi.cs rename to Kyoo.Core/Views/ShowApi.cs index 1c3c3fa5..fe0aaeee 100644 --- a/Kyoo/Views/ShowApi.cs +++ b/Kyoo.Core/Views/ShowApi.cs @@ -8,10 +8,10 @@ using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Exceptions; using Kyoo.Abstractions.Models.Permissions; -using Kyoo.Models.Options; +using Kyoo.Core.Models.Options; using Microsoft.Extensions.Options; -namespace Kyoo.Api +namespace Kyoo.Core.Api { [Route("api/show")] [Route("api/shows")] diff --git a/Kyoo/Views/StudioApi.cs b/Kyoo.Core/Views/StudioApi.cs similarity index 97% rename from Kyoo/Views/StudioApi.cs rename to Kyoo.Core/Views/StudioApi.cs index 5474d1f5..87a06a11 100644 --- a/Kyoo/Views/StudioApi.cs +++ b/Kyoo.Core/Views/StudioApi.cs @@ -5,11 +5,11 @@ using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Permissions; -using Kyoo.Models.Options; +using Kyoo.Core.Models.Options; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; -namespace Kyoo.Api +namespace Kyoo.Core.Api { [Route("api/studio")] [Route("api/studios")] diff --git a/Kyoo/Views/SubtitleApi.cs b/Kyoo.Core/Views/SubtitleApi.cs similarity index 99% rename from Kyoo/Views/SubtitleApi.cs rename to Kyoo.Core/Views/SubtitleApi.cs index b6681841..04ddf1d5 100644 --- a/Kyoo/Views/SubtitleApi.cs +++ b/Kyoo.Core/Views/SubtitleApi.cs @@ -7,7 +7,7 @@ using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Permissions; -namespace Kyoo.Api +namespace Kyoo.Core.Api { [Route("subtitle")] [ApiController] diff --git a/Kyoo/Views/TaskApi.cs b/Kyoo.Core/Views/TaskApi.cs similarity index 97% rename from Kyoo/Views/TaskApi.cs rename to Kyoo.Core/Views/TaskApi.cs index 25097411..4bb5b534 100644 --- a/Kyoo/Views/TaskApi.cs +++ b/Kyoo.Core/Views/TaskApi.cs @@ -5,7 +5,7 @@ using Kyoo.Abstractions.Models.Exceptions; using Kyoo.Abstractions.Models.Permissions; using Microsoft.AspNetCore.Mvc; -namespace Kyoo.Api +namespace Kyoo.Core.Api { [Route("api/task")] [Route("api/tasks")] diff --git a/Kyoo/Views/TrackApi.cs b/Kyoo.Core/Views/TrackApi.cs similarity index 95% rename from Kyoo/Views/TrackApi.cs rename to Kyoo.Core/Views/TrackApi.cs index a6a1b6cb..6d16f632 100644 --- a/Kyoo/Views/TrackApi.cs +++ b/Kyoo.Core/Views/TrackApi.cs @@ -4,11 +4,11 @@ using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Exceptions; using Kyoo.Abstractions.Models.Permissions; -using Kyoo.Models.Options; +using Kyoo.Core.Models.Options; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; -namespace Kyoo.Api +namespace Kyoo.Core.Api { [Route("api/track")] [Route("api/tracks")] diff --git a/Kyoo/Views/VideoApi.cs b/Kyoo.Core/Views/VideoApi.cs similarity index 98% rename from Kyoo/Views/VideoApi.cs rename to Kyoo.Core/Views/VideoApi.cs index 2badb6dd..b2fa82df 100644 --- a/Kyoo/Views/VideoApi.cs +++ b/Kyoo.Core/Views/VideoApi.cs @@ -5,11 +5,11 @@ using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Exceptions; using Kyoo.Abstractions.Models.Permissions; -using Kyoo.Models.Options; +using Kyoo.Core.Models.Options; using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.Extensions.Options; -namespace Kyoo.Api +namespace Kyoo.Core.Api { [Route("video")] [ApiController] diff --git a/Kyoo/Views/WatchApi.cs b/Kyoo.Core/Views/WatchApi.cs similarity index 97% rename from Kyoo/Views/WatchApi.cs rename to Kyoo.Core/Views/WatchApi.cs index d4a46e8a..f310c258 100644 --- a/Kyoo/Views/WatchApi.cs +++ b/Kyoo.Core/Views/WatchApi.cs @@ -5,7 +5,7 @@ using Kyoo.Abstractions.Models.Exceptions; using Kyoo.Abstractions.Models.Permissions; using Microsoft.AspNetCore.Mvc; -namespace Kyoo.Api +namespace Kyoo.Core.Api { [Route("api/watch")] [ApiController] diff --git a/Kyoo/settings.json b/Kyoo.Core/settings.json similarity index 100% rename from Kyoo/settings.json rename to Kyoo.Core/settings.json diff --git a/Kyoo.Database/Extensions.cs b/Kyoo.Database/Extensions.cs index 43031638..57c72417 100644 --- a/Kyoo.Database/Extensions.cs +++ b/Kyoo.Database/Extensions.cs @@ -1,7 +1,7 @@ using System.Data.Common; using Microsoft.Extensions.Configuration; -namespace Kyoo +namespace Kyoo.Database { /// /// A class that regroup extensions used by some asp-net related parts of the app. diff --git a/Kyoo.Host.Console/Kyoo.Host.Console.csproj b/Kyoo.Host.Console/Kyoo.Host.Console.csproj index e7b396be..20dc8559 100644 --- a/Kyoo.Host.Console/Kyoo.Host.Console.csproj +++ b/Kyoo.Host.Console/Kyoo.Host.Console.csproj @@ -9,8 +9,17 @@ https://github.com/AnonymusRaccoon/Kyoo default + + + + win-x64 + - + diff --git a/Kyoo.Host.Console/Program.cs b/Kyoo.Host.Console/Program.cs index b6699fcf..6d5edb49 100644 --- a/Kyoo.Host.Console/Program.cs +++ b/Kyoo.Host.Console/Program.cs @@ -1,4 +1,5 @@ using System.Threading.Tasks; +using Kyoo.Core; using Microsoft.AspNetCore.Hosting; namespace Kyoo.Host.Console diff --git a/Kyoo.Host.WindowsTrait/Kyoo.Host.WindowsTrait.target b/Kyoo.Host.WindowsTrait/Kyoo.Host.WindowsTrait.target index c10e4fa0..d0f97e34 100644 --- a/Kyoo.Host.WindowsTrait/Kyoo.Host.WindowsTrait.target +++ b/Kyoo.Host.WindowsTrait/Kyoo.Host.WindowsTrait.target @@ -11,7 +11,8 @@ - + + diff --git a/Kyoo.Host.WindowsTrait/Program.cs b/Kyoo.Host.WindowsTrait/Program.cs index 9b4936ba..65b9a2bc 100644 --- a/Kyoo.Host.WindowsTrait/Program.cs +++ b/Kyoo.Host.WindowsTrait/Program.cs @@ -1,5 +1,6 @@ using System.Threading.Tasks; using Autofac; +using Kyoo.Core; namespace Kyoo.Host.WindowsTrait { diff --git a/Kyoo.Host.WindowsTrait/SystemTrait.cs b/Kyoo.Host.WindowsTrait/SystemTrait.cs index 86037c1d..34708f86 100644 --- a/Kyoo.Host.WindowsTrait/SystemTrait.cs +++ b/Kyoo.Host.WindowsTrait/SystemTrait.cs @@ -6,7 +6,7 @@ using System.Threading; using System.Windows.Forms; using Autofac; using Kyoo.Abstractions.Controllers; -using Kyoo.Models.Options; +using Kyoo.Core.Models.Options; using Microsoft.Extensions.Options; namespace Kyoo.Host.WindowsTrait diff --git a/Kyoo.Postgresql/PostgresContext.cs b/Kyoo.Postgresql/PostgresContext.cs index cbefb849..c8477169 100644 --- a/Kyoo.Postgresql/PostgresContext.cs +++ b/Kyoo.Postgresql/PostgresContext.cs @@ -5,6 +5,7 @@ using System.Reflection; using EFCore.NamingConventions.Internal; using Kyoo.Abstractions.Models; using Kyoo.Database; +using Kyoo.Utils; using Microsoft.EntityFrameworkCore; using Npgsql; diff --git a/Kyoo.SqLite/SqLiteContext.cs b/Kyoo.SqLite/SqLiteContext.cs index 123de717..87aa5637 100644 --- a/Kyoo.SqLite/SqLiteContext.cs +++ b/Kyoo.SqLite/SqLiteContext.cs @@ -4,6 +4,7 @@ using System.Linq.Expressions; using System.Reflection; using Kyoo.Abstractions.Models; using Kyoo.Database; +using Kyoo.Utils; using Microsoft.Data.Sqlite; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; diff --git a/Kyoo.TheMovieDb/Convertors/CollectionConvertors.cs b/Kyoo.TheMovieDb/Convertors/CollectionConvertors.cs index 3c1460f2..47c88f41 100644 --- a/Kyoo.TheMovieDb/Convertors/CollectionConvertors.cs +++ b/Kyoo.TheMovieDb/Convertors/CollectionConvertors.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using Kyoo.Abstractions.Models; +using Kyoo.Utils; using TMDbLib.Objects.Search; namespace Kyoo.TheMovieDb diff --git a/Kyoo.TheMovieDb/Convertors/MovieConvertors.cs b/Kyoo.TheMovieDb/Convertors/MovieConvertors.cs index f859c489..d123ca28 100644 --- a/Kyoo.TheMovieDb/Convertors/MovieConvertors.cs +++ b/Kyoo.TheMovieDb/Convertors/MovieConvertors.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using Kyoo.Abstractions.Models; +using Kyoo.Utils; using TMDbLib.Objects.Movies; using TMDbLib.Objects.Search; diff --git a/Kyoo.TheMovieDb/Convertors/PeopleConvertors.cs b/Kyoo.TheMovieDb/Convertors/PeopleConvertors.cs index 32a0cbaf..61c57db9 100644 --- a/Kyoo.TheMovieDb/Convertors/PeopleConvertors.cs +++ b/Kyoo.TheMovieDb/Convertors/PeopleConvertors.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using Kyoo.Abstractions.Models; +using Kyoo.Utils; using TMDbLib.Objects.General; using TMDbLib.Objects.People; using TMDbLib.Objects.Search; diff --git a/Kyoo.TheMovieDb/Convertors/ShowConvertors.cs b/Kyoo.TheMovieDb/Convertors/ShowConvertors.cs index a47b62c5..99ccc046 100644 --- a/Kyoo.TheMovieDb/Convertors/ShowConvertors.cs +++ b/Kyoo.TheMovieDb/Convertors/ShowConvertors.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using Kyoo.Abstractions.Models; +using Kyoo.Utils; using TMDbLib.Objects.Search; using TMDbLib.Objects.TvShows; diff --git a/Kyoo.TheMovieDb/Convertors/StudioConvertors.cs b/Kyoo.TheMovieDb/Convertors/StudioConvertors.cs index 42290c73..22f2ef9d 100644 --- a/Kyoo.TheMovieDb/Convertors/StudioConvertors.cs +++ b/Kyoo.TheMovieDb/Convertors/StudioConvertors.cs @@ -1,4 +1,5 @@ using Kyoo.Abstractions.Models; +using Kyoo.Utils; using TMDbLib.Objects.Companies; using TMDbLib.Objects.Search; diff --git a/Kyoo.TheTvdb/Convertors.cs b/Kyoo.TheTvdb/Convertors.cs index 20413570..d53dfe62 100644 --- a/Kyoo.TheTvdb/Convertors.cs +++ b/Kyoo.TheTvdb/Convertors.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; using Kyoo.Abstractions.Models; +using Kyoo.Utils; using TvDbSharper.Dto; namespace Kyoo.TheTvdb diff --git a/Kyoo.WebApp/Kyoo.WebApp.csproj b/Kyoo.WebApp/Kyoo.WebApp.csproj index c5f22695..d1a0402b 100644 --- a/Kyoo.WebApp/Kyoo.WebApp.csproj +++ b/Kyoo.WebApp/Kyoo.WebApp.csproj @@ -47,7 +47,8 @@ - + + diff --git a/Kyoo.sln b/Kyoo.sln index cbb05a6c..39e1cc4e 100644 --- a/Kyoo.sln +++ b/Kyoo.sln @@ -1,5 +1,5 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kyoo", "Kyoo\Kyoo.csproj", "{0F8275B6-C7DD-42DF-A168-755C81B1C329}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kyoo.Core", "Kyoo.Core\Kyoo.Core.csproj", "{0F8275B6-C7DD-42DF-A168-755C81B1C329}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kyoo.Abstractions", "Kyoo.Abstractions\Kyoo.Abstractions.csproj", "{BAB2CAE1-AC28-4509-AA3E-8DC75BD59220}" EndProject diff --git a/deployment/PKGBUILD b/deployment/PKGBUILD index ecd32404..5446499f 100644 --- a/deployment/PKGBUILD +++ b/deployment/PKGBUILD @@ -29,7 +29,7 @@ build() { # cd "Kyoo-$pkgver" cd "Kyoo" export DOTNET_CLI_TELEMETRY_OPTOUT=1 - dotnet publish -c Release -o "$srcdir/output" Kyoo + dotnet publish -c Release -o "$srcdir/output" Kyoo.Host.Console } package() { diff --git a/deployment/kyoo-windows.iss b/deployment/kyoo-windows.iss index 34744576..276fe810 100644 --- a/deployment/kyoo-windows.iss +++ b/deployment/kyoo-windows.iss @@ -25,8 +25,8 @@ Name: "startupShortcut"; Description: "Create shortcut in Startup folder (Starts Name: "none"; Description: "Do not start automatically"; GroupDescription: "Start automatically"; Flags: exclusive unchecked [Files] -Source: "{#kyoo}\Kyoo.exe"; DestDir: "{app}"; Flags: ignoreversion -Source: "{#kyoo}\Kyoo.WindowsHost.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "{#kyoo}\Kyoo.Host.Console.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "{#kyoo}\Kyoo.Host.WindowsTrait.exe"; DestDir: "{app}"; Flags: ignoreversion Source: "{#kyoo}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs [Registry] @@ -38,13 +38,13 @@ Root: HKA; Subkey: "Software\SDG\Kyoo\Settings"; ValueType: string; ValueName: " Type: filesandordirs; Name: "{code:GetDataDir}" [Icons] -Name: "{autoprograms}\Kyoo"; Filename: "{app}\Kyoo.WindowsHost.exe" -Name: "{autoprograms}\Kyoo (Console)"; Filename: "{app}\Kyoo.exe" -Name: "{autodesktop}\Kyoo"; Filename: "{app}\Kyoo.WindowsHost.exe"; Tasks: desktopicon -Name: "{autostartup}\Kyoo"; Filename: "{app}\Kyoo.WindowsHost.exe"; Tasks: startupShortcut +Name: "{autoprograms}\Kyoo"; Filename: "{app}\Kyoo.Host.WindowsTrait.exe" +Name: "{autoprograms}\Kyoo (Console)"; Filename: "{app}\Kyoo.Host.Console.exe" +Name: "{autodesktop}\Kyoo"; Filename: "{app}\Kyoo.Host.WindowsTrait.exe"; Tasks: desktopicon +Name: "{autostartup}\Kyoo"; Filename: "{app}\Kyoo.Host.WindowsTrait.exe"; Tasks: startupShortcut [Run] -Filename: "{app}\Kyoo.WindowsHost.exe"; Description: "{cm:LaunchProgram,Kyoo}"; Flags: nowait postinstall skipifsilent +Filename: "{app}\Kyoo.Host.WindowsTrait.exe"; Description: "{cm:LaunchProgram,Kyoo}"; Flags: nowait postinstall skipifsilent [Code] var diff --git a/deployment/kyoo.service b/deployment/kyoo.service index a53b1967..121ffc9d 100644 --- a/deployment/kyoo.service +++ b/deployment/kyoo.service @@ -6,7 +6,7 @@ After=network.target [Service] User=kyoo Environment=KYOO_DATADIR=/var/lib/kyoo -ExecStart=/usr/lib/kyoo/Kyoo +ExecStart=/usr/lib/kyoo/Kyoo.Host.Console Restart=on-abort TimeoutSec=20 diff --git a/tests/Kyoo.Tests/Database/RepositoryActivator.cs b/tests/Kyoo.Tests/Database/RepositoryActivator.cs index 92addd86..267bafb7 100644 --- a/tests/Kyoo.Tests/Database/RepositoryActivator.cs +++ b/tests/Kyoo.Tests/Database/RepositoryActivator.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; -using Kyoo.Controllers; +using Kyoo.Core.Controllers; using Kyoo.Database; using Xunit.Abstractions; diff --git a/tests/Kyoo.Tests/Database/SpecificTests/LibraryTests.cs b/tests/Kyoo.Tests/Database/SpecificTests/LibraryTests.cs index 20b7defe..a1a3d131 100644 --- a/tests/Kyoo.Tests/Database/SpecificTests/LibraryTests.cs +++ b/tests/Kyoo.Tests/Database/SpecificTests/LibraryTests.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; using Kyoo.Database; +using Kyoo.Utils; using Microsoft.EntityFrameworkCore; using Xunit; using Xunit.Abstractions; diff --git a/tests/Kyoo.Tests/Database/SpecificTests/ShowTests.cs b/tests/Kyoo.Tests/Database/SpecificTests/ShowTests.cs index c46aaa26..b502e125 100644 --- a/tests/Kyoo.Tests/Database/SpecificTests/ShowTests.cs +++ b/tests/Kyoo.Tests/Database/SpecificTests/ShowTests.cs @@ -6,6 +6,7 @@ using FluentAssertions; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; using Kyoo.Database; +using Kyoo.Utils; using Microsoft.EntityFrameworkCore; using Xunit; using Xunit.Abstractions; diff --git a/tests/Kyoo.Tests/Identifier/IdentifierTests.cs b/tests/Kyoo.Tests/Identifier/IdentifierTests.cs index 93f6c345..3ab526d6 100644 --- a/tests/Kyoo.Tests/Identifier/IdentifierTests.cs +++ b/tests/Kyoo.Tests/Identifier/IdentifierTests.cs @@ -2,8 +2,8 @@ using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Exceptions; -using Kyoo.Controllers; -using Kyoo.Models.Options; +using Kyoo.Core.Controllers; +using Kyoo.Core.Models.Options; using Microsoft.Extensions.Options; using Moq; using Xunit; diff --git a/tests/Kyoo.Tests/Identifier/ProviderTests.cs b/tests/Kyoo.Tests/Identifier/ProviderTests.cs index 0d9eb34a..384e6b79 100644 --- a/tests/Kyoo.Tests/Identifier/ProviderTests.cs +++ b/tests/Kyoo.Tests/Identifier/ProviderTests.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; -using Kyoo.Controllers; +using Kyoo.Core.Controllers; using Microsoft.Extensions.Logging; using Moq; using Xunit; diff --git a/tests/Kyoo.Tests/Kyoo.Tests.csproj b/tests/Kyoo.Tests/Kyoo.Tests.csproj index 7568e9d5..02627f91 100644 --- a/tests/Kyoo.Tests/Kyoo.Tests.csproj +++ b/tests/Kyoo.Tests/Kyoo.Tests.csproj @@ -34,7 +34,7 @@ - + diff --git a/tests/Kyoo.Tests/Utility/EnumerableTests.cs b/tests/Kyoo.Tests/Utility/EnumerableTests.cs index c03efa06..627de26b 100644 --- a/tests/Kyoo.Tests/Utility/EnumerableTests.cs +++ b/tests/Kyoo.Tests/Utility/EnumerableTests.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Kyoo.Utils; using Xunit; namespace Kyoo.Tests.Utility diff --git a/tests/Kyoo.Tests/Utility/MergerTests.cs b/tests/Kyoo.Tests/Utility/MergerTests.cs index a378ebb7..2765c7e2 100644 --- a/tests/Kyoo.Tests/Utility/MergerTests.cs +++ b/tests/Kyoo.Tests/Utility/MergerTests.cs @@ -5,6 +5,7 @@ using System.Linq; using JetBrains.Annotations; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Attributes; +using Kyoo.Utils; using Xunit; namespace Kyoo.Tests.Utility diff --git a/tests/Kyoo.Tests/Utility/TaskTests.cs b/tests/Kyoo.Tests/Utility/TaskTests.cs index 3bcd723f..47cbbf69 100644 --- a/tests/Kyoo.Tests/Utility/TaskTests.cs +++ b/tests/Kyoo.Tests/Utility/TaskTests.cs @@ -1,6 +1,7 @@ using System; using System.Threading; using System.Threading.Tasks; +using Kyoo.Utils; using Xunit; namespace Kyoo.Tests.Utility diff --git a/tests/Kyoo.Tests/Utility/UtilityTests.cs b/tests/Kyoo.Tests/Utility/UtilityTests.cs index 5c01069c..262337d0 100644 --- a/tests/Kyoo.Tests/Utility/UtilityTests.cs +++ b/tests/Kyoo.Tests/Utility/UtilityTests.cs @@ -2,9 +2,10 @@ using System; using System.Linq.Expressions; using System.Reflection; using Kyoo.Abstractions.Models; +using Kyoo.Utils; using Xunit; -using Utils = Kyoo.Utility; +using KUtility = Kyoo.Utils.Utility; namespace Kyoo.Tests.Utility { @@ -16,12 +17,12 @@ namespace Kyoo.Tests.Utility Expression> member = x => x.ID; Expression> memberCast = x => x.ID; - Assert.False(Utils.IsPropertyExpression(null)); - Assert.True(Utils.IsPropertyExpression(member)); - Assert.True(Utils.IsPropertyExpression(memberCast)); + Assert.False(KUtility.IsPropertyExpression(null)); + Assert.True(KUtility.IsPropertyExpression(member)); + Assert.True(KUtility.IsPropertyExpression(memberCast)); Expression> call = x => x.GetID("test"); - Assert.False(Utils.IsPropertyExpression(call)); + Assert.False(KUtility.IsPropertyExpression(call)); } [Fact] @@ -30,15 +31,15 @@ namespace Kyoo.Tests.Utility Expression> member = x => x.ID; Expression> memberCast = x => x.ID; - Assert.Equal("ID", Utils.GetPropertyName(member)); - Assert.Equal("ID", Utils.GetPropertyName(memberCast)); - Assert.Throws(() => Utils.GetPropertyName(null)); + Assert.Equal("ID", KUtility.GetPropertyName(member)); + Assert.Equal("ID", KUtility.GetPropertyName(memberCast)); + Assert.Throws(() => KUtility.GetPropertyName(null)); } [Fact] public void GetMethodTest() { - MethodInfo method = Utils.GetMethod(typeof(UtilityTests), + MethodInfo method = KUtility.GetMethod(typeof(UtilityTests), BindingFlags.Instance | BindingFlags.Public, nameof(GetMethodTest), Array.Empty(), @@ -49,17 +50,17 @@ namespace Kyoo.Tests.Utility [Fact] public void GetMethodInvalidGenericsTest() { - Assert.Throws(() => Utils.GetMethod(typeof(UtilityTests), + Assert.Throws(() => KUtility.GetMethod(typeof(UtilityTests), BindingFlags.Instance | BindingFlags.Public, nameof(GetMethodTest), - new [] { typeof(Utils) }, + new [] { typeof(KUtility) }, Array.Empty())); } [Fact] public void GetMethodInvalidParamsTest() { - Assert.Throws(() => Utils.GetMethod(typeof(UtilityTests), + Assert.Throws(() => KUtility.GetMethod(typeof(UtilityTests), BindingFlags.Instance | BindingFlags.Public, nameof(GetMethodTest), Array.Empty(), @@ -69,7 +70,7 @@ namespace Kyoo.Tests.Utility [Fact] public void GetMethodTest2() { - MethodInfo method = Utils.GetMethod(typeof(Merger), + MethodInfo method = KUtility.GetMethod(typeof(Merger), BindingFlags.Static | BindingFlags.Public, nameof(Merger.MergeLists), new [] { typeof(string) }, From fe70b1de6641679ba52167c5d2e6daa06ed52292 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Tue, 31 Aug 2021 21:04:37 +0200 Subject: [PATCH 34/38] CI: Adding the console host on the windows build --- .github/workflows/build.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c6f063b7..226c61be 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,7 +43,10 @@ jobs: uses: ilammy/msvc-dev-cmd@v1 - name: Select the project to build shell: bash - run: echo "PROJECT=$([ "${{runner.os}}" == "Windows" ] && echo Kyoo.Host.WindowsTrait || echo Kyoo.Host.Console)" >> $GITHUB_ENV + run: | + echo "PROJECT=$([ "${{runner.os}}" == "Windows" ] + && echo " -p:IncludeConsole=true Kyoo.Host.WindowsTrait" + || echo Kyoo.Host.Console)" >> $GITHUB_ENV - name: Build the app env: INCLUDE: ${{env.INCLUDE}};C:\Program Files\FFmpeg\include From 87244df4974ad3edac89569ee60aea4c506956c1 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Tue, 31 Aug 2021 21:07:05 +0200 Subject: [PATCH 35/38] CI: Fixing missing \ --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 226c61be..32482194 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,8 +44,8 @@ jobs: - name: Select the project to build shell: bash run: | - echo "PROJECT=$([ "${{runner.os}}" == "Windows" ] - && echo " -p:IncludeConsole=true Kyoo.Host.WindowsTrait" + echo "PROJECT=$([ "${{runner.os}}" == "Windows" ] \ + && echo " -p:IncludeConsole=true Kyoo.Host.WindowsTrait" \ || echo Kyoo.Host.Console)" >> $GITHUB_ENV - name: Build the app env: From 186a2d15ca9df2d06b555ed16f8d8f6ced18ddf7 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Wed, 1 Sep 2021 17:29:52 +0200 Subject: [PATCH 36/38] Build: Removing the need of symlink, cleaning up plugin enable state and fixing main logger --- Kyoo.Abstractions/Controllers/IPlugin.cs | 9 ------ Kyoo.Core/Application.cs | 32 +++++++++++++------- Kyoo.Core/Controllers/PluginManager.cs | 19 +++--------- Kyoo.Core/settings.json | 4 +-- Kyoo.TheMovieDb/PluginTmdb.cs | 27 +++++++++++++++-- Kyoo.TheTvdb/Kyoo.TheTvdb.csproj | 1 + Kyoo.TheTvdb/PluginTvdb.cs | 29 +++++++++++++++++-- Kyoo.WebApp/Kyoo.WebApp.csproj | 5 ---- Kyoo.WebApp/WebAppModule.cs | 37 ++++++++++++++---------- 9 files changed, 100 insertions(+), 63 deletions(-) diff --git a/Kyoo.Abstractions/Controllers/IPlugin.cs b/Kyoo.Abstractions/Controllers/IPlugin.cs index 0ff6c932..6fc2cc3c 100644 --- a/Kyoo.Abstractions/Controllers/IPlugin.cs +++ b/Kyoo.Abstractions/Controllers/IPlugin.cs @@ -93,14 +93,5 @@ namespace Kyoo.Abstractions.Controllers { // Skipped } - - /// - /// An optional callback function called when the startups ends and this plugin has been flagged has disabled. - /// It allow a plugin to log an error or warning message to inform why it has been disabled. - /// - void Disabled() - { - // Skipped - } } } \ No newline at end of file diff --git a/Kyoo.Core/Application.cs b/Kyoo.Core/Application.cs index 2101aeb6..f09245e9 100644 --- a/Kyoo.Core/Application.cs +++ b/Kyoo.Core/Application.cs @@ -42,6 +42,11 @@ namespace Kyoo.Core /// private readonly string _environment; + /// + /// The logger used for startup and error messages. + /// + private ILogger _logger; + /// /// Create a new that will use the specified environment. @@ -76,9 +81,9 @@ namespace Kyoo.Core _dataDir = _SetupDataDir(args); LoggerConfiguration config = new(); - _ConfigureLogging(config, null); - Log.Logger = config.CreateBootstrapLogger() - .ForContext(); + _ConfigureLogging(config, null, null); + Log.Logger = config.CreateBootstrapLogger(); + _logger = Log.Logger.ForContext(); AppDomain.CurrentDomain.ProcessExit += (_, _) => Log.CloseAndFlush(); AppDomain.CurrentDomain.UnhandledException += (_, ex) @@ -89,7 +94,6 @@ namespace Kyoo.Core IHost host = _CreateWebHostBuilder(args) .ConfigureContainer(configure) .Build(); - Log.Logger = host.Services.GetRequiredService().ForContext(); _tokenSource = new CancellationTokenSource(); await _StartWithHost(host, _tokenSource.Token); @@ -173,13 +177,13 @@ namespace Kyoo.Core { try { - Log.Information("Running as {Name}", Environment.UserName); - Log.Information("Data directory: {DataDirectory}", GetDataDirectory()); + _logger.Information("Running as {Name}", Environment.UserName); + _logger.Information("Data directory: {DataDirectory}", GetDataDirectory()); await host.RunAsync(cancellationToken); } catch (Exception ex) { - Log.Fatal(ex, "Unhandled exception"); + _logger.Fatal(ex, "Unhandled exception"); } } @@ -197,7 +201,7 @@ namespace Kyoo.Core .UseContentRoot(AppDomain.CurrentDomain.BaseDirectory) .UseEnvironment(_environment) .ConfigureAppConfiguration(x => _SetupConfig(x, args)) - .UseSerilog((host, builder) => _ConfigureLogging(builder, host.Configuration)) + .UseSerilog((host, services, builder) => _ConfigureLogging(builder, host.Configuration, services)) .ConfigureServices(x => x.AddRouting()) .ConfigureContainer(x => { @@ -227,13 +231,16 @@ namespace Kyoo.Core .AddEnvironmentVariables("KYOO_") .AddCommandLine(args); } - + /// /// Configure the logging. /// /// The logger builder to configure. /// The configuration to read settings from. - private void _ConfigureLogging(LoggerConfiguration builder, [CanBeNull] IConfiguration configuration) + /// The services to read configuration from. + private void _ConfigureLogging(LoggerConfiguration builder, + [CanBeNull] IConfiguration configuration, + [CanBeNull] IServiceProvider services) { if (configuration != null) { @@ -243,10 +250,13 @@ namespace Kyoo.Core } catch (Exception ex) { - Log.Fatal(ex, "Could not read serilog configuration"); + _logger.Fatal(ex, "Could not read serilog configuration"); } } + if (services != null) + builder.ReadFrom.Services(services); + const string template = "[{@t:HH:mm:ss} {@l:u3} {Substring(SourceContext, LastIndexOf(SourceContext, '.') + 1), 15} " + "({@i:0000000000})] {@m}{#if not EndsWith(@m, '\n')}\n{#end}{@x}"; diff --git a/Kyoo.Core/Controllers/PluginManager.cs b/Kyoo.Core/Controllers/PluginManager.cs index 37dc173d..e87d83a8 100644 --- a/Kyoo.Core/Controllers/PluginManager.cs +++ b/Kyoo.Core/Controllers/PluginManager.cs @@ -51,14 +51,6 @@ namespace Kyoo.Core.Controllers _logger = logger; } - public void SetProvider(IServiceProvider provider) - { - // TODO temporary bullshit to inject services before the configure asp net. - // TODO should rework this when the host will be reworked, as well as the asp net configure. - _provider = provider; - } - - /// public T GetPlugin(string name) { @@ -111,16 +103,13 @@ namespace Kyoo.Core.Controllers _logger.LogTrace("Loading new plugins..."); string[] pluginsPaths = Directory.GetFiles(pluginFolder, "*.dll", SearchOption.AllDirectories); - IPlugin[] newPlugins = plugins + _plugins.AddRange(plugins .Concat(pluginsPaths.SelectMany(LoadPlugin)) + .Where(x => x.Enabled) .GroupBy(x => x.Name) .Select(x => x.First()) - .ToArray(); - _plugins.AddRange(newPlugins.Where(x => x.Enabled)); - - foreach (IPlugin plugin in newPlugins.Where(x => !x.Enabled)) - plugin.Disabled(); - + ); + if (!_plugins.Any()) _logger.LogInformation("No plugin enabled"); else diff --git a/Kyoo.Core/settings.json b/Kyoo.Core/settings.json index 299f0e5c..64466270 100644 --- a/Kyoo.Core/settings.json +++ b/Kyoo.Core/settings.json @@ -74,9 +74,9 @@ }, "tvdb": { - "apiKey": "REDACTED" + "apiKey": "" }, "the-moviedb": { - "apiKey": "REDACTED" + "apiKey": "" } } diff --git a/Kyoo.TheMovieDb/PluginTmdb.cs b/Kyoo.TheMovieDb/PluginTmdb.cs index 6fb94e23..9af1a267 100644 --- a/Kyoo.TheMovieDb/PluginTmdb.cs +++ b/Kyoo.TheMovieDb/PluginTmdb.cs @@ -4,6 +4,8 @@ using Autofac; using Kyoo.Abstractions; using Kyoo.Abstractions.Controllers; using Kyoo.TheMovieDb.Models; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; namespace Kyoo.TheMovieDb { @@ -16,17 +18,38 @@ namespace Kyoo.TheMovieDb public string Slug => "the-moviedb"; /// - public string Name => "TheMovieDb Provider"; + public string Name => "TheMovieDb"; /// public string Description => "A metadata provider for TheMovieDB."; - + + /// + public bool Enabled => !string.IsNullOrEmpty(_configuration.GetValue("the-moviedb:apikey")); + /// public Dictionary Configuration => new() { { TheMovieDbOptions.Path, typeof(TheMovieDbOptions) } }; + /// + /// The configuration used to check if the api key is present or not. + /// + private readonly IConfiguration _configuration; + + /// + /// Create a new . + /// + /// The configuration used to check if the api key is present or not. + /// The logger used to warn when the api key is not present. + public PluginTmdb(IConfiguration configuration, ILogger logger) + { + _configuration = configuration; + if (!Enabled) + logger.LogWarning("No API key configured for TheMovieDB provider. " + + "To enable TheMovieDB, specify one in the setting the-moviedb:APIKEY "); + } + /// public void Configure(ContainerBuilder builder) { diff --git a/Kyoo.TheTvdb/Kyoo.TheTvdb.csproj b/Kyoo.TheTvdb/Kyoo.TheTvdb.csproj index 29995a3c..f2c052ff 100644 --- a/Kyoo.TheTvdb/Kyoo.TheTvdb.csproj +++ b/Kyoo.TheTvdb/Kyoo.TheTvdb.csproj @@ -10,6 +10,7 @@ + diff --git a/Kyoo.TheTvdb/PluginTvdb.cs b/Kyoo.TheTvdb/PluginTvdb.cs index 8d43cb81..75feee76 100644 --- a/Kyoo.TheTvdb/PluginTvdb.cs +++ b/Kyoo.TheTvdb/PluginTvdb.cs @@ -4,6 +4,8 @@ using Autofac; using Kyoo.Abstractions; using Kyoo.Abstractions.Controllers; using Kyoo.TheTvdb.Models; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; using TvDbSharper; namespace Kyoo.TheTvdb @@ -15,19 +17,40 @@ namespace Kyoo.TheTvdb { /// public string Slug => "the-tvdb"; - + /// - public string Name => "The TVDB Provider"; - + public string Name => "TVDB"; + /// public string Description => "A metadata provider for The TVDB."; + /// + public bool Enabled => !string.IsNullOrEmpty(_configuration.GetValue("tvdb:apikey")); + /// public Dictionary Configuration => new() { { TvdbOption.Path, typeof(TvdbOption) } }; + /// + /// The configuration used to check if the api key is present or not. + /// + private readonly IConfiguration _configuration; + + /// + /// Create a new . + /// + /// The configuration used to check if the api key is present or not. + /// The logger used to warn when the api key is not present. + public PluginTvdb(IConfiguration configuration, ILogger logger) + { + _configuration = configuration; + if (!Enabled) + logger.LogWarning("No API key configured for TVDB provider. " + + "To enable TVDB, specify one in the setting TVDB:APIKEY "); + } + /// public void Configure(ContainerBuilder builder) { diff --git a/Kyoo.WebApp/Kyoo.WebApp.csproj b/Kyoo.WebApp/Kyoo.WebApp.csproj index d1a0402b..910d2167 100644 --- a/Kyoo.WebApp/Kyoo.WebApp.csproj +++ b/Kyoo.WebApp/Kyoo.WebApp.csproj @@ -63,11 +63,6 @@ - - - - - diff --git a/Kyoo.WebApp/WebAppModule.cs b/Kyoo.WebApp/WebAppModule.cs index dc17c899..a83910cb 100644 --- a/Kyoo.WebApp/WebAppModule.cs +++ b/Kyoo.WebApp/WebAppModule.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Runtime.CompilerServices; using Kyoo.Abstractions.Controllers; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -33,28 +34,17 @@ namespace Kyoo.WebApp /// public bool Enabled => Directory.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "wwwroot")); - - /// - /// A logger only used to inform the user if the webapp could not be enabled. - /// - private readonly ILogger _logger; - /// /// Create a new . /// /// A logger only used to inform the user if the webapp could not be enabled. public WebAppModule(ILogger logger) { - _logger = logger; + if (!Enabled) + logger.LogError("The web app files could not be found, it will be disabled. " + + "If you cloned the project, you probably forgot to use the --recurse flag"); } - - /// - public void Disabled() - { - _logger.LogError("The web app files could not be found, it will be disabled. " + - "If you cloned the project, you probably forgot to use the --recurse flag"); - } - + /// public void Configure(IServiceCollection services) { @@ -99,12 +89,27 @@ namespace Kyoo.WebApp { app.UseSpa(spa => { - spa.Options.SourcePath = Path.Join(AppDomain.CurrentDomain.BaseDirectory, "Kyoo.WebApp", "Front"); + spa.Options.SourcePath = _GetSpaSourcePath(); if (env.IsDevelopment()) spa.UseAngularCliServer("start"); }); }, SA.Endpoint - 500) }; + + /// + /// Get the root directory of the web app + /// + /// The path of the source code of the web app or null if the directory has been deleted. + private static string _GetSpaSourcePath() + { + string GetSelfPath([CallerFilePath] string path = null) + { + return path; + } + + string path = Path.Join(Path.GetDirectoryName(GetSelfPath()), "Front"); + return Directory.Exists(path) ? path : null; + } } } \ No newline at end of file From 145967f5c6e2a6ea698b96225b6ee6972f4464d5 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Wed, 1 Sep 2021 17:47:05 +0200 Subject: [PATCH 37/38] CI: Only creating packets on push to master --- .github/workflows/build.yml | 2 ++ Kyoo.Core/Controllers/PluginManager.cs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 32482194..83b3e507 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -79,6 +79,7 @@ jobs: name: Create windows release runs-on: windows-latest needs: build + if: github.ref == 'refs/heads/master' steps: - uses: actions/checkout@v1 - name: Download windows build @@ -105,6 +106,7 @@ jobs: name: Create debian, rpm & arch releases runs-on: ubuntu-latest needs: build + if: github.ref == 'refs/heads/master' env: description: "A media browser" version: v0.0.1 #${{ github.ref }} diff --git a/Kyoo.Core/Controllers/PluginManager.cs b/Kyoo.Core/Controllers/PluginManager.cs index e87d83a8..7fc2c6cf 100644 --- a/Kyoo.Core/Controllers/PluginManager.cs +++ b/Kyoo.Core/Controllers/PluginManager.cs @@ -21,7 +21,7 @@ namespace Kyoo.Core.Controllers /// /// The service provider. It allow plugin's activation. /// - private IServiceProvider _provider; + private readonly IServiceProvider _provider; /// /// The configuration to get the plugin's directory. /// From 7d63a4d254e542cb20b6dd0cd621da48fcafe380 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Wed, 1 Sep 2021 18:07:05 +0200 Subject: [PATCH 38/38] Build: Cleaning up the windows host toolings on linux --- Kyoo.Core/Application.cs | 1 - Kyoo.Host.WindowsTrait/Kyoo.Host.WindowsTrait.linux.target | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Kyoo.Core/Application.cs b/Kyoo.Core/Application.cs index f09245e9..150dfb6a 100644 --- a/Kyoo.Core/Application.cs +++ b/Kyoo.Core/Application.cs @@ -263,7 +263,6 @@ namespace Kyoo.Core builder .WriteTo.Console(new ExpressionTemplate(template, theme: TemplateTheme.Code)) - .WriteTo.Debug() .WriteTo.File( path: Path.Combine(GetDataDirectory(), "logs", "log-.log"), formatter: new ExpressionTemplate(template), diff --git a/Kyoo.Host.WindowsTrait/Kyoo.Host.WindowsTrait.linux.target b/Kyoo.Host.WindowsTrait/Kyoo.Host.WindowsTrait.linux.target index 490cbebe..e60b9c2a 100644 --- a/Kyoo.Host.WindowsTrait/Kyoo.Host.WindowsTrait.linux.target +++ b/Kyoo.Host.WindowsTrait/Kyoo.Host.WindowsTrait.linux.target @@ -18,4 +18,9 @@ + + + + + \ No newline at end of file