mirror of
https://github.com/bpatrik/pigallery2.git
synced 2025-01-08 04:03:48 +02:00
Fix errors reading properties of undefined
This commit is contained in:
parent
3ec3b5a030
commit
6173350a69
@ -82,9 +82,14 @@ export class MetadataLoader {
|
|||||||
if (Utils.isInt32(parseInt(stream.avg_frame_rate, 10))) {
|
if (Utils.isInt32(parseInt(stream.avg_frame_rate, 10))) {
|
||||||
metadata.fps = parseInt(stream.avg_frame_rate, 10) || null;
|
metadata.fps = parseInt(stream.avg_frame_rate, 10) || null;
|
||||||
}
|
}
|
||||||
metadata.creationDate =
|
if (
|
||||||
Date.parse(stream.tags.creation_time) ||
|
stream.tags !== undefined &&
|
||||||
metadata.creationDate;
|
typeof stream.tags.creation_time === 'string'
|
||||||
|
) {
|
||||||
|
metadata.creationDate =
|
||||||
|
Date.parse(stream.tags.creation_time) ||
|
||||||
|
metadata.creationDate;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -139,22 +144,26 @@ export class MetadataLoader {
|
|||||||
if (fs.existsSync(sidecarPath)) {
|
if (fs.existsSync(sidecarPath)) {
|
||||||
const sidecarData = await exifr.sidecar(sidecarPath);
|
const sidecarData = await exifr.sidecar(sidecarPath);
|
||||||
if (sidecarData !== undefined) {
|
if (sidecarData !== undefined) {
|
||||||
if ((sidecarData as SideCar).dc.subject !== undefined) {
|
if ((sidecarData as SideCar).dc !== undefined) {
|
||||||
if (metadata.keywords === undefined) {
|
if ((sidecarData as SideCar).dc.subject !== undefined) {
|
||||||
metadata.keywords = [];
|
if (metadata.keywords === undefined) {
|
||||||
}
|
metadata.keywords = [];
|
||||||
let keywords = (sidecarData as SideCar).dc.subject || [];
|
}
|
||||||
if (typeof keywords === 'string') {
|
let keywords = (sidecarData as SideCar).dc.subject || [];
|
||||||
keywords = [keywords];
|
if (typeof keywords === 'string') {
|
||||||
}
|
keywords = [keywords];
|
||||||
for (const kw of keywords) {
|
}
|
||||||
if (metadata.keywords.indexOf(kw) === -1) {
|
for (const kw of keywords) {
|
||||||
metadata.keywords.push(kw);
|
if (metadata.keywords.indexOf(kw) === -1) {
|
||||||
|
metadata.keywords.push(kw);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((sidecarData as SideCar).xmp.Rating !== undefined) {
|
if ((sidecarData as SideCar).xmp !== undefined) {
|
||||||
metadata.rating = (sidecarData as SideCar).xmp.Rating;
|
if ((sidecarData as SideCar).xmp.Rating !== undefined) {
|
||||||
|
metadata.rating = (sidecarData as SideCar).xmp.Rating;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -623,25 +632,29 @@ export class MetadataLoader {
|
|||||||
const sidecarData = await exifr.sidecar(sidecarPath);
|
const sidecarData = await exifr.sidecar(sidecarPath);
|
||||||
|
|
||||||
if (sidecarData !== undefined) {
|
if (sidecarData !== undefined) {
|
||||||
if ((sidecarData as SideCar).dc.subject !== undefined) {
|
if ((sidecarData as SideCar).dc !== undefined) {
|
||||||
if (metadata.keywords === undefined) {
|
if ((sidecarData as SideCar).dc.subject !== undefined) {
|
||||||
metadata.keywords = [];
|
if (metadata.keywords === undefined) {
|
||||||
}
|
metadata.keywords = [];
|
||||||
let keywords = (sidecarData as SideCar).dc.subject || [];
|
}
|
||||||
if (typeof keywords === 'string') {
|
let keywords = (sidecarData as SideCar).dc.subject || [];
|
||||||
keywords = [keywords];
|
if (typeof keywords === 'string') {
|
||||||
}
|
keywords = [keywords];
|
||||||
for (const kw of keywords) {
|
}
|
||||||
if (metadata.keywords.indexOf(kw) === -1) {
|
for (const kw of keywords) {
|
||||||
metadata.keywords.push(kw);
|
if (metadata.keywords.indexOf(kw) === -1) {
|
||||||
|
metadata.keywords.push(kw);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((sidecarData as SideCar).xmp.Rating !== undefined) {
|
if ((sidecarData as SideCar).xmp !== undefined) {
|
||||||
metadata.rating = (sidecarData as SideCar).xmp.Rating;
|
if ((sidecarData as SideCar).xmp.Rating !== undefined) {
|
||||||
}
|
metadata.rating = (sidecarData as SideCar).xmp.Rating;
|
||||||
if ((sidecarData as SideCar).xmp.CreateDate) {
|
}
|
||||||
metadata.creationDate = timestampToMS((sidecarData as SideCar).xmp.CreateDate, null);
|
if ((sidecarData as SideCar).xmp.CreateDate) {
|
||||||
|
metadata.creationDate = timestampToMS((sidecarData as SideCar).xmp.CreateDate, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user