ghaiklor / icecast-parser Goto Github PK
View Code? Open in Web Editor NEWNode.js module for getting and parsing metadata from SHOUTcast/Icecast radio streams
License: MIT License
Node.js module for getting and parsing metadata from SHOUTcast/Icecast radio streams
License: MIT License
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
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?
Hi !
When i try to use icecast parser with various strem, for example from streamtheworld : http://20073.live.streamtheworld.com/LOS40_SC i don't have any result
what am i doing wrong ?
thanks
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.
Hello,
Thanks for you work, but how to integrate this with html tag to ensure meta data was the realy stream audio current output ?
Thanks
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
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.
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:
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})
})
})
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!
Should properly emit metadata from Icecast:
Uncaught TypeError: data.replace(...).matchAll(...)[Symbol.iterator] is not a function
at _parseMetadata (src/StreamReader.js:9:850)
at StreamReader._onMetaData (src/StreamReader.js:9:6744)
at _processData (src/StreamReader.js:9:3417)
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;
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?
Describe the bug
Crashing on startup
To Reproduce
Steps to reproduce the behavior:
Expected behavior
That it would work
Additional context
Code:
const readiostream = new reader.Parser({
url: 'http://stream.animeradio.de/animeradio.ogg',
autoUpdate: true,
keepListen: true
})
readiostream.on('metadata', (metadata) => {
console.log(metadata)
})
A feature request: would it possible to add a webhook as output? (to use with discord)
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...?
/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)
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?
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
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
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
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...
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:
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.
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
@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
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:
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.
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
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;
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.