Guest User

Untitled

a guest
Mar 24th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. const files = process.argv.slice(2);
  2.  
  3. function main(){
  4. if (!files.length) {
  5. console.log('Please provide at least one .uc file to decode.')
  6. return
  7. }
  8. files.forEach(async name => {
  9. await decodeFile(name);
  10. })
  11. }
  12.  
  13. function decodeFile(name){
  14. try {
  15. if (fs.statSync(name+'.mp3').isFile()){
  16. console.log('Skip ' + name);
  17. return Promise.resolve();
  18. }
  19. } catch (e) {}
  20. const fileIn = fs.createReadStream(name);
  21. const fileOut = fs.createWriteStream(name+'.mp3');
  22.  
  23. console.log('Processing: ' + name);
  24. fileIn.on('data',(chunk) => {
  25. fileOut.write(Buffer.from([...chunk].map(d=>d^0xa3)))
  26. });
  27.  
  28. return new Promise((res, rej)=>{
  29. fileIn.on('end',() => {
  30. console.log('Finished: ' + name);
  31. fileOut.end();
  32. res();
  33. })
  34. });
  35. }
  36.  
  37. main();
Add Comment
Please, Sign In to add comment