Giter VIP home page Giter VIP logo

icecast-parser's Introduction

SWUbanner

icecast-parser's People

Contributors

alexandertirik avatar dependabot[bot] avatar ghaiklor avatar greenkeeper[bot] avatar greenkeeperio-bot avatar kostia1359 avatar pellicceama avatar xgustavoh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

icecast-parser's Issues

[HELP] - Already having icecast running to suck out trackname from Traktor DJ Software

Describe the bug
Hello Bro,

this is not a Bug directly, I try to use your approach for taking out the tracknames from traktor dj software and put them into Butt Streaming software.

You might ask why all of this headache? Traktor likes only icecast, the Software Butt likes only shoutcast, so a lot of people in the community are trying and nobody has really a nice answer and from my side I would just like to help here.

I use the approach of having one laptop with dj software to put the sound to another soundcard, from whereout I broadcast with Butt on a second system. So just imagine, one source has another ip in the network, than the other.

To Reproduce
Steps to reproduce the behavior: Please see the link below, the step with liquidsoap is not needed for the approach, as your parser is supposed to take over this role

1. Please see Link here

  • you have traktor running for example in auto dj mode, so it will play from a list
  • you have traktor configured like described in article
  • you have traktor running in broadcast mode, which works only icecast is running as server to take over info, where antenna button is cyan all time NOT BLINKING, NOT BLACK

I use just icecast, see install and the config below

brew install icecast
icecast -c ./icecast.xml
<!-- Sets up an icecast mount point on your own machine -->
<icecast>
    <limits>
        <sources>2</sources>
    </limits>
    <authentication>
        <source-password>hackme</source-password>
        <relay-password>hackme</relay-password>
        <admin-user>admin</admin-user>
        <admin-password>hackme</admin-password>
    </authentication>

    <mount>
        <mount-name>/traktor.ogg</mount-name>
    </mount>

    <hostname>localhost</hostname>
    <location>earth</location>
    <fileserve>1</fileserve>

    <listen-socket>
        <port>8000</port>
    </listen-socket>
    <fileserve>1</fileserve>
    <paths>
        <logdir>./logs</logdir>
        <webroot>./web</webroot>
        <adminroot>./admin</adminroot>
        <alias source="/" dest="/status.xsl"/>
    </paths>
    <logging>
        <accesslog>access.log</accesslog>
        <errorlog>error.log</errorlog>
        <playlistlog>playlist.log</playlistlog>
        <loglevel>4</loglevel>        <!-- 4 Debug, 3 Info, 2 Warn, 1 Error -->
    </logging>
</icecast>

Expected behavior
I would like to get exact trackinfo similar to your given example.

Additional context
if you see playlist log I already noticed, I coud take away the live track info with a simple tail -f, so very similar to this, I would like to just get meta info from the traktor stream.

