Skip to main content
Inspiring
July 11, 2019
Answered

Is rootItem.setProjectMetadata possible?

  • July 11, 2019
  • 2 replies
  • 1192 views

Hi,

we use a MAM that manages all our assets. It also keeps track which Premiere projects use the asset. This enables us to find "footage that is not used in any project" or "other projects using that footage".

In order to make that work, the project needs an ID in the MAM. I assumed this should be easy, but after some research, I learned that only assets are supposed to have metadata, not projects.

So how can I write an external ID persistently in a .pproj-File?

We need this information because the panel will watch for changes in the project. If items are added/removed, the panel will tell the MAM about this, so the asset <--> project relations stay up to date.

Maybe someone has a suggestion how to solve the problem, thank you very much!

This topic has been closed for replies.
Correct answer Justin Taylor-Hyper Brew

Yes, you can with AdobeXMPScript, I do this in some of my tools like Pro IO. Here's the basic gist:

function setPrMetadata(projectItem, metadata) {

    var kPProPrivateProjectMetadataURI = "http://ns.adobe.com/premierePrivateProjectMetaData/1.0/";

    if (app.isDocumentOpen()) {

        if (projectItem) {

            if (ExternalObject.AdobeXMPScript === undefined)

                ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');

            if (ExternalObject.AdobeXMPScript !== undefined) {

                var projectMetadata = projectItem.getProjectMetadata();

                var xmp = new XMPMeta(projectMetadata);

                for (var pc = 0; pc < metadata.length; pc++) {

                    var successfullyAdded = app.project.addPropertyToProjectMetadataSchema(metadata[pc][0], metadata[pc][1], 2);

                }

                var array = [];

                for (var pc = 0; pc < metadata.length; pc++) {

                    xmp.setProperty(kPProPrivateProjectMetadataURI, metadata[pc][0], metadata[pc][2]);

                    array.push(metadata[pc][0]);

                }

                var str = xmp.serialize();

                projectItem.setProjectMetadata(str, array);

            }

        }

    }

}

// usage

setPrMetadata(app.project.rootItem, [["myCustomField", "UniqID", "Value"]]);

// check result

app.project.rootItem.getProjectMetadata();

See the PPRO Sample Panel for more details

2 replies

wiejetzAuthor
Inspiring
July 12, 2019

Yes that's the plan now : )

I just wanted to spare custom fields in order to stay as close to standards as possible.

It seems not to be best-practice to write any piece of metadata into the project itself, so it won't be much worse to write into a custom field.

Thanks for your help

Justin Taylor-Hyper Brew
Community Expert
Community Expert
July 11, 2019

Yes, you can with AdobeXMPScript, I do this in some of my tools like Pro IO. Here's the basic gist:

function setPrMetadata(projectItem, metadata) {

    var kPProPrivateProjectMetadataURI = "http://ns.adobe.com/premierePrivateProjectMetaData/1.0/";

    if (app.isDocumentOpen()) {

        if (projectItem) {

            if (ExternalObject.AdobeXMPScript === undefined)

                ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');

            if (ExternalObject.AdobeXMPScript !== undefined) {

                var projectMetadata = projectItem.getProjectMetadata();

                var xmp = new XMPMeta(projectMetadata);

                for (var pc = 0; pc < metadata.length; pc++) {

                    var successfullyAdded = app.project.addPropertyToProjectMetadataSchema(metadata[pc][0], metadata[pc][1], 2);

                }

                var array = [];

                for (var pc = 0; pc < metadata.length; pc++) {

                    xmp.setProperty(kPProPrivateProjectMetadataURI, metadata[pc][0], metadata[pc][2]);

                    array.push(metadata[pc][0]);

                }

                var str = xmp.serialize();

                projectItem.setProjectMetadata(str, array);

            }

        }

    }

}

// usage

setPrMetadata(app.project.rootItem, [["myCustomField", "UniqID", "Value"]]);

// check result

app.project.rootItem.getProjectMetadata();

See the PPRO Sample Panel for more details

wiejetzAuthor
Inspiring
July 11, 2019

Hi, thanks for this.

I think I tried this already, not exacltly your code, but I tried setting the metadata for regular project items (assets), which worked.

Then I set the item to the project root item. I checked the result of "xmp.serialize()", which was correct.

Then, I did "setProjectMetadata" which returned undefined. I guess this should be true on success...

"app.project.rootItem.getProjectMetadata()" returned the original (unchanged) metadata.

Maybe it depends on the field.

I'll try your code.