mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
youtube search is now less official prone
classic genius-lyrics selection improved [android] fixed status white icon in white bg & black icon in dark bg
This commit is contained in:
parent
3b7f7785b6
commit
c0e2a21765
@ -200,6 +200,9 @@ class Home extends HookConsumerWidget {
|
||||
statusBarColor: brightness == Brightness.dark
|
||||
? Colors.blueGrey[900]
|
||||
: Colors.white, // status bar color
|
||||
statusBarIconBrightness: brightness == Brightness.dark
|
||||
? Brightness.light
|
||||
: Brightness.dark,
|
||||
),
|
||||
);
|
||||
return null;
|
||||
|
@ -46,15 +46,32 @@ class PlayerView extends HookConsumerWidget {
|
||||
|
||||
final PaletteColor paletteColor = usePaletteColor(context, albumArt);
|
||||
|
||||
final brightness = Theme.of(context).brightness;
|
||||
|
||||
useEffect(() {
|
||||
SystemChrome.setSystemUIOverlayStyle(
|
||||
SystemUiOverlayStyle(
|
||||
statusBarColor: paletteColor.color, // status bar color
|
||||
),
|
||||
);
|
||||
return null;
|
||||
return;
|
||||
}, [paletteColor.color]);
|
||||
|
||||
useEffect(() {
|
||||
return () {
|
||||
SystemChrome.setSystemUIOverlayStyle(
|
||||
SystemUiOverlayStyle(
|
||||
statusBarColor: brightness == Brightness.dark
|
||||
? Colors.blueGrey[900]
|
||||
: Colors.white, // status bar color
|
||||
statusBarIconBrightness: brightness == Brightness.dark
|
||||
? Brightness.light
|
||||
: Brightness.dark,
|
||||
),
|
||||
);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: const PageWindowTitleBar(
|
||||
|
@ -102,7 +102,8 @@ Future<List?> searchSong(
|
||||
"id": val["result"]["id"],
|
||||
"full_title": val["result"]["full_title"],
|
||||
"albumArt": val["result"]["song_art_image_url"],
|
||||
"url": val["result"]["url"]
|
||||
"url": val["result"]["url"],
|
||||
"author": val["result"]["primary_artist"]["name"],
|
||||
};
|
||||
}).toList();
|
||||
return results;
|
||||
@ -128,23 +129,33 @@ Future<String?> getLyrics(
|
||||
authHeader: authHeader,
|
||||
);
|
||||
if (results == null) return null;
|
||||
final worthyOne = results
|
||||
.map((result) {
|
||||
title = getTitle(
|
||||
title,
|
||||
artists: artists,
|
||||
onlyCleanArtist: true,
|
||||
).trim();
|
||||
final ratedLyrics = results.map((result) {
|
||||
final gTitle = (result["full_title"] as String).toLowerCase();
|
||||
int points = 0;
|
||||
final hasTitle = gTitle.contains(title.toLowerCase());
|
||||
final hasTitle = gTitle.contains(title);
|
||||
final hasAllArtists =
|
||||
artists.every((artist) => gTitle.contains(artist.toLowerCase()));
|
||||
final String lyricAuthor = result["author"].toLowerCase();
|
||||
final fromOriginalAuthor =
|
||||
lyricAuthor.contains(artists.first.toLowerCase());
|
||||
|
||||
for (var criteria in [hasTitle, hasAllArtists]) {
|
||||
for (final criteria in [
|
||||
hasTitle,
|
||||
hasAllArtists,
|
||||
fromOriginalAuthor,
|
||||
]) {
|
||||
if (criteria) points++;
|
||||
}
|
||||
return {"result": result, "points": points};
|
||||
})
|
||||
.sorted(
|
||||
(a, b) => ((b["points"] as int).compareTo(a["points"] as int)),
|
||||
)
|
||||
.first["result"];
|
||||
}).sorted(
|
||||
(a, b) => ((a["points"] as int).compareTo(a["points"] as int)),
|
||||
);
|
||||
final worthyOne = ratedLyrics.first["result"];
|
||||
|
||||
String? lyrics = await extractLyrics(Uri.parse(worthyOne["url"]));
|
||||
return lyrics;
|
||||
|
@ -37,39 +37,36 @@ Future<SpotubeTrack> toSpotubeTrack(
|
||||
// the find should be lazy thus everything case insensitive
|
||||
final ytTitle = video.title.toLowerCase();
|
||||
final bool hasTitle = ytTitle.contains(title);
|
||||
final bool hasYtTitle = title.contains(ytTitle);
|
||||
final bool hasAllArtists = track.artists?.every(
|
||||
(artist) => ytTitle.contains(artist.name!.toLowerCase()),
|
||||
) ??
|
||||
false;
|
||||
final bool authorIsArtist = track.artists?.any((artist) {
|
||||
return artist.name?.toLowerCase() == video.author.toLowerCase();
|
||||
}) ??
|
||||
false;
|
||||
final bool authorIsArtist = track.artists?.first.name?.toLowerCase() ==
|
||||
video.author.toLowerCase();
|
||||
|
||||
final bool hasNoLive = !containsTextInBracket(ytTitle, "live");
|
||||
final bool hasOfficialVideo = [
|
||||
"(official video)",
|
||||
"[official video]",
|
||||
"(official music video)",
|
||||
"[official music video]"
|
||||
].any((v) => ytTitle.contains(v));
|
||||
final bool hasNoLiveInTitle = !containsTextInBracket(ytTitle, "live");
|
||||
|
||||
final bool hasOfficialAudio = [
|
||||
"[official audio]",
|
||||
"(official audio)",
|
||||
].any((v) => ytTitle.contains(v));
|
||||
// final bool hasOfficialVideo = [
|
||||
// "(official video)",
|
||||
// "[official video]",
|
||||
// "(official music video)",
|
||||
// "[official music video]"
|
||||
// ].any((v) => ytTitle.contains(v));
|
||||
|
||||
// final bool hasOfficialAudio = [
|
||||
// "[official audio]",
|
||||
// "(official audio)",
|
||||
// ].any((v) => ytTitle.contains(v));
|
||||
|
||||
int rate = 0;
|
||||
for (final el in [
|
||||
hasTitle,
|
||||
hasYtTitle,
|
||||
hasAllArtists,
|
||||
authorIsArtist,
|
||||
hasNoLive,
|
||||
hasNoLiveInTitle,
|
||||
!video.isLive,
|
||||
hasOfficialAudio,
|
||||
hasOfficialVideo,
|
||||
// hasOfficialVideo,
|
||||
// hasOfficialAudio,
|
||||
]) {
|
||||
if (el) rate++;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user