Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import all OS X tags attached to video files #370

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
88a0a07
tags extracted from OS X correctly
whyboris Feb 21, 2020
dbdcfe3
osx-tag thank you
whyboris Feb 21, 2020
7959f56
merge master
whyboris Feb 27, 2020
c27a488
merge master
whyboris Mar 3, 2020
300fca5
Merge branch 'os-tags' of https://github.com/whyboris/Video-Hub-App i…
whyboris Mar 3, 2020
eb64e8f
Merge branch 'master' into os-tags
whyboris Mar 25, 2020
cb0b5de
Merge branch 'master' into os-tags
whyboris Apr 12, 2020
9643b1f
optional dependency
whyboris Apr 12, 2020
65b5dd7
Merge branch 'master' of https://github.com/whyboris/Video-Hub-App in…
whyboris Apr 12, 2020
c6b3253
Merge branch 'os-tags' of https://github.com/whyboris/Video-Hub-App i…
whyboris Apr 12, 2020
e1aaba0
try-catch & handle error
whyboris Apr 12, 2020
39149be
Merge branch 'os-tags' of https://github.com/whyboris/Video-Hub-App i…
whyboris Apr 12, 2020
5366071
use native mdls instead of npm osx-tag
whyboris Apr 12, 2020
93914fb
Merge branch 'os-tags' of https://github.com/whyboris/Video-Hub-App i…
whyboris Apr 15, 2020
f561028
Merge branch 'master' into os-tags
whyboris Apr 20, 2020
a521cf7
Merge branch 'os-tags' of https://github.com/whyboris/Video-Hub-App i…
whyboris Apr 23, 2020
4bfdd78
Merge branch 'master' into os-tags
whyboris Apr 24, 2020
00558d0
Merge branch 'master' into os-tags
whyboris May 11, 2020
0e8d393
Merge branch 'master' into os-tags
whyboris May 13, 2020
9bd3c38
Merge branch 'master' into os-tags
whyboris May 17, 2020
600d2fd
Merge branch 'master' into os-tags
whyboris May 19, 2020
3b94ae4
Merge branch 'master' into os-tags
whyboris May 28, 2020
698bb51
Merge branch 'master' into os-tags
whyboris Jun 22, 2020
418f98f
merge main, resolve conflicts
whyboris Jul 26, 2020
fa3d15f
Merge branch 'main' into os-tags
whyboris Aug 10, 2020
640ae0d
merge main
whyboris Oct 11, 2020
7aa7b7b
Merge branch 'main' into os-tags
whyboris Oct 28, 2020
47443af
Merge branch 'main' into os-tags
whyboris Nov 2, 2020
63e7c36
Merge branch 'main' into os-tags
whyboris Nov 29, 2020
2ee41ab
Merge branch 'main' into os-tags
whyboris Feb 7, 2021
c77bc85
Merge branch 'main' into os-tags
whyboris Apr 22, 2021
3e87d04
Merge branch 'main' into os-tags
whyboris Jul 9, 2021
e926e98
Merge branch 'main' into os-tags
whyboris Mar 27, 2022
1562038
re-add osx-tag dependency
whyboris Mar 27, 2022
8cf4a1a
sike
whyboris Mar 27, 2022
96b86a6
merge main, resolve conflicts
whyboris Feb 19, 2023
98c2a22
Merge branch 'main' into os-tags
whyboris Oct 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@ This software would not be possible without the tremendous work by other people:
- [ngx-translate](https://github.com/ngx-translate/core)
- [trash](https://github.com/sindresorhus/trash)
- [Fuse.js](https://github.com/krisk/Fuse)
- [osx-tag](https://github.com/keichi/osx-tag)

Since becoming open source, this software was made better with the awesome contributions by [cal2195](https://github.com/cal2195)
27 changes: 26 additions & 1 deletion main-support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@
* There should be no side-effects of running any of them
* They should depend only on their inputs and behave exactly
* the same way each time they run no matter the outside state
*
* !!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!
* DANGEROUSLY DEPENDS ON `codeRunningOnMac` when extracting metadata
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*/

const codeRunningOnMac: boolean = process.platform === 'darwin'; // <---- MAKES MANY FUNCTIONS NOT PURE !!!!

import * as path from 'path';

const fs = require('fs');
Expand All @@ -14,6 +20,8 @@ const hasher = require('crypto').createHash;

const exec = require('child_process').exec;

const tag = require('osx-tag');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guard this require, or try catch it 😄


const ffprobePath = require('@ffprobe-installer/ffprobe').path.replace('app.asar', 'app.asar.unpacked');

import { acceptableFiles } from './main-filenames';
Expand Down Expand Up @@ -490,7 +498,24 @@ function extractMetadataForThisONEFile(
imageElement.width = origWidth;
imageElement.screens = computeNumberOfScreenshots(screenshotSettings, duration);

extractMetaCallback(imageElement);
// !!!! WARNING !!!!!! NOT A PURE FUNCTION ANY MORE !!!!!!!!!!!!!!!
if (codeRunningOnMac) {
tag.getTags(filePath, (tagErr: any, tags: string[]) => {
if (tagErr) {
console.log('tags error!!!');
extractMetaCallback(imageElement);
}
console.log('tags found:');
console.log(tags);
if (tags.length) {
imageElement.tags = tags;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️⚠️⚠️ I think this will overwrite any user entered tags if you move the file within the video folder! ⚠️⚠️⚠️

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch! 👀

This code is WIP placeholder just to test out the library.

Thank you for adding the note -- I'll definitely not forget to fix it before merging 🤝

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm planning on adding my .tag file support after this, so we can probably make a nice way to implement both! 👍

}
extractMetaCallback(imageElement);
});
} else {
extractMetaCallback(imageElement);
}

}
});
}
Expand Down
11 changes: 9 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"@ngx-translate/core": "12.1.1",
"fuse.js": "3.4.6",
"ngx-virtual-scroller": "4.0.2",
"osx-tag": "0.4.1",
"trash": "6.1.1"
},
"devDependencies": {
Expand Down