File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ internal struct FRadioAPI {
6262 // Strip off trailing '[???]' characters left there by ShoutCast and Centova Streams
6363 // It will leave the string alone if the pattern is not there
6464
65- let pattern = " ( \\ [.*? \\ ] \\ w*$) "
65+ let pattern = # "(\(.*?\)\w*)|(\ [.*?\]\w*)"#
6666 guard let regex = try ? NSRegularExpression ( pattern: pattern, options: [ ] ) else { return rawValue }
6767
6868 let rawCleaned = NSMutableString ( string: rawValue)
Original file line number Diff line number Diff line change @@ -399,7 +399,8 @@ open class FRadioPlayer: NSObject {
399399 }
400400
401401 private func timedMetadataDidChange( rawValue: String ? ) {
402- let parts = rawValue? . components ( separatedBy: " - " )
402+ let metadataCleaned = cleanMetadata ( rawValue)
403+ let parts = metadataCleaned? . components ( separatedBy: " - " )
403404 delegate? . radioPlayer ? ( self , metadataDidChange: parts? . first, trackName: parts? . last)
404405 delegate? . radioPlayer ? ( self , metadataDidChange: rawValue)
405406 shouldGetArtwork ( for: rawValue, enableArtwork)
@@ -418,7 +419,16 @@ open class FRadioPlayer: NSObject {
418419 }
419420 } )
420421 }
421-
422+
423+ private func cleanMetadata( _ rawValue: String ? ) -> String ? {
424+ guard let rawValue = rawValue else { return nil }
425+ return rawValue. replacingOccurrences (
426+ of: #"(\(.*?\)\w*)|(\[.*?\]\w*)"# ,
427+ with: " " ,
428+ options: . regularExpression
429+ )
430+ }
431+
422432 private func reloadItem( ) {
423433 player? . replaceCurrentItem ( with: nil )
424434 player? . replaceCurrentItem ( with: playerItem)
You can’t perform that action at this time.
0 commit comments