function sendCdnPlaylist(response){
  let uploadDir = path.join(__dirname, 'catalogue');
  if (!fs.existsSync(uploadDir)){
    	fs.mkdirSync(uploadDir);
	}
  fs.readdir(uploadDir, (err, files) => {
    if(err){
      console.log(err);
      response.writeHead(400, {'Content-Type': 'application/json'});
      response.write(JSON.stringify(err.message));
      response.end();
    }else{
	//Deleting the files with no m3u8 extension from the list
	for( var i = 0; i < files.length; i++){ 
	   if ( path.extname(files[i]) != ".m3u8") {
	     files.splice(i, 1); 
	     i--;
	   }
	}
      response.writeHead(200, {'Content-Type': 'application/json'});
      response.write(JSON.stringify(files));
      response.end();
    }
  })
}
//Send playlist of videos available on the cdn
Send playlist of videos available on the cdn
Send playlist of videos available on the cdn
function sendCdnPlaylist(response){
  let uploadDir = path.join(__dirname, 'catalogue');
  if (!fs.existsSync(uploadDir)){
    	fs.mkdirSync(uploadDir);
	}
  fs.readdir(uploadDir, (err, files) => {
    if(err){
      console.log(err);
      response.writeHead(400, {'Content-Type': 'application/json'});
      response.write(JSON.stringify(err.message));
      response.end();
    }else{
	for( var i = 0; i < files.length; i++){ 
	   if ( path.extname(files[i]) != ".m3u8") {
	     files.splice(i, 1); 
	     i--;
	   }
	}
      response.writeHead(200, {'Content-Type': 'application/json'});
      response.write(JSON.stringify(files));
      response.end();
    }
  })
}
function sendCdnPlaylist ( response ) { let uploadDir = path . join ( __dirname , 'catalogue' ) ; if ( ! fs . existsSync ( uploadDir ) ) { fs . mkdirSync ( uploadDir ) ; } fs . readdir ( uploadDir , ( err , files ) => { if ( err ) { console . log ( err ) ; response . writeHead ( 400 , { 'Content-Type' : 'application/json' } ) ; response . write ( JSON . stringify ( err . message ) ) ; response . end ( ) ; } else { for ( var i = 0 ; i < files . length ; i ++ ) { if ( path . extname ( files [ i ] ) != ".m3u8" ) { files . splice ( i , 1 ) ; i -- ; } } response . writeHead ( 200 , { 'Content-Type' : 'application/json' } ) ; response . write ( JSON . stringify ( files ) ) ; response . end ( ) ; } } ) }
Send playlist of videos available on the cdn
Send playlist of videos available on the cdn
//Deleting the files with no m3u8 extension from the list