Export caption in the sidecar file

This commit is contained in:
Neeraj Gupta 2022-11-19 12:17:49 +05:30
parent 1b45b8447b
commit 14b8fe8288
No known key found for this signature in database
GPG key ID: 3C5A1684DC1729E1
2 changed files with 9 additions and 19 deletions

View file

@ -39,7 +39,6 @@ import {
} from 'utils/file';
import { updateFileCreationDateInEXIF } from './upload/exifService';
import { Metadata } from 'types/upload';
import QueueProcessor from './queueProcessor';
import { Collection } from 'types/collection';
import {
@ -460,11 +459,7 @@ class ExportService {
await this.exportMotionPhoto(fileStream, file, collectionPath);
} else {
this.saveMediaFile(collectionPath, fileSaveName, fileStream);
await this.saveMetadataFile(
collectionPath,
fileSaveName,
file.metadata
);
await this.saveMetadataFile(collectionPath, fileSaveName, file);
}
}
@ -483,11 +478,7 @@ class ExportService {
file.id
);
this.saveMediaFile(collectionPath, imageSaveName, imageStream);
await this.saveMetadataFile(
collectionPath,
imageSaveName,
file.metadata
);
await this.saveMetadataFile(collectionPath, imageSaveName, file);
const videoStream = generateStreamFromArrayBuffer(motionPhoto.video);
const videoSaveName = getUniqueFileSaveName(
@ -496,11 +487,7 @@ class ExportService {
file.id
);
this.saveMediaFile(collectionPath, videoSaveName, videoStream);
await this.saveMetadataFile(
collectionPath,
videoSaveName,
file.metadata
);
await this.saveMetadataFile(collectionPath, videoSaveName, file);
}
private saveMediaFile(
@ -516,11 +503,11 @@ class ExportService {
private async saveMetadataFile(
collectionFolderPath: string,
fileSaveName: string,
metadata: Metadata
file: EnteFile
) {
await this.electronAPIs.saveFileToDisk(
getFileMetadataSavePath(collectionFolderPath, fileSaveName),
getGoogleLikeMetadataFile(fileSaveName, metadata)
getGoogleLikeMetadataFile(fileSaveName, file)
);
}

View file

@ -128,15 +128,18 @@ export const dedupe = (files: any[]) => {
export const getGoogleLikeMetadataFile = (
fileSaveName: string,
metadata: Metadata
file: EnteFile
) => {
const metadata: Metadata = file.metadata;
const creationTime = Math.floor(metadata.creationTime / 1000000);
const modificationTime = Math.floor(
(metadata.modificationTime ?? metadata.creationTime) / 1000000
);
const captionValue: string = file?.pubMagicMetadata?.data?.caption ?? '';
return JSON.stringify(
{
title: fileSaveName,
caption: captionValue,
creationTime: {
timestamp: creationTime,
formatted: formatDate(creationTime * 1000),