org.stanwood.media.source.xbmc
Class XBMCScraper

java.lang.Object
  extended by org.stanwood.media.xml.XMLParser
      extended by org.stanwood.media.source.xbmc.XBMCExtension
          extended by org.stanwood.media.source.xbmc.XBMCScraper

public class XBMCScraper
extends XBMCExtension

This class is used to handle the XML scraper files from XBMC.


Field Summary
 
Fields inherited from class org.stanwood.media.xml.XMLParser
DTD_WEB_LOCATION, SCHEMA_WEB_LOCATION
 
Constructor Summary
XBMCScraper(XBMCAddon addon, java.io.File scraperFile, java.lang.String point, Mode mode)
          Used to create the class and set the scraper file
 
Method Summary
 java.lang.String executeXBMCScraperFunction(java.lang.String functionName, java.util.Map<java.lang.Integer,java.lang.String> params)
          Used to execute a scraper function
 org.w3c.dom.Document getCreateSearchUrl(java.lang.String searchTerm, java.lang.String year)
          Used to get the URL which should be used to search
 org.w3c.dom.Document getEpisodeGuideUrl(java.lang.String rawHtml)
          Used to get the episode guide URL
 org.w3c.dom.Document getGetDetails(java.io.File file, java.lang.String... contents)
          Used to get the show/film details as a XML document.
 org.w3c.dom.Document getGetEpisodeDetails(java.lang.String contents, java.lang.String episodeId)
          Used to get the details of the a episode.
 org.w3c.dom.Document getGetEpisodeList(java.lang.String html, java.net.URL showURL)
          Used to get a list of the the episodes in a show
 org.w3c.dom.Document getGetSearchResults(java.lang.String rawHtml, java.lang.String searchTerm)
          This function is used to get a XML document of the search results.
 Mode getMode()
          Get the mode of the scrper
 boolean getNfoUrl(java.lang.String contents)
          Used to get a Show or film URL from the contents of a NFO file.
 boolean supportsURL(java.net.URL url)
          This method is used to check if the scraper can be used for the episode details URL
 
Methods inherited from class org.stanwood.media.source.xbmc.XBMCExtension
executeXBMCFunction, getAddon, getDocument, getFile, toString
 
Methods inherited from class org.stanwood.media.xml.XMLParser
createDocBuilder, createFactory, deleteNode, domToStr, encodeAttributeValue, firstChild, getAttribute, getElement, getFirstChildElement, getFloatFromXML, getIntegerFromXML, getLastChildElement, getLongFromXML, getSchema, getStringFromXML, getStringFromXMLOrNull, getURLFromXML, getURLFromXMLOrNull, hasNode, parse, parse, parse, quoteXPathQuery, selectChildNodes, selectNodeList, selectSingleNode, strToDom, strToDom, strToDom, writeXML
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XBMCScraper

public XBMCScraper(XBMCAddon addon,
                   java.io.File scraperFile,
                   java.lang.String point,
                   Mode mode)
Used to create the class and set the scraper file

Parameters:
addon - The addon been used
point - The addon extension point for this scraper
mode - The mode this scraper is to be used for
scraperFile - The XML scraper file
Method Detail

getMode

public Mode getMode()
Get the mode of the scrper

Returns:
The scraper mode

getCreateSearchUrl

public org.w3c.dom.Document getCreateSearchUrl(java.lang.String searchTerm,
                                               java.lang.String year)
                                        throws XBMCException
Used to get the URL which should be used to search

Parameters:
searchTerm - The search term to use
year - The year to search for the result or empty string for any
Returns:
The search URL XML result
Throws:
XBMCException - Thrown if their are any problems creating the search URL

getGetSearchResults

public org.w3c.dom.Document getGetSearchResults(java.lang.String rawHtml,
                                                java.lang.String searchTerm)
                                         throws XBMCException
This function is used to get a XML document of the search results. It takes as input the webpage downloaded from the URL obtained with the @{link getCreateSearchUrl(String,String)} call.

Parameters:
rawHtml - The raw search results
searchTerm - The term been searched for
Returns:
The search results as a XML document
Throws:
XBMCException - Thrown if their are any problems creating the search urlXML

getGetDetails

public org.w3c.dom.Document getGetDetails(java.io.File file,
                                          java.lang.String... contents)
                                   throws XBMCException
Used to get the show/film details as a XML document. It takes as input the 1 or more webpages downloaded from the URL obtained with the @{link getCreateSearchUrl(String,String)} call.

Parameters:
file - the file that the details are been retrieved for, or NULL if this is not known
contents - A list of webpage contents
Returns:
The results as a XML document
Throws:
XBMCException - Thrown if their are any problems

getEpisodeGuideUrl

public org.w3c.dom.Document getEpisodeGuideUrl(java.lang.String rawHtml)
                                        throws XBMCException
Used to get the episode guide URL

Parameters:
rawHtml - The show weppage
Returns:
The XML doc containg the URL
Throws:
XBMCException - Thrown if their are any problem

getNfoUrl

public boolean getNfoUrl(java.lang.String contents)
                  throws XBMCException
Used to get a Show or film URL from the contents of a NFO file.

Parameters:
contents - The contents of a NFO file
Returns:
The XML containing a URL
Throws:
XBMCException - Thrown if their are any problems

getGetEpisodeList

public org.w3c.dom.Document getGetEpisodeList(java.lang.String html,
                                              java.net.URL showURL)
                                       throws XBMCException
Used to get a list of the the episodes in a show

Parameters:
html - The contents of the episode list
showURL - The URL used to fetch show info
Returns:
The XML document containing the episode list
Throws:
XBMCException - Thrown if their are any problems

executeXBMCScraperFunction

public java.lang.String executeXBMCScraperFunction(java.lang.String functionName,
                                                   java.util.Map<java.lang.Integer,java.lang.String> params)
                                            throws XBMCException,
                                                   XMLParserException
Used to execute a scraper function

Specified by:
executeXBMCScraperFunction in class XBMCExtension
Parameters:
functionName - The name of the function to execute
params - Numbered parameters passed to the function
Returns:
The result retured by the function
Throws:
XBMCException - Thrown if their is a XBMC problem
XMLParserException - Thrown if their is a XML problem

supportsURL

public boolean supportsURL(java.net.URL url)
                    throws SourceException
This method is used to check if the scraper can be used for the episode details URL

Parameters:
url - The NFO file
Returns:
True of the scraper is compatible with the URL
Throws:
SourceException - Thrown if their are any problems

getGetEpisodeDetails

public org.w3c.dom.Document getGetEpisodeDetails(java.lang.String contents,
                                                 java.lang.String episodeId)
                                          throws XBMCException
Used to get the details of the a episode. The contents argument contains the downloaded weppage of the episode details. The episode details URL is obtained by calling getGetEpisodeList(String, URL)

Parameters:
contents - The downloaded HTML of the episode guide
episodeId - The ID of the episode to get the details for
Returns:
episode details XML
Throws:
XBMCException - Thrown if their are any problems