MythTV  master
Public Member Functions | Public Attributes | List of all members
nv_python_libs.common.common_api.Common Class Reference

Start - Utility functions. More...

Inheritance diagram for nv_python_libs.common.common_api.Common:
Inheritance graph
[legend]
Collaboration diagram for nv_python_libs.common.common_api.Common:
Collaboration graph
[legend]

Public Member Functions

def __init__ (self, logger=False, debug=False)
 
def massageText (self, text)
 
def initLogger (self, path=sys.stderr, log_name=u 'MNV_Grabber')
 
def textUtf8 (self, text)
 
def ampReplace (self, text)
 
def callCommandLine (self, command, stderr=False)
 
def detectUserLocationByIP (self)
 
def displayCustomHTML (self)
 
def mnvChannelElement (self, channelDetails)
 
def checkURL (self, url)
 
def getUrlData (self, inputUrls, pageFilter=None)
 
def buildFunctionDict (self)
 Start - Utility functions specifically used to modify MNV item data. More...
 
def addDynamicFunctions (self, dirPath)
 
def pubDate (self, context, *inputArgs)
 
def getSeasonEpisode (self, context, text)
 
def convertDuration (self, context, duration)
 
def getHtmlData (self, context, *args)
 
def linkWebPage (self, context, sourceLink)
 
def baseDir (self, context, dummy)
 
def stringLower (self, context, data)
 
def stringUpper (self, context, data)
 
def stringReplace (self, context, *inputArgs)
 
def stringEscape (self, context, *args)
 
def removePunc (self, context, data)
 
def htmlToString (self, context, html)
 
def getLanguage (self, context, args)
 
def checkIfDBItem (self, context, arg)
 
def getItemElement (self, context, arg)
 
def testSubString (self, context, *arg)
 
def getDBRecords (self, context, *arg)
 
def createItemElement (self, context, *arg)
 
def initializeMythDB (self)
 

Public Attributes

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

Detailed Description

Start - Utility functions.

A collection of common functions used by many grabbers

Definition at line 132 of file common_api.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 135 of file common_api.py.

Member Function Documentation

◆ massageText()

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 221 of file common_api.py.

Referenced by giantbomb.giantbomb_api.gamedbQueries.htmlToString(), and nv_python_libs.common.common_api.Common.htmlToString().

◆ initLogger()

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 255 of file common_api.py.

◆ textUtf8()

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

◆ ampReplace()

def nv_python_libs.common.common_api.Common.ampReplace (   self,
  text 
)

◆ callCommandLine()

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 301 of file common_api.py.

◆ detectUserLocationByIP()

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 351 of file common_api.py.

◆ displayCustomHTML()

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 411 of file common_api.py.

◆ mnvChannelElement()

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 437 of file common_api.py.

◆ checkURL()

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 456 of file common_api.py.

◆ getUrlData()

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 475 of file common_api.py.

◆ buildFunctionDict()

def nv_python_libs.common.common_api.Common.buildFunctionDict (   self)

Start - Utility functions specifically used to modify MNV item data.

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 572 of file common_api.py.

◆ addDynamicFunctions()

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 607 of file common_api.py.

◆ pubDate()

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 643 of file common_api.py.

◆ getSeasonEpisode()

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 684 of file common_api.py.

Referenced by nv_python_libs.hulu.hulu_api.Videos.displayTreeView(), nv_python_libs.rev3.rev3_api.Videos.displayTreeView(), nv_python_libs.hulu.hulu_api.Videos.searchTitle(), nv_python_libs.rev3.rev3_api.Videos.searchTitle(), and nv_python_libs.thewb.thewb_api.Videos.searchTitle().

◆ convertDuration()

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 704 of file common_api.py.

◆ getHtmlData()

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 718 of file common_api.py.

◆ linkWebPage()

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 742 of file common_api.py.

◆ baseDir()

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

Definition at line 755 of file common_api.py.

◆ stringLower()

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

Definition at line 762 of file common_api.py.

◆ stringUpper()

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

Definition at line 771 of file common_api.py.

◆ stringReplace()

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 780 of file common_api.py.

◆ stringEscape()

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 796 of file common_api.py.

◆ removePunc()

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 808 of file common_api.py.

◆ htmlToString()

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 817 of file common_api.py.

◆ getLanguage()

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

Definition at line 826 of file common_api.py.

◆ checkIfDBItem()

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 833 of file common_api.py.

◆ getItemElement()

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 845 of file common_api.py.

◆ testSubString()

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 851 of file common_api.py.

◆ getDBRecords()

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 866 of file common_api.py.

Referenced by nv_python_libs.common.common_api.Common.checkIfDBItem().

◆ createItemElement()

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 882 of file common_api.py.

◆ initializeMythDB()

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

Definition at line 929 of file common_api.py.

Referenced by nv_python_libs.common.common_api.Common.getDBRecords().

Member Data Documentation

◆ logger

nv_python_libs.common.common_api.Common.logger

◆ debug

nv_python_libs.common.common_api.Common.debug

◆ baseProcessingDir

nv_python_libs.common.common_api.Common.baseProcessingDir

◆ namespaces

nv_python_libs.common.common_api.Common.namespaces

◆ parsers

nv_python_libs.common.common_api.Common.parsers

Definition at line 147 of file common_api.py.

Referenced by nv_python_libs.common.common_api.Common.getUrlData().

◆ pubDateFormat

nv_python_libs.common.common_api.Common.pubDateFormat

◆ mnvRSS

nv_python_libs.common.common_api.Common.mnvRSS

Definition at line 153 of file common_api.py.

◆ mnvItem

nv_python_libs.common.common_api.Common.mnvItem

◆ s_e_Patterns

nv_python_libs.common.common_api.Common.s_e_Patterns

◆ nv_python_libs_path

nv_python_libs.common.common_api.Common.nv_python_libs_path

Definition at line 210 of file common_api.py.

◆ apiSuffix

nv_python_libs.common.common_api.Common.apiSuffix

Definition at line 211 of file common_api.py.

◆ language

nv_python_libs.common.common_api.Common.language

Definition at line 212 of file common_api.py.

Referenced by nv_python_libs.common.common_api.Common.getLanguage().

◆ mythdb

nv_python_libs.common.common_api.Common.mythdb

◆ linksWebPage

nv_python_libs.common.common_api.Common.linksWebPage

Definition at line 214 of file common_api.py.

Referenced by nv_python_libs.common.common_api.Common.linkWebPage().

◆ etree

nv_python_libs.common.common_api.Common.etree

Definition at line 215 of file common_api.py.

◆ functionDict

nv_python_libs.common.common_api.Common.functionDict

Definition at line 583 of file common_api.py.

◆ itemElement

nv_python_libs.common.common_api.Common.itemElement

◆ itemThumbnail

nv_python_libs.common.common_api.Common.itemThumbnail

◆ itemContent

nv_python_libs.common.common_api.Common.itemContent

The documentation for this class was generated from the following file: