Skip to content

Commit

Permalink
Merge pull request #2 from Eimaen/master
Browse files Browse the repository at this point in the history
Plugin system prototype
  • Loading branch information
AlexanderDotH committed May 5, 2023
2 parents 24a956a + f144bcc commit 5b36a2a
Show file tree
Hide file tree
Showing 198 changed files with 892 additions and 418 deletions.
62 changes: 62 additions & 0 deletions OpenLyricsClient.Plugin/ExamplePlugin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using DevBase.Format.Structure;
using DevBase.Generics;
using OpenLyricsClient.Shared.Plugin;
using OpenLyricsClient.Shared.Structure.Artwork;
using OpenLyricsClient.Shared.Structure.Lyrics;
using OpenLyricsClient.Shared.Structure.Song;

namespace OpenLyricsClient.Plugin
{
public class ExamplePlugin : IPlugin
{
public PluginScope Scope => PluginScope.LyricsCollector;

public Task<Artwork?> CollectArtwork(SongResponseObject songResponseObject)
{
throw new NotImplementedException();
}

public async Task<LyricData?> CollectLyrics(SongResponseObject songResponseObject)
{
AList<LyricElement> lyrics = new AList<LyricElement>();
lyrics.Add(new LyricElement(533, "Here's my line"));
lyrics.Add(new LyricElement(536, "Here's another"));
lyrics.Add(new LyricElement(573, "Here's my line"));
lyrics.Add(new LyricElement(83, "Here's another"));
lyrics.Add(new LyricElement(5563, "Here's my line"));
lyrics.Add(new LyricElement(333, "Here's another"));
lyrics.Add(new LyricElement(43, "Here's another"));
lyrics.Add(new LyricElement(5323, "Here's another"));
lyrics.Add(new LyricElement(6333, "Here's another"));
lyrics.Add(new LyricElement(7453, "Here's another"));
lyrics.Add(new LyricElement(84583, "Here's another"));
lyrics.Add(new LyricElement(45743, "Here's another"));
return await LyricData.ConvertToData(lyrics, songResponseObject.SongRequestObject.Song.SongMetadata, "Plugin");
}

public Task<SongResponseObject?> CollectSong(SongRequestObject songRequestObject)
{
throw new NotImplementedException();
}

public int GetCollectedArtworkQuality()
{
throw new NotImplementedException();
}

public int GetCollectedLyricsQuality()
{
return 1337;
}

public int GetCollectedSongQuality()
{
throw new NotImplementedException();
}

public Task<LyricData> ProcessLyrics(SongResponseObject songResponse, LyricData lyrics)
{
throw new NotImplementedException();
}
}
}
13 changes: 13 additions & 0 deletions OpenLyricsClient.Plugin/OpenLyricsClient.Plugin.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

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

</Project>
27 changes: 27 additions & 0 deletions OpenLyricsClient.Shared/OpenLyricsClient.Shared.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.19" />
<PackageReference Include="Avalonia.X11" Version="0.10.19" />
<PackageReference Include="DevBase" Version="1.1.1" />
<PackageReference Include="DevBase.Api" Version="1.1.5" />
<PackageReference Include="DevBase.Avalonia" Version="1.0.1" />
<PackageReference Include="DevBase.Format" Version="1.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="SpotifyAPI.Web" Version="7.0.0" />
<PackageReference Include="Squalr.Engine" Version="2.3.0.1" />
</ItemGroup>

<ItemGroup>
<Reference Include="XWindowManager">
<HintPath>..\Libraries\XWindowManager.dll</HintPath>
</Reference>
</ItemGroup>

</Project>
22 changes: 22 additions & 0 deletions OpenLyricsClient.Shared/Plugin/IPlugin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using OpenLyricsClient.Shared.Structure.Lyrics;
using OpenLyricsClient.Shared.Structure.Song;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OpenLyricsClient.Shared.Plugin
{
public interface IPlugin
{
PluginScope Scope { get; }
Task<LyricData> ProcessLyrics(SongResponseObject songResponse, LyricData lyrics);
Task<LyricData?> CollectLyrics(SongResponseObject songResponseObject);
int GetCollectedLyricsQuality();
Task<SongResponseObject?> CollectSong(SongRequestObject songRequestObject);
int GetCollectedSongQuality();
Task<Structure.Artwork.Artwork?> CollectArtwork(SongResponseObject songResponseObject);
int GetCollectedArtworkQuality();
}
}
15 changes: 15 additions & 0 deletions OpenLyricsClient.Shared/Plugin/PluginScope.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;

namespace OpenLyricsClient.Shared.Plugin
{
[Flags]
public enum PluginScope
{
Dummy = 1,
LyricsPostprocess = 2,
LyricsViewRendering = 4,
LyricsCollector = 8,
SongCollector = 16,
ArtworkCollector = 32
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
using Bitmap = Avalonia.Media.Imaging.Bitmap;
using Color = Avalonia.Media.Color;

namespace OpenLyricsClient.Backend.Structure.Artwork
namespace OpenLyricsClient.Shared.Structure.Artwork
{
[Serializable]
public class Artwork
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace OpenLyricsClient.Backend.Structure.Artwork
namespace OpenLyricsClient.Shared.Structure.Artwork
{
public enum ArtworkReturnCode
{
Expand Down
6 changes: 6 additions & 0 deletions OpenLyricsClient.Shared/Structure/Enum/DataOrigin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace OpenLyricsClient.Shared.Structure.Enum;

public enum DataOrigin
{
SPOTIFY, TIDAL
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace OpenLyricsClient.Backend.Structure.Enum;
namespace OpenLyricsClient.Shared.Structure.Enum;

public enum EnumLyricsDisplayMode
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace OpenLyricsClient.Backend.Structure.Enum;
namespace OpenLyricsClient.Shared.Structure.Enum;

public enum EnumPlayback
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace OpenLyricsClient.Backend.Structure.Enum
namespace OpenLyricsClient.Shared.Structure.Enum
{
public enum EnumRegisterTypes
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Avalonia.Media;
using Newtonsoft.Json;

namespace OpenLyricsClient.Backend.Structure.Json;
namespace OpenLyricsClient.Shared.Structure.Json;

public class JsonArtwork
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Newtonsoft.Json;

namespace OpenLyricsClient.Backend.Structure.Json;
namespace OpenLyricsClient.Shared.Structure.Json;

public class JsonCacheData
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Newtonsoft.Json;
using OpenLyricsClient.Backend.Structure.Lyrics;
using OpenLyricsClient.Shared.Structure.Lyrics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OpenLyricsClient.Backend.Structure.Json
namespace OpenLyricsClient.Shared.Structure.Json
{
public class JsonLyricData
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Newtonsoft.Json;

namespace OpenLyricsClient.Backend.Structure.Json;
namespace OpenLyricsClient.Shared.Structure.Json;

public class JsonSongMetadata
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

using Newtonsoft.Json;
using OpenLyricsClient.Backend.Structure.Song;
using OpenLyricsClient.Shared.Structure.Song;

namespace OpenLyricsClient.Backend.Structure.Json;
namespace OpenLyricsClient.Shared.Structure.Json;

public class JsonSongState
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Newtonsoft.Json;

namespace OpenLyricsClient.Backend.Structure.Json.Musixmatch.Json
namespace OpenLyricsClient.Shared.Structure.Json.Musixmatch.Json
{
public class MusixMatchAryGenres
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Newtonsoft.Json;

namespace OpenLyricsClient.Backend.Structure.Json.Musixmatch.Json
namespace OpenLyricsClient.Shared.Structure.Json.Musixmatch.Json
{
public class MusixMatchFetchResponse
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Newtonsoft.Json;

namespace OpenLyricsClient.Backend.Structure.Json.Musixmatch.Json
namespace OpenLyricsClient.Shared.Structure.Json.Musixmatch.Json
{
public class MusixMatchFetchResponseMessage
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Newtonsoft.Json;

namespace OpenLyricsClient.Backend.Structure.Json.Musixmatch.Json
namespace OpenLyricsClient.Shared.Structure.Json.Musixmatch.Json
{
public class MusixMatchFetchResponseMessageBody
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Newtonsoft.Json;

namespace OpenLyricsClient.Backend.Structure.Json.Musixmatch.Json
namespace OpenLyricsClient.Shared.Structure.Json.Musixmatch.Json
{
public class MusixMatchFetchResponseMessageHeader
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using Newtonsoft.Json;

namespace OpenLyricsClient.Backend.Structure.Json.Musixmatch.Json
namespace OpenLyricsClient.Shared.Structure.Json.Musixmatch.Json
{
public class MusixMatchLyrics
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Newtonsoft.Json;

namespace OpenLyricsClient.Backend.Structure.Json.Musixmatch.Json
namespace OpenLyricsClient.Shared.Structure.Json.Musixmatch.Json
{
public class MusixMatchMacroCalls
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Newtonsoft.Json;

namespace OpenLyricsClient.Backend.Structure.Json.Musixmatch.Json
namespace OpenLyricsClient.Shared.Structure.Json.Musixmatch.Json
{
public class MusixMatchMatcherTrackGet
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Newtonsoft.Json;

namespace OpenLyricsClient.Backend.Structure.Json.Musixmatch.Json
namespace OpenLyricsClient.Shared.Structure.Json.Musixmatch.Json
{
public class MusixMatchMatcherTrackGetMessage
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Newtonsoft.Json;

namespace OpenLyricsClient.Backend.Structure.Json.Musixmatch.Json
namespace OpenLyricsClient.Shared.Structure.Json.Musixmatch.Json
{
public class MusicMatchMatcherTrackGetMessageBody
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Newtonsoft.Json;

namespace OpenLyricsClient.Backend.Structure.Json.Musixmatch.Json
namespace OpenLyricsClient.Shared.Structure.Json.Musixmatch.Json
{
public class MusixMatchMatcherTrackGetMessageHeader
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using Newtonsoft.Json;

namespace OpenLyricsClient.Backend.Structure.Json.Musixmatch.Json
namespace OpenLyricsClient.Shared.Structure.Json.Musixmatch.Json
{
public class MusixMatchMeta
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Newtonsoft.Json;

namespace OpenLyricsClient.Backend.Structure.Json.Musixmatch.Json
namespace OpenLyricsClient.Shared.Structure.Json.Musixmatch.Json
{
public class MusixMatchMusicGenre
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Newtonsoft.Json;

namespace OpenLyricsClient.Backend.Structure.Json.Musixmatch.Json
namespace OpenLyricsClient.Shared.Structure.Json.Musixmatch.Json
{
public class MusixMatchMusicGenreList
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using Newtonsoft.Json;

namespace OpenLyricsClient.Backend.Structure.Json.Musixmatch.Json
namespace OpenLyricsClient.Shared.Structure.Json.Musixmatch.Json
{
public class MusixMatchSnippet
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using Newtonsoft.Json;

namespace OpenLyricsClient.Backend.Structure.Json.Musixmatch.Json
namespace OpenLyricsClient.Shared.Structure.Json.Musixmatch.Json
{
public class MusixMatchSubtitle
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Newtonsoft.Json;

namespace OpenLyricsClient.Backend.Structure.Json.Musixmatch.Json
namespace OpenLyricsClient.Shared.Structure.Json.Musixmatch.Json
{
public class MusixMatchSubtitleList
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using Newtonsoft.Json;

namespace OpenLyricsClient.Backend.Structure.Json.Musixmatch.Json
namespace OpenLyricsClient.Shared.Structure.Json.Musixmatch.Json
{
public class MusixMatchTrack
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Newtonsoft.Json;

namespace OpenLyricsClient.Backend.Structure.Json.Musixmatch.Json
namespace OpenLyricsClient.Shared.Structure.Json.Musixmatch.Json
{
public class MusixMatchTrackLyricsGet
{
Expand Down
Loading

0 comments on commit 5b36a2a

Please sign in to comment.