Skip to content

Commit

Permalink
fix: lyrics decoding for non-latin chars
Browse files Browse the repository at this point in the history
ref #188
  • Loading branch information
MSOB7YY committed May 13, 2024
1 parent 931c82d commit 47c2351
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions lib/controller/lyrics_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -210,17 +210,18 @@ class Lyrics {
try {
final req = await http.get(url);
final fetched = <LyricsModel>[];
final jsonLists = (jsonDecode(req.body) as List<dynamic>?) ?? [];
final jsonLists = (jsonDecode(utf8.decode(req.bodyBytes)) as List<dynamic>?) ?? [];
for (final jsonRes in jsonLists) {
final syncedLyrics = jsonRes?["syncedLyrics"] as String? ?? '';
final plain = jsonRes?["plainLyrics"] as String? ?? '';
if (syncedLyrics != '') {
// lrc
final lines = <String>[];
if (artist != '') lines.add('[ar:$artist]');
if (album != '') lines.add('[al:$album]');
if (title != '') lines.add('[ti:$title]');
if (durationInSeconds > 0) lines.add('[length:${formatTime(durationInSeconds)}]');
if (artist != '') lines.add('[ar:${jsonRes['artistName'] ?? artist}]');
if (album != '') lines.add('[al:${jsonRes['albumName'] ?? album}]');
if (title != '') lines.add('[ti:${jsonRes['trackName'] ?? title}]');
final dur = (jsonRes['duration'] as num?)?.toInt() ?? durationInSeconds;
if (dur > 0) lines.add('[length:${formatTime(dur)}]');
for (final l in syncedLyrics.split('\n')) {
lines.add(l);
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: namida
description: A Beautiful and Feature-rich Music Player, With YouTube & Video Support Built in Flutter
publish_to: "none"
version: 2.3.0-beta+240513132
version: 2.3.1-beta+240513133

environment:
sdk: ">=3.1.4 <4.0.0"
Expand Down

0 comments on commit 47c2351

Please sign in to comment.