Skip to content

Commit

Permalink
version con liquidsoap
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Nov 20, 2019
2 parents 8b2a544 + 1851462 commit 3a57b64
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ datos.json
!video/.gitkeep
!audio/.gitkeep
!texto/.gitkeep
!documentos/.gitkeep
node_modules
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Un bot (script) de Telegram captura todo lo que le envias y:

### Corre con:
node-v8.9.0-linux-armv6l en rPi - https://nodejs.org/dist/v8.9.0/node-v8.9.0-linux-armv6l.tar.gz <br>
Codigo de Nestor@ckweb con ayudas en desarrollo de gstreamer en rpi de juan kalash
Codigo de [Néstor Andrés Peña](http://www.nestorandres.com) [@ckweb](https://ckweb.gov.co/) con ayudas en desarrollo de gstreamer en rpi de juan kalash

## Pasos a seguir para correr una instancia en un computador con Node.js instalado

Expand Down
Binary file added alsasrc.ogg
Binary file not shown.
6 changes: 5 additions & 1 deletion datos.json

Large diffs are not rendered by default.

Empty file added documentos/.gitkeep
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 33 additions & 1 deletion t2i.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ var urlFile = "https://api.telegram.org/file/bot" + TOKEN + "/";
var express = require('express')
var app = express()

var reproducidos = [];
var pendientes = [];
var sonando = false;

app.set('port', (process.env.PORT || 5000))

app.use(express.static(__dirname))
Expand Down Expand Up @@ -48,7 +52,7 @@ bot.on('message', (msg) => {
file: ''
};

// console.log(msg);
console.log(msg);

if(msg.voice != null){
obj.type = 'audio';
Expand Down Expand Up @@ -93,8 +97,16 @@ bot.on('message', (msg) => {
var fileUrl = urlFile + data.result.file_path;
download(fileUrl).then(data => {
fs.writeFileSync(darStringArchivo(carpeta, ext), data);
<<<<<<< HEAD
if(carpeta == 'audio' || carpeta == 'video'){
// var play = spawn('cvlc', ['--no-video', './' + darStringArchivo(carpeta, ext)]);
=======
if(carpeta == 'audio' && msg.voice.file_size < 57000){
pendientes.push('./' + darStringArchivo(carpeta, ext));
if(!sonando){
reproducirStream();
}
>>>>>>> 1851462a661e182422d5473f72c172ff5211496d
bot.sendMessage(chatId, 'se fue al streaming en vivo');
}
obj.file = darStringArchivo(carpeta, ext);
Expand Down Expand Up @@ -136,3 +148,23 @@ bot.on('message', (msg) => {

});

function reproducirStream() {
if(pendientes.length > 0){
sonando = true;
var play = spawn('cvlc', ['--no-video', '--play-and-exit' , pendientes[0]]);
play.on('exit', function() {
reproducidos.push(pendientes[0]);
pendientes = pendientes.slice(1);
sonando = false;
reproducirStream();
});
} else if(reproducidos.length > 0){
sonando = true;
var random = Math.floor(Math.random() * reproducidos.length);
var play = spawn('cvlc', ['--no-video', '--play-and-exit' , reproducidos[random]]);
play.on('exit', function() {
sonando = false;
reproducirStream();
});
}
}

0 comments on commit 3a57b64

Please sign in to comment.