NFO agent

Thanks Harley, understood.



I’m encountering an issue with some mp4 files. Can you make heads or tails of this error log? Is it my files that are the problem or is it the nfo importer? Everything else is working fine.



<br />
2011-01-17 22:56:35,969 (-4faed000) :  CRITICAL (core) - Exception in the search function of agent named 'XBMC .nfo Importer', called with keyword arguments {'openSubtitlesHash': 'd7ce87bcda7b6eaf', 'name': 'Batman Forever', 'filename': '%2FVolumes%2FElements2%%2Fbatman%20Forever%281995%29%2Emp4', 'plexHash': '8ef06b8c18a74066bd4878676884e97380efbcd2', 'duration': '5949000', 'id': '1325'} (most recent call last):<br />
  File "/Users/scott/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/api/agentkit.py", line 641, in _search<br />
    agent.search(results, media, lang)<br />
  File "/Users/scott/Library/Application Support/Plex Media Server/Plug-ins/xbmcnfo.bundle/Contents/Code/__init__.py", line 46, in search<br />
    nfoXML = XML.ElementFromString(nfoText).xpath('//movie')[0]<br />
  File "/Users/scott/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/api/parsekit.py", line 115, in ElementFromString<br />
    return self._core.data.xml.from_string(string, isHTML, encoding)<br />
  File "/Users/scott/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/data.py", line 137, in from_string<br />
    return etree.fromstring(markup)<br />
  File "lxml.etree.pyx", line 2435, in lxml.etree.fromstring (src/lxml/lxml.etree.c:24170)<br />
  File "parser.pxi", line 1511, in lxml.etree._parseMemoryDocument (src/lxml/lxml.etree.c:64170)<br />
  File "parser.pxi", line 1390, in lxml.etree._parseDoc (src/lxml/lxml.etree.c:63103)<br />
  File "parser.pxi", line 932, in lxml.etree._BaseParser._parseDoc (src/lxml/lxml.etree.c:60168)<br />
  File "parser.pxi", line 538, in lxml.etree._ParserContext._handleParseResultDoc (src/lxml/lxml.etree.c:56751)<br />
  File "parser.pxi", line 624, in lxml.etree._handleParseResult (src/lxml/lxml.etree.c:57595)<br />
  File "parser.pxi", line 564, in lxml.etree._raiseParseError (src/lxml/lxml.etree.c:56993)<br />
XMLSyntaxError: xmlParseEntityRef: no name, line 4, column 50<br />
<br />
2011-01-17 22:56:35,971 (-4faed000) :  DEBUG (core) - Response: 200<br />
2011-01-17 22:56:35,982 (-4e7a1000) :  CRITICAL (core) - Exception in the search function of agent named 'XBMC .nfo Importer', called with keyword arguments {'openSubtitlesHash': 'd7ce87bcda7b6eaf', 'name': 'Batman Forever', 'filename': '%2FVolumes%2FElements2%%2Fbatman%20Forever%281995%29%2Emp4', 'plexHash': '8ef06b8c18a74066bd4878676884e97380efbcd2', 'duration': '5949000', 'id': '1325'} (most recent call last):<br />
  File "/Users/scott/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/api/agentkit.py", line 641, in _search<br />
    agent.search(results, media, lang)<br />
  File "/Users/scott/Library/Application Support/Plex Media Server/Plug-ins/xbmcnfo.bundle/Contents/Code/__init__.py", line 46, in search<br />
    nfoXML = XML.ElementFromString(nfoText).xpath('//movie')[0]<br />
  File "/Users/scott/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/api/parsekit.py", line 115, in ElementFromString<br />
    return self._core.data.xml.from_string(string, isHTML, encoding)<br />
  File "/Users/scott/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/data.py", line 137, in from_string<br />
    return etree.fromstring(markup)<br />
  File "lxml.etree.pyx", line 2435, in lxml.etree.fromstring (src/lxml/lxml.etree.c:24170)<br />
  File "parser.pxi", line 1511, in lxml.etree._parseMemoryDocument (src/lxml/lxml.etree.c:64170)<br />
  File "parser.pxi", line 1390, in lxml.etree._parseDoc (src/lxml/lxml.etree.c:63103)<br />
  File "parser.pxi", line 932, in lxml.etree._BaseParser._parseDoc (src/lxml/lxml.etree.c:60168)<br />
  File "parser.pxi", line 538, in lxml.etree._ParserContext._handleParseResultDoc (src/lxml/lxml.etree.c:56751)<br />
  File "parser.pxi", line 624, in lxml.etree._handleParseResult (src/lxml/lxml.etree.c:57595)<br />
  File "parser.pxi", line 564, in lxml.etree._raiseParseError (src/lxml/lxml.etree.c:56993)<br />
XMLSyntaxError: xmlParseEntityRef: no name, line 4, column 50<br />
<br />
2011-01-17 22:56:35,984 (-4e7a1000) :  DEBUG (core) - Response: 200<br />
 

nfoXML = XML.ElementFromString(nfoText).xpath(’//movie’)[0]





This line is the problem. In you nfo file, make sure you have something inside of Movie Name

First of all I’d just like to say thank you for this great little plugin which has made my life much easier now that I don’t need to edit the meta data by hand, but I was wondering if it would be possible to import the sort title from the nfo as well as the normal title so that my movies will order correctly. At the moment the sort title is updated but it’s identical to the normal one.

Currently, sorttitle is not available to set in the metadata at this time. WHen it becomes available, I’ll add it.



Thank you.


I thought I would share my version of the NFO agent. It is based on the work by Harley, but I've tried to simplify the code a bit.

It is a secondary scanner so you need to use the Freebase agent as the primary agent. You can also use it in combination with the Personal Media agent - therefore, I don't see the need for an primary NFO agent...

It requires you to have a movie file with the name "moviename (year).ext" and a nfo file with the name "moviename (year).nfo" in the same folder. The nfo file should at least contain the following:


<?xml version="1.0" encoding="UTF-8"?><br />
<movie><br />
<title>Movie title</title><br />
</movie><br />



My nfo files also contain elements such as


<collection>Star Wars</collection><br />
<rating>8.1</rating><br />
<mpaa>PG-13</mpaa>



Also, if you included the IMDB id in the nfo like this


<id>tt1234567</id>


Plex will have an easier time matching your movies.

Looking at the code, it should be quite easy for anyone to modify it to their hearts desires. For example, because I keep my movies on separate external hard disks, which I attach when I want to watch a movie, I've included a


<disk>Disk 1</disk>


element in my nfo files. Then in the agent code I've changed this line


try: metadata.tagline=nfoXML.xpath('./tagline')[0].text


to this


try: metadata.tagline=nfoXML.xpath('./disk')[0].text


This will have Plex show "Disk 1" as the tagline, just below the title of the movie in the client (Info List view).

Put the attached bundle into this folder:


~/Library/Application Support/Plex Media Server/Plug-Ins


Have fun!

A question for the dev team:

Is it possible to define the Sort Title in this way? I.e. is it possible to update the metadata.sorttitle through agents? In general, it would be nice, if somewhere it could be learned, which metadata items (metadata.*) is exposed to the agents (a simple list of the items would do it)...

I found where you can identify what metadata models are available to you and sadly like you I was looking for some thing for the ‘Sort title’ but there is no template for it thus currently Sort title can not be entered through metadata. Hopefully it will be added down the road, please.



To find the metadata.??? options go to /Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Models/Metadata/ movie_models and common_models both are used for movies.



Chris

If you add sorttitle to that list, then it becomes something you can read in as a form of metadata.sorttitle, but it does not get stored to the actual metadata. Let’s see if we can figure this one out. Whereas before the nfo importer would fail on Log(metadata.sorttitle) now it displays the stored value.

I bet it is actually getting stored, just overwritten when somewhere in the server after our agents plex goes to drop ‘the’ and ‘a’ from titles. I will do some digging. I would love to have the sorttitle in by .nfo.



Chris




Well, this is a general problem. I.e. that we have to figure this out by ourselves. Why is this not documented somewhere? Why doesn't the dev team offer some more help for us DIY'ers? :o


Plex is ■■■■■■ diy'ers! You make few scheckels and people think you owe them the world. When you ■■■■■ next time, don't include my quote.

Err, excuse me? How did I offend you?

I’m over this crap. In my mind sack up or shut up. Stop being fed by the teat of the dev team. And stop the goddamn whining.



Especially don’t bring my quotes into this. I am all about figuring this stuff out, and doing it as a community. Decoding is learning. Maybe we learn enough to come out with an alternative framework. Who knows what could happen. I am over all of this petty " you guys don’t do what I want." bullcrap, You want to know why the dev team isn’t helping? Check out lighthouse.425 open tickets. Do you think HotDog would appreciate the dev team being taken off of his pet projects to help out with this? I doubt it.


I'm sorry, you are making very little sense to me... Care to explain in detail the meaning of what you just wrote?

What I meant to say was (and I’m sorry if I somehow offended you or anyone) that I think that it would be beneficial and helpful for coding amateurs like myself - with a genuine interest in coding something useful for other Plex users to take advantage of - if more documentation was available. Disagree?



1. In this post you ask why the dev team hasn't documented the api anywhere, and why they don't help us out. I can tell you from first hand experience that technical documentation is an afterthought if that. Get over it not being around.
2. You are asking for help not from a closed source software that is PMS. You are asking for help with the open source Framework. The source files are in your plugins folder as we speak. Pop it open, root around. Get your hands dirty. Learn. How did you learn how to write your agent. You popped open my stuff and got your hands dirty. This is fantastic, and I am very excited that you are growing stuff that I started. I get a rush from that.
3. When you ask questions why devs aren't helping out. Oh really? I think they have bigger fish to fry other than sort title.
4. The simple fact that this software doesn't do what I want out of the box is of no issue to me. Plex nine is not useful to me without my plugins. That's why I wrote them. This situation is no different. I could pull a git clone of the framework, modify it, and issue a pull request to add sort title if I knew what needed to be fixed. This is actually my preferred solution. Yes, i posted a request to add it, but I have since rethought my position.

I hope that is clearer.


No I don't disagree, that would be silly. But to say a) that is a problem B) to rehash once again that there is no documentation (maybe not by you specifically but there are threads for that topic already [here](http://www.google.com/search?q=forum.plexapp.com+documentation&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a#hl=en&safe=off&client=firefox-a&hs=uLz&rls=org.mozilla:en-US:official&q=+site:forums.plexapp.com+forum.plexapp.com+documentation&sa=X&ei=YZNETdDRBoO_gQeX7qCbAg&ved=0CB0QrQIwAA&fp=dded8f20a6bb9442)) greatly annoys me.

1. It's not a problem, it's a hurdle.
2. Why rehash things already spoken on. It is not useful or helpful

It is thanks.

What this all boils down to I guess is: I would love to help out (myself and others) by doing some simple coding for agents and plugins. I just don't have the experience and most importantly the time it takes to go through the complicated framework looking for obscure details.

If those details were exposed in some sort of documentation, I (and others I bet) would be able to contribute more to this great project...






And the devs know that they are in a small way hindering their own project by not having documentation. But when your engineers are the very ones best suited to write said documentation, you have to make a priority call. Documentation only comes around at the last minute possible. That's the way of engineering.

Ad 1. Well, IMO, this is one in many hurdles that is limiting Plex (which, to be fair, is great).
Ad 2. I'll always maintain that it is my right to voice my opinion. That you can point to other posts about the problem to me just solidifies my point. You have to cope with that being annoying to you!