Skip to content

Commit 5bbc066

Browse files
authored
Merge pull request #3
Add refactorings
2 parents b420d88 + 7071a4b commit 5bbc066

File tree

14 files changed

+511
-80
lines changed

14 files changed

+511
-80
lines changed

.github/workflows/publish.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
9+
jobs:
10+
11+
build-windows:
12+
permissions:
13+
contents: write
14+
runs-on: windows-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v3
18+
19+
- name: Setup .NET
20+
uses: actions/setup-dotnet@v3
21+
with:
22+
dotnet-version: 8.0.x
23+
24+
- name: Restore Dependencies
25+
run: dotnet restore
26+
27+
- name: Get version
28+
id: package_version
29+
uses: KageKirin/get-csproj-version@v0
30+
with:
31+
file: D:\a\nitefox\nitefox\Nitefox.Client.Photino\Nitefox.Client.Photino.csproj
32+
33+
- name: Setup PupNet
34+
run: dotnet tool install -g KuiperZone.PupNet
35+
36+
- name: Build x86 Zip
37+
run: pupnet -r win-x86 -y -k zip -v ${{ steps.package_version.outputs.version }} -o nitefox-win-${{ steps.package_version.outputs.version }}-x86.zip
38+
39+
- name: Build x64 Zip
40+
run: pupnet -r win-x64 -y -k zip -v ${{ steps.package_version.outputs.version }} -o nitefox-win-${{ steps.package_version.outputs.version }}-x64.zip
41+
42+
- name: Build x86 Setup
43+
run: pupnet -r win-x86 -y -k setup -v ${{ steps.package_version.outputs.version }} -o nitefox-win-${{ steps.package_version.outputs.version }}-installer-x86.exe
44+
45+
- name: Build x64 Setup
46+
run: pupnet -r win-x64 -y -k setup -v ${{ steps.package_version.outputs.version }} -o nitefox-win-${{ steps.package_version.outputs.version }}-installer-x64.exe
47+
48+
- name: Publish Release
49+
uses: softprops/action-gh-release@v1
50+
with:
51+
name: '🎉 Nitefox ${{ steps.package_version.outputs.version }} Windows Release'
52+
body: 'Latest windows builds for Nitefox PDF'
53+
tag_name: 'v${{ steps.package_version.outputs.version }}-win'
54+
files: |
55+
D:/a/nitefox/nitefox/Deploy/bin/nitefox-win-${{ steps.package_version.outputs.version }}-x86.zip
56+
D:/a/nitefox/nitefox/Deploy/bin/nitefox-win-${{ steps.package_version.outputs.version }}-x64.zip
57+
D:/a/nitefox/nitefox/Deploy/bin/nitefox-win-${{ steps.package_version.outputs.version }}-installer-x86.exe
58+
D:/a/nitefox/nitefox/Deploy/bin/nitefox-win-${{ steps.package_version.outputs.version }}-installer-x64.exe
59+
60+
build-linux:
61+
permissions:
62+
contents: write
63+
runs-on: ubuntu-latest
64+
steps:
65+
- name: Checkout
66+
uses: actions/checkout@v3
67+
68+
- name: Setup .NET
69+
uses: actions/setup-dotnet@v3
70+
with:
71+
dotnet-version: 8.0.x
72+
73+
- name: Restore Dependencies
74+
run: dotnet restore
75+
76+
- name: Get version
77+
id: package_version
78+
uses: KageKirin/get-csproj-version@v0
79+
with:
80+
file: /home/runner/work/nitefox/nitefox/Nitefox.Client.Photino/Nitefox.Client.Photino.csproj
81+
82+
- name: Install Dpkg
83+
run: sudo apt install dpkg
84+
85+
- name: Install Rpm
86+
run: sudo apt install rpm
87+
88+
- name: Install Fuse
89+
run: sudo apt install fuse libfuse2
90+
91+
- name: Setup PupNet
92+
run: dotnet tool install -g KuiperZone.PupNet
93+
94+
- name: Build x64 Zip
95+
run: pupnet Nitefox.Pupnet.conf -r linux-x64 -y -k zip -v ${{ steps.package_version.outputs.version }} -o nitefox-linux-${{ steps.package_version.outputs.version }}-x64.zip
96+
97+
- name: Build x64 AppImage
98+
run: pupnet Nitefox.Pupnet.conf -r linux-x64 -y -k appimage -v ${{ steps.package_version.outputs.version }} -o nitefox-linux-${{ steps.package_version.outputs.version }}-x64.appimage
99+
100+
- name: Build x64 Deb
101+
run: pupnet Nitefox.Pupnet.conf -r linux-x64 -y -k deb -v ${{ steps.package_version.outputs.version }} -o nitefox-linux-${{ steps.package_version.outputs.version }}-x64.deb
102+
103+
- name: Build x64 Rpm
104+
run: pupnet Nitefox.Pupnet.conf -r linux-x64 -y -k rpm -v ${{ steps.package_version.outputs.version }} -o nitefox-linux-${{ steps.package_version.outputs.version }}-x64.rpm
105+
106+
- name: Publish Release
107+
uses: softprops/action-gh-release@v1
108+
with:
109+
name: '🎉 Nitefox PDF ${{ steps.package_version.outputs.version }} Linux Release'
110+
body: 'Latest Linux builds for Nitefox PDF'
111+
tag_name: 'v${{ steps.package_version.outputs.version }}-linux'
112+
files: |
113+
/home/runner/work/nitefox/nitefox/Deploy/bin/nitefox-linux-${{ steps.package_version.outputs.version }}-x64.zip
114+
/home/runner/work/nitefox/nitefox/Deploy/bin/nitefox-linux-${{ steps.package_version.outputs.version }}-x64.appimage
115+
/home/runner/work/nitefox/nitefox/Deploy/bin/nitefox-linux-${{ steps.package_version.outputs.version }}-x64.deb
116+
/home/runner/work/nitefox/nitefox/Deploy/bin/nitefox-linux-${{ steps.package_version.outputs.version }}-x64.rpm

