SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV v7 Customizations > Batch Metadata Tools
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

Batch Metadata Tools This forums is for discussing the user-created Batch Metadata Tools for SageTV.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-18-2012, 07:42 PM
Phydeaux Phydeaux is offline
Sage Advanced User
 
Join Date: Aug 2008
Posts: 222
Use media path for title and season?

I'm sure this has probably come up before, but I'm having no luck searching for the answer. Actually, I'm pretty sure I know what will be involved - MediaTitles.xml - but I have no clue what I'm doing in there...

From SageTV's perspective, all my TV series media files are stored in this kind of structure:


TV Series\
All Creatures Great and Small\
Series 01\
Series 02
Series 03
etc...

The files themselves, using Series 01 of the above example, are named like this:

01 Horse Sense.mkv
02 Dog Days.mkv
03 It Takes All Kinds.mkv
etc....


Note that I'm calling the seasons "series" for UK shows and "seasons" for US shows...

All I want BMT to do is to take the Title from the first level folder name (from the root of TV Series), take the Season from the last two characters of the second level folder, and take the Episode from the first two characters of the filename. So "All Creatures Great and Small S01E01" etc... That should scrape well, shouldn't it?

Possible?

RLW
Reply With Quote
  #2  
Old 11-19-2012, 07:01 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
This is definately possible but it will require a new "scraper". If you are same person that PM'd me, then I alluded that there as well.

Basically a scraper takes a complete filename path and then parses out the relevant pieces of information, including Series, Season, and Episode.

The scrapers for Phoenix/BMT tv files, are located in the SAGE_HOME/STVs/Phoenix/Scrapers/xbmc/tvfilenames/ directory.

If you go there, you'll see a number of existing scrapers, and if you are technical enough, you may be able to create your scraper that matches your directory structure. (It's regex and xml). If you don't feel comfortable doing that, I can certainly help.

Here's the sXXeXX scraper
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!-- 
   TV Filename Scraper.  Used to Scrape Show Name, Season and Episode from a given file URI
   $$1 is always the complete file path
-->
<scraper name="title-s00e00" content="filename" thumb="thumb.png">
        <!--    input:          $1=complete file uri -->
        <!--    returns:        show name -->
        <GetShowName dest="3">
                <RegExp input="$$1" output="\1" dest="3">
                                
                        <expression>.*[/\\](.*)[es]([0-9]{1,2})[sexp]{1,2}([[0-9]]+)</expression>
                </RegExp>
        </GetShowName>

        <!--    input:          $1=complete file uri -->
        <!--    returns:        Season #-->
        <GetSeason dest="3">
                <RegExp input="$$1" output="\2" dest="3">
                        <expression>.*[/\\](.*)[es]([0-9]{1,2})[sexp]{1,2}([[0-9]]+)</expression>
                </RegExp>
        </GetSeason>

        <!--    input:          $1=complete file uri -->
        <!--    returns:        Episode #-->
        <GetEpisode dest="3">
                <RegExp input="$$1" output="\3" dest="3">
                        <expression>.*[/\\](.*)[es]([0-9]{1,2})[sexp]{1,2}([[0-9]]+)</expression>
                </RegExp>
        </GetEpisode>
</scraper>
You can see that there are 3 "functions" in the scraper, GetShowName, GetSeason, and GetEpisode. The input ($$1) is always the complete file path.

This expression is only looking at the filename to pull the information, so your expression will be a little more complex as it will look at the entire directory structure to pull the same information.

Sean.
Reply With Quote
  #3  
Old 11-19-2012, 08:40 AM
Phydeaux Phydeaux is offline
Sage Advanced User
 
Join Date: Aug 2008
Posts: 222
Thank you for clearing up the distinction between what the scraper does vs. customized mediatitles.xml. So it's really the scraper I need to work on. I'll study it and perhaps there is someone here at my work who can assist. If so, I'll post the solution back here. If not... well, it won't be the first time I'll depend on the kindness of others!

Thanks for the hint Sean!

RLW
Reply With Quote
  #4  
Old 11-19-2012, 09:41 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Here's a tip when creating a new expression...

I tend to use the exact same regular expression for each "function". ie, in the case above they all use

Code:
<expression>.*[/\\](.*)[es]([0-9]{1,2})[sexp]{1,2}([[0-9]]+)</expression>
Notice it has 3 round bracketed sections, which are called groups in regex. So for each function, I use the exact same regular expression with 3 groups, and then I tell the expression which "group" I want to extact for the expression (ie, for GetShowName output=\1 , and for GetSeason output=\2, and for GetEpisode output=\3)

