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;
|
||||
}
|
||||
if (
|
||||
stream.tags !== undefined &&
|
||||
typeof stream.tags.creation_time === 'string'
|
||||
) {
|
||||
metadata.creationDate =
|
||||
Date.parse(stream.tags.creation_time) ||
|
||||
metadata.creationDate;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -139,6 +144,7 @@ export class MetadataLoader {
|
||||
if (fs.existsSync(sidecarPath)) {
|
||||
const sidecarData = await exifr.sidecar(sidecarPath);
|
||||
if (sidecarData !== undefined) {
|
||||
if ((sidecarData as SideCar).dc !== undefined) {
|
||||
if ((sidecarData as SideCar).dc.subject !== undefined) {
|
||||
if (metadata.keywords === undefined) {
|
||||
metadata.keywords = [];
|
||||
@ -153,12 +159,15 @@ export class MetadataLoader {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((sidecarData as SideCar).xmp !== undefined) {
|
||||
if ((sidecarData as SideCar).xmp.Rating !== undefined) {
|
||||
metadata.rating = (sidecarData as SideCar).xmp.Rating;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
Logger.silly(LOG_TAG, 'Error loading sidecar metadata for : ' + fullPath);
|
||||
Logger.silly(err);
|
||||
@ -623,6 +632,7 @@ export class MetadataLoader {
|
||||
const sidecarData = await exifr.sidecar(sidecarPath);
|
||||
|
||||
if (sidecarData !== undefined) {
|
||||
if ((sidecarData as SideCar).dc !== undefined) {
|
||||
if ((sidecarData as SideCar).dc.subject !== undefined) {
|
||||
if (metadata.keywords === undefined) {
|
||||
metadata.keywords = [];
|
||||
@ -637,6 +647,8 @@ export class MetadataLoader {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((sidecarData as SideCar).xmp !== undefined) {
|
||||
if ((sidecarData as SideCar).xmp.Rating !== undefined) {
|
||||
metadata.rating = (sidecarData as SideCar).xmp.Rating;
|
||||
}
|
||||
@ -646,6 +658,7 @@ export class MetadataLoader {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
Logger.silly(LOG_TAG, 'Error loading sidecar metadata for : ' + fullPath);
|
||||
Logger.silly(err);
|
||||
|
Loading…
Reference in New Issue
Block a user