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:
[legend]
Collaboration diagram for nv_python_libs.common.common_api.Common:
[legend]

Public Member Functions

def __init__ (self, logger=False, debug=False)
 
def massageText (self, text)
 
def initLogger (self, path=sys.stderr, log_name='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 101 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 104 of file common_api.py.

Member Function Documentation

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

◆ ampReplace()

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

◆ 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 724 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 541 of file common_api.py.

◆ 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 270 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 802 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 425 of file common_api.py.

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

◆ 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 851 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 320 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 380 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 835 of file common_api.py.

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

◆ 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 687 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 814 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 795 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 653 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.thewb.thewb_api.Videos.searchTitle(), and nv_python_libs.rev3.rev3_api.Videos.searchTitle().

◆ 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 444 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 786 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 898 of file common_api.py.

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

◆ initLogger()

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

Definition at line 224 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 711 of file common_api.py.

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

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

◆ 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 406 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 612 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 777 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 765 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 731 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 749 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 740 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 820 of file common_api.py.

◆ textUtf8()

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

Member Data Documentation

◆ apiSuffix

nv_python_libs.common.common_api.Common.apiSuffix

Definition at line 180 of file common_api.py.

◆ baseProcessingDir

nv_python_libs.common.common_api.Common.baseProcessingDir

◆ debug

nv_python_libs.common.common_api.Common.debug

◆ etree

nv_python_libs.common.common_api.Common.etree

Definition at line 184 of file common_api.py.

◆ functionDict

nv_python_libs.common.common_api.Common.functionDict

Definition at line 552 of file common_api.py.

◆ itemContent

nv_python_libs.common.common_api.Common.itemContent

◆ itemElement

nv_python_libs.common.common_api.Common.itemElement

◆ itemThumbnail

nv_python_libs.common.common_api.Common.itemThumbnail

◆ language

nv_python_libs.common.common_api.Common.language

Definition at line 181 of file common_api.py.

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

◆ linksWebPage

nv_python_libs.common.common_api.Common.linksWebPage

Definition at line 183 of file common_api.py.

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

◆ logger

nv_python_libs.common.common_api.Common.logger

◆ mnvItem

nv_python_libs.common.common_api.Common.mnvItem

◆ mnvRSS

nv_python_libs.common.common_api.Common.mnvRSS

Definition at line 122 of file common_api.py.

◆ mythdb

nv_python_libs.common.common_api.Common.mythdb

◆ namespaces

nv_python_libs.common.common_api.Common.namespaces

◆ nv_python_libs_path

nv_python_libs.common.common_api.Common.nv_python_libs_path

Definition at line 179 of file common_api.py.

◆ parsers

nv_python_libs.common.common_api.Common.parsers

Definition at line 116 of file common_api.py.

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

◆ pubDateFormat

nv_python_libs.common.common_api.Common.pubDateFormat

◆ s_e_Patterns

nv_python_libs.common.common_api.Common.s_e_Patterns

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