Skip to content

Instantly share code, notes, and snippets.

@wiedymi
Last active November 15, 2019 13:18
Show Gist options
  • Save wiedymi/691a76320beafb8fa0a6e31cd8854b3d to your computer and use it in GitHub Desktop.
Save wiedymi/691a76320beafb8fa0a6e31cd8854b3d to your computer and use it in GitHub Desktop.
getGoogleDriveEmbedLink From Array Of Shared Links
'use strict'
const fs = require('fs');
function getGoogleDriveEmbedLink(links = ``, nameFile = 'output.txt'){
links = links
.split('\n')
.map(link => link.toString().replace('https://drive.google.com/open?id=',''))
.map(hash => `https://drive.google.com/file/d/${hash}/preview`)
.reduce((output, input, index) => {
return output += `\n${index + 1} | ${input}`;
}, '');
return fs.appendFile(nameFile, links, function (err) {
if (err) throw err;
console.log('Saved!');
});
}
let links = `https://drive.google.com/open?id=1N2KyQDz1b682ABOG0JCCroojHvazYKO2`;//list of links threw Enter \n
getGoogleDriveEmbedLink(links, 'Embed Links.txt');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment