Skip to content

Commit

Permalink
Merge pull request #3
Browse files Browse the repository at this point in the history
Add refactorings
  • Loading branch information
russkyc authored Dec 22, 2024
2 parents b420d88 + 7071a4b commit 5bbc066
Show file tree
Hide file tree
Showing 14 changed files with 511 additions and 80 deletions.
116 changes: 116 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: Publish

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:

build-windows:
permissions:
contents: write
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x

- name: Restore Dependencies
run: dotnet restore

- name: Get version
id: package_version
uses: KageKirin/get-csproj-version@v0
with:
file: D:\a\nitefox\nitefox\Nitefox.Client.Photino\Nitefox.Client.Photino.csproj

- name: Setup PupNet
run: dotnet tool install -g KuiperZone.PupNet

- name: Build x86 Zip
run: pupnet -r win-x86 -y -k zip -v ${{ steps.package_version.outputs.version }} -o nitefox-win-${{ steps.package_version.outputs.version }}-x86.zip

- name: Build x64 Zip
run: pupnet -r win-x64 -y -k zip -v ${{ steps.package_version.outputs.version }} -o nitefox-win-${{ steps.package_version.outputs.version }}-x64.zip

- name: Build x86 Setup
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

- name: Build x64 Setup
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

- name: Publish Release
uses: softprops/action-gh-release@v1
with:
name: '🎉 Nitefox ${{ steps.package_version.outputs.version }} Windows Release'
body: 'Latest windows builds for Nitefox PDF'
tag_name: 'v${{ steps.package_version.outputs.version }}-win'
files: |
D:/a/nitefox/nitefox/Deploy/bin/nitefox-win-${{ steps.package_version.outputs.version }}-x86.zip
D:/a/nitefox/nitefox/Deploy/bin/nitefox-win-${{ steps.package_version.outputs.version }}-x64.zip
D:/a/nitefox/nitefox/Deploy/bin/nitefox-win-${{ steps.package_version.outputs.version }}-installer-x86.exe
D:/a/nitefox/nitefox/Deploy/bin/nitefox-win-${{ steps.package_version.outputs.version }}-installer-x64.exe
build-linux:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x

- name: Restore Dependencies
run: dotnet restore

- name: Get version
id: package_version
uses: KageKirin/get-csproj-version@v0
with:
file: /home/runner/work/nitefox/nitefox/Nitefox.Client.Photino/Nitefox.Client.Photino.csproj

- name: Install Dpkg
run: sudo apt install dpkg

- name: Install Rpm
run: sudo apt install rpm

- name: Install Fuse
run: sudo apt install fuse libfuse2

- name: Setup PupNet
run: dotnet tool install -g KuiperZone.PupNet

- name: Build x64 Zip
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

- name: Build x64 AppImage
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

- name: Build x64 Deb
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

- name: Build x64 Rpm
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

- name: Publish Release
uses: softprops/action-gh-release@v1
with:
name: '🎉 Nitefox PDF ${{ steps.package_version.outputs.version }} Linux Release'
body: 'Latest Linux builds for Nitefox PDF'
tag_name: 'v${{ steps.package_version.outputs.version }}-linux'
files: |
/home/runner/work/nitefox/nitefox/Deploy/bin/nitefox-linux-${{ steps.package_version.outputs.version }}-x64.zip
/home/runner/work/nitefox/nitefox/Deploy/bin/nitefox-linux-${{ steps.package_version.outputs.version }}-x64.appimage
/home/runner/work/nitefox/nitefox/Deploy/bin/nitefox-linux-${{ steps.package_version.outputs.version }}-x64.deb
/home/runner/work/nitefox/nitefox/Deploy/bin/nitefox-linux-${{ steps.package_version.outputs.version }}-x64.rpm
20 changes: 8 additions & 12 deletions Nitefox.App/Media/MetadataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,15 @@

using SpotifyExplode;
using SpotifyExplode.Tracks;
using YoutubeExplode;
using YoutubeExplode.Videos.Streams;

namespace Nitefox.App.Media;

public class MetadataService
{
private readonly SpotifyClient _spotifyClient;
private readonly YoutubeClient _youtubeClient;

public MetadataService(SpotifyClient spotifyClient, YoutubeClient youtubeClient)
public MetadataService(SpotifyClient spotifyClient)
{
_spotifyClient = spotifyClient;
_youtubeClient = youtubeClient;
}

public async Task<int> GetAlbumTrackCount(string id)
Expand Down Expand Up @@ -55,6 +50,10 @@ public async Task<string> GetAlbumImageUrl(string id)
{
return string.Empty;
}
catch (Exception)
{
return string.Empty;
}
}

public async Task<string> GetPlaylistImageUrl(string id)
Expand Down Expand Up @@ -84,13 +83,10 @@ public async Task<string> GetPlaylistImageUrl(string id)
return stream;
}

public async Task<string> GetPreviewStream(string url)
public async Task<string?> GetPreviewStream(string url)
{
var youtubeId = await _spotifyClient.Tracks.GetYoutubeIdAsync(url);
var streamManifest = await _youtubeClient.Videos.Streams.GetManifestAsync($"https://youtube.com/watch?v={youtubeId}");
return streamManifest.GetAudioOnlyStreams()
.OrderByDescending(stream => stream.Size)
.First().Url;
var previewStream = await _spotifyClient.Tracks.GetDownloadUrlAsync(url);
return previewStream;
}

public async Task<IEnumerable<Track>> GetAlbumTracksMetadata(string id, string title)
Expand Down
1 change: 0 additions & 1 deletion Nitefox.App/Nitefox.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<PackageReference Include="Russkyc.Configuration" Version="1.0.1" />
<PackageReference Include="SharpCompress" Version="0.38.0" />
<PackageReference Include="SpotifyExplode" Version="1.1.2" />
<PackageReference Include="YoutubeExplode" Version="6.4.3" />
</ItemGroup>

<ItemGroup>
Expand Down
12 changes: 7 additions & 5 deletions Nitefox.Client.Photino/Nitefox.Client.Photino.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ApplicationIcon>nitefox_icon.ico</ApplicationIcon>
<Version>1.1.0</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BlazorAnimation" Version="2.2.0" />
<PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="7.0.1" />
<PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="7.1.0" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebView" Version="8.0.10" />
<PackageReference Include="MudBlazor" Version="7.11.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0"/>
<PackageReference Include="Photino.Blazor" Version="3.1.10" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebView" Version="8.0.11" />
<PackageReference Include="MudBlazor" Version="7.15.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.1"/>
<PackageReference Include="Photino.Blazor" Version="3.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions Nitefox.Client.Photino/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ static void Main(string[] args)

// customize window
app.MainWindow
.SetMinWidth(650)
.SetMinHeight(700)
.SetContextMenuEnabled(false)
.SetIconFile("nitefox_icon.ico")
.SetTitle("Nitefox");
Expand Down
2 changes: 1 addition & 1 deletion Nitefox.Client.Photino/Services/PhotinoFileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public async Task<string> OpenFolder()
{
try
{
var path = Program.App.MainWindow.ShowOpenFolder();
var path = await Program.App.MainWindow.ShowOpenFolderAsync();
return path[0];
}
catch (Exception)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@
await InvokeAsync(StateHasChanged);

var stream = await MetadataService.GetPreviewStream(Url);
if (stream is null) return;
MediaPlayerState.Play($"{Title} - {Subtitle}", stream);
_isPreviewStreamLoading = false;
await InvokeAsync(StateHasChanged);
Expand Down
7 changes: 4 additions & 3 deletions Nitefox.Client.Shared/Nitefox.Client.Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BlazorAnimation" Version="2.2.0" />
<PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="7.0.1" />
<PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="7.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebView" Version="8.0.10" />
<PackageReference Include="MudBlazor" Version="7.11.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebView" Version="8.0.11" />
<PackageReference Include="MudBlazor" Version="7.15.0" />
<PackageReference Include="Sve.Blazor.InfiniteScroll" Version="1.0.0-alpha" />
</ItemGroup>
<ItemGroup>
<Watch Include="**\*\*\*.cs" />
Expand Down
4 changes: 0 additions & 4 deletions Nitefox.Client.Shared/NitefoxShared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
using Nitefox.App.Configuration;
using Nitefox.App.Ffmpeg;
using Nitefox.App.Media;
using Nitefox.App.Services;
using Nitefox.App.States;
using Nitefox.Client.Shared.Pages;
using SpotifyExplode;
using YoutubeExplode;

namespace Nitefox.Client.Shared
{
Expand All @@ -19,7 +16,6 @@ public static IServiceCollection AddNitefoxServices(this IServiceCollection coll
return collection.AddSingleton(_ => new SpotifyClient())
.AddMudServices()
.AddMudExtensions()
.AddSingleton(_ => new YoutubeClient())
.AddSingleton<SearchState>()
.AddSingleton<NitefoxConfig>()
.AddSingleton<FfmpegService>()
Expand Down
Loading

0 comments on commit 5bbc066

Please sign in to comment.