mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08: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))) {
|
||||
metadata.fps = parseInt(stream.avg_frame_rate, 10) || null;
|
||||
}
|
||||
metadata.creationDate =
|
||||
Date.parse(stream.tags.creation_time) ||
|
||||
metadata.creationDate;
|
||||
if (
|
||||
stream.tags !== undefined &&
|
||||
typeof stream.tags.creation_time === 'string'
|
||||
) {
|
||||
metadata.creationDate =
|
||||
Date.parse(stream.tags.creation_time) ||
|
||||
metadata.creationDate;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -139,22 +144,26 @@ export class MetadataLoader {
|
||||
if (fs.existsSync(sidecarPath)) {
|
||||
const sidecarData = await exifr.sidecar(sidecarPath);
|
||||
if (sidecarData !== undefined) {
|
||||
if ((sidecarData as SideCar).dc.subject !== undefined) {
|
||||
if (metadata.keywords === undefined) {
|
||||
metadata.keywords = [];
|
||||
}
|
||||
let keywords = (sidecarData as SideCar).dc.subject || [];
|
||||
if (typeof keywords === 'string') {
|
||||
keywords = [keywords];
|
||||
}
|
||||
for (const kw of keywords) {
|
||||
if (metadata.keywords.indexOf(kw) === -1) {
|
||||
metadata.keywords.push(kw);
|
||||
if ((sidecarData as SideCar).dc !== undefined) {
|
||||
if ((sidecarData as SideCar).dc.subject !== undefined) {
|
||||
if (metadata.keywords === undefined) {
|
||||
metadata.keywords = [];
|
||||
}
|
||||
let keywords = (sidecarData as SideCar).dc.subject || [];
|
||||
if (typeof keywords === 'string') {
|
||||
keywords = [keywords];
|
||||
}
|
||||
for (const kw of keywords) {
|
||||
if (metadata.keywords.indexOf(kw) === -1) {
|
||||
metadata.keywords.push(kw);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((sidecarData as SideCar).xmp.Rating !== undefined) {
|
||||
metadata.rating = (sidecarData as SideCar).xmp.Rating;
|
||||
if ((sidecarData as SideCar).xmp !== undefined) {
|
||||
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);
|
||||
|
||||
if (sidecarData !== undefined) {
|
||||
if ((sidecarData as SideCar).dc.subject !== undefined) {
|
||||
if (metadata.keywords === undefined) {
|
||||
metadata.keywords = [];
|
||||
}
|
||||
let keywords = (sidecarData as SideCar).dc.subject || [];
|
||||
if (typeof keywords === 'string') {
|
||||
keywords = [keywords];
|
||||
}
|
||||
for (const kw of keywords) {
|
||||
if (metadata.keywords.indexOf(kw) === -1) {
|
||||
metadata.keywords.push(kw);
|
||||
if ((sidecarData as SideCar).dc !== undefined) {
|
||||
if ((sidecarData as SideCar).dc.subject !== undefined) {
|
||||
if (metadata.keywords === undefined) {
|
||||
metadata.keywords = [];
|
||||
}
|
||||
let keywords = (sidecarData as SideCar).dc.subject || [];
|
||||
if (typeof keywords === 'string') {
|
||||
keywords = [keywords];
|
||||
}
|
||||
for (const kw of keywords) {
|
||||
if (metadata.keywords.indexOf(kw) === -1) {
|
||||
metadata.keywords.push(kw);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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 !== undefined) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user