Skip to content

Commit

Permalink
various bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Eimaen committed May 5, 2023
1 parent b61ac3d commit f144bcc
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 16 deletions.
23 changes: 17 additions & 6 deletions OpenLyricsClient.Plugin/ExamplePlugin.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using OpenLyricsClient.Shared.Plugin;
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;
Expand All @@ -16,11 +18,20 @@ public class ExamplePlugin : IPlugin

public async Task<LyricData?> CollectLyrics(SongResponseObject songResponseObject)
{
return new LyricData()
{
LyricParts = new LyricPart[] { new LyricPart(0, "PLUGINS ARE COMING") },
LyricReturnCode = LyricReturnCode.SUCCESS
};
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using DevBase.Generics;
using OpenLyricsClient.Backend.Collector.Artwork.Providers.Deezer;
using OpenLyricsClient.Backend.Collector.Artwork.Providers.Musixmatch;
using OpenLyricsClient.Backend.Collector.Artwork.Providers.Plugin;
using OpenLyricsClient.Backend.Collector.Artwork.Providers.Spotify;
using OpenLyricsClient.Backend.Debugger;
using OpenLyricsClient.Backend.Events.EventArgs;
Expand All @@ -29,6 +30,7 @@ public ArtworkCollector()
this._artworkCollectors.Add(new SpotifyCollector());
this._artworkCollectors.Add(new DeezerCollector());
//this._artworkCollectors.Add(new MusixMatchCollector());
this._artworkCollectors.Add(new PluginArtworkCollector());
}

public async Task CollectArtwork(SongResponseObject songResponseObject)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ public int Quality()
IPlugin? plugin = Core.INSTANCE.PluginManager.GetPluginsByScope(PluginScope.ArtworkCollector).MaxBy((IPlugin plugin) => plugin.GetCollectedArtworkQuality());
if (plugin == null)
return -1;
else
return plugin.GetCollectedArtworkQuality();
return plugin.GetCollectedArtworkQuality();
}
}
}
4 changes: 2 additions & 2 deletions OpenLyricsClient/Backend/Collector/Lyrics/LyricCollector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ class LyricCollector
public LyricCollector()
{
this._lyricCollectors = new AList<ILyricsCollector>();

this._lyricCollectors.Add(new MusixmatchCollector());
this._lyricCollectors.Add(new DeezerCollector());
this._lyricCollectors.Add(new NetEaseCollector());
this._lyricCollectors.Add(new NetEaseV2Collector());
this._lyricCollectors.Add(new TextylCollector());
this._lyricCollectors.Add(new PluginLyricsCollector()); // i think OLC is always a fallback option that always works, so put it here
this._lyricCollectors.Add(new OpenLyricsClientCollector());
this._lyricCollectors.Add(new PluginLyricsCollector());
}

public async Task CollectLyrics(SongResponseObject songResponseObject)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using OpenLyricsClient.Shared.Plugin;
using OpenLyricsClient.Shared.Structure.Lyrics;
using OpenLyricsClient.Shared.Structure.Song;
using System;
using System.Linq;
using System.Threading.Tasks;

Expand Down Expand Up @@ -33,8 +34,7 @@ public int ProviderQuality()
IPlugin? plugin = Core.INSTANCE.PluginManager.GetPluginsByScope(PluginScope.LyricsCollector).MaxBy((IPlugin plugin) => plugin.GetCollectedLyricsQuality());
if (plugin == null)
return -1;
else
return plugin.GetCollectedLyricsQuality();
return plugin.GetCollectedLyricsQuality();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using OpenLyricsClient.Shared.Plugin;
using OpenLyricsClient.Shared.Structure.Song;
using Org.BouncyCastle.Utilities;
using System.Linq;
using System.Threading.Tasks;

Expand All @@ -14,11 +15,11 @@ public string CollectorName()

async public Task<SongResponseObject> GetSong(SongRequestObject songRequestObject)
{
SongResponseObject collectedData = new SongResponseObject();
SongResponseObject collectedData = null;
foreach (IPlugin plugin in Core.INSTANCE.PluginManager.GetPluginsByScope(PluginScope.SongCollector).OrderByDescending((IPlugin plugin) => plugin.GetCollectedSongQuality()))
{
SongResponseObject? data = await plugin.CollectSong(songRequestObject);
if (data != null && data != collectedData)
if (data != null)
{
collectedData = data;
break;
Expand All @@ -32,8 +33,7 @@ public int ProviderQuality()
IPlugin? plugin = Core.INSTANCE.PluginManager.GetPluginsByScope(PluginScope.SongCollector).MaxBy((IPlugin plugin) => plugin.GetCollectedSongQuality());
if (plugin == null)
return -1;
else
return plugin.GetCollectedSongQuality();
return plugin.GetCollectedSongQuality();
}
}
}
2 changes: 2 additions & 0 deletions OpenLyricsClient/Backend/Collector/Song/SongCollector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using OpenLyricsClient.Backend.Collector.Song.Providers.Musixmatch;
using OpenLyricsClient.Backend.Collector.Song.Providers.NetEase;
using OpenLyricsClient.Backend.Collector.Song.Providers.NetEaseV2;
using OpenLyricsClient.Backend.Collector.Song.Providers.Plugin;
using OpenLyricsClient.Backend.Collector.Song.Providers.Spotify;
using OpenLyricsClient.Backend.Events;
using OpenLyricsClient.Backend.Events.EventArgs;
Expand Down Expand Up @@ -35,6 +36,7 @@ public SongCollector(SongHandler songHandler, LyricHandler lyricHandler, Artwork
this._songCollectors.Add(new NetEaseV2Collector());*/
this._songCollectors.Add(new DeezerSongCollector());
this._songCollectors.Add(new SpotifyCollector());
this._songCollectors.Add(new PluginSongCollector());

this._songResponses = new ATupleList<SongRequestObject, SongResponseObject>();

Expand Down

0 comments on commit f144bcc

Please sign in to comment.