Welcome to our forums! Please take a few moments to read through our Community Guidelines (also conveniently linked in the header at the top of each page). There, you'll find guidelines on conduct, tips on getting the help you may be searching for, and more!

Metadata agents for exported XBMC library

gboudreaugboudreau Posts: 70Members, Plex Pass Plex Pass

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

I took the code posted by Harley Hooligan, 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
XBMC TV Shows Metadata Agent

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

Tagged:
«13456757

Comments

  • elanelan Sheriff of Plexville MauiPosts: 9,026Members, Plex Employee, Plex Pass, Plex Ninja Plex Employee
    Very nice, thanks for writing it!
  • chanderchander Posts: 158Members, Plex Pass Plex Pass
    Great, it works fine except for the duration/runtime...

    Any hints?

    Thanks
  • gboudreaugboudreau Posts: 70Members, Plex Pass Plex Pass
    chander wrote:
    Great, it works fine except for the duration/runtime...
    Any hints?

    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 <runtime> tag, and tell me what you have in there?

    If for TV ShowsL I see it uses the <aired> 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.
  • chanderchander Posts: 158Members, Plex Pass Plex Pass
    edited March 2012
    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"?>
    <movie xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <id>tt0086606</id>
    <title>8 Diagram Pole Fighter</title>
    <originaltitle>8 Diagram Pole Fighter</originaltitle>
    <year>1984</year>
    <releasedate>17 February 1984</releasedate>
    <top250>0</top250>
    <country>Hong Kong</country>
    <rating>7.6</rating>
    <votes>697</votes>
    <mpaa>Rated PG-13</mpaa>
    <genre>Martial Arts</genre>
    <studio>Shaw Brothers</studio>
    <director>Chia-Liang Liu</director>
    <runtime>93</runtime>

    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...
  • chanderchander Posts: 158Members, Plex Pass Plex Pass
    edited March 2012
    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
    
  • chanderchander Posts: 158Members, Plex Pass Plex Pass
    edited March 2012
    I've also added a line for importing the original title:

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


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

    #countries
    try: 
    	countries = nfoXML.xpath('./country')
    	metadata.countries.clear()
    	for countryXML in countries:
    		cs = countryXML.text.split("/")
    		if cs &#33;= "":
    			for c in cs:
    				metadata.countries.add(c)
    except: pass
    


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

    #director
    try: 
    	directors = nfoXML.xpath('./director')
    	metadata.directors.clear()
    	for directorXML in directors:
    		ds = directorXML.text.split("/")
    		if ds &#33;= "":
    			for d in ds:
    				metadata.directors.add(d)
    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.
  • gboudreaugboudreau Posts: 70Members, Plex Pass Plex Pass
    edited March 2012
    chander wrote:
    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...


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


    I also added your code for country, director & original_title, and fixed duration. It all in Github now.
    Thanks for the help here.
  • chanderchander Posts: 158Members, Plex Pass Plex Pass
    edited March 2012
    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...
  • CemusCemus Posts: 6Members ✭✭
    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).
  • psycikpsycik Posts: 301Members, Plex Pass Plex Pass
    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.
  • CemusCemus Posts: 6Members ✭✭
    psycik wrote:

    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.


    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.
  • psycikpsycik Posts: 301Members, Plex Pass Plex Pass
    Cemus wrote:

    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.



    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
  • gboudreaugboudreau Posts: 70Members, Plex Pass Plex Pass
    chander wrote:

    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...

    I know why. Fixed. :)
  • gboudreaugboudreau Posts: 70Members, Plex Pass Plex Pass
    psycik wrote:

    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

    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.)
  • aloooiutaloooiut Posts: 1Members
    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
    [attachment=9967:A Love Song for Bobby Long 2004.zip]
  • psouza4psouza4 Posts: 1Members
    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?
  • gboudreaugboudreau Posts: 70Members, Plex Pass Plex Pass
    Pete_ wrote:

    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?

    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
  • ghostknyghtghostknyght Posts: 3Members
    edited April 2012
    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?
  • gwarkylegwarkyle Posts: 2Members, Plex Pass

    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.)


    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?
  • gboudreaugboudreau Posts: 70Members, Plex Pass Plex Pass
    gwarkyle wrote:

    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?

    That's why I said "I didn't add anything for the seasons thumbs."
    Season artworks/thumbs will NOT be imported right now.
    Maybe if you find the documentation where it says where season thumbs are loaded from in XBMC, I might write something when I have some free time.
«13456757
Sign In or Register to comment.