• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CEP ExtendScript Download from url

New Here ,
Dec 07, 2020 Dec 07, 2020

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

TOPICS
Import , SDK

Views

1.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Adobe Employee , Dec 08, 2020 Dec 08, 2020

Votes

Translate

Translate
New Here , Dec 10, 2020 Dec 10, 2020

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 = 
...

Votes

Translate

Translate
Adobe Employee ,
Dec 08, 2020 Dec 08, 2020

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 10, 2020 Dec 10, 2020

Copy link to clipboard

Copied

LATEST

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)
  }
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines