fent / node-m3u8stream

Concatenates segments from a m3u8/dash-mpd playlist into a consumable stream.
MIT License
217 stars 54 forks source link

MinigetError: Status code: 404 #94

Closed halisyucel closed 1 year ago

halisyucel commented 3 years ago

I have a code like this

app.get('/stream', (req, res) => {
        res.attachment('twitter-spaces-' + Date.now() + '.aac');
        const stream = m3u8stream(req.query['url'])
            .pipe(res)
})

But when the stream ends I get the error MinigetError: Status code: 404. This is quite logical. However, I want to do stream.end() when the stream ends. I tried this but was unsuccessful.

app.get('/stream', (req, res) => {
        res.attachment('twitter-spaces-' + Date.now() + '.aac');
        const stream = m3u8stream(req.query['url']);
        try{
            stream.pipe(res);
        }catch (e) {
            stream.end();
        }
})

here is the whole error

events.js:292
      throw er; // Unhandled 'error' event
      ^

MinigetError: Status code: 404
    at ClientRequest.<anonymous> (C:\Users\halisycel\Desktop\deneme\node_modules\miniget\dist\index.js:210:27)
    at Object.onceWrapper (events.js:422:26)
    at ClientRequest.emit (events.js:315:20)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:641:27)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:126:17)
    at TLSSocket.socketOnData (_http_client.js:509:22)
    at TLSSocket.emit (events.js:315:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at TLSSocket.Readable.push (internal/streams/readable.js:223:10)
Emitted 'error' event on PassThrough instance at:
    at PassThrough.onError (C:\Users\halisycel\Desktop\deneme\node_modules\m3u8stream\dist\index.js:73:16)
    at PassThrough.emit (events.js:315:20)
    at ClientRequest.<anonymous> (C:\Users\halisycel\Desktop\deneme\node_modules\miniget\dist\index.js:215:28)
    at Object.onceWrapper (events.js:422:26)
    [... lines matching original stack trace ...]
    at addChunk (internal/streams/readable.js:309:12) {
  statusCode: 404
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! deneme@1.0.0 start: `node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the deneme@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\halisycel\AppData\Roaming\npm-cache\_logs\2021-06-07T17_53_39_113Z-debug.log
fent commented 3 years ago

when the stream ends you always get the 404 error? as in, for every single stream?

halisyucel commented 3 years ago

I get 404 errors at the end of every stream and all I've tried are twitter space streams.