Skip to content

Commit c2980c9

Browse files
committed
✨ implement core functionality
1 parent 065ae8c commit c2980c9

File tree

76 files changed

+1858
-846
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1858
-846
lines changed

.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
root = true
22
[{*.cs,*.py,*.php,*.js,*.xaml,*.axaml,*.java,*.kt,*.fxml}]
3-
file_header_template=GroomWise\nCopyright (C) 2023 John Russell C. Camo (@russkyc)\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see <http://www.gnu.org/licenses/>.
3+
file_header_template=Copyright (C) 2023 John Russell C. Camo (@russkyc)\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see <http://www.gnu.org/licenses/>.

.github/FUNDING.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# These are supported funding model platforms
2+
3+
github: russkyc
4+
patreon: russkyc
5+
custom: ["https://paypal.me/jrcmo"]
228 KB
Loading

.github/resources/nitefox-social-preview.svg

-117
This file was deleted.

NiteFox.sln

+11-28
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,30 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nitefox.Client", "Nitefox.Client\Nitefox.Client\Nitefox.Client.csproj", "{CAE08668-441B-4F7C-A356-E3E19AC8FF0F}"
4-
EndProject
5-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nitefox.Client.Android", "Nitefox.Client\Nitefox.Client.Android\Nitefox.Client.Android.csproj", "{298BDD31-B011-43E7-B901-C3B2FD3B77E3}"
6-
EndProject
7-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nitefox.Client.Desktop", "Nitefox.Client\Nitefox.Client.Desktop\Nitefox.Client.Desktop.csproj", "{6C747869-999F-41E0-977C-455E7D521ED1}"
8-
EndProject
9-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nitefox.Client.Browser", "Nitefox.Client\Nitefox.Client.Browser\Nitefox.Client.Browser.csproj", "{6539B3CA-827E-4C8B-A48F-697918569F94}"
3+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nitefox.App", "Nitefox.App\Nitefox.App.csproj", "{87F7DA51-0867-4F04-ADA8-9396DAA235E1}"
104
EndProject
11-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Platforms", "Platforms", "{352F0BE6-F655-41D9-A331-83B317354E9D}"
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nitefox.Client.Shared", "Nitefox.Client.Shared\Nitefox.Client.Shared.csproj", "{EB890DC7-A03F-406B-9E2E-47E1337DA4C0}"
126
EndProject
13-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nitefox.App", "Nitefox.App\Nitefox.App.csproj", "{87F7DA51-0867-4F04-ADA8-9396DAA235E1}"
7+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nitefox.Client.Avalonia", "Nitefox.Client.Avalonia\Nitefox.Client.Avalonia.csproj", "{A60A5804-4DB8-47EC-9E53-3DB41C0E8B3D}"
148
EndProject
159
Global
1610
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1711
Debug|Any CPU = Debug|Any CPU
1812
Release|Any CPU = Release|Any CPU
1913
EndGlobalSection
2014
GlobalSection(ProjectConfigurationPlatforms) = postSolution
21-
{CAE08668-441B-4F7C-A356-E3E19AC8FF0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22-
{CAE08668-441B-4F7C-A356-E3E19AC8FF0F}.Debug|Any CPU.Build.0 = Debug|Any CPU
23-
{CAE08668-441B-4F7C-A356-E3E19AC8FF0F}.Release|Any CPU.ActiveCfg = Release|Any CPU
24-
{CAE08668-441B-4F7C-A356-E3E19AC8FF0F}.Release|Any CPU.Build.0 = Release|Any CPU
25-
{298BDD31-B011-43E7-B901-C3B2FD3B77E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26-
{298BDD31-B011-43E7-B901-C3B2FD3B77E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
27-
{298BDD31-B011-43E7-B901-C3B2FD3B77E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
28-
{298BDD31-B011-43E7-B901-C3B2FD3B77E3}.Release|Any CPU.Build.0 = Release|Any CPU
29-
{6C747869-999F-41E0-977C-455E7D521ED1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
30-
{6C747869-999F-41E0-977C-455E7D521ED1}.Debug|Any CPU.Build.0 = Debug|Any CPU
31-
{6C747869-999F-41E0-977C-455E7D521ED1}.Release|Any CPU.ActiveCfg = Release|Any CPU
32-
{6C747869-999F-41E0-977C-455E7D521ED1}.Release|Any CPU.Build.0 = Release|Any CPU
33-
{6539B3CA-827E-4C8B-A48F-697918569F94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
34-
{6539B3CA-827E-4C8B-A48F-697918569F94}.Debug|Any CPU.Build.0 = Debug|Any CPU
35-
{6539B3CA-827E-4C8B-A48F-697918569F94}.Release|Any CPU.ActiveCfg = Release|Any CPU
36-
{6539B3CA-827E-4C8B-A48F-697918569F94}.Release|Any CPU.Build.0 = Release|Any CPU
3715
{87F7DA51-0867-4F04-ADA8-9396DAA235E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
3816
{87F7DA51-0867-4F04-ADA8-9396DAA235E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
3917
{87F7DA51-0867-4F04-ADA8-9396DAA235E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
4018
{87F7DA51-0867-4F04-ADA8-9396DAA235E1}.Release|Any CPU.Build.0 = Release|Any CPU
19+
{EB890DC7-A03F-406B-9E2E-47E1337DA4C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20+
{EB890DC7-A03F-406B-9E2E-47E1337DA4C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
21+
{EB890DC7-A03F-406B-9E2E-47E1337DA4C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
22+
{EB890DC7-A03F-406B-9E2E-47E1337DA4C0}.Release|Any CPU.Build.0 = Release|Any CPU
23+
{A60A5804-4DB8-47EC-9E53-3DB41C0E8B3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24+
{A60A5804-4DB8-47EC-9E53-3DB41C0E8B3D}.Debug|Any CPU.Build.0 = Debug|Any CPU
25+
{A60A5804-4DB8-47EC-9E53-3DB41C0E8B3D}.Release|Any CPU.ActiveCfg = Release|Any CPU
26+
{A60A5804-4DB8-47EC-9E53-3DB41C0E8B3D}.Release|Any CPU.Build.0 = Release|Any CPU
4127
EndGlobalSection
4228
GlobalSection(NestedProjects) = preSolution
43-
{298BDD31-B011-43E7-B901-C3B2FD3B77E3} = {352F0BE6-F655-41D9-A331-83B317354E9D}
44-
{6539B3CA-827E-4C8B-A48F-697918569F94} = {352F0BE6-F655-41D9-A331-83B317354E9D}
45-
{6C747869-999F-41E0-977C-455E7D521ED1} = {352F0BE6-F655-41D9-A331-83B317354E9D}
4629
EndGlobalSection
4730
EndGlobal
+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// Copyright (C) 2023 John Russell C. Camo (@russkyc)
2+
//
3+
// This program is free software: you can redistribute it and/or modify
4+
// it under the terms of the GNU General Public License as published by
5+
// the Free Software Foundation, either version 3 of the License, or
6+
// (at your option) any later version.
7+
//
8+
// This program is distributed in the hope that it will be useful,
9+
// but WITHOUT ANY WARRANTY
10+
11+
using Russkyc.Configuration;
12+
13+
namespace Nitefox.App.Configuration;
14+
15+
public class NitefoxConfig : ConfigProvider
16+
{
17+
public NitefoxConfig() : base($"{AppContext.BaseDirectory}nitefox.json")
18+
{
19+
try
20+
{
21+
if (string.IsNullOrWhiteSpace(FfmpegLocation))
22+
{
23+
FfmpegLocation = $"{AppContext.BaseDirectory}ffmpeg\\";
24+
}
25+
}
26+
catch (Exception)
27+
{
28+
FfmpegLocation = $"{AppContext.BaseDirectory}ffmpeg\\";
29+
throw;
30+
}
31+
32+
try
33+
{
34+
if (string.IsNullOrWhiteSpace(TempFilesLocation))
35+
{
36+
TempFilesLocation = $"{AppContext.BaseDirectory}temp\\";
37+
}
38+
}
39+
catch (Exception)
40+
{
41+
TempFilesLocation = $"{AppContext.BaseDirectory}temp\\";
42+
throw;
43+
}
44+
45+
try
46+
{
47+
if (string.IsNullOrWhiteSpace(DownloadLocation))
48+
{
49+
DownloadLocation = $"{AppContext.BaseDirectory}songs\\";
50+
}
51+
}
52+
catch (Exception)
53+
{
54+
DownloadLocation = $"{AppContext.BaseDirectory}songs\\";
55+
throw;
56+
}
57+
}
58+
59+
public string FfmpegLocation
60+
{
61+
get => GetValue<string>(nameof(FfmpegLocation));
62+
set => SetValue(nameof(FfmpegLocation), value);
63+
}
64+
65+
public string TempFilesLocation
66+
{
67+
get => GetValue<string>(nameof(TempFilesLocation));
68+
set => SetValue(nameof(TempFilesLocation), value);
69+
}
70+
71+
public string DownloadLocation
72+
{
73+
get => GetValue<string>(nameof(DownloadLocation));
74+
set => SetValue(nameof(DownloadLocation), value);
75+
}
76+
}

Nitefox.App/Ffmpeg/FfmpegService.cs

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
// Copyright (C) 2023 John Russell C. Camo (@russkyc)
2+
//
3+
// This program is free software: you can redistribute it and/or modify
4+
// it under the terms of the GNU General Public License as published by
5+
// the Free Software Foundation, either version 3 of the License, or
6+
// (at your option) any later version.
7+
//
8+
// This program is distributed in the hope that it will be useful,
9+
// but WITHOUT ANY WARRANTY
10+
11+
using FFMpegCore;
12+
using GithubReleaseDownloader;
13+
using GithubReleaseDownloader.Entities;
14+
using Nitefox.App.Configuration;
15+
using SharpCompress.Common;
16+
using SharpCompress.Readers;
17+
namespace Nitefox.App.Ffmpeg;
18+
19+
public class FfmpegService
20+
{
21+
private readonly NitefoxConfig _nitefoxConfig;
22+
23+
public FfmpegService(NitefoxConfig nitefoxConfig)
24+
{
25+
_nitefoxConfig = nitefoxConfig;
26+
27+
}
28+
29+
public async Task<bool> StreamConvert(string url, string fileName)
30+
{
31+
return await FFMpegArguments
32+
.FromUrlInput(new Uri(url))
33+
.OutputToFile(fileName)
34+
.ProcessAsynchronously();
35+
}
36+
37+
public void ConfigureFfmpeg()
38+
{
39+
GlobalFFOptions.Configure(new FFOptions
40+
{
41+
BinaryFolder = _nitefoxConfig.FfmpegLocation,
42+
TemporaryFilesFolder = _nitefoxConfig.TempFilesLocation
43+
});
44+
}
45+
46+
public async Task<bool> DownloadFfmpeg()
47+
{
48+
if (new DirectoryInfo(_nitefoxConfig.FfmpegLocation).EnumerateFiles()
49+
.Count() >= 3)
50+
{
51+
return true;
52+
}
53+
54+
var release = await ReleaseManager.Instance.GetLatestAsync("Tyrrrz","FFmpegBin");
55+
if (release is null || !release.Assets.Any()) return false;
56+
57+
var releaseAsset = new ReleaseAsset();
58+
59+
if (OperatingSystem.IsWindows())
60+
{
61+
releaseAsset = release.Assets.First(asset => asset.Name.EndsWith("windows-x64.zip"));
62+
}
63+
64+
if (OperatingSystem.IsLinux())
65+
{
66+
releaseAsset = release.Assets.First(asset => asset.Name.EndsWith("linux-x64.zip"));
67+
}
68+
69+
if (OperatingSystem.IsMacOS())
70+
{
71+
releaseAsset = release.Assets.First(asset => asset.Name.EndsWith("osx-x64.zip"));
72+
}
73+
74+
if (OperatingSystem.IsMacCatalyst())
75+
{
76+
releaseAsset = release.Assets.First(asset => asset.Name.EndsWith("osx-arm64.zip"));
77+
}
78+
79+
var downloadInfo = await AssetDownloader.Instance.DownloadAssetAsync(releaseAsset, _nitefoxConfig.FfmpegLocation);
80+
81+
await Task.Run(async () =>
82+
{
83+
await using var stream = File.OpenRead(downloadInfo.Path);
84+
using var reader = ReaderFactory.Open(stream);
85+
86+
while (reader.MoveToNextEntry())
87+
{
88+
if (!reader.Entry.IsDirectory)
89+
{
90+
reader.WriteEntryToDirectory(_nitefoxConfig.FfmpegLocation, new ExtractionOptions()
91+
{
92+
ExtractFullPath = true,
93+
Overwrite = true
94+
});
95+
}
96+
}
97+
98+
}).ContinueWith(_ =>
99+
{
100+
File.Delete(downloadInfo.Path);
101+
});
102+
103+
return true;
104+
}
105+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright (C) 2023 John Russell C. Camo (@russkyc)
2+
//
3+
// This program is free software: you can redistribute it and/or modify
4+
// it under the terms of the GNU General Public License as published by
5+
// the Free Software Foundation, either version 3 of the License, or
6+
// (at your option) any later version.
7+
//
8+
// This program is distributed in the hope that it will be useful,
9+
// but WITHOUT ANY WARRANTY
10+
11+
namespace Nitefox.App.Media.Entities;
12+
13+
#pragma warning disable CS8618
14+
15+
public class TrackDownload
16+
{
17+
public string Id { get; init; }
18+
public string Name { get; init; }
19+
public string Author { get; init; }
20+
public string Collection { get; set; }
21+
public string SavePath { get; set; }
22+
public bool IsDownloaded { get; set; }
23+
}

0 commit comments

Comments
 (0)