By using the same expression, it means that you can just copy and paste the expression and just change the output= attribute to pull the group you want from the expression.

For testing... I'd recommend that you use the online site...
http://www.regexplanet.com/advanced/java/index.html

I just quickly created the expression.

Code:
TV Series\\([^\\]+)\\Series ([0-9]+)\\([0-9]+)
and added test data of

Code:
C:\TV Series\All Creatures Great and Small\Series 01\01 Horse Sense.mkv
I can quickly see that it matches the 3 groups...

Code:
group(1 -- Show) All Creatures Great and Small
group(2 -- Season) 01
group(3 -- Episode) 01

Sean.

Last edited by stuckless; 11-19-2012 at 03:18 PM.
Reply With Quote
  #5  
Old 11-20-2012, 11:31 AM
Phydeaux Phydeaux is offline
Sage Advanced User
 
Join Date: Aug 2008
Posts: 222
Thanks very much, Sean. I'm sure this is spoon-feeding at the extreme and I should be able to just implement this and carry on. But I can't. I have no coding skills beyond a mildly complex batch file (remember those?) and even at that it's been a long time.

Anyone care to take a crack at this and shoot me a scraper file I can test?

RLW
Reply With Quote
  #6  
Old 11-20-2012, 12:22 PM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!-- 
   TV Filename Scraper.  Used to Scrape Show Name, Season and Episode from a given file URI
   $$1 is always the complete file path
-->
<scraper name="phydeaux" content="filename" thumb="thumb.png">
        <!--    input:          $1=complete file uri -->
        <!--    returns:        show name -->
        <GetShowName dest="3">
                <RegExp input="$$1" output="\1" dest="3">
                                
                        <expression>TV Series\\([^\\]+)\\Series ([0-9]+)\\([0-9]+)</expression>
                </RegExp>
        </GetShowName>

        <!--    input:          $1=complete file uri -->
        <!--    returns:        Season #-->
        <GetSeason dest="3">
                <RegExp input="$$1" output="\2" dest="3">
                        <expression>TV Series\\([^\\]+)\\Series ([0-9]+)\\([0-9]+)</expression>
                </RegExp>
        </GetSeason>

        <!--    input:          $1=complete file uri -->
        <!--    returns:        Episode #-->
        <GetEpisode dest="3">
                <RegExp input="$$1" output="\3" dest="3">
                        <expression>TV Series\\([^\\]+)\\Series ([0-9]+)\\([0-9]+)</expression>
                </RegExp>
        </GetEpisode>
