Skip to content

Commit

Permalink
Merge pull request #969 from philippe44/ogg-metadata
Browse files Browse the repository at this point in the history
add utf-8 guess decoding on Ogg metadata
  • Loading branch information
mherger committed Dec 31, 2023
2 parents 75674a4 + 1dc3ddd commit 24dd9cf
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Slim/Player/Protocols/HTTP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -354,25 +354,26 @@ sub parseMetadata {
# 2-byte length/string pairs.
elsif ( $metadata =~ /^Ogg(.+)/s ) {
my $comments = $1;

# Bug 15896, a stream had CRLF in the metadata (no conflict with utf-8)
$comments =~ s/\s*[\r\n]+\s*/; /g;

my $meta = {};
while ( $comments ) {
my $length = unpack 'n', substr( $comments, 0, 2, '' );
my $value = substr $comments, 0, $length, '';

main::DEBUGLOG && $directlog->is_debug && $directlog->debug("Ogg comment: $value");

# Bug 15896, a stream had CRLF in the metadata
$metadata =~ s/\s*[\r\n]+\s*/; /g;

# Look for artist/title/album
if ( $value =~ /ARTIST=(.+)/i ) {
$meta->{artist} = $1;
$meta->{artist} = Slim::Utils::Unicode::utf8decode_guess($1);
}
elsif ( $value =~ /ALBUM=(.+)/i ) {
$meta->{album} = $1;
$meta->{album} = Slim::Utils::Unicode::utf8decode_guess($1);
}
elsif ( $value =~ /TITLE=(.+)/i ) {
$meta->{title} = $1;
$meta->{title} = Slim::Utils::Unicode::utf8decode_guess($1);
}
}

Expand Down

0 comments on commit 24dd9cf

Please sign in to comment.