We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Search 'Taiwan' in 'Country', then play the content in red box.
1766 Radio 百家知識頻道 - 音樂時間
try fix this issue with those code, but missing content in red box.
diff --git a/lib/common/data/mpv_meta_data.dart b/lib/common/data/mpv_meta_data.dart index 0c7bd6b..bd9e597 100644 --- a/lib/common/data/mpv_meta_data.dart +++ b/lib/common/data/mpv_meta_data.dart @@ -66,7 +66,9 @@ class MpvMetaData { icyAudioInfo: map['icy-audio-info'] ?? '', icyPub: map['icy-pub'] ?? '', icyDescription: map['icy-description'] ?? '', - icyTitle: map['icy-title'] ?? '', + icyTitle: map['icy-title'] != null + ? map['icy-title'].parseHtmlEntities() + : '', ); } diff --git a/lib/extensions/string_x.dart b/lib/extensions/string_x.dart index e57c5fc..a09159a 100644 --- a/lib/extensions/string_x.dart +++ b/lib/extensions/string_x.dart @@ -31,6 +31,39 @@ extension StringExtension on String { } } +extension ParseHtmlEntities on String { + String get parseHtmlEntities { + final regex = RegExp(r'&[#\w]+;'); + return replaceAllMapped(regex, (match) { + String entity = match.group(0)!; + return _decodeHtmlEntity(entity); + }); + } + + String _decodeHtmlEntity(String entity) { + const htmlEntities = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + ''': "'", + }; + + if (htmlEntities.containsKey(entity)) { + return htmlEntities[entity]!; + } + + if (entity.startsWith('&#')) { + int? codePoint = int.tryParse(entity.substring(2, entity.length - 1)); + if (codePoint != null) { + return String.fromCharCode(codePoint); + } + } + + return entity; + } +} + extension NullableStringX on String? { Duration? get parsedDuration { final durationAsString = this;
The text was updated successfully, but these errors were encountered:
fix: some title of radio is html format, need to convert to human rea…
b372753
…dable format Fixes #866
4c398e1
…dable format (#870) Fixes #866
Feichtmeier
Successfully merging a pull request may close this issue.
Search 'Taiwan' in 'Country', then play the content in red box.
1766 Radio 百家知識頻道 - 音樂時間
try fix this issue with those code, but missing content in red box.
The text was updated successfully, but these errors were encountered: