nv_python_libs::common::common_api::Common Class Reference

List of all members.

Public Member Functions

def __init__
def massageText
def initLogger
def textUtf8
def ampReplace
def callCommandLine
def detectUserLocationByIP
def displayCustomHTML
def mnvChannelElement
def checkURL
def getUrlData
def buildFunctionDict
def addDynamicFunctions
def pubDate
def getSeasonEpisode
def convertDuration
def getHtmlData
def linkWebPage
def baseDir
def stringLower
def stringUpper
def stringReplace
def stringEscape
def removePunc
def htmlToString
def getLanguage
def checkIfDBItem
def getItemElement
def testSubString
def getDBRecords
def createItemElement
def initializeMythDB

Public Attributes

 logger
 debug
 baseProcessingDir
 namespaces
 parsers
 pubDateFormat
 mnvRSS
 mnvItem
 s_e_Patterns
 nv_python_libs_path
 apiSuffix
 language
 mythdb
 linksWebPage
 functionDict
 itemElement
 itemThumbnail
 itemContent

Detailed Description

A collection of common functions used by many grabbers

Definition at line 132 of file common_api.py.


Member Function Documentation

def nv_python_libs::common::common_api::Common::__init__ (   self,
  logger = False,
  debug = False 
)

Definition at line 135 of file common_api.py.

def nv_python_libs::common::common_api::Common::massageText (   self,
  text 
)
Removes HTML markup from a text string.
@param text The HTML source.
@return The plain text.  If the HTML source contains non-ASCII
entities or character references, this is a Unicode string.

Definition at line 220 of file common_api.py.

def nv_python_libs::common::common_api::Common::initLogger (   self,
  path = sys.stderr,
  log_name = u'MNV_Grabber' 
)
Setups a logger using the logging module, returns a logger object

Definition at line 254 of file common_api.py.

def nv_python_libs::common::common_api::Common::textUtf8 (   self,
  text 
)

Definition at line 277 of file common_api.py.

def nv_python_libs::common::common_api::Common::ampReplace (   self,
  text 
)
Replace all "&" characters with "&"

Definition at line 289 of file common_api.py.

def nv_python_libs::common::common_api::Common::callCommandLine (   self,
  command,
  stderr = False 
)
Perform the requested command line and return an array of stdout strings and
stderr strings if stderr=True
return array of stdout string array or stdout and stderr string arrays

Definition at line 296 of file common_api.py.

def nv_python_libs::common::common_api::Common::detectUserLocationByIP (   self  ) 
Get longitude and latitiude to find videos relative to your location. Up to three different
servers will be tried before giving up.
return a dictionary e.g.
{'Latitude': '43.6667', 'Country': 'Canada', 'Longitude': '-79.4167', 'City': 'Toronto'}
return an empty dictionary if there were any errors
Code found at: http://blog.suinova.com/2009/04/from-ip-to-geolocation-country-city.html

Definition at line 346 of file common_api.py.

def nv_python_libs::common::common_api::Common::displayCustomHTML (   self  ) 
Common name for a custom HTML display. Used to interface with MythTV plugin NetVision

Definition at line 406 of file common_api.py.

def nv_python_libs::common::common_api::Common::mnvChannelElement (   self,
  channelDetails 
)
Create a MNV Channel element populated with channel details
return the channel element

Definition at line 432 of file common_api.py.

def nv_python_libs::common::common_api::Common::checkURL (   self,
  url 
)
Verify that a URL actually exists. Be careful as redirects can lead to false positives. Use
the info details to be sure.
return True when it exists and info
return False when it does not exist and info

Definition at line 451 of file common_api.py.

def nv_python_libs::common::common_api::Common::getUrlData (   self,
  inputUrls,
  pageFilter = None 
)
Fetch url data and extract the desired results using a dynamic filter or XSLT stylesheet.
The URLs are requested in parallel using threading
return the extracted data organised into directories

Definition at line 470 of file common_api.py.

def nv_python_libs::common::common_api::Common::buildFunctionDict (   self  ) 
Create a dictionary of functions that manipulate items data. These functions are imported
from other MNV grabbers. These functions are meant to be used by the MNV WebCgi type of grabber
which aggregates data from a number of different sources (e.g. RSS feeds and HTML Web pages)
including sources from other grabbers.
Using a dictionary facilitates mixing XSLT functions with pure python functions to use the best
capabilities of both technologies when translating source information into MNV compliant item
data.
return nothing

Definition at line 567 of file common_api.py.

def nv_python_libs::common::common_api::Common::addDynamicFunctions (   self,
  dirPath 
)
Dynamically add functions to the function dictionary from a specified directory
return nothing

Definition at line 602 of file common_api.py.

def nv_python_libs::common::common_api::Common::pubDate (   self,
  context,
  inputArgs 
)
Convert a date/time string in a specified format into a pubDate. The default is the
MNV item format
return the formatted pubDate string
return on error return the original date string

Definition at line 638 of file common_api.py.

def nv_python_libs::common::common_api::Common::getSeasonEpisode (   self,
  context,
  text 
)
Check is there is any season or episode number information in an item's text
return a string of season and/or episode numbers e.g. "2_21"
return a string with "None_None" values

Definition at line 679 of file common_api.py.

def nv_python_libs::common::common_api::Common::convertDuration (   self,
  context,
  duration 
)
Take a duration and convert it to seconds
return a string of seconds

Definition at line 699 of file common_api.py.

def nv_python_libs::common::common_api::Common::getHtmlData (   self,
  context,
  args 
)
Take a HTML string and convert it to an HTML element. Then apply a filter and return
that value.
return filter value as a string
return an empty sting if the filter failed to find any values.

Definition at line 713 of file common_api.py.

def nv_python_libs::common::common_api::Common::linkWebPage (   self,
  context,
  sourceLink 
)
Check if there is a special local HTML page for the link. If not then return a generic
download only local HTML url.
return a file://.... link to a local HTML web page

Definition at line 737 of file common_api.py.

def nv_python_libs::common::common_api::Common::baseDir (   self,
  context,
  dummy 
)
Return the base directory string
return the base directory

Definition at line 750 of file common_api.py.

def nv_python_libs::common::common_api::Common::stringLower (   self,
  context,
  data 
)
return a lower case string

Definition at line 757 of file common_api.py.

def nv_python_libs::common::common_api::Common::stringUpper (   self,
  context,
  data 
)
return a upper case string

Definition at line 766 of file common_api.py.

def nv_python_libs::common::common_api::Common::stringReplace (   self,
  context,
  inputArgs 
)
Replace substring values in a string
return the resulting string from a replace operation

Definition at line 775 of file common_api.py.

def nv_python_libs::common::common_api::Common::stringEscape (   self,
  context,
  args 
)
Replace substring values in a string
return the resulting string from a replace operation

Definition at line 791 of file common_api.py.

def nv_python_libs::common::common_api::Common::removePunc (   self,
  context,
  data 
)
Remove all punctuation for a string
return the resulting string

Definition at line 803 of file common_api.py.

def nv_python_libs::common::common_api::Common::htmlToString (   self,
  context,
  html 
)
Remove HTML tags and LFs from a string
return the string without HTML tags or LFs

Definition at line 812 of file common_api.py.

def nv_python_libs::common::common_api::Common::getLanguage (   self,
  context,
  args 
)
Return the current selected language code
return language code

Definition at line 821 of file common_api.py.

def nv_python_libs::common::common_api::Common::checkIfDBItem (   self,
  context,
  arg 
)
Find an 'internetcontentarticles' table record based on fields and values
return True if a record was found and an item element created
return False if no record was found

Definition at line 828 of file common_api.py.

def nv_python_libs::common::common_api::Common::getItemElement (   self,
  context,
  arg 
)
Return an item element that was created by a previous call to the checkIfDBItem function

Definition at line 840 of file common_api.py.

def nv_python_libs::common::common_api::Common::testSubString (   self,
  context,
  arg 
)
Return True or False if a substring is at the beginning or end of a string

Definition at line 846 of file common_api.py.

def nv_python_libs::common::common_api::Common::getDBRecords (   self,
  context,
  arg 
)
Return a list of 'internetcontentarticles' table records based on field and value matches

Definition at line 861 of file common_api.py.

def nv_python_libs::common::common_api::Common::createItemElement (   self,
  context,
  arg 
)
Create an item element from an 'internetcontentarticles' table record dictionary
return the item element

Definition at line 877 of file common_api.py.

def nv_python_libs::common::common_api::Common::initializeMythDB (   self  ) 
Import the MythTV database bindings
return nothing

Definition at line 924 of file common_api.py.


Member Data Documentation

Definition at line 136 of file common_api.py.

Definition at line 137 of file common_api.py.

Definition at line 138 of file common_api.py.

Definition at line 139 of file common_api.py.

Definition at line 147 of file common_api.py.

Definition at line 152 of file common_api.py.

Definition at line 153 of file common_api.py.

Definition at line 165 of file common_api.py.

Definition at line 180 of file common_api.py.

Definition at line 210 of file common_api.py.

Definition at line 211 of file common_api.py.

Definition at line 212 of file common_api.py.

Definition at line 213 of file common_api.py.

Definition at line 214 of file common_api.py.

Definition at line 578 of file common_api.py.

Definition at line 835 of file common_api.py.

Definition at line 866 of file common_api.py.

Definition at line 867 of file common_api.py.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends
Generated on Sat Feb 11 06:42:31 2012 for MythTV by  doxygen 1.6.3