Please enable 'Use embedded tags' in Photo libraries

Can you share this script?

Hi everybody,

I made some changes to the script and removed some dependecies and made it public:

See the README for details how get it running.

It needs local access to the photos. So a local instance is best.
In my installation it runs on the same machine as Plex (Qnap NAS) inside a Docker Container.

It searches for lightroom xmp data in the JPEG images. Other data is not parsed at the moment but could be integrated.

2 Likes

@andreasrehbein Thank you for this very timely script. I tested it out tonight and it works like a champ.

There is this great SW https://tagthatphoto.com/ that does face recognition extremly well and fast, and add XMP tags.
What about parsing these tags? One could search its plex photo collection by people name.

That is exactly what I’m doing. Importing the tagged facial recognition from tag that photo into Plex tags

and how do you do that ?
by default, it seems these tags are not recognized in Plex

I used @andreasrehbein’s script to pull the tag from the photo after TagThatPhoto embedded it in the image.

My script uses the Plex api to update the tags. You can put in tags by hand using the webpage. The script automates this process by reading the embedded tags in the xmp data included in the jpeg image and putting these tags into Plex.
You need some knowledge to set it up but it is not to complicated. I may put some additional information in the github repo.

The script reads xmp data from Lightroom. Other software may put the data in other xmp structures (other keywords). But this is not difficult to add to the script. I can do that but I need some image files with embedded xmp from other software.

1 Like

Hello @andreasrehbein. I have no programmer or Python experience but spent some time yesterday learning. I was able to successfully use your script to add a few Lightroom photo tags to Plex photo tags…YAY!!!

However, some of my Lightroom photos have tags (i.e. those with faces) but others do not (i.e. scenes with no people). When the script encounters a Lightroom photo with no tags it throws an error as follows:

Traceback (most recent call last):

File “C:\Users\eedac\AppData\Local\Programs\Python\Python38\pptag.py”, line 261, in
loopThroughAllPhotos()

File “C:\Users\eedac\AppData\Local\Programs\Python\Python38\pptag.py”, line 211, in loopThroughAllPhotos
updateTagsAndRating(key, src)

File “C:\Users\eedac\AppData\Local\Programs\Python\Python38\pptag.py”, line 154, in updateTagsAndRating
parsedXMP = parse_xmp_for_lightroom_tags(xml)

File “C:\Users\eedac\AppData\Local\Programs\Python\Python38\lightroomTags.py”, line 19, in parse_xmp_for_lightroom_tags
subject = desc.getElementsByTagName(‘dc:subject’)[0]
IndexError: list index out of range

I looked at the def_get_elements_by_tagName_help routine where the error occurs, but the code is too complex for me to figure out a way to trap and avoid the error from occurring.

def _get_elements_by_tagName_helper(parent, name, rc):
for node in parent.childNodes:
if node.nodeType == Node.ELEMENT_NODE and
(name == “*” or node.tagName == name):
rc.append(node)
_get_elements_by_tagName_helper(node, name, rc)
return rc

Any assistance or advice that you could provide for me to get past this would be MUCH appreciated!

I’m excited to finally have Lightroom tags in PLEX!

Thank you

Hallo @EEDacho,

Sorry, as all images of my collection have tags, I did not ran into this issue. I will fix this in the next days when I have time.

No worries…especially given the situation these days. Thank you.

i can not use it in windows,i dont know why,shows error like that:
C:\Users\Timmy-home>python3 D:\ppTag-master\pptag.py
Traceback (most recent call last):
File “D:\ppTag-master\pptag.py”, line 257, in
p = plexUsers()
File “D:\ppTag-master\plexUsers.py”, line 143, in init
if user[’@title’] in self.USERDATA.keys():
TypeError: string indices must be integers

Hi @timmyhome,

As it is a simply script without lots of error checking there is no check for a valid Plex login. I think the error in your case is that the script gets no data from the server, so please check again your token.
When I have time I will add some error checking there.

Thank you for your reply. I don’t know why. When I open a guest account in the plex, It can start scanning the photos, but shows all the photos are unreadable. If I close the guest account, this error will appear. I don’t know if it’s because I have this character “-” in my user name,but after I change my user name and password, the problem still exists.Anyway, I can’t solve this problem.

Hi @timmyhome, I had a similar problem initially and found the problem was with my parameters in plexUsers.py. Perhaps this will help…

  1. Populate PLEX_LOGIN and PLEX_PASS with your plex pass info
  2. Run the pptag.py script, it will finish with a line mentioning your PLEX_TOKEN. Update PLEX_TOKEN in plexUsers.py
  3. Update USERDATA with your login id. In my case my param looks like this: USERDATA = { ‘EEDacho’: ‘’ }

Until I got the following info correct I ran into similar error as you…

  1. Update SERVERNAME. If you’re not sure what it is, go to PLEX, Settings, General, and find “Friendly Name” (in my case “EEDNAS”). My param looks like this: SERVERNAME = ‘EEDNAS’
  2. I am hosting my server on Windows-10 and my photo library is called “Photos-ALL”. My param looks like this: PHOTOS_LIBRARY_PATH = ‘/share/Photos-ALL/’

Not sure if this is your problem but hopefully it helps!

Hi @timmyhome and @EEDacho,

the instructions are correct.
The 3rd step is only needed if you want to include ratings from lightroom. In Plex all ratings are user based and as such you need the Plex user names and pin numbers for all users you want to update the ratings.

Yes, the SERVERNAME needs to be the one of your plex server. Otherwise the script can not gather the needed information from the Plex API.

The path of photo library (look in you setup in Plex) needs to be defined in PHOTOS_LIBRARY_PATH. Make sure that it is correct. Under Linux (or NAS) it is typically something like “/share/”. In Windows it could be completly different.
Just look inside Plex. -> Manage Library -> Edit -> Add Folder. There you find the path.

Hi @EEDacho,

I’ve just added the check for missing tags in the latest version.

Thanks for your help. But Its still display the error after I follow your steps. My system is also using win10.error:
Traceback (most recent call last):
File “D:\ppTag-master\pptag.py”, line 257, in
p = plexUsers()
File “D:\ppTag-master\plexUsers.py”, line 143, in init
if user[’@title’] in self.USERDATA.keys():
TypeError: string indices must be integers

I’ve tried all the ways and still haven’t solved the problem. I can only give it up temporarily and wait for your next update. This is a very useful script, thank you for your contribution.

Hi @timmyhome,

The user variable is returned from the plex api and is always a dict (xml) whose indices are strings.
Windows 10 is not the problem as I test the script on Windows 10.
This error is due to no server response. Could you please put the following into your browser:
https://plex.tv/api/home/users/?X-Plex-Token=<PLEX_TOKEN>

The output should be a xml that lists the users linked to this token. If there are no users than your token is somehow different the usual. I can check for this but you won’t be able to update the ratings of the photos then.