</scraper>
Put this in the SAGE_HOME/userdata/Phoenix/scrapers/xbmc/tvfilenames/ directory (you'll have to create that directory area). The filename doesn't matter, but should end in .xml, so call it, phydeaux.xml. You'll then need to restart the server and test in bmt.
Reply With Quote
  #7  
Old 11-20-2012, 05:44 PM
Phydeaux Phydeaux is offline
Sage Advanced User
 
Join Date: Aug 2008
Posts: 222
Thanks so much Sean. It never fails to amaze me, the generosity of the folks who frequent this site. Much appreciated. I'll provide feedback after I test tonight.

RLW
Reply With Quote
  #8  
Old 11-21-2012, 09:00 AM
Phydeaux Phydeaux is offline
Sage Advanced User
 
Join Date: Aug 2008
Posts: 222
I think this probably works fine, but I have yet to verify as I'm running into a different issue. I'll surf it down elsewhere in this forum since I'm sure I've seen reference to it before.

To test I browsed to one of the series of the program in the example above (All Creatures Great and Small) and fetched the metadata. However BTM saw each episode as a movie. If I do each episode individually I can change the media type to TV and change the provider to thetvdb, and it works fine IF I provide it with title, season and episode. But I'm obviously not going to do that for each file. There must be a way to tell BMT that the entire directory is TV media.

RLW
Reply With Quote
  #9  
Old 11-21-2012, 09:23 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Well... typically, bmt will applies all the TV scrapers to the filename, and if one matches, then it does a TV search. It nothing matches, then it a default movie search, so, in your case, the scraper isn't matching

When you do a manual lookup in BMT the scrapers are not used (except when you click on "Discover Defaults"). So, forcing a TV search will always work, but in your case, it doubt it is finding a match using the scraper.

Are you sure you copied the scraper file to the correct location?

If you email me the logs/phoenix.log, I can see if it is picking up the new scraper file.

Sean.
Reply With Quote
  #10  
Old 11-21-2012, 09:59 AM
Phydeaux Phydeaux is offline
Sage Advanced User
 
Join Date: Aug 2008
Posts: 222
Hi Stuckless,

Yes, I followed the directions closely and created the directory structure you indicated. Of course, /userdata/Phoenix already existed, so I just created the /scrapers/xbmc/tvfilenames directories. I copied the code from your post into a new notepad file called phydeaux.xml and placed that in the tvfilenames directory. Then stopped and restarted my SageTV service before logging into BMT.

I'll track down the log file tonight and post it tomorrow.

Thanks,
RLW
Reply With Quote
  #11  
Old 11-21-2012, 06:13 PM
Phydeaux Phydeaux is offline
Sage Advanced User
 
Join Date: Aug 2008
Posts: 222
I can sent the entire phoenix.log file if you like, but a quick look and I think this is likely an issue:

Code:
2012-11-20 17:49:30,646 [Timer-8] WARN  sagex.phoenix.metadata.search.TVScraperManager - Failed to load User TV scraper: .\userdata\Phoenix\scrapers\xbmc\tvfilenames\phydeaux.xml
org.xml.sax.SAXParseException: Content is not allowed in trailing section.
	at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
	at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
	at sagex.phoenix.scrapers.xbmc.XbmcScraperParser.parseScraper(XbmcScraperParser.java:20)
	at sagex.phoenix.metadata.search.XbmcFilenameScraper.<init>(XbmcFilenameScraper.java:17)
	at sagex.phoenix.metadata.search.XbmcTVFilenameScraper.<init>(XbmcTVFilenameScraper.java:20)
	at sagex.phoenix.metadata.search.TVScraperManager.loadXmbcScraper(TVScraperManager.java:13)
	at sagex.phoenix.metadata.search.ScraperManager.visitConfigurationFile(ScraperManager.java:54)
	at sagex.phoenix.common.SystemConfigurationFileManager.visitFiles(SystemConfigurationFileManager.java:100)
	at sagex.phoenix.common.SystemConfigurationFileManager.accept(SystemConfigurationFileManager.java:89)
	at sagex.phoenix.metadata.search.ScraperManager.loadConfigurations(ScraperManager.java:31)
	at sagex.phoenix.Phoenix.initServices(Phoenix.java:304)
	at sagex.phoenix.plugin.PhoenixPlugin.onPluginsLoaded(PhoenixPlugin.java:243)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at sagex.plugin.AbstractPlugin$1.run(AbstractPlugin.java:254)
	at java.util.TimerThread.mainLoop(Unknown Source)
	at java.util.TimerThread.run(Unknown Source)
Reply With Quote
  #12  
Old 11-21-2012, 06:23 PM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Delete your file. Unzip and use this one. I've verified the xml is valid.

Sean.
Attached Files
File Type: zip phydeaux-SSEE.xml.zip (553 Bytes, 94 views)
Reply With Quote
  #13  
Old 11-21-2012, 06:46 PM
Phydeaux Phydeaux is offline
Sage Advanced User
 
Join Date: Aug 2008
Posts: 222
Will do Sean, but a quick look at the file I created revealed what I've suspected all along: I'm an idiot. Apparently when I selected the code you provided here I dragged the mouse a little too far and included the following in the code, right after the final </scraper>:

Put this in the SAGE_HOME/userdata/Phoenix/scrapers/xbmc/tvfilenames/ directory


Yeah, nice.

Thanks. Sorry for the goose chase.

RLW
Reply With Quote
  #14  
Old 11-21-2012, 07:56 PM
Phydeaux Phydeaux is offline
Sage Advanced User
 
Join Date: Aug 2008
Posts: 222
Works perfectly. Now I can get to work.....

Thanks again Sean.

RLW
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
season Title no banner bikesquid Diamond 2 12-13-2011 01:15 PM
Question for Developers: imported video title, episode, and relative import path Opus4 SageTV Studio 36 06-03-2011 06:47 PM
Full-Path as Title? ChaOConnor Batch Metadata Tools 5 05-16-2011 07:01 AM
BMT Media Type by Path ? Jabroni Batch Metadata Tools 9 03-14-2011 08:46 PM
Looking for Title/Season/Episode naming formats to support for metadata scraper evilpenguin General Discussion 17 01-08-2009 04:43 PM


All times are GMT -6. The time now is 03:41 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.