Export caption in the sidecar file
This commit is contained in:
parent
1b45b8447b
commit
14b8fe8288
|
@ -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)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Reference in a new issue