Nitefox.App/Media/MetadataService.cs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,15 @@
1010

1111
using SpotifyExplode;
1212
using SpotifyExplode.Tracks;
13-
using YoutubeExplode;
14-
using YoutubeExplode.Videos.Streams;
15-
1613
namespace Nitefox.App.Media;
1714

1815
public class MetadataService
1916
{
2017
private readonly SpotifyClient _spotifyClient;
21-
private readonly YoutubeClient _youtubeClient;
2218

23-
public MetadataService(SpotifyClient spotifyClient, YoutubeClient youtubeClient)
19+
public MetadataService(SpotifyClient spotifyClient)
2420
{
2521
_spotifyClient = spotifyClient;
26-
_youtubeClient = youtubeClient;
2722
}
2823

2924
public async Task<int> GetAlbumTrackCount(string id)
@@ -55,6 +50,10 @@ public async Task<string> GetAlbumImageUrl(string id)
5550
{
5651
return string.Empty;
5752
}
53+
catch (Exception)
54+
{
55+
return string.Empty;
56+
}
5857
}
5958

6059
public async Task<string> GetPlaylistImageUrl(string id)
@@ -84,13 +83,10 @@ public async Task<string> GetPlaylistImageUrl(string id)
8483
return stream;
8584
}
8685

87-
public async Task<string> GetPreviewStream(string url)
86+
public async Task<string?> GetPreviewStream(string url)
8887
{
89-
var youtubeId = await _spotifyClient.Tracks.GetYoutubeIdAsync(url);
90-
var streamManifest = await _youtubeClient.Videos.Streams.GetManifestAsync($"https://youtube.com/watch?v={youtubeId}");
91-
return streamManifest.GetAudioOnlyStreams()
92-
.OrderByDescending(stream => stream.Size)
93-
.First().Url;
88+
var previewStream = await _spotifyClient.Tracks.GetDownloadUrlAsync(url);
89+
return previewStream;
9490
}
9591

9692
public async Task<IEnumerable<Track>> GetAlbumTracksMetadata(string id, string title)

Nitefox.App/Nitefox.App.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
<PackageReference Include="Russkyc.Configuration" Version="1.0.1" />
1818
<PackageReference Include="SharpCompress" Version="0.38.0" />
1919
<PackageReference Include="SpotifyExplode" Version="1.1.2" />
20-
<PackageReference Include="YoutubeExplode" Version="6.4.3" />
2120
</ItemGroup>
2221

2322
<ItemGroup>

