15__title__ =
"hubbleCast_api - XPath and XSLT functions for the HubbleCast RSS/HTML"
16__author__=
"R.D. Vaughan"
18This python script is intended to perform a variety of utility functions
19for the conversion of data to the MNV standard RSS output format.
20See this link for the specifications:
21http://www.mythtv.org/wiki/MythNetvision_Grabber_Script_Format
29__xpathClassList__ = [
'xpathFunctions', ]
33__xsltExtentionList__ = []
35import os, sys, re, time, datetime, shutil,
urllib.request, urllib.parse, urllib.error, string
36from copy
import deepcopy
40 """Wraps a stream with an encoder"""
49 """Wraps the output stream, encoding Unicode strings with the specified encoding"""
50 if isinstance(obj, str):
53 self.
out.buffer.write(obj)
58 """Delegate everything but write to the stream"""
59 return getattr(self.
out, attr)
61if isinstance(sys.stdout, io.TextIOWrapper):
66 from io
import StringIO
67 from lxml
import etree
69 sys.stderr.write(
'\n! Error - Importing the "lxml" and "StringIO" python libraries failed on error(%s)\n' % e)
74 """Functions specific extending XPath
79 'atom':
"http://www.w3.org/2005/Atom",
80 'atom10':
"http://www.w3.org/2005/Atom",
81 'media':
"http://search.yahoo.com/mrss/",
82 'itunes':
"http://www.itunes.com/dtds/podcast-1.0.dtd",
83 'xhtml':
"http://www.w3.org/1999/xhtml",
84 'mythtv':
"http://www.mythtv.org/wiki/MythNetvision_Grabber_Script_Format",
85 'feedburner':
"http://rssnamespace.org/feedburner/ext/1.0",
86 'amp':
"http://www.adobe.com/amp/1.0",
97 '''Generate a link for the video.
98 Call example: 'mnvXpath:hubbleCastLinkGeneration(string(guid))'
102 index = guidURL.find('.m4v')
104 index2 = guidURL.rfind(
'/')
105 return '%s%s' % (common.linkWebPage(
'dummy',
'hubble'), guidURL[index2+1:index])
106 elif guidURL[len(guidURL)-1] ==
'/':
107 index2 = guidURL[:-1].rfind(
'/')
108 return '%s%s' % (common.linkWebPage(
'dummy',
'hubble'), guidURL[index2+1:-1])
def __init__(self, outstream, encoding=None)
def __getattr__(self, attr)
def hubbleCastLinkGeneration(self, context, *arg)
Start of XPath extension functions.