tail -f playlist.log
```

Does it make sense to have the header for meta info aswell configurable, as I have seen it is always set to 1?

notifyOnChangeOnly ignore UTC data

When using notifyOnChangeOnly: true, if the stream passes UTC data, the metadata event is triggered due to the change in time between requests causing a false update which essensially ignores the notifyOnChangeOnly option.

Would it be possible/resonable to make it so that the UTC data does not trigger the metadata event?

Or preferably change the functionality to be able to add a list of metadata to cause the update such as notifyOnChangeOnly: ['StreamTitle'] - This example only triggering the event when there is a change in the stream title.

Stop cast

I would like to stop streaming the audio and start listening to another radio station.

What I've tried so far: stream.unpipe();

Not sure whether this all that needs to be done to gracefully stop Parser without creating memory leaks before creating a new instance of Parser

Port to TypeScript

Because of (possibly) increasing complexity in how radio stations will be parsed, we need to port it to TypeScript before and make sure that tests coverage are good.

Question marks instead of some characters

Describe the bug
A clear and concise description of what the bug is.
I have a track which has "Tiësto" as an artist tag. But after metadata.get('StreamTitle') i see "Ti�sto".
If i see info of this track the name is correct; if i just try to output it in the console or on the website - everything works fine until metadata.get. I already tried change encoding to utf8 for string or set header - no luck.

To Reproduce
Steps to reproduce the behavior:

  1. just have a track with weird characters in tags

Expected behavior
A clear and concise description of what you expected to happen.
I should see "Tiësto" as a result of metadata.get('StreamTitle').

Additional context
Add any other context about the problem here.

const icecast = require('icecast-parser')
...
app.post('/ajax/meta', (req, res)=>{
	const radio = new icecast.Parser({
		url: req.body.url,
		autoUpdate: false,
	})
	radio.on('error', function(err){
		res.jsonp({status: false, errcode: err.code})
	})
	radio.on('metadata', (metadata) => {
		let meta = metadata.get('StreamTitle') // already "Ti�sto"
		res.jsonp({status: true, title: meta})
	})
})

Is it possible to use it in browser?

Hello,
I want to read icecast metadata in client-side application.
If it's possible, tell me please how can I use your library in browser.
Thanks!

fix for metadata that has ;

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;

Error

When trying to parse the metadata i get error inside console
Uncaught TypeError: Class extends value undefined is not a constructor or null at node_modules/icecast-parser/dist/StreamReader.js (icecast-parser.js?v=e2d0f265:452:47) at __require (chunk-TYRVL62N.js?v=e2d0f265:5:50) at node_modules/icecast-parser/dist/Parser.js (icecast-parser.js?v=e2d0f265:532:26) at __require (chunk-TYRVL62N.js?v=e2d0f265:5:50) at icecast-parser.js?v=e2d0f265:617:16

The title of stream keeps appearing on the console, but other functions stops from working.
What could be the issue?

Unexpected Token "."

Describe the bug
Crashing on startup

To Reproduce
Steps to reproduce the behavior:

  1. Use the parse onces

Expected behavior
That it would work

Additional context

https://prnt.sc/uzj85b

Code:

    const readiostream = new reader.Parser({
        url: 'http://stream.animeradio.de/animeradio.ogg',
        autoUpdate: true,
        keepListen: true
    })
    readiostream.on('metadata', (metadata) => {
        console.log(metadata)
    })

webhook feature

A feature request: would it possible to add a webhook as output? (to use with discord)

Stream timeout

My application listens for ~30 radio streams and the goal is to run the application for weeks.

Sadly, some streams stops after some time.

For example:
http://84.46.162.57:8000/ehr (stops after 12 hours, other streams seems to be stoping at random intervals)

I didn't get any error event and it does not auto refresh with errorInterval... I was also using another library and had exactly the same issue.

const stream = new Parser({ url: 'http://84.46.162.57:8000/ehr', keepListen: true, metadataInterval: 1 });

My initial thought is to catch more events such as timeout/finish/close...?

StreamReader.js .matchAll(...) error (Crashes app)

/home/adstichrplayer/node_modules/icecast-parser/src/StreamReader.js:51
  const parts = [...data.replace(/\0*$/, '').matchAll(METADATA_REGEX)];
                                             ^

TypeError: data.replace(...).matchAll(...) is not a function or its return value is not iterable

I am wondering if something is not right here?

/home/adstichrplayer/node_modules/icecast-parser/src/StreamReader.js:51
const parts = [...data.replace(/\0*$/, '').matchAll(METADATA_REGEX)];
^


TypeError: data.replace(...).matchAll(...) is not a function or its return value is not iterable
    at _parseMetadata (/home/adstichrplayer/node_modules/icecast-parser/src/StreamReader.js:51:46)
    at StreamReader._onMetaData (/home/adstichrplayer/node_modules/icecast-parser/src/StreamReader.js:232:27)
    at _processData (/home/adstichrplayer/node_modules/icecast-parser/src/StreamReader.js:102:8)
    at /home/adstichrplayer/node_modules/icecast-parser/src/StreamReader.js:123:14
    at /home/adstichrplayer/node_modules/icecast-parser/src/StreamReader.js:65:51
    at /home/adstichrplayer/node_modules/icecast-parser/src/StreamReader.js:126:24
    at /home/adstichrplayer/node_modules/icecast-parser/src/StreamReader.js:65:51
    at /home/adstichrplayer/node_modules/icecast-parser/src/StreamReader.js:126:24
    at /home/adstichrplayer/node_modules/icecast-parser/src/StreamReader.js:65:51
    at StreamReader._transform (/home/adstichrplayer/node_modules/icecast-parser/src/StreamReader.js:200:5)
    at StreamReader.Transform._read (_stream_transform.js:190:10)
    at StreamReader.Transform._write (_stream_transform.js:178:12)
    at doWrite (_stream_writable.js:415:12)
    at writeOrBuffer (_stream_writable.js:399:5)
    at StreamReader.Writable.write (_stream_writable.js:299:11)
    at IncomingMessage.ondata (_stream_readable.js:710:20)

Unable to parse Radio Paradise stream

This code fragment does not work:

const Parser = require('icecast-parser');
const radioStation = new Parser('http://stream-dc1.radioparadise.com:80/ogg-96m');

radioStation.on('metadata', function(metadata) {
    console.log([metadata.StreamTitle, 'is playing on', this.getConfig('url')].join(' '));
});

But inside the stream I do see:

server=Icecast 2.4.0-kh13

I was just wondering if this was supposed to work?

Error when module load

Hi,

I have the error below when module load:
node_modules/icecast-parser/lib/index.js:31
f (typeof superClass !== "function" && superClass !== null) { throw new TypeEr
^
TypeError: Super expression must either be null or a function, not object

This error occured when I uncomment this line:
var icecast_parser = require('icecast-parser');

Do you know how can I solve this error ?

Best regards

Tests are failing

Just cloned the repo and ran tests and I got error without any modifications:
$ istanbul cover mocha
5 -
---,------,
1 -
---| /_/\
0 -
---^|__( x .x)
---_- "" ""

5 passing (10s)
1 failing

  1. RadioParser
    Should properly emit metadata from Icecast:
    Error: Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

the culprit seems to be that the url in the tests http://online-kissfm.tavrmedia.ua/KissFM_deep it's returning 404 - The file you requested could not be found

Icecast-parser fails to run out-of-the-box tsc and node

Describe the bug
A clear and concise description of what the bug is.
The icecast-parser-master I downloaded yestereday Nov 28, 2020 onto my workspace with node and typscript already glabally installed fails to run the 'simple' testcase right out of the box. A couple issues were detected right away before starting -- no presence of ;s or mjs files in this zipped package -- all ts files even though the Github summary sayss it is anodejs package.
Secondly, I used tsc to compile the simle.ts file after entering my radiostation url failed with basic un-runnable issues such as the import Parser from '..'; -- this doesn't compile as directories are not allowed, so modifiying this to import Parser from '../src/Parser'; at least got further in tsc compile with these error messages:

$ tsc simple.ts
../src/Parser.ts(3,9): error TS1192: Module '"http"' has no default export.
../src/Parser.ts(4,9): error TS1192: Module '"https"' has no default export.
../src/Parser.ts(118,32): error TS2569: Type 'IterableIterator<[string, string]>' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators.
../src/StreamReader.ts(18,47): error TS2550: Property 'matchAll' does not exist on type 'string'. Do you need to change your target library? Try changing the lib compiler option to 'es2020' or later.

I went ahead and added es2020 into the lib for the tsconfig.json did improve 'string' issues, but resulted in the a above errors.

I've tested an older version of this package some 7 months ago and that package same name almost runs right out of the box. in that version you used 'const Parser = require(); I was able to get that version of events.js and simple.js to run after taking about 1/2 to debug and fix.

Unlike the previous version, I cannot get this package to run the examples.

What would be helpful, is to list dependencies, procide documentation and assumptions expected in order to run the examples right out of the box.

I understand this is an Icy only parser, however, I've used the older package to capture streaming ID3V2 metadata with ID3V2-parser integrated in the stream event option. I'd like to see if I can get this to work here too.

I am hoping thise version has the capability to report streamingTitle and othere data when songs change on the sreaming shoutcast station I am using for testing/.

To Reproduce
Steps to reproduce the behavior:
I am not sure this and below fline items is helpful because of the first step failure and no documentation in the readme on what assumptions and dependencies. I've ran many other Gitub packages which for the most part worked out of the box. So, I would not call myself a newbie, but I am not an expert either...

  1. tsc simple.ts
  2. Fails on import dir path not allowed
  3. changed import Parser frum '..'; to import Parser from '../src/Parser'; got past the one failure
  4. re-ran tsc simple.ts
  5. received the above tsc errors - went to Parser.ts and put {} around import { http } and [ https }
  6. after re-running tsc simple.ts after edit for {} in imports - stated addional errors wrt http and https.

Also received tsc error stating Iterator, is not tyle array.

So as you can see, this isn't going to play nicely on the tsc compile -- even after inserting es2020.string in the lib options for compile options as suggsted.

Expected behavior
A clear and concise description of what you expected to happen.
I expected to have something that compiles and run like:
node simple.js (after tsc successfully compiles)
Shoult pring streamingTitle, whether in an infinite loop ever 5 seconds, or have it watch for changes in streamingTitle and prints it when song mp3 tracks change under Shoutcast mp3 stream.

In my specific case, I have a song loaded for debug purpose that has the following format:
"album - artist - title.mp3" where the album may have the following string format:

  1. simply the album name;
  2. Control tokens like Promo:Album Name, Sponsor:Album name; Logo:Album name; Banner:Album name;

I can test by going to : http://whsh4u-panel.com:14083/stream or 14029
then I intended to make the song request from our rockitbroadcasting.com/troprock or americana to request the song title Frosty and artist "Major Tom" to test our token control app we've built. We intend only to use the icasecast-parser as a separate monitor to make sure streamingTitle reflects the song file name correctly.

Additional context
Add any other context about the problem here.

'"http"' has no default export.

Describe the bug
I am using icecast-parser in my angular project but i get the following error

ERROR in node_modules/icecast-parser/dist/Parser.d.ts:4:8 - error TS1192: Module '"http"' has no default export.

4 import http from 'http';
         ~~~~

please advice

Additional context

Angular CLI: 10.0.8
Node: 12.18.4
OS: darwin x64

Angular: 10.0.14
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
... service-worker
Ivy Workspace: Yes

Package Version

@angular-devkit/architect 0.1000.8
@angular-devkit/build-angular 0.1000.8
@angular-devkit/build-optimizer 0.1000.8
@angular-devkit/build-webpack 0.1000.8
@angular-devkit/core 10.0.8
@angular-devkit/schematics 10.0.8
@angular/cli 10.0.8
@ngtools/webpack 10.0.8
@schematics/angular 10.0.8
@schematics/update 0.1000.8
rxjs 6.5.5
typescript 3.9.7
webpack 4.43.0

How to obtain all the metadata content besides the "streamTitle".

Hi, Firstly, thank you for developing this module. I've gone through the documentation & example codes but didn't find what I was looking for. In your "simple" code example, you use metatadata.streamingTitle to print this piece of metadata to the console. I have a number of questions so that I can possibly integrate this module into my project. Here are the questions:

  1. You used streamTitle as an example which is fine for that example, however, I would like to know all the metadata object names besides streamTitle. Is there a way to tell this method to print out the name of all the metatdata names the has been collected successfully? Incling CoverArt and other items. I ask this as my current stream is SHOUTCast and their metadata specification labels doesn't seem to many the streamTitle item you used as an example.
  2. As part of my project, I'd like to pass the values of the miscelaneous metadata objects as values into the rest of my application. For instance I'd like to pass the coverArt to be displayed if it exists. song duration, artist name, and other tagged items that are used in the SHOUTCast.
  3. I'd also like to pipe the output of the .stream item into another component in my app which will basically play the audio, or in separate id3 metadata parser. When I pipe the stream to an id3 parser, the keeplisten: true does not seem to keep the connection but drops out. What should I be aware of that could case the connection to 'end'.
  4. FInally, I noticed another user had the same question, can this module be configured to only update all the metadata only when songs are changed or changein metadata content. For instance, are there any triggerable events that this module can observve and trigger an event to "collect" the metadata?

Also, if you find my questions useful to others, would you update the Readme and and additional code examples?
Just my observations as a newbie to JS. Thanks again for the time reviewing in advance.

FR: Autoupdate only when changed.

Hi,

Nice work on this lib.

This will be more of a feature request.
I noticed you use a simple interval mechanism to pull metadata changes.
However it would be nice if you could have an autoupdate feature that only triggers when the previous metadata changed.
Something like RxJs scan operator

Thanks

Icecast-parser does not work with React

I have an issue when trying to include icecast-parser in a React project running with node v16.10.0

Directly after importing the package with

import { Parser } from 'icecast-parser';

the following error occurs:

Failed to compile.

./node_modules/icecast-parser/dist/StreamReader.js 20:115
Module parse failed: Unexpected token (20:115)
File was processed with these loaders:
 * ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|     var _part$groups, _part$groups2;
| 
>     return map.set(((_part$groups = part.groups) === null || _part$groups === void 0 ? void 0 : _part$groups.key) ?? '', ((_part$groups2 = part.groups) === null || _part$groups2 === void 0 ? void 0 : _part$groups2.value) ?? '');
|   });
|   return map;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.