Nitefox.Client.Photino/Nitefox.Client.Photino.csproj

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@
44
<OutputType>WinExe</OutputType>
55
<TargetFramework>net8.0</TargetFramework>
66
<ApplicationIcon>nitefox_icon.ico</ApplicationIcon>
7+
<Version>1.1.0</Version>
78
</PropertyGroup>
89

910
<ItemGroup>
1011
<PackageReference Include="BlazorAnimation" Version="2.2.0" />
11-
<PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="7.0.1" />
12+
<PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="7.1.0" />
13+
<PackageReference Include="Microsoft.Extensions.FileProviders.Abstractions" Version="8.0.0" />
1214
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.1" />
13-
<PackageReference Include="Microsoft.AspNetCore.Components.WebView" Version="8.0.10" />
14-
<PackageReference Include="MudBlazor" Version="7.11.0" />
15-
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0"/>
16-
<PackageReference Include="Photino.Blazor" Version="3.1.10" />
15+
<PackageReference Include="Microsoft.AspNetCore.Components.WebView" Version="8.0.11" />
16+
<PackageReference Include="MudBlazor" Version="7.15.0" />
17+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.1"/>
18+
<PackageReference Include="Photino.Blazor" Version="3.2.0" />
1719
</ItemGroup>
1820

1921
<ItemGroup>

Nitefox.Client.Photino/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ static void Main(string[] args)
2525

2626
// customize window
2727
app.MainWindow
28+
.SetMinWidth(650)
29+
.SetMinHeight(700)
2830
.SetContextMenuEnabled(false)
2931
.SetIconFile("nitefox_icon.ico")
3032
.SetTitle("Nitefox");

Nitefox.Client.Photino/Services/PhotinoFileService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public async Task<string> OpenFolder()
3030
{
3131
try
3232
{
33-
var path = Program.App.MainWindow.ShowOpenFolder();
33+
var path = await Program.App.MainWindow.ShowOpenFolderAsync();
3434
return path[0];
3535
}
3636
catch (Exception)

Nitefox.Client.Shared/Components/Search/SearchQueryCard.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@
283283
await InvokeAsync(StateHasChanged);
284284

285285
var stream = await MetadataService.GetPreviewStream(Url);
286+
if (stream is null) return;
286287
MediaPlayerState.Play($"{Title} - {Subtitle}", stream);
287288
_isPreviewStreamLoading = false;
288289
await InvokeAsync(StateHasChanged);

Nitefox.Client.Shared/Nitefox.Client.Shared.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
</PropertyGroup>
55
<ItemGroup>
66
<PackageReference Include="BlazorAnimation" Version="2.2.0" />
7-
<PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="7.0.1" />
7+
<PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="7.1.0" />
88
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.1" />
9-
<PackageReference Include="Microsoft.AspNetCore.Components.WebView" Version="8.0.10" />
10-
<PackageReference Include="MudBlazor" Version="7.11.0" />
9+
<PackageReference Include="Microsoft.AspNetCore.Components.WebView" Version="8.0.11" />
10+
<PackageReference Include="MudBlazor" Version="7.15.0" />
11+
<PackageReference Include="Sve.Blazor.InfiniteScroll" Version="1.0.0-alpha" />
1112
</ItemGroup>
1213
<ItemGroup>
1314
<Watch Include="**\*\*\*.cs" />

Nitefox.Client.Shared/NitefoxShared.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@
44
using Nitefox.App.Configuration;
55
using Nitefox.App.Ffmpeg;
66
using Nitefox.App.Media;
7-
using Nitefox.App.Services;
87
using Nitefox.App.States;
9-
using Nitefox.Client.Shared.Pages;
108
using SpotifyExplode;
11-
using YoutubeExplode;
129

1310
namespace Nitefox.Client.Shared
1411
{
@@ -19,7 +16,6 @@ public static IServiceCollection AddNitefoxServices(this IServiceCollection coll
1916
return collection.AddSingleton(_ => new SpotifyClient())
2017
.AddMudServices()
2118
.AddMudExtensions()
22-
.AddSingleton(_ => new YoutubeClient())
2319
.AddSingleton<SearchState>()
2420
.AddSingleton<NitefoxConfig>()
2521
.AddSingleton<FfmpegService>()

0 commit comments

Comments
 (0)