so far I have been unable to reproduce this, atrus. Could you re-run the command adding in the flag ‘-vv’. This basically turns on ‘debug’ mode which will output a lot more stuff which will at least help us narrow down which file is causing the errors. My biggest difficulty has actually been to get plex to downloads subs for my files, as none of them are matching the ones it seems the opensubtitles and podnaspi have matches for… Any tips on that front?
Very interesting, I’m just about to convert my library to .mkv, so I will be able to help test this on that front in a few days.
Here’s what I get, with -vv enabled
Traceback (most recent call last):
File “./plexmediatagger.py”, line 260, in
sys.exit(main())
File “./plexmediatagger.py”, line 221, in main
section_processor.process_section(section_element)
File “/Users/ndawson/PlexMediaTagger/SectionProcessor.py”, line 43, in process_section
self.process_show_section_element(section_element)
File “/Users/ndawson/PlexMediaTagger/SectionProcessor.py”, line 166, in process_show_section_element
self.process_season_section_element(show_item)
File “/Users/ndawson/PlexMediaTagger/SectionProcessor.py”, line 180, in process_season_section_element
self.process_episode_section_element(season_item)
File “/Users/ndawson/PlexMediaTagger/SectionProcessor.py”, line 198, in process_episode_section_element
threading.Thread(None, self.process_video(full_episode_item)).start()
File “/Users/ndawson/PlexMediaTagger/SectionProcessor.py”, line 207, in process_video
video_item_processor.process()
File “/Users/ndawson/PlexMediaTagger/VideoItemProcessor.py”, line 372, in process
if self.opts.tag and self.canTag(part_item) and self.shouldTag(part_item):
File “/Users/ndawson/PlexMediaTagger/VideoItemProcessor.py”, line 41, in shouldTag
comment_tag_contents = self.getFileCommentTagContents(part_item)
File “/Users/ndawson/PlexMediaTagger/VideoItemProcessor.py”, line 96, in getFileCommentTagContents
result = subprocess.Popen(get_tags_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0]
File “/usr/lib/python2.7/subprocess.py”, line 679, in init
errread, errwrite)
File “/usr/lib/python2.7/subprocess.py”, line 1249, in _execute_child
raise child_exception
OSError: [Errno 8] Exec format error
Sorry to see you are having trouble, SpaceBass. I need a bit more information to find out what the issue could be.
1. What platform/OS are you running the script on?
2. What was the full command you ran?
3. I need more of the output prior to the error (especially what resources the script was requesting. this should be printed out to the console when the double v flag is passed in (enables debug mode)).
That should at least get us started :) Feel free to send me a personal message if you prefer not to share these details with the board.
Have made progress by using the script on my mac - works quite well!
Is there a way to automate adding meta data and to new files and then automatically add them into iTunes?
Yes, to at least parts of your question 
Lets split them up and deal with them separately.
- Automatic:
Sounds like you want to use the “batch” mode by supplying
-b, --batch
.
2. add metadata:
use
-t, --tag
(by itself will only update non previously tagged files)
3. add to iTunes:
How about the
--add-to-itunes
flag, sounds like it would do the right thing 
So so far we have:
./plexmediatagger --batch --tag --add-to-itunes
Ok, so as long as you want your entire library in iTunes, the above will work. BUT it will "processes" your entire plex library on each and every execution. If we wanted to try and be a bit more smart about it, you will have to pass in some variables from whatever just downloaded the file/added the file. For example, if the filename of the file you just added has the show name or movie title in it, we can narrow the scope of what the script will do.
Let's say you added a tv show episode (Lost S01E01), and you keep all your tv episodes in one plex section called TV. We could then run the script with:
./plexmediatagger --batch --tag --add-to-itunes --batch-breadcrumb="TV>Lost>1"
This will then only processes items in a section who's name contains "tv", any show within that section with a name that contains "lost", and any season name who contains "1". Obviously, if we had parts of the episode name we could use that to narrow it even further. If we are certain it's a tv show episode, we could also add:
./plexmediatagger --batch --tag --add-to-itunes --batch-breadcrumb="TV>Lost>1" --batch-mediatype=show
which would only find sections who's type is TV Show who's name contains "tv" :)
My suggestion would be to use the
-d, --dry-run
flag to stop the script from actually making any changes, and then play around with the flags to see if you can get it to do what you want. You could also add in the
-q, --quiet
if you want to reduce the amount of console spew 
If there was a way for the PMS to have a “plugin” that got activated each time a new file was added, we could obviously improve this workflow a lot, but unfortunately I don’t think that currently is possible.
Let me know if there is a specific case that you don’t think the flags allow you to do, and we can discuss how to solve that!
Thanks for this !!! Would it be possible to not only export the subtitles but to able to merge it back in? So then you can have embedded subs within itunes and no need for your srt file? So I guess after the subtitle gets exported you could run something like SublerCLI -source $SRT -dest $OUT.
I am also having issues with breadcrumbs. I basically would like to just run it against that movie.
<br />
$ ./plexmediatagger.py -v -b --tag --remove-tags --optimize --batch-breadcrumb='The Tall Man' --subtitles --batch-mediatype=movie<br />
WARNING, TAGS WILL BE REMOVED PERMANENTLY<br />
===================================================================================================== Plex Media Tagger Started ======================================================================================================<br />
Connecting to PMS at localhost:32400<br />
Processing sections<br />
Processing section 1/2 : 'Movies' ====================================================================================================================================================================================================<br />
Skipping 'Movies' because it does not match breadcrumb 'The Tall Man'<br />
Processing section 2/2 : 'TV Shows' ==================================================================================================================================================================================================<br />
Skipping 'TV Shows' because it is not of type 'movie'<br />
Processing sections completed<br />
==================================================================================================== Plex Media Tagger Completed =====================================================================================================<br />
Parts processed: 0<br />
Execution Duration: 0:00:00
Also tried:
<br />
$ ./plexmediatagger.py -v -b --tag --remove-tags --optimize --batch-breadcrumb='Movies>The Tall Man' --subtitles --batch-mediatype=movie<br />
WARNING, TAGS WILL BE REMOVED PERMANENTLY<br />
===================================================================================================== Plex Media Tagger Started ======================================================================================================<br />
Connecting to PMS at localhost:32400<br />
Processing sections<br />
Processing section 1/2 : 'Movies' ====================================================================================================================================================================================================<br />
Skipping 'Movies' because it does not match breadcrumb 'Movies'<br />
Processing section 2/2 : 'TV Shows' ==================================================================================================================================================================================================<br />
Skipping 'TV Shows' because it is not of type 'movie'<br />
Processing sections completed<br />
==================================================================================================== Plex Media Tagger Completed =====================================================================================================<br />
Parts processed: 0<br />
Execution Duration: 0:00:00
Any help would be appreciated.
That's an excellent idea. I didn't know subler supported embedding srt files.
This definitely looks like a bug. Could you try running (double v to give even further output):
./plexmediatagger.py -vv -b --tag --remove-tags --optimize --batch-breadcrumb='Movies>The Tall Man' --subtitles --batch-mediatype=movie
Also, as a temporary workaround, try:
./plexmediatagger.py -v -b --tag --remove-tags --optimize --batch-breadcrumb='Movies>The Tall Man' --subtitles
Not much different
$ ./plexmediatagger.py -vv -b --tag --remove-tags --optimize --batch-breadcrumb='Movies>The Tall Man' --subtitles --batch-mediatype=movie<br />
WARNING, TAGS WILL BE REMOVED PERMANENTLY<br />
=================================================================================================== Plex Media Tagger Started ====================================================================================================<br />
Connecting to PMS at localhost:32400<br />
Get contents: http://localhost:32400/library/sections<br />
Processing sections<br />
Processing section 1/2 : 'Movies' ================================================================================================================================================================================================<br />
Skipping 'Movies' because it does not match breadcrumb 'Movies'<br />
Processing section 2/2 : 'TV' ====================================================================================================================================================================================================<br />
Skipping 'TV' because it is not of type 'movie'<br />
Processing sections completed<br />
================================================================================================== Plex Media Tagger Completed ===================================================================================================<br />
Parts processed: 0<br />
Execution Duration: 0:00:00
$ ./plexmediatagger.py -v -b --tag --remove-tags --optimize --batch-breadcrumb='Movies>The Tall Man' --subtitles<br />
WARNING, TAGS WILL BE REMOVED PERMANENTLY<br />
=================================================================================================== Plex Media Tagger Started ====================================================================================================<br />
Connecting to PMS at localhost:32400<br />
Processing sections<br />
Processing section 1/2 : 'Movies' ================================================================================================================================================================================================<br />
Skipping 'Movies' because it does not match breadcrumb 'Movies'<br />
Processing section 2/2 : 'TV' ====================================================================================================================================================================================================<br />
Skipping 'TV' because it does not match breadcrumb 'Movies'<br />
Processing sections completed<br />
================================================================================================== Plex Media Tagger Completed ===================================================================================================<br />
Parts processed: 0<br />
Execution Duration: 0:00:00
Yeah I like that "merge" feature. Allows you have subs without having the srt file around. Also helps when other players can't read srt files. Heads up the latest version of sublercli options has changed a bit.
So after testing some more it works if you do it in all in lower case.
<br />
./plexmediatagger.py -vv -b --tag --remove-tags --optimize --batch-breadcrumb='movies>the tall man' --subtitles --batch-mediatype=movie
Thanks for the debugging. I have pushed a fix (untested as I am at work). Could you update your copy of the script and give it a go with your original command?
I will take a look at the "new" SublerCLI and look into adding an option to merge the subs back in. Remind me in a week if I haven't reported back.
The section part 'movies>The Tall Man' still had to be lower case. Btw what does that stuff in comments mean "{Comments:I_T_U_N_E_S::::R_74::::PC_0::::D_1350948106}" ??
Thanks for testing. I think I just put in a fix that will actually make the case of the breadcrumb work as intended (case insensitive matching).
This
Comments:I_T_U_N_E_S::::R_74::::PC_0::::D_1350948106
is in the script split by
::::
So the records are:
I_T_U_N_E_S
marks the line that the script has used (it tries to preserve current comment if present)
R_74
rating value (i.e. how good people think the movie is) from plex
PC_0
play count in plex
D_1350948106
date metadata in plex was updated for this item
These are stored in the comment field because there isn’t a metadata field in the mp4 spec to hold rating and play count. So the only way to get those into iTunes (unless you use the
--add-to-itunes
flag in the script (which didn’t used to be there)) is to embed the data into the comment field, and then later run one of the attached iTunes script to move the data from the comment field to the rating and play count fields in iTunes (which are held in the iTunes DB rather than in the individual files metadata). Make sense? ![]()
Thanks that does make sense. Will test some more and will let you know.
I'm having trouble getting plex to download subtitles. Does it require me to have pirated episodes so that the hashes will match online sources (as I don't really have any of those)?
Any suggestions how I can get plex to download subs?
I use the podnapsi metadata agent https://github.com/Coi-l/PodnapisiSubtitles.bundle which I believe uses name and not hashes.
So I’ve managed to get one episode to download subs. I had to add the name of a “release group” to the end of my episode filename to get it to find anything. That should at least be enough to let me implement support for this stuff. Expect some changes over the weekend, and then I’ll probably need some help testing 
hmm maybe I used the patch to it which does not require the release group. Sorry I don’t remember exactly what I did. I guess I could look at the code and compare. I do recall on the forum couple of people added patches for it.