MythTV
master
|
Start - Utility functions. More...
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) |
Start - Utility functions.
A collection of common functions used by many grabbers
Definition at line 128 of file common_api.py.
def nv_python_libs.common.common_api.Common.__init__ | ( | self, | |
logger = False , |
|||
debug = False |
|||
) |
Definition at line 131 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 217 of file common_api.py.
Referenced by giantbomb.giantbomb_api.gamedbQueries.htmlToString(), and nv_python_libs.common.common_api.Common.htmlToString().
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 251 of file common_api.py.
def nv_python_libs.common.common_api.Common.textUtf8 | ( | self, | |
text | |||
) |
Definition at line 274 of file common_api.py.
Referenced by giantbomb.giantbomb_api.gamedbQueries.ampReplace(), nv_python_libs.common.common_api.Common.ampReplace(), nv_python_libs.mtv.mtv_api.Videos.ampReplace(), nv_python_libs.dailymotion.dailymotion_api.Videos.ampReplace(), nv_python_libs.vimeo.vimeo_api.Videos.ampReplace(), nv_python_libs.mtv.mtv_api.Videos.massageDescription(), nv_python_libs.dailymotion.dailymotion_api.Videos.massageDescription(), nv_python_libs.vimeo.vimeo_api.Videos.massageDescription(), giantbomb.giantbomb_api.gamedbQueries.massageText(), and nv_python_libs.common.common_api.Common.massageText().
def nv_python_libs.common.common_api.Common.ampReplace | ( | self, | |
text | |||
) |
Replace all &, ', ", <, and > characters with the predefined XML entities
Definition at line 286 of file common_api.py.
Referenced by nv_python_libs.vimeo.vimeo_api.Videos.getTreeVideos(), nv_python_libs.dailymotion.dailymotion_api.Videos.getVideosForGroupURL(), nv_python_libs.mtv.mtv_api.Videos.getVideosForURL(), nv_python_libs.mtv.mtv_api.Videos.massageDescription(), nv_python_libs.dailymotion.dailymotion_api.Videos.massageDescription(), nv_python_libs.vimeo.vimeo_api.Videos.massageDescription(), giantbomb.giantbomb_api.gamedbQueries.massageText(), nv_python_libs.common.common_api.Common.massageText(), nv_python_libs.dailymotion.dailymotion_api.Videos.processVideoUrl(), nv_python_libs.vimeo.vimeo_api.Videos.processVideoUrl(), and nv_python_libs.vimeo.vimeo_api.Videos.searchTitle().
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 297 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 347 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 407 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 433 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 452 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 471 of file common_api.py.
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 568 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 603 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 639 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 680 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().
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 700 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 714 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 738 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 751 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 758 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 767 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 776 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 792 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 804 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 813 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 822 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 829 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 841 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 847 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 862 of file common_api.py.
Referenced by nv_python_libs.common.common_api.Common.checkIfDBItem().
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 878 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 925 of file common_api.py.
Referenced by nv_python_libs.common.common_api.Common.getDBRecords().
nv_python_libs.common.common_api.Common.logger |
Definition at line 132 of file common_api.py.
Referenced by nv_python_libs.common.common_api.Common.callCommandLine(), and nv_python_libs.common.common_api.Common.initLogger().
nv_python_libs.common.common_api.Common.debug |
nv_python_libs.common.common_api.Common.baseProcessingDir |
Definition at line 134 of file common_api.py.
Referenced by nv_python_libs.common.common_api.Common.addDynamicFunctions(), nv_python_libs.common.common_api.Common.baseDir(), giantbomb.giantbomb_api.gamedbQueries.gameData(), giantbomb.giantbomb_api.gamedbQueries.gameSearch(), nv_python_libs.common.common_api.Common.getUrlData(), and nv_python_libs.common.common_api.Common.linkWebPage().
nv_python_libs.common.common_api.Common.namespaces |
Definition at line 135 of file common_api.py.
Referenced by nv_python_libs.common.common_api.Common.displayCustomHTML(), and nv_python_libs.common.common_api.Common.getUrlData().
nv_python_libs.common.common_api.Common.parsers |
Definition at line 143 of file common_api.py.
Referenced by nv_python_libs.common.common_api.Common.getUrlData().
nv_python_libs.common.common_api.Common.pubDateFormat |
Definition at line 148 of file common_api.py.
Referenced by nv_python_libs.common.common_api.Common.createItemElement(), giantbomb.giantbomb_api.gamedbQueries.pubDate(), and nv_python_libs.common.common_api.Common.pubDate().
nv_python_libs.common.common_api.Common.mnvRSS |
Definition at line 149 of file common_api.py.
nv_python_libs.common.common_api.Common.mnvItem |
Definition at line 161 of file common_api.py.
Referenced by nv_python_libs.common.common_api.Common.createItemElement().
nv_python_libs.common.common_api.Common.s_e_Patterns |
nv_python_libs.common.common_api.Common.nv_python_libs_path |
Definition at line 206 of file common_api.py.
nv_python_libs.common.common_api.Common.apiSuffix |
Definition at line 207 of file common_api.py.
nv_python_libs.common.common_api.Common.language |
Definition at line 208 of file common_api.py.
Referenced by nv_python_libs.common.common_api.Common.getLanguage().
nv_python_libs.common.common_api.Common.mythdb |
Definition at line 209 of file common_api.py.
Referenced by nv_python_libs.common.common_api.Common.getDBRecords(), and nv_python_libs.common.common_api.Common.initializeMythDB().
nv_python_libs.common.common_api.Common.linksWebPage |
Definition at line 210 of file common_api.py.
Referenced by nv_python_libs.common.common_api.Common.linkWebPage().
nv_python_libs.common.common_api.Common.etree |
Definition at line 211 of file common_api.py.
nv_python_libs.common.common_api.Common.functionDict |
Definition at line 579 of file common_api.py.
nv_python_libs.common.common_api.Common.itemElement |
Definition at line 836 of file common_api.py.
Referenced by nv_python_libs.common.common_api.Common.getItemElement().
nv_python_libs.common.common_api.Common.itemThumbnail |
Definition at line 867 of file common_api.py.
Referenced by nv_python_libs.common.common_api.Common.createItemElement().
nv_python_libs.common.common_api.Common.itemContent |
Definition at line 868 of file common_api.py.
Referenced by nv_python_libs.common.common_api.Common.createItemElement().