mirror of
https://github.com/immich-app/immich.git
synced 2024-12-28 22:51:59 +00:00
feat(server): support lightroom tags (#12288)
This commit is contained in:
parent
a96f41aa11
commit
7ca53ba507
2 changed files with 55 additions and 0 deletions
|
@ -449,6 +449,51 @@ describe(MetadataService.name, () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should extract hierarchy from HierarchicalSubject', async () => {
|
||||
assetMock.getByIds.mockResolvedValue([assetStub.image]);
|
||||
metadataMock.readTags.mockResolvedValue({ HierarchicalSubject: ['Parent|Child'] });
|
||||
tagMock.upsertValue.mockResolvedValueOnce(tagStub.parent);
|
||||
tagMock.upsertValue.mockResolvedValueOnce(tagStub.child);
|
||||
|
||||
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
||||
|
||||
expect(tagMock.upsertValue).toHaveBeenNthCalledWith(1, { userId: 'user-id', value: 'Parent', parent: undefined });
|
||||
expect(tagMock.upsertValue).toHaveBeenNthCalledWith(2, {
|
||||
userId: 'user-id',
|
||||
value: 'Parent/Child',
|
||||
parent: tagStub.parent,
|
||||
});
|
||||
});
|
||||
|
||||
it('should extract ignore / characters in a HierarchicalSubject tag', async () => {
|
||||
assetMock.getByIds.mockResolvedValue([assetStub.image]);
|
||||
metadataMock.readTags.mockResolvedValue({ HierarchicalSubject: ['Mom/Dad'] });
|
||||
tagMock.upsertValue.mockResolvedValueOnce(tagStub.parent);
|
||||
|
||||
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
||||
|
||||
expect(tagMock.upsertValue).toHaveBeenCalledWith({
|
||||
userId: 'user-id',
|
||||
value: 'Mom|Dad',
|
||||
parent: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
it('should ignore HierarchicalSubject when TagsList is present', async () => {
|
||||
assetMock.getByIds.mockResolvedValue([assetStub.image]);
|
||||
metadataMock.readTags.mockResolvedValue({ HierarchicalSubject: ['Parent2|Child2'], TagsList: ['Parent/Child'] });
|
||||
tagMock.upsertValue.mockResolvedValue(tagStub.parent);
|
||||
|
||||
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
||||
|
||||
expect(tagMock.upsertValue).toHaveBeenNthCalledWith(1, { userId: 'user-id', value: 'Parent', parent: undefined });
|
||||
expect(tagMock.upsertValue).toHaveBeenNthCalledWith(2, {
|
||||
userId: 'user-id',
|
||||
value: 'Parent/Child',
|
||||
parent: tagStub.parent,
|
||||
});
|
||||
});
|
||||
|
||||
it('should not apply motion photos if asset is video', async () => {
|
||||
assetMock.getByIds.mockResolvedValue([{ ...assetStub.livePhotoMotionAsset, isVisible: true }]);
|
||||
mediaMock.probe.mockResolvedValue(probeStub.matroskaContainer);
|
||||
|
|
|
@ -355,6 +355,16 @@ export class MetadataService {
|
|||
const tags: unknown[] = [];
|
||||
if (exifTags.TagsList) {
|
||||
tags.push(...exifTags.TagsList);
|
||||
} else if (exifTags.HierarchicalSubject) {
|
||||
tags.push(
|
||||
exifTags.HierarchicalSubject.map((tag) =>
|
||||
tag
|
||||
// convert | to /
|
||||
.replaceAll('/', '<PLACEHOLDER>')
|
||||
.replaceAll('|', '/')
|
||||
.replaceAll('<PLACEHOLDER>', '|'),
|
||||
),
|
||||
);
|
||||
} else if (exifTags.Keywords) {
|
||||
let keywords = exifTags.Keywords;
|
||||
if (!Array.isArray(keywords)) {
|
||||
|
|
Loading…
Reference in a new issue