mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
metadataloader.ts modifications to add xmp sidecar
Modified module imports and added code to read xmp sidecar for videometadata using exifr module.
This commit is contained in:
parent
54b16285dc
commit
2702f9d41d
@ -12,6 +12,8 @@ import {IptcParser} from 'ts-node-iptc';
|
|||||||
import {FFmpegFactory} from '../FFmpegFactory';
|
import {FFmpegFactory} from '../FFmpegFactory';
|
||||||
import {FfprobeData} from 'fluent-ffmpeg';
|
import {FfprobeData} from 'fluent-ffmpeg';
|
||||||
import {Utils} from '../../../common/Utils';
|
import {Utils} from '../../../common/Utils';
|
||||||
|
import * as exifr from 'exifr';
|
||||||
|
import * as path from 'path';
|
||||||
|
|
||||||
const LOG_TAG = '[MetadataLoader]';
|
const LOG_TAG = '[MetadataLoader]';
|
||||||
const ffmpeg = FFmpegFactory.get();
|
const ffmpeg = FFmpegFactory.get();
|
||||||
@ -30,6 +32,29 @@ export class MetadataLoader {
|
|||||||
fileSize: 0,
|
fileSize: 0,
|
||||||
fps: 0,
|
fps: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
// search for sidecar and merge metadata
|
||||||
|
const fullPathWithoutExt = path.parse(fullPath).name;
|
||||||
|
const sidecarPaths = [
|
||||||
|
fullPath + '.xmp',
|
||||||
|
fullPath + '.XMP',
|
||||||
|
fullPathWithoutExt + '.xmp',
|
||||||
|
fullPathWithoutExt + '.XMP',
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const sidecarPath of sidecarPaths) {
|
||||||
|
if (fs.existsSync(sidecarPath)) {
|
||||||
|
const sidecarData = exifr.sidecar(sidecarPath);
|
||||||
|
sidecarData.then((response) => {
|
||||||
|
metadata.keywords = [(response as any).dc.subject].flat();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
// ignoring errors
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const stat = fs.statSync(fullPath);
|
const stat = fs.statSync(fullPath);
|
||||||
metadata.fileSize = stat.size;
|
metadata.fileSize = stat.size;
|
||||||
|
Loading…
Reference in New Issue
Block a user