Skip to content

Commit

Permalink
🏗️ Add Photino project
Browse files Browse the repository at this point in the history
  • Loading branch information
russkyc committed Nov 8, 2023
1 parent 2cc2396 commit f8790e5
Show file tree
Hide file tree
Showing 7 changed files with 213 additions and 27 deletions.
6 changes: 6 additions & 0 deletions NiteFox.sln
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nitefox.Client.Shared", "Ni
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nitefox.Client.Avalonia", "Nitefox.Client.Avalonia\Nitefox.Client.Avalonia.csproj", "{A60A5804-4DB8-47EC-9E53-3DB41C0E8B3D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nitefox.Client.Photino", "Nitefox.Client.Photino\Nitefox.Client.Photino.csproj", "{4BE343A7-CBBD-436A-A01C-7249E9383CDC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -24,6 +26,10 @@ Global
{A60A5804-4DB8-47EC-9E53-3DB41C0E8B3D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A60A5804-4DB8-47EC-9E53-3DB41C0E8B3D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A60A5804-4DB8-47EC-9E53-3DB41C0E8B3D}.Release|Any CPU.Build.0 = Release|Any CPU
{4BE343A7-CBBD-436A-A01C-7249E9383CDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4BE343A7-CBBD-436A-A01C-7249E9383CDC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4BE343A7-CBBD-436A-A01C-7249E9383CDC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4BE343A7-CBBD-436A-A01C-7249E9383CDC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
EndGlobalSection
Expand Down
26 changes: 17 additions & 9 deletions Nitefox.App/Media/MediaSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,27 @@ public MediaSearch(SpotifyClient spotifyClient)

public async Task<IEnumerable<ISearchResult>> SearchAsync(string query, int limit = Int32.MaxValue, int skip = 0)
{
var cleanQuery = query.ToCleanQueryString();

if (query.Contains("album", StringComparison.InvariantCultureIgnoreCase))
try
{
return await _spotifyClient.Search.GetAlbumsAsync(cleanQuery, skip, limit);
var cleanQuery = query.ToCleanQueryString();

if (query.Contains("album", StringComparison.InvariantCultureIgnoreCase))
{
return await _spotifyClient.Search.GetAlbumsAsync(cleanQuery, skip, limit);
}

if (query.Contains("playlist", StringComparison.InvariantCultureIgnoreCase))
{
return await _spotifyClient.Search.GetPlaylistsAsync(cleanQuery, skip, limit);
}

return await _spotifyClient.Search.GetTracksAsync(cleanQuery, skip, limit);
}

if (query.Contains("playlist", StringComparison.InvariantCultureIgnoreCase))
catch (Exception e)
{
return await _spotifyClient.Search.GetPlaylistsAsync(cleanQuery, skip, limit);
Console.WriteLine(e);
return Enumerable.Empty<ISearchResult>();
}

return await _spotifyClient.Search.GetTracksAsync(cleanQuery, skip, limit);
}

}
56 changes: 56 additions & 0 deletions Nitefox.Client.Photino/Nitefox.Client.Photino.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ApplicationIcon>nitefox_icon.ico</ApplicationIcon>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BlazorAnimation" Version="2.2.0" />
<PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="6.6.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebView" Version="7.0.13" />
<PackageReference Include="MudBlazor" Version="6.11.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0"/>
<PackageReference Include="Photino.Blazor" Version="2.6.0"/>
</ItemGroup>

<ItemGroup>
<Content Update="wwwroot\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<None Include="nitefox_icon.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<_ContentIncludedByDefault Remove="wwwroot\css\app.css" />
<_ContentIncludedByDefault Remove="wwwroot\css\bootstrap\bootstrap.min.css" />
<_ContentIncludedByDefault Remove="wwwroot\css\bootstrap\bootstrap.min.css.map" />
<_ContentIncludedByDefault Remove="wwwroot\css\custom.css" />
<_ContentIncludedByDefault Remove="wwwroot\css\open-iconic\FONT-LICENSE" />
<_ContentIncludedByDefault Remove="wwwroot\css\open-iconic\font\css\open-iconic-bootstrap.min.css" />
<_ContentIncludedByDefault Remove="wwwroot\css\open-iconic\font\fonts\open-iconic.eot" />
<_ContentIncludedByDefault Remove="wwwroot\css\open-iconic\font\fonts\open-iconic.otf" />
<_ContentIncludedByDefault Remove="wwwroot\css\open-iconic\font\fonts\open-iconic.svg" />
<_ContentIncludedByDefault Remove="wwwroot\css\open-iconic\font\fonts\open-iconic.ttf" />
<_ContentIncludedByDefault Remove="wwwroot\css\open-iconic\font\fonts\open-iconic.woff" />
<_ContentIncludedByDefault Remove="wwwroot\css\open-iconic\ICON-LICENSE" />
<_ContentIncludedByDefault Remove="wwwroot\css\open-iconic\README.md" />
<_ContentIncludedByDefault Remove="wwwroot\index.html" />
<_ContentIncludedByDefault Remove="wwwroot\sample-data\weather.json" />
<_ContentIncludedByDefault Remove="Shared\MainLayout.razor" />
<_ContentIncludedByDefault Remove="Shared\NavMenu.razor" />
<_ContentIncludedByDefault Remove="Shared\SurveyPrompt.razor" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Nitefox.Client.Shared\Nitefox.Client.Shared.csproj" />
</ItemGroup>

</Project>
47 changes: 47 additions & 0 deletions Nitefox.Client.Photino/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using Microsoft.Extensions.DependencyInjection;
using Nitefox.App.Services.Interfaces;
using Nitefox.Client.Photino.Services;
using Nitefox.Client.Shared;
using Photino.Blazor;

namespace Nitefox.Client.Photino
{
class Program
{
[STAThread]
static void Main(string[] args)
{
var appBuilder = PhotinoBlazorAppBuilder.CreateDefault(args);

appBuilder.Services
.AddNitefoxServices()
.AddSingleton<IFileService, PhotinoFileService>();

// register root component and selector
appBuilder.RootComponents.Add<NitefoxApp>("#app");

var app = appBuilder.Build();

// customize window
app.MainWindow
.SetContextMenuEnabled(false)
.SetIconFile("nitefox_icon.ico")
.SetTitle("Nitefox");

app.MainWindow.Centered = true;
app.MainWindow.GrantBrowserPermissions = true;

App = app;

AppDomain.CurrentDomain.UnhandledException += (sender, error) =>
{
app.MainWindow.ShowMessage("Fatal exception", error.ExceptionObject.ToString());
};

app.Run();
}

public static PhotinoBlazorApp App { get; private set; }
}
}
87 changes: 87 additions & 0 deletions Nitefox.Client.Photino/Services/PhotinoFileService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Copyright (C) 2023 John Russell C. Camo (@russkyc)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY

using System;
using System.IO;
using System.Threading.Tasks;
using Nitefox.App.Configuration;
using Nitefox.App.Services.Interfaces;

namespace Nitefox.Client.Photino.Services;

public class PhotinoFileService : IFileService
{
private readonly NitefoxConfig _nitefoxConfig;

public PhotinoFileService(NitefoxConfig nitefoxConfig)
{
_nitefoxConfig = nitefoxConfig;
SetupDirectories();
}

public async Task<string> OpenFolder()
{
try
{
var path = Program.App.MainWindow.ShowOpenFolder();
return path[0];
}
catch (Exception)
{
return "";
}
}

public bool CreateMediaDirectory(string basePath, string directoryName)
{
var mediaDirectory = $"{basePath}{directoryName}\\";

if (Directory.Exists(mediaDirectory))
{
return true;
}

Directory.CreateDirectory(mediaDirectory);
return Directory.Exists(mediaDirectory);
}

public void SetupDirectories()
{
if (string.IsNullOrWhiteSpace(_nitefoxConfig.DownloadLocation))
{
_nitefoxConfig.DownloadLocation = Environment.CurrentDirectory + "\\songs\\";
}

if (!Directory.Exists(_nitefoxConfig.DownloadLocation))
{
Directory.CreateDirectory(_nitefoxConfig.DownloadLocation);
}

if (string.IsNullOrWhiteSpace(_nitefoxConfig.TempFilesLocation))
{
_nitefoxConfig.TempFilesLocation = Environment.CurrentDirectory + "\\temp\\";
}

if (!Directory.Exists(_nitefoxConfig.TempFilesLocation))
{
Directory.CreateDirectory(_nitefoxConfig.TempFilesLocation);
}

if (string.IsNullOrWhiteSpace(_nitefoxConfig.FfmpegLocation))
{
_nitefoxConfig.FfmpegLocation = Environment.CurrentDirectory + "\\ffmpeg\\";
}

if (!Directory.Exists(_nitefoxConfig.FfmpegLocation))
{
Directory.CreateDirectory(_nitefoxConfig.FfmpegLocation);
}
}
}
Binary file added Nitefox.Client.Photino/nitefox_icon.ico
Binary file not shown.
18 changes: 0 additions & 18 deletions Nitefox.Client.Shared/NitefoxApp.razor.cs

This file was deleted.

0 comments on commit f8790e5

Please sign in to comment.