Skip to content

Instantly share code, notes, and snippets.

@sixertoy
Last active October 16, 2023 21:16
Show Gist options
  • Save sixertoy/6b5433220a45aa754354287ff54a1e2a to your computer and use it in GitHub Desktop.
Save sixertoy/6b5433220a45aa754354287ff54a1e2a to your computer and use it in GitHub Desktop.
Simple Audio Streaming Proxy | NodeJS + Express + MP3
/**
* INSTALL:
* ----
* > yarn add express request
*
* RUN:
* ----
* > node ./audio-proxy-server
*/
const os = require('os');
const dns = require('dns');
const express = require('express');
const request = require('request');
const app = express();
const hostname = os.hostname();
// defined in .env file
const serverport = (process.env.PORT || process.env.PROXY_PORT || 3000);
// Any streaming radio URI
const radiouri = 'http://novazz.ice.infomaniak.ch/novazz-128.mp3';
app.get('/', (req, res) => {
process.stdout.write('Connected to server\n');
request.get(radiouri)
.on('error', () => {})
.on('response', () => {})
.pipe(res);
});
app.listen(serverport, () => {
dns.lookup(hostname, (err, ip) => {
// retrieve network local ip
process.stdout.write('Audio Proxy Server runs under\n');
process.stdout.write(` Local: http://locahost:${serverport}\n`);
process.stdout.write(` Home Network: http://${ip}:${serverport}\n`);
});
});
@sixertoy
Copy link
Author

@bertrandmd et encore je fais des efforts je suis passé à l'ES6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment