Skip to content

Commit

Permalink
All thumbnails are cahced now instead of these ones with valid metadata
Browse files Browse the repository at this point in the history
This is needed so thumbnail can later be checked if they have been updated. Otherwise the system will always overlook cases with failed metadata.
  • Loading branch information
Agrarvolution committed Mar 18, 2024
1 parent 669bdd0 commit 1908574
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/jsx/KBRG/CacheThumbnails.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ CacheThumbnails.PROCESS_METHODS = {
fromTimecode: 'updateFromTimecode',
fromTimecodes: 'updateFromTimecodes'
}

/**
* Constructer for a thumbnail cache.
* @param {object} parameters has to contain a search target, folder search and whether only erroneous thumbnails should be added
Expand Down Expand Up @@ -53,6 +54,7 @@ CacheThumbnails.prototype.cacheTimecodeOfThumbnails = function (searchTarget, se
this.logCallback("Start searching for selected media items.", Agrarvolution.logLevels.status, this.logTarget, this.logging);
}


for (i = 0; i < app.document.selectionLength; i++) {
this.extractTimecodeFromThumbnail(app.document.selections[i], searchRecursive);
}
Expand Down Expand Up @@ -116,13 +118,14 @@ CacheThumbnails.prototype.extractTimecodeFromThumbnail = function (thumb, search
if (!(thumb instanceof Thumbnail)) {
return false;
}

if (thumb.type === CacheThumbnails.THUMBNAIL_TYPES.folder && searchRecursive) {
for (var i = 0; i < thumb.children.length; i++) {
this.extractTimecodeFromThumbnail(thumb.children[i], searchRecursive);
}
return true;
}
if (thumb.type !== CacheThumbnails.THUMBNAIL_TYPES.file || !thumb.hasMetadata) {
if (thumb.type !== CacheThumbnails.THUMBNAIL_TYPES.file) {
return false;
}

Expand Down
15 changes: 14 additions & 1 deletion src/jsx/KBRG/ThumbnailMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ThumbnailMetadata.METADATA_DATE = {
* @return {object} returns empty object if thumbnail is not a file or the file has no metadata.
*/
function ThumbnailMetadata(thumbnail) {
if (thumbnail.type !== CacheThumbnails.THUMBNAIL_TYPES.file || !thumbnail.hasMetadata) {
if (thumbnail.type !== CacheThumbnails.THUMBNAIL_TYPES.file) {
return {};
}
this.thumb = thumbnail;
Expand Down Expand Up @@ -57,6 +57,19 @@ ThumbnailMetadata.prototype.toTimecodeCSV = function () {
* @return {boolean} on true, contains no errors, on false has values that errored / are invalid.
*/
ThumbnailMetadata.prototype.extractMetadata = function () {
if (!this.thumb.hasMetadata) { //caches thumbnail with corrupt Metadata as well - this is needed so a later recheck actually shows failed changes
this.timecodeMetadata = {
startTime: new Timecode(),
framerate: 0,
prevStartTime: new Timecode(),
prevFramerate: 0,
isDropFrame: false,
timecodeStruct: ThumbnailMetadata.TIME_CODE_STRUCT.start
};

return false;
}

this.xmp = new XMPMeta(this.thumb.synchronousMetadata.serialize());

if (this.xmp.doesPropertyExist(XMPConst.NS_BWF, "codingHistory")) {
Expand Down

0 comments on commit 1908574

Please sign in to comment.