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

Commit

Permalink
Add files from upload
Browse files Browse the repository at this point in the history
  • Loading branch information
devbab authored Mar 22, 2020
0 parents commit 3513573
Show file tree
Hide file tree
Showing 11 changed files with 2,692 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/*

46 changes: 46 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"env": {
"node": true,
"es6": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2017
},
"rules": {
"indent": [
"error",
4,
{
"SwitchCase": 1
}
],
"linebreak-style": [
"error",
"windows"
],
"quotes": [
"error",
"double"
],
"semi": [
"error",
"always"
],
"no-empty": [
"error",
{
"allowEmptyCatch": true
}
],
"no-console": [
"error",
{
"allow": [
"warn",
"error"
]
}
]
}
}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/
.vscode/*
database*
dbbrowser*
DBstructure*
package-lock.json
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# plex-ttp
[Plex](http://plex.tv) is an amazing software to organize, stream, and share your personal multimedia collections, including photos.

[Tag That Photo](http://tagthatphoto.com), aka TTP, is an amazing software to recognise faces from your collection of photos.

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.

## Warning
**The script interacts directly with Plex database.**
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.
In case of any issues, [restore your database](https://support.plex.tv/articles/201539237-backing-up-plex-media-server-data/) !

## Installation

1/ assuming node.js and npm are already installed, install the package as follow:

npm install plex-ttp

## Usage

usage node plex-ttp.js [-s] [-h] [-l tag] [-d tag]
-s : scan images and put face tags into Plex
-l [tag] : list matching tags
-d tag: delete the tag
-h : show this help


**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)


* * *

© 2020 devbab
67 changes: 67 additions & 0 deletions exif.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//const exiftool = require("exiftool-vendored").exiftool;

const ExifTool = require("exiftool-vendored").ExifTool;
let numCPUs = require("os").cpus().length;
const exiftool = new ExifTool({
maxProcs: numCPUs
});

// maxProcs: DefaultMaxProcs,

/**
* look for XMP tag and return an array of it
* @param {} filename
* @returns {modif,tags}
*/
function getFromImage(filename) {
// console.log(`getting exif for ${filename}`);

return new Promise(function (resolve, reject) {
exiftool
.read(filename)
.then(tags => {

//console.log("exif tags ",tags);
const d = tags.FileModifyDate;
const modif = new Date(d.year, d.month - 1, d.day, d.hour, d.minute, d.second, 0);
//console.log("fileModifyDate: ",d );

const lat = tags.GPSLatitude;
const lng = tags.GPSLongitude;
let pos = null;
if (lat && lng)
pos = {
lat: lat,
lng: lng
};

let faces = [];
if (Object.prototype.hasOwnProperty.call(tags, "PersonInImage"))
faces = tags.PersonInImage;

resolve({
modif: modif,
faces: faces,
pos: pos,
tags: tags
});

})
.catch(err => {
reject(err);

});

});

}

function end() {
exiftool.end();
}


module.exports = {
getFromImage: getFromImage,
end: end
};
Loading

0 comments on commit 3513573

Please sign in to comment.