ghaiklor / icecast-parser

Node.js module for getting and parsing metadata from SHOUTcast/Icecast radio streams
MIT License
70 stars 18 forks source link

fix for metadata that has ; #167

Closed redimongo closed 3 years ago

redimongo commented 4 years ago

So we ran into a number of issues with songs that have artist names with ; in it.

G-Ezzy;Black eye peas for example

So we have made a change to the icecast-stack.js file. Note that this only looks for 2 ;. we have had songs that have 4 artists and each one is seperated by ;

If the developer could come up with a better solution that would be great, but just wanted to share ours.

Maybe even a for each function could solve this issue.

function parseMetadata(metadata) {
  var rtn = {}, pieces = metadata.toString().replace(nullExp, '').split(";");
  for (var i=0, l=pieces.length; i<l; i++) {
    var piece = pieces[i];
    if (piece.length) {
      console.error(piece);
      piece = piece.split("='");
      if(piece[2]){
      piece[1] = piece[1]+piece[2];
      }
      rtn[piece[0]] = piece[1].slice(0,-1);//.substring(0, piece[1].length-1);
    }
  }
  return rtn;
}
exports.parseMetadata = parseMetadata;
ghaiklor commented 4 years ago

Interesting case, we could try to improve a regular expression for such cases.

ghaiklor commented 4 years ago

@redimongo can you check if issue still persists with master implementation? I've added a test case for semicolons and it passes - https://github.com/ghaiklor/icecast-parser/blob/e83c88244416f33bd5e9b6d57abefedcbcc72f17/test/StreamReader.spec.ts#L41

redimongo commented 4 years ago

I’ll clone our app and update it with the master version.

Sent from my iPhone

On 13 Sep 2020, at 2:05 am, Eugene Obrezkov notifications@github.com wrote:

 @redimongo can you check if issue still persists with master implementation? I've added a test case for semicolons and it passes - https://github.com/ghaiklor/icecast-parser/blob/e83c88244416f33bd5e9b6d57abefedcbcc72f17/test/StreamReader.spec.ts#L41

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

ghaiklor commented 3 years ago

The latest master branch is published in v4.0.1. I could not reproduce the issue with semicolons. Moreover, I have a test case that successfully parses the metadata with semicolons in there.