SHARE
TWEET

Untitled

a guest May 21st, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const request = require('request-promise-native');
  2. const m3u8 = require('m3u8');
  3. const ffmpeg = require('fluent-ffmpeg');
  4. const fs = require('fs');
  5.  
  6. function parse_aa(file){
  7.         const parser = m3u8.createStream();
  8.         const ffile = fs.createReadStream(file);
  9.         ffile.pipe(parser);
  10.         return new Promise((resolve, reject)=>{
  11.                 parser.on('error',reject);
  12.                 parser.on('m3u',resolve);
  13.         });
  14. }
  15.  
  16. parse_aa('sample_0').then(items=>{
  17.         return new Promise((resolve, reject)=>{
  18.                 items.forEach((item,index)=>{
  19.                         ffmpeg.ffprobe(item.uri, (err, metadata)=>{
  20.                                 if(err){
  21.                                         items.splice(index,1);
  22.                                 }
  23.                         });
  24.                         resolve(items);
  25.                 });
  26.         });
  27. }).then(a=>console.log(a));
  28.  
  29.  
  30. // error : items.forEach < is not a function ?
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top