Last active
October 16, 2023 21:16
-
-
Save sixertoy/6b5433220a45aa754354287ff54a1e2a to your computer and use it in GitHub Desktop.
Simple Audio Streaming Proxy | NodeJS + Express + MP3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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`); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Lint moi ce fichier j'ai les yeux qui piquent ! ;)