Metadata agents for exported XBMC library

I’m having trouble with tv shows and movies that I have not scrapped from the net. I use Ember Media Manager to scrape and enter all my metadata information. I have TV Shows and Movies that are not in databases like IMBD and TVDB and I have just entered the information manually in Ember but when I try to scrape it with the nfo agent in plex the information does not appear.



I eventually figured out after much frustration that because these shows and movies aren’t from a online database ember has not put an id to them.

I can fix movies eaisly by just going into the nfo file and putting an id in there like this


 <id>MIKADO2011</id>


and it scrapes the information correctly. However this does not work for tv shows as it scrapes the tv show information from the nfo but not the episode information. The actor information also doesn't appear at the tv show level


Edit:
I would like to not that anyone who uses this method to get metadata and edit it in ember, for ember not to overwrite your self put in id's your id's have to confirm to a standard. for movies that standard is having to lower case t's before your id

<id>ttMIKADO2011</id>


and for tv shows that have to be numbers

<id>287537287537</id>


any non confirming id's will either be changed (I have only found this to be the case for movies and not tv shows), or ember will simply remove them (this mostly happens with tv shows.

This hasn't fixed the problem of episode information not showing up in plex though.


2nd Edit:
I eventually figured out (by accident) that if I rename my mp4 files from .mp4 to .m4v it shows the episode information. However this only works for shows using the naming convention of

 Show Name - s##e## - Episode Title 


and not shows named with Plex's datebased convention of

The Colbert Report - 2011-11-15 - Elijah Wood.avi


found here [Date-Based TV Show Shows](http://wiki.plexapp.com/index.php/PlexNine_PMS_Naming_Guide#Date-Based_TV_Show_Shows).

Is there a way to fix this? I can't use the normal s##e## type naming convention for Music Videos as I would be forever renaming the files as soon as I added new files.

Note: it still needs the id number to be able to retrieve the metadata from the nfo files

Hi and First n1 Work



but … in the TV Shows Plugin



first it didn’t work i got just the title … so i took a closer look and i just changed



class xbmcnfo(Agent.TV_Shows):

name = ‘XBMC TV .nfo Importer’

primary_provider = True

languages = [Locale.Language.English] ----->>>> languages = [Locale.Language.NoLanguage]



and now it works fine hope this will helb anyone who isnt English using this Plugin


I changed the file at the source. The packages in the first post are now updated.
I changed this in the Movies plugin, but I guess I forgot do to the same change in the TV Shows plugin. All if well now. Thanks.

Hi Guillaume,



after several weeks of using my PLEX, I updated the server to the newest version (0.9.6.4) and added some movies. After updating the metadata, I got just crap :angry: :frowning:



I deleted all my installation, installed PMS and your importer in the most actual versions again and started from scratch, but I couldn’t get your importer working.



What am I doing?

I generate a new collection and add just one folder for testing (the nfo, tbn files are properly edited (worked before - nothing changed there).



Heres the configuration:

http://www.die-bonns.de/downloads/PLEX/PLEX-XBMC_1.JPG



And that is what I get ;-(

http://www.die-bonns.de/downloads/PLEX/PLEX-XBMC_2.JPG



Attached, please find all the logs. Do you have any glue what is going wrong here?

next try:



I cleaned everything up again and this time, I used a different folder with another collection (which also worked before).



Here are some screenshots:

[spoiler]




[/spoiler]

interestingly, your log finds an ERROR:
[spoiler]
2012-06-22 11:17:21,720 (164c) : CRITICAL (core:337) - Exception in the update function of agent named 'XBMC .nfo Importer', called with guid 'com.plexapp.agents.xbmcnfo://tt?lang=xn' (most recent call last):
File "C:\Users\Administrator\AppData\Local\Plex Media Server\Plug-ins\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\api\agentkit.py", line 895, in _update
agent.update(obj, media, lang)
File "C:\Users\Administrator\AppData\Local\Plex Media Server\Plug-ins\XBMC .nfo Importer.bundle\Contents\Code\__init__.py", line 219, in update
if fanartData:
UnboundLocalError: local variable 'fanartData' referenced before assignment
[/spoiler]

The relevant part in the script is:
[spoiler]
#(local) fanart
if fanartData:
metadata.art[fanartFilename] = Proxy.Media(fanartData)
Log("++++++++++++++++++++++++")
[/spoiler]

Is this just with me?

I marked the two lines out and tried it again. The ERROR is gone, but the effect is the same:

I have three movies with the same poster / Metadata (at least some of it).
These are:

IMAX - Bugs - Abenteuer im Regenwald
IMAX - Deep Sea
IMAX - Hurricane Bayou

As you can see in the screenshot in the first spoiler, they all show up the the PMS as "IMAX: Hurrikan über Louisiana", but with the poster of Bugs

In the log I find several ERRORS:
[spoiler]
2012-06-22 11:42:17,578 (17e0) : DEBUG (core:890) - No shared code to load
2012-06-22 11:42:17,578 (188c) : CRITICAL (core:337) - Function named 'Start' couldn't be found in the current environment
2012-06-22 11:42:17,578 (188c) : INFO (core:472) - Started plug-in
2012-06-22 11:42:17,578 (188c) : DEBUG (socketinterface:137) - Starting socket server
2012-06-22 11:42:17,578 (188c) : DEBUG (core:337) - Created a thread named 'start'
2012-06-22 11:42:17,578 (188c) : INFO (socketinterface:161) - Socket server started on port 50260
2012-06-22 11:42:17,578 (188c) : INFO (pipeinterface:28) - Entering run loop
2012-06-22 11:42:17,578 (188c) : DEBUG (core:337) - Handling request GET /:/prefixes
2012-06-22 11:42:17,578 (188c) : DEBUG (core:337) - Response: 200

2012-06-22 11:42:39,950 (1504) : DEBUG (core:337) - Handling request GET /:/plugins/com.plexapp.agents.xbmcnfo/messaging/function/X0FnZW50S2l0OlVwZGF0ZU1ldGFkYXRh/Y2VyZWFsMQoxCmxpc3QKMApyMAo_/Y2VyZWFsMQoxCmRpY3QKNwpzMgp4bnM0CmxhbmdiMXM1CmZvcmNlbnMxMApwYXJlbnRHVUlEczUKTW92aWVzMTAKbWVkaWFfdHlwZXMzCjE5NnM0CmRiaWRzNDYKY29tLnBsZXhhcHAuYWdlbnRzLnhibWNuZm86Ly90dDAxOTM5MjU%40bGFuZz14bnM0Cmd1aWRzOQp0dDAxOTM5MjVzMgppZHIwCg__
2012-06-22 11:42:39,950 (1504) : DEBUG (model:32) - Loading model with GUID com.plexapp.agents.xbmcnfo://tt0193925?lang=xn
2012-06-22 11:42:39,950 (1504) : ERROR (model:194) - Cannot read model from C:\Users\Administrator\AppData\Local\Plex Media Server\Metadata\Movies\e\d94e05fd034930d6c7693706de540b595367e13.bundle\Contents\com.plexapp.agents.xbmcnfo
2012-06-22 11:42:39,950 (1504) : DEBUG (core:337) - Requesting 'http://127.0.0.1:32400/library/metadata/196/tree'
2012-06-22 11:42:39,964 (1504) : INFO (core:337) - Update called for Movie with id = 196

but interestingly the last error is not just related to the three wrong movies
[/spoiler]

Attached, please find the following files:
The whole log
The NFOs of the three wrong movies + a working one (IMAX Extreme)
The XML download of ":32400/library/sections/11/all"

Within this last XML there you can see, that the Metadata of one of the wrong movies is totally crap:
[spoiler]









[/spoiler]


It seems, that there is anything totally going wrong here. I couldn't see any problem or difference in the NFOs.

It would be really really great, if you could help

Thanks in advance

myhtpc

Try to use the desktop (not web) Media Manager, and in the Metadata Agents Settings (the cogwheel in the toolbar at the top), enable Local Media Assets, and move it above the .nfo importer:


I use the Windows PMS and unfortunately, there isn’t a desktop manager yet.



Within the item XBMC nfo. importer in the scrappe rlisting, I just habe your scapper, nothing else.


That's the problem. The Local Media Assets option needs to be enabled. I don't know why it doesn't appear in the web options and it does in the native client.

I think you can shut down your Plex server, change a XML file, and restart it to have the Local Media Assets option enabled for my .nfo importer.

Look for this file (I don't know where on Windows): .../Plug-in Support/Metadata Combination/com.plexapp.agents.xbmcnfo/Movies.xml
Here's what I have in mine:


<?xml version='1.0' encoding='utf8'?><br />
<combine class="Movie"><br />
  <sources><br />
    <agent>com.plexapp.agents.localmedia</agent><br />
    <agent>com.plexapp.agents.xbmcnfo</agent><br />
  </sources><br />
</combine>


Create the com.plexapp.agents.xbmcnfo folder and Movies.xml file if they don't exist.

thanks for your input. Will check Tomorrow, as I am not at my PC.



Keep you updated Tomorrow.

after 4 hours of searching, testing, reinstalling and almost shortly before throwing my server out of the window, I identified the problem - It’s the IMDB-ID!



In the second test-series, the three movies which didn’t work, had a “tt” in the id.field:



     <watched>False</watched><br />
     <id>tt</id><br />
     <genre>Dokumentation</genre>



Your script is generating a media.id from this field


<br />
# IMDB id<br />
try: media.id = nfoXML.xpath('./id')[0].text<br />
except: pass<br />




which caused the problem as all movies got the same media.id

I marked the two lines out and now it works ;-)

Would it be possible to modify/enhance this section in a way, that "tt" will be ignored (like if ... <> "tt", then ...).
Sorry, but I have no glue about python to write this code for myself;-(

All the Best

myhtpc

Just committed a fix. Re-download to get it.
Also fixed the fanartData & posterData problem.

Guillaume Boudreau you rock.



All works fine now :wink:

First off, thanks for all the work you’ve already put into this project; without it I’m not sure I’d be using Plex right now. Unfortunately I’m stuck running PMS on a windows box right now and I believe my main problem is not being able to enable the Local Media Assets scanner for the xbmcnfo agent. I can’t even get it to show up at all, I only have a disabled, checked option for the xbmc nfo scanner. Everything works great in the getting the metadata out of the nfo file, my problem is with the poster art. I have placed dvd cover art in my file structure but whenever I scan a directory the wide banners are displayed instead.



I have confirmed that everything works fine with the Mac desktop version of PMS by installing the server onto my macbook and scanning in the same directory. Once I had enabled the local media assets everything worked great, the nfo data was read and my local pictures were displayed. I know this may be outside the scope of the plugin developer, but do you have any more hints on how to enable this scanner on the Windows/Web version of PMS, with both Movies and TV Shows as well.



Any help would be appreciated, and thanks again for all you’ve already contributed.


See #69 above on how to manually edit a XML (text) file to include the Local Media Assets option.
Let me know where you found that file, and it you had to create the file and folder (if they existed or not); I'll update the instructions in my first post following your feedback.


Ahh, sorry for not being clear on that. I did follow the instructions, even tried the file supplied by another user, but still no luck. I did have to create the directory as well as the file. The path is (Win7):

C:\Users\\AppData\Local\Plex Media Server\Plug-In Support\Metadata Combination\

and the contents of file 'Movies.xml' is as follows:


<?xml version='1.0' encoding='utf8'?><br />
<combine class="Movie"><br />
  <sources><br />
	<agent>com.plexapp.agents.localmedia</agent><br />
        <agent>com.plexapp.agents.xbmcnfo</agent><br />
  </sources><br />
</combine>




One thing, and correct me because I'm guessing, this would only impact the Movie scanner, so part of my question is; even if/when this works correctly for movies, how would I go about doing the same thing for TV Shows?

Thanks again for all the help, it's much appreciated!

I think I may be able to shed some light on the subject.



If you look at:

Library/Application Support/Plex Media Server/Plug-ins/LocalMedia.bundle/Contents/Code/init.py

(or its equivalent on windows, C:\Users<you>\AppData\Local\Plex Media Server\Plug-ins…)



you will find two troubling lines:


<br />
class localMediaMovie(Agent.Movies):<br />
  name = 'Local Media Assets (Movies)'<br />
...<br />
  contributes_to = ['com.plexapp.agents.imdb', 'com.plexapp.agents.none']<br />




and


<br />
class localMediaTV(Agent.TV_Shows):<br />
  name = 'Local Media Assets (TV)'<br />
...<br />
  contributes_to = ['com.plexapp.agents.thetvdb', 'com.plexapp.agents.none']<br />




In a nutshell, it won't send contribute metadata to the xbmc import method any more. Nothing you do to Movies.xml or TV_Shows.xml is going to connect the two any more and "Local" will never appear. Presumably something has changed in later versions of Plex, and the metadata graph is built dynamically now.

On my copy, I changed the first so that:

<br />
  contributes_to = ['com.plexapp.agents.imdb', 'com.plexapp.agents.xbmcnfo', 'com.plexapp.agents.none']<br />




and the second:

<br />
  contributes_to = ['com.plexapp.agents.thetvdb', 'com.plexapp.agents.xbmcnfotv', 'com.plexapp.agents.none']<br />




With this change I was able to see the "Local Media(TV)" and "Local Media(Movies)" on the preferences dialog for the metadata. You can check the box and make sure they're moved above XBMC.

Repeat.. the change was to ***LocalMedia.bundle*** and not the xbmc agent plugins!

My main interest is to avoid a duplicate thetvdb.com lookup for a large media library. I already have a complete set of local metadata so it's wasteful to have Plex re-query and download the data again. Particularly when thetvdb.com is melting or having serious issues.

I can tell that it's working because of differences in the gathered metadata. eg: no paragraph breaks in descriptive text or missing genre/rating data. My XMBC source data is missing season thumbnails for some shows only, and they don't show up when imported to plex.

I'm not entirely sure if that's an 'export to xbmc' issue or something else. I'm looking into it.

hi



first again tx 4 the awsum work



i got a second folder with series in it sometimes same series with an other season

i am trying to scann the mediqa but i get









INFO (logkit:16) - X:…\ALF\Season01\ALF.S01E01.Hallo, da bin ich.avi

: CRITICAL (core:541) - Exception in the search function of agent named ‘XBMC TV .nfo Importer’, called with keyword arguments {‘openSubtitlesHash’: ‘d347dd11dbe2d402’, ‘episode’: ‘24’, ‘episodic’: ‘1’, ‘show’: ‘Alf’, ‘season’: ‘3’, ‘filename’: ‘X:%…5CALF%2ES03E24%2EDer%20Tramp%2Eavi’, ‘plexHash’: ‘81c9…4fc0b60623’, ‘duration’: ‘13…728’, ‘id’: ‘9960’} (most recent call last):

File “C:…\Plex Media Server\Plug-ins\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\api\agentkit.py”, line 918, in search

agent.search(results, media, lang)

File "C:…\Plex Media Server\Plug-ins\XBMCnfoTV.bundle\Contents\Code_init
.py", line 25, in search

path = os.path.dirname(path1)

AttributeError: ‘module’ object has no attribute ‘path’





the example series isnt double or but gives an error and i cant figure out why cause in info he says he got the path and then not (line 25)?!

pleas help me



tx Sepp


That error seems to point to a problem with your Python... It's saying that os.path doesn't exists... which isn't right.

That line didn't change since the very first version of the plugin, so I don't see why it would have worked before, and wouldn't work now.
There's also no reason why this would work in a folder, and not in another. os.path exists or it doesn't; it doesn't exist just sometimes!
Maybe you ought to post this error in a new post, for developers to look at.
Maybe a new thread titled "os.path.dirname call returns AttributeError: 'module' object has no attribute 'path'".
Elan (or another dev?) might be able to chip in with an idea why that could happen...

Hi again Thanks for ur answer



so i restarted reinstalled phyton …



nothing worked kicked old ones out of the lib updated to the newest beta nothing



finaly i erased all of plex reinstalled it and now it scans and seems to work



i dont realy understand why or the problem cause i have taken the phytonconsole and … tryed the code he wanted to execute and it worked but so it seems solved



tip: u can create an symlink to get ur plex database on an other haddrive …

ok scan complete now everything seems to work exept : the tv show season pictures aren’t displayed all episodes searies pics are working well but the other dont



someone with the same problem ??? i am using plex 9.6.5



tx seppl