muralikg / puppetcam

Export puppeteer tab as webm video
MIT License
322 stars 63 forks source link

Changing download folder? #6

Closed theianjohnson closed 6 years ago

theianjohnson commented 6 years ago

I'm currently working through the docs to try and find this as well, but have you seen any way to change the download location? Ideally I'd like to just download the video into a subdirectory relative to where the script is being run from, ie -

/puppetcam
    export.js
    ... etc
    /videos
        spinner.webm <- can we get it here?

Currently it gets dropped into the ~/Downloads/spinner.webm folder on my virtual machine, then I have to manually move to a linked folder to access (using Vagrant and Virtualbox with a *nix image)

I tried with a relative path as a filename, but no luck, still dropped it in ~/Downloads

muralikg commented 6 years ago

You can only set relative paths from the download location as per the docs. To set a custom downloads folder you need to create a chrome profile with that appropriate location and use that with puppeteer. I thought it is easier to mv the file through a script than go through that hassle

theianjohnson commented 6 years ago

Looks like that is indeed the best way to go, for any future readers, my solution using fs

fs.copyFile('/home/vagrant/Downloads/'+ exportname, __dirname +'/screencasts/'+ exportname, (err) => {if(err) console.log(err)});
fs.unlink('/home/vagrant/Downloads/'+ exportname, (err) => {if(err) console.log(err)});

I couldn't just do fs.rename since moving from a non-vagrant synced folder to a synced folder is across partitions