Last active
November 15, 2019 13:18
-
-
Save wiedymi/691a76320beafb8fa0a6e31cd8854b3d to your computer and use it in GitHub Desktop.
getGoogleDriveEmbedLink From Array Of Shared Links
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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