mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-12-13 02:17:30 +00:00
Added method to fetch unsynced lyrics from azlyrics as a fallback.
Spotify lyrics for many songs are not available for non-premium users. Now, it will fetch unsynced lyrics from Azlyrics as a fallback.
This commit is contained in:
parent
f5438cf04a
commit
9259e61367
@ -32,10 +32,12 @@ class PlainLyrics extends HookConsumerWidget {
|
|||||||
final playlist = ref.watch(ProxyPlaylistNotifier.provider);
|
final playlist = ref.watch(ProxyPlaylistNotifier.provider);
|
||||||
final lyricsQuery =
|
final lyricsQuery =
|
||||||
useQueries.lyrics.spotifySynced(ref, playlist.activeTrack);
|
useQueries.lyrics.spotifySynced(ref, playlist.activeTrack);
|
||||||
|
final azLyricsQuery = useQueries.lyrics.azLyrics(playlist.activeTrack);
|
||||||
final mediaQuery = MediaQuery.of(context);
|
final mediaQuery = MediaQuery.of(context);
|
||||||
final textTheme = Theme.of(context).textTheme;
|
final textTheme = Theme.of(context).textTheme;
|
||||||
|
|
||||||
final textZoomLevel = useState<int>(defaultTextZoom);
|
final textZoomLevel = useState<int>(defaultTextZoom);
|
||||||
|
bool useAZLyrics = false;
|
||||||
|
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
@ -75,38 +77,46 @@ class PlainLyrics extends HookConsumerWidget {
|
|||||||
if (lyricsQuery.isLoading || lyricsQuery.isRefreshing) {
|
if (lyricsQuery.isLoading || lyricsQuery.isRefreshing) {
|
||||||
return const ShimmerLyrics();
|
return const ShimmerLyrics();
|
||||||
} else if (lyricsQuery.hasError) {
|
} else if (lyricsQuery.hasError) {
|
||||||
return Container(
|
if (azLyricsQuery.isLoading ||
|
||||||
alignment: Alignment.center,
|
azLyricsQuery.isRefreshing) {
|
||||||
padding: const EdgeInsets.all(16),
|
return const ShimmerLyrics();
|
||||||
child: Column(
|
} else if (azLyricsQuery.hasError) {
|
||||||
mainAxisSize: MainAxisSize.min,
|
return Container(
|
||||||
children: [
|
alignment: Alignment.center,
|
||||||
Text(
|
padding: const EdgeInsets.all(16),
|
||||||
context.l10n.no_lyrics_available,
|
child: Column(
|
||||||
style: textTheme.bodyLarge?.copyWith(
|
mainAxisSize: MainAxisSize.min,
|
||||||
color: palette.bodyTextColor,
|
children: [
|
||||||
|
Text(
|
||||||
|
context.l10n.no_lyrics_available,
|
||||||
|
style: textTheme.bodyLarge?.copyWith(
|
||||||
|
color: palette.bodyTextColor,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
textAlign: TextAlign.center,
|
const Gap(26),
|
||||||
),
|
const Icon(SpotubeIcons.noLyrics, size: 60),
|
||||||
const Gap(26),
|
],
|
||||||
const Icon(SpotubeIcons.noLyrics, size: 60),
|
),
|
||||||
],
|
);
|
||||||
),
|
} else {
|
||||||
);
|
useAZLyrics = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final lyrics =
|
final lyrics = !useAZLyrics
|
||||||
lyricsQuery.data?.lyrics.mapIndexed((i, e) {
|
? lyricsQuery.data?.lyrics.mapIndexed((i, e) {
|
||||||
final next =
|
final next = lyricsQuery.data?.lyrics
|
||||||
lyricsQuery.data?.lyrics.elementAtOrNull(i + 1);
|
.elementAtOrNull(i + 1);
|
||||||
if (next != null &&
|
if (next != null &&
|
||||||
e.time - next.time >
|
e.time - next.time >
|
||||||
const Duration(milliseconds: 700)) {
|
const Duration(milliseconds: 700)) {
|
||||||
return "${e.text}\n";
|
return "${e.text}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
return e.text;
|
return e.text;
|
||||||
}).join("\n");
|
}).join("\n")
|
||||||
|
: azLyricsQuery.data;
|
||||||
|
|
||||||
return AnimatedDefaultTextStyle(
|
return AnimatedDefaultTextStyle(
|
||||||
duration: const Duration(milliseconds: 200),
|
duration: const Duration(milliseconds: 200),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user