Metadata agents for exported XBMC library

scanner-agent-dev

#1

If you already have metadata in XBMC, and would like to use that in Plex.

I took the [code posted by Harley Hooligan](http://forums.plexapp.com/index.php/topic/16293-nfo-agent/page__view__findpost__p__97610), and changed it to work with my files.

In XBMC, go in Settings > Videos > Library > Export Video Library. Choose Separate files & Export Thumbnails and fanart, and optionally overwrite existing files.
This will create .nfo & .jpg files for your TV Shows and Movies, in the appropriate directories.

The following Plex Plug-ins will then import those into your Plex library.

To use them in Plex, first install them: unzip both files, rename them to end with .bundle, and move both .bundle packages into ~/Library/Application Support/Plex Media Server/Plug-ins/

Image%202012.04.14%206:40:12%20.png

Then, create a new section (or edit an existing one), and choose "XBMC .nfo importer" as the Primary metadata agent.

Image%202012.04.14%206:56:06%20.png or Image%202012.04.14%207:02:42%20.png

Note: For TV Shows sections, the folder(s) you choose in your section settings should be a folder that contains TV shows folders. i.e. adding a folder that contains media files will NOT work!

Good:
Screen%20Shot%202012-07-08%20at%2011.16.

Bad:
Screen%20Shot%202012-07-08%20at%2011.18.

What it will import:
- Title, summary, tagline, rating, year, director, actors, genre, etc. from .nfo files.
- Artwork files: posters, banners & fanarts.

[XBMC Movies Metadata Agent](https://github.com/gboudreau/XBMCnfoMoviesImporter.bundle/archive/master.zip)
[XBMC TV Shows Metadata Agent](https://github.com/gboudreau/XBMCnfoTVImporter.bundle/archive/master.zip)

The source is available on Github, so anyone who would like to make changes can fork my branch, and submit a pull request with their change(s).

Movies agent: https://github.com/gboudreau/XBMCnfoMoviesImporter.bundle
TV Shows agent: https://github.com/gboudreau/XBMCnfoTVImporter.bundle


How to load actor images from local disk?
How do you manage your media's (naming convention and metadata)?
Media info/get xml now completely AWOL
What happened to "first aired date" on the episode summary screen?
Populating database with data from webscraper
Plex Server seeing '/' character in collection name as seperate collections
#2

Very nice, thanks for writing it!


#3

Great, it works fine except for the duration/runtime...



Any hints?



Thanks


#4

[quote name='chander' timestamp='1331764251' post='246395']
Great, it works fine except for the duration/runtime...

Any hints?

[/quote]


For movies, or TV Shows?



If for movies: Can you open one of the .nfo that doesn't work with the duration, and look for the tag, and tell me what you have in there?



If for TV ShowsL I see it uses the tag, which doesn't make sense! But then, there is no duration or runtime tags in the nfos I have for TV Shows episodes...

But there is one (runtime) in the tvshow.nfo I have, but it's always empty. What about you? Do you have runtime tags in tvshow.nfo or in your episodes .nfo?

If you have runtimes in your episodes nfo, just re-download the latest zip from Github, and replace it. That should fix your problem.


#5

Thanks for your quick answer, let's try to fix this.



First, for movies: here is the beginning of .nfo that doesn't work for duration:



<?xml version="1.0" encoding="utf-8"?>



tt0086606

8 Diagram Pole Fighter

8 Diagram Pole Fighter

1984

17 February 1984

0

Hong Kong

7.6

697

Rated PG-13

Martial Arts

Shaw Brothers

Chia-Liang Liu

93



I've done many tests with all my movies but duration always returning "0:00" in the latest Plex client (mediastream or retroflex skin).



Hope that helps...


#6

I've just checked the sqlite plex database after applying the nfo importer and it appears that the duration is still in minutes (93) rather than in ms (93*60000=5580000). Plex understand only ms for duration, the bug is here. Just multiplying by 60000 and it works:



metadata.duration = int(re.compile('^([0-9]+)').findall(runtime)[0]) * 60 * 1000


#7

I've also added a line for importing the original title:



# Original Title<br />
try: metadata.original_title = nfoXML.xpath('./originaltitle')[0].text<br />
except: pass





And just pasted & modified the genres parser for the countries tags:



#countries<br />
try: <br />
    countries = nfoXML.xpath('./country')<br />
    metadata.countries.clear()<br />
    for countryXML in countries:<br />
        cs = countryXML.text.split("/")<br />
        if cs != "":<br />
            for c in cs:<br />
                metadata.countries.add(c)<br />
except: pass





Also modified the directors parser cause just the first one was taken:



#director<br />
try: <br />
    directors = nfoXML.xpath('./director')<br />
    metadata.directors.clear()<br />
    for directorXML in directors:<br />
        ds = directorXML.text.split("/")<br />
        if ds != "":<br />
            for d in ds:<br />
                metadata.directors.add(d)<br />
except: pass





Now, i'm trying to import the release date (originally_available_at) and the sort title tags but i need your help cause i'm really a total noob with python...



Thanks anyway.


#8

[quote name='chander' timestamp='1331806472' post='246515']
Now, i'm trying to import the release date (originally_available_at) and the sort title tags but i need your help cause i'm really a total noob with python...

[/quote]




<br />
try:<br />
    try:<br />
        release_date = time.strptime(nfoXML.xpath("releasedate")[0].text, "%d %B %Y")<br />
    except:<br />
        release_date = time.strptime(nfoXML.xpath("releasedate")[0].text, "%Y-%m-%d")<br />
    if release_date:<br />
        metadata.originally_available_at = datetime.datetime.fromtimestamp(time.mktime(release_date)).date()<br />
except: pass<br />






I also added your code for country, director & original_title, and fixed duration. It all in Github now.

Thanks for the help here.


#9

I don't really know why but if you move the clearing line for genres/directors/countries (metadata.directors.clear()...) like you do in your last modifications on github, you only get one country, one director or one genre. Replacing the clearing lines and all works perfectly...


#10

Hello, have been waiting for a reliable agent for local metadata for some time and had high hopes for this one. The agent for movie NFO files works perfectly, however, the TV scraper for local metadata pulls nothing. No images, no metadata...zilch.



I do not use Plex, but have been waiting to use it for some time...the use of local metadata being my only reservation at the moment. I have looked into the logs, but am not really sure what I am looking for. The series and containing files are there and discovered, just no metadata or images. My structure is as follows:



/Seriesname

- tvshow.nfo

- fanart.jpg

- season##.tbn

/Season #

- #x## - episodename.ext

- #x## - episodename.nfo

- #x## - episodename.tbn



Using the TVDB agent, my TV is picked up fine, but I have a very large collection with many incomplete series, so I would rather use my local files. If there is anything specific I can provide, I will do so. I am on the very latest Plex Media Server available for download (as of yesterday 3/21).


#11

Hi I had a play with this yesterday as I only just found it. I noticed it didn't support tv shows in season folders.



But I had a hack around in code file and managed to add support for it. It's fairly simple, but I think someone who can actually write python should have a go, and I've done it fairly messily as I don't understand how variables etc work.


#12

[quote name='psycik' timestamp='1332442241' post='248272']


Hi I had a play with this yesterday as I only just found it. I noticed it didn't support tv shows in season folders.



But I had a hack around in code file and managed to add support for it. It's fairly simple, but I think someone who can actually write python should have a go, and I've done it fairly messily as I don't understand how variables etc work.

[/quote]




Ah, didn't realize it didn't support season folders...that would explain the problem for me then. I'd be interested in your code though...I've been mucking around with it and got it close, but is not quite there. I don't know python either, but would still like to see your workaround.


#13

[quote name='Cemus' timestamp='1332443704' post='248284']


Ah, didn't realize it didn't support season folders...that would explain the problem for me then. I'd be interested in your code though...I've been mucking around with it and got it close, but is not quite there. I don't know python either, but would still like to see your workaround.

[/quote]






It's really hacky, I'm not proud of it, couldn't get it to keep that Season folders were used from the search to the update, so had to do the test twice. So I wont be putting it up to github. But here's the code file (so you can keep your original) - I've tried to add the season posters as well, but they may be a bit hit and miss. YMMV


#14

[quote name='chander' timestamp='1331814906' post='246529']


I don't really know why but if you move the clearing line for genres/directors/countries (metadata.directors.clear()...) like you do in your last modifications on github, you only get one country, one director or one genre. Replacing the clearing lines and all works perfectly...

[/quote]


I know why. Fixed. :)


#15

[quote name='psycik' timestamp='1332444226' post='248289']


It's really hacky, I'm not proud of it, couldn't get it to keep that Season folders were used from the search to the update, so had to do the test twice. So I wont be putting it up to github. But here's the code file (so you can keep your original) - I've tried to add the season posters as well, but they may be a bit hit and miss. YMMV

[/quote]


I committed something I think should work for you guys on Github.

Let me know if it does or doesn't work.

(I didn't add anything for the seasons thumbs.)


#16

Hi



I install your bundle and select it for scraping i export my xbmc data base to the movie folders but it cant do any thing and dont show movie information or fanarts and pictures please help me

it is one of my info file

thanks

A Love Song for Bobby Long 2004.zip (1.61 KB)


#17

This is a great start -- but it doesn't seem like it will pull metadata from NFOs for DVD or BluRay folder structures (/VIDEO_TS, etc.) -- is that the case or am I doing something wrong?



I've tried:



/Movie/movie.nfo (generic XBMC)

/Movie/VIDEO_TS.nfo (matching subfolder)

/Movie/VIDEO_TS/VTS_01_1.nfo (matching .VOB)



None work. The log just shows the title getting skipped over. Thoughts?


#18

[quote name='Pete_' timestamp='1333308239' post='251370']


This is a great start -- but it doesn't seem like it will pull metadata from NFOs for DVD or BluRay folder structures (/VIDEO_TS, etc.) -- is that the case or am I doing something wrong?



I've tried:



/Movie/movie.nfo (generic XBMC)

/Movie/VIDEO_TS.nfo (matching subfolder)

/Movie/VIDEO_TS/VTS_01_1.nfo (matching .VOB)



None work. The log just shows the title getting skipped over. Thoughts?

[/quote]


My XBMC exported the following files for the VIDEO_TS folders I have:

- Movie Name/VIDEO_TS/VIDEO_TS.nfo

- Movie Name/VIDEO_TS/VIDEO_TS.tbn

- Movie Name/VIDEO_TS/VIDEO_TS-fanart.jpg



Plex, using this plugin, seems to use those without problems, since the media file it lists for those folders is VIDEO_TS.IFO


#19

I don't know if its because Im using Yet Another Media Manager to scrape for my nfo files, but all I'm getting is the title, year and cover for my media. This shouldnt be a problem because the program states that it pulls .nfo files for the purpose of XBMC consumption. Anyone have any ideas as to what I'm doing wrong?



edit: I just realized that all of my movie nfos are named movie.nfo, not actually matching the video file name. Could this be causing the problem?


#20

[quote name='Guillaume Boudreau' timestamp='1332472162' post='248405']


I committed something I think should work for you guys on Github.

Let me know if it does or doesn't work.

(I didn't add anything for the seasons thumbs.)

[/quote]




I tried using the script and everything runs great except for artwork for season folders still. I tried psycik's script as well but no luck with that either. Any suggestions?