Copy link to clipboard
Copied
Is there an easy way in ExtendScript for Adobe Premiere 2020 to download a file from an https url?
Basically, doing:
function importFile(filePath) {
app.project.importFiles([filePath],
false, // suppress warnings
app.project.getInsertionBin(),
false); // import as numbered stills
}
where `filePath` is a url (like https://example.com/video.mp4) instead of a local file.
Any help appreciated!
Cheers,
Damien
There is no easy way, in ExtendScript. However, a panel's JavaScript can download files.
https://www.hacksparrow.com/nodejs/using-node-js-to-download-files.html
https://stackoverflow.com/questions/4771614/download-large-file-with-node-js-avoiding-high-memory-consumption
Thanks @Bruce Bullis ; with your help I was able to achieve my goal!
There were a couple of gotchas, like remembering to enable Node.js in the manifest:
<CEFCommandLine>
<Parameter>--enable-nodejs</Parameter>
<Parameter>--mixed-context</Parameter>
</CEFCommandLine>
or using
const fs = cep_node.require('fs')
instead of just
const fs = require('fs')
In the end, here is what I came up with, in case it helps anyone in the future:
export const importInPremiere =
...
Copy link to clipboard
Copied
There is no easy way, in ExtendScript. However, a panel's JavaScript can download files.
https://www.hacksparrow.com/nodejs/using-node-js-to-download-files.html
https://stackoverflow.com/questions/4771614/download-large-file-with-node-js-avoiding-high-memory-co...
Copy link to clipboard
Copied
Thanks @Bruce Bullis ; with your help I was able to achieve my goal!
There were a couple of gotchas, like remembering to enable Node.js in the manifest:
<CEFCommandLine>
<Parameter>--enable-nodejs</Parameter>
<Parameter>--mixed-context</Parameter>
</CEFCommandLine>
or using
const fs = cep_node.require('fs')
instead of just
const fs = require('fs')
In the end, here is what I came up with, in case it helps anyone in the future:
export const importInPremiere = async ({ url, name }) => {
/**
* Initialize CSInterface
*/
const { CSInterface } = require('@cep/csinterface')
const csInterface = new CSInterface()
/**
* Create temporary directory
*/
const tempFolder = '/tmp/adobe_cep_panel'
window.cep.fs.makedir(tempFolder)
const filePath = `${tempFolder}/${name}`
/**
* Open file
*/
const fs = window.cep_node.require('fs')
const file = fs.createWriteStream(filePath)
/**
* Fetch ressource as stream
*/
const response = await fetch(url)
const reader = response.body.getReader()
while (true) {
/**
* Read stream chunks
*/
const { value, done } = await reader.read()
if (done) {
/**
* Close file
*/
file.end()
/**
* Send file path to JSX for import into Premiere
*/
csInterface.evalScript(`importFile("${filePath}")`)
break
}
/**
* Write stream chunks to file
*/
file.write(value)
}
}