feat: implemented new API getLyricsBySongId for retrieving (synced) song lyrics based on song ID

This commit is contained in:
CappielloAntonio 2024-02-17 23:43:02 +01:00
parent b9462d7374
commit 54be869081
11 changed files with 197 additions and 0 deletions

View file

@ -0,0 +1,41 @@
package com.cappielloantonio.tempo.util;
import com.cappielloantonio.tempo.subsonic.models.OpenSubsonicExtension;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import java.util.List;
public class OpenSubsonicExtensionsUtil {
private static List<OpenSubsonicExtension> getOpenSubsonicExtensions() {
List<OpenSubsonicExtension> extensions = null;
if (Preferences.isOpenSubsonic() && Preferences.getOpenSubsonicExtensions() != null) {
extensions = new Gson().fromJson(
Preferences.getOpenSubsonicExtensions(),
new TypeToken<List<OpenSubsonicExtension>>() {
}.getType()
);
}
return extensions;
}
private static OpenSubsonicExtension getOpenSubsonicExtension(String extensionName) {
if (getOpenSubsonicExtensions() == null) return null;
return getOpenSubsonicExtensions().stream().filter(openSubsonicExtension -> openSubsonicExtension.getName().equals(extensionName)).findAny().orElse(null);
}
public static boolean isTranscodeOffsetExtensionAvailable() {
return getOpenSubsonicExtension("transcodeOffset") != null;
}
public static boolean isFormPostExtensionAvailable() {
return getOpenSubsonicExtension("formPost") != null;
}
public static boolean isSongLyricsExtensionAvailable() {
return getOpenSubsonicExtension("songLyrics") != null;
}
}