Skip to content
This repository was archived by the owner on Feb 5, 2022. It is now read-only.

Commit 3513573

Browse files
authored
Add files from upload
0 parents  commit 3513573

File tree

11 files changed

+2692
-0
lines changed

11 files changed

+2692
-0
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/*
2+

.eslintrc.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"env": {
3+
"node": true,
4+
"es6": true
5+
},
6+
"extends": "eslint:recommended",
7+
"parserOptions": {
8+
"ecmaVersion": 2017
9+
},
10+
"rules": {
11+
"indent": [
12+
"error",
13+
4,
14+
{
15+
"SwitchCase": 1
16+
}
17+
],
18+
"linebreak-style": [
19+
"error",
20+
"windows"
21+
],
22+
"quotes": [
23+
"error",
24+
"double"
25+
],
26+
"semi": [
27+
"error",
28+
"always"
29+
],
30+
"no-empty": [
31+
"error",
32+
{
33+
"allowEmptyCatch": true
34+
}
35+
],
36+
"no-console": [
37+
"error",
38+
{
39+
"allow": [
40+
"warn",
41+
"error"
42+
]
43+
}
44+
]
45+
}
46+
}

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules/
2+
.vscode/*
3+
database*
4+
dbbrowser*
5+
DBstructure*
6+
package-lock.json

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# plex-ttp
2+
[Plex](http://plex.tv) is an amazing software to organize, stream, and share your personal multimedia collections, including photos.
3+
4+
[Tag That Photo](http://tagthatphoto.com), aka TTP, is an amazing software to recognise faces from your collection of photos.
5+
6+
Unfortunately, Plex does not recognise the XMP tags created by TTP. This script allows one to insert TTP faces recorded into the photos into Plex database.
7+
8+
## Warning
9+
**The script interacts directly with Plex database.**
10+
Make sure you have a [backup of your database](https://support.plex.tv/articles/201539237-backing-up-plex-media-server-data/) before using this script.
11+
In case of any issues, [restore your database](https://support.plex.tv/articles/201539237-backing-up-plex-media-server-data/) !
12+
13+
## Installation
14+
15+
1/ assuming node.js and npm are already installed, install the package as follow:
16+
17+
npm install plex-ttp
18+
19+
## Usage
20+
21+
usage node plex-ttp.js [-s] [-h] [-l tag] [-d tag]
22+
-s : scan images and put face tags into Plex
23+
-l [tag] : list matching tags
24+
-d tag: delete the tag
25+
-h : show this help
26+
27+
28+
**node plex-ttp.js -s** is the basic command to run to scan all photos from our Plex library, extract the tag faces and insert them into Plex. Face names are then available within the [Tag list of Plex](http:plex_screenshot.jpg)
29+
30+
31+
* * *
32+
33+
© 2020 devbab

exif.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
//const exiftool = require("exiftool-vendored").exiftool;
2+
3+
const ExifTool = require("exiftool-vendored").ExifTool;
4+
let numCPUs = require("os").cpus().length;
5+
const exiftool = new ExifTool({
6+
maxProcs: numCPUs
7+
});
8+
9+
// maxProcs: DefaultMaxProcs,
10+
11+
/**
12+
* look for XMP tag and return an array of it
13+
* @param {} filename
14+
* @returns {modif,tags}
15+
*/
16+
function getFromImage(filename) {
17+
// console.log(`getting exif for ${filename}`);
18+
19+
return new Promise(function (resolve, reject) {
20+
exiftool
21+
.read(filename)
22+
.then(tags => {
23+
24+
//console.log("exif tags ",tags);
25+
const d = tags.FileModifyDate;
26+
const modif = new Date(d.year, d.month - 1, d.day, d.hour, d.minute, d.second, 0);
27+
//console.log("fileModifyDate: ",d );
28+
29+
const lat = tags.GPSLatitude;
30+
const lng = tags.GPSLongitude;
31+
let pos = null;
32+
if (lat && lng)
33+
pos = {
34+
lat: lat,
35+
lng: lng
36+
};
37+
38+
let faces = [];
39+
if (Object.prototype.hasOwnProperty.call(tags, "PersonInImage"))
40+
faces = tags.PersonInImage;
41+
42+
resolve({
43+
modif: modif,
44+
faces: faces,
45+
pos: pos,
46+
tags: tags
47+
});
48+
49+
})
50+
.catch(err => {
51+
reject(err);
52+
53+
});
54+
55+
});
56+
57+
}
58+
59+
function end() {
60+
exiftool.end();
61+
}
62+
63+
64+
module.exports = {
65+
getFromImage: getFromImage,
66+
end: end
67+
};

0 commit comments

Comments
 (0)