00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 __title__ ="Search all tree views";
00026 __mashup_title__ = "mnvsearch"
00027 __author__="R.D. Vaughan"
00028 __version__="0.13"
00029
00030
00031
00032
00033
00034 __usage_examples__ ='''
00035 (Option Help)
00036 > ./mnvsearch.py -h
00037 Usage: ./mnvsearch.py -hduvlS [parameters] <search text>
00038 Version: v0.1.0 Author: R.D.Vaughan
00039
00040 For details on the MythTV Netvision plugin see the wiki page at:
00041 http://www.mythtv.org/wiki/MythNetvision
00042
00043 Options:
00044 -h, --help show this help message and exit
00045 -d, --debug Show debugging info (URLs, raw XML ... etc, info
00046 varies per grabber)
00047 -u, --usage Display examples for executing the script
00048 -v, --version Display grabber name and supported options
00049 -l LANGUAGE, --language=LANGUAGE
00050 Select data that matches the specified language fall
00051 back to English if nothing found (e.g. 'es' EspaƱol,
00052 'de' Deutsch ... etc). Not all sites or grabbers
00053 support this option.
00054 -p PAGE NUMBER, --pagenumber=PAGE NUMBER
00055 Display specific page of the search results. Default
00056 is page 1. Page number is ignored with the Tree View
00057 option (-T).
00058 -S, --search Search for videos
00059
00060 > ./mnvsearch.py -v
00061 <grabber>
00062 <name>Search all tree views</name>
00063 <author>R.D.Vaughan</author>
00064 <thumbnail>mnvsearch.png</thumbnail>
00065 <type>video</type>
00066 <description>MythNetvision treeview data base search</description>
00067 <version>v0.11</version>
00068 <search>true</search>
00069 </grabber>
00070
00071 > ./mnvsearch.py -S "Doctor Who"
00072 <?xml version="1.0" encoding="UTF-8"?>
00073 <rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:cnettv="http://cnettv.com/mrss/" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:media="http://search.yahoo.com/mrss/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:amp="http://www.adobe.com/amp/1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
00074 <channel>
00075 <title>Search all tree views</title>
00076 <link>http://www.mythtv.org/wiki/MythNetvision</link>
00077 <description>MythNetvision treeview data base search</description>
00078 <numresults>21</numresults>
00079 <returned>20</returned>
00080 <startindex>20</startindex>
00081 <item>
00082 <title>Doctor Who - Doctor Who and The Brain of Morbius - Episode 8</title>
00083 <author>BBC</author>
00084 <pubDate>Sat, 01 May 2010 15:04:02 GMT</pubDate>
00085 <description>The Doctor and Sarah Jane confront the Morbius monster and seek help from the Sisterhood.</description>
00086 <link>file:///usr/local/share/mythtv/mythnetvision/scripts/nv_python_libs/configs/HTML/bbciplayer.html?videocode=b00s5ztx</link>
00087 <media:group>
00088 <media:thumbnail url="http://node1.bbcimg.co.uk/iplayer/images/episode/b00s5ztx_120_68.jpg"/>
00089 <media:content url="file:///usr/local/share/mythtv/mythnetvision/scripts/nv_python_libs/configs/HTML/bbciplayer.html?videocode=b00s5ztx" length="" duration="" width="" height="" lang=""/>
00090 </media:group>
00091 <rating>0.0</rating>
00092 </item>
00093 ...
00094 <item>
00095 <title>Every Doctor Who Story 1963-2008 - by Babelcolour</title>
00096 <author>BabelColour</author>
00097 <pubDate>Mon, 07 Jul 2008 14:45:12 GMT</pubDate>
00098 <description>To celebrate the 45th Anniversary of the series, here is every Who story from 1963 to 2008, with the spin-off shows and bbci internet productions & the Children In Need specials, but doesn't include any of the spoofs, comedy sketches or other charity skits not made by the official Who Production Team. Edit: It was made & uploaded before the BBC Proms Special 'Music Of The Spheres'. That's why it isn't included! The fabulous music mix (called 'Whorythmics') was created by jex</description>
00099 <link>http://www.youtube.com/v/lCZhlEdGIm0?f=videos&app=youtube_gdata&autoplay=1</link>
00100 <media:group>
00101 <media:thumbnail url="http://i.ytimg.com/vi/lCZhlEdGIm0/hqdefault.jpg"/>
00102 <media:content url="http://www.youtube.com/v/lCZhlEdGIm0?f=videos&app=youtube_gdata&autoplay=1" length="" duration="" width="" height="" lang=""/>
00103 </media:group>
00104 <rating>4.957553</rating>
00105 </item></channel></rss>
00106 '''
00107 __search_max_page_items__ = 20
00108 __tree_max_page_items__ = 20
00109
00110 import sys, os
00111
00112
00113 class OutStreamEncoder(object):
00114 """Wraps a stream with an encoder"""
00115 def __init__(self, outstream, encoding=None):
00116 self.out = outstream
00117 if not encoding:
00118 self.encoding = sys.getfilesystemencoding()
00119 else:
00120 self.encoding = encoding
00121
00122 def write(self, obj):
00123 """Wraps the output stream, encoding Unicode strings with the specified encoding"""
00124 if isinstance(obj, unicode):
00125 try:
00126 self.out.write(obj.encode(self.encoding))
00127 except IOError:
00128 pass
00129 else:
00130 try:
00131 self.out.write(obj)
00132 except IOError:
00133 pass
00134
00135 def __getattr__(self, attr):
00136 """Delegate everything but write to the stream"""
00137 return getattr(self.out, attr)
00138 sys.stdout = OutStreamEncoder(sys.stdout, 'utf8')
00139 sys.stderr = OutStreamEncoder(sys.stderr, 'utf8')
00140
00141
00142
00143
00144 try:
00145 '''Import the common python class
00146 '''
00147 import nv_python_libs.common.common_api as common_api
00148 except Exception, e:
00149 sys.stderr.write('''
00150 The subdirectory "nv_python_libs/common" containing the modules common_api.py and
00151 common_exceptions.py (v0.1.3 or greater),
00152 They should have been included with the distribution of MythNetvision
00153 Error(%s)
00154 ''' % e)
00155 sys.exit(1)
00156 if common_api.__version__ < '0.1.3':
00157 sys.stderr.write("\n! Error: Your current installed common_api.py version is (%s)\nYou must at least have version (0.1.3) or higher.\n" % target.__version__)
00158 sys.exit(1)
00159
00160
00161
00162 try:
00163 '''Import the python mnvsearch support classes
00164 '''
00165 import nv_python_libs.mnvsearch.mnvsearch_api as target
00166 except Exception, e:
00167 sys.stderr.write('''
00168 The subdirectory "nv_python_libs/mnvsearch" containing the modules mnvsearch_api and
00169 mnvsearch_exceptions.py (v0.1.0 or greater),
00170 They should have been included with the distribution of mnvsearch.py.
00171 Error(%s)
00172 ''' % e)
00173 sys.exit(1)
00174 if target.__version__ < '0.1.0':
00175 sys.stderr.write("\n! Error: Your current installed mnvsearch_api.py version is (%s)\nYou must at least have version (0.1.0) or higher.\n" % target.__version__)
00176 sys.exit(1)
00177
00178
00179 try:
00180 import nv_python_libs.mainProcess as process
00181 except Exception, e:
00182 sys.stderr.write('''
00183 The python script "nv_python_libs/mainProcess.py" must be present.
00184 Error(%s)
00185 ''' % e)
00186 sys.exit(1)
00187
00188 if process.__version__ < '0.2.0':
00189 sys.stderr.write("\n! Error: Your current installed mainProcess.py version is (%s)\nYou must at least have version (0.2.0) or higher.\n" % process.__version__)
00190 sys.exit(1)
00191
00192 if __name__ == '__main__':
00193
00194 apikey = ""
00195
00196 target.baseProcessingDir = os.path.dirname( os.path.realpath( __file__ ))
00197
00198 target.common = common_api.Common()
00199 main = process.mainProcess(target, apikey, )
00200 main.grabberInfo = {}
00201 main.grabberInfo['title'] = __title__
00202 main.grabberInfo['command'] = u'mnvsearch.py'
00203 main.grabberInfo['mashup_title'] = __mashup_title__
00204 main.grabberInfo['author'] = __author__
00205 main.grabberInfo['thumbnail'] = 'mnvsearch.png'
00206 main.grabberInfo['type'] = ['video', ]
00207 main.grabberInfo['desc'] = u"MythTV Online Content database search."
00208 main.grabberInfo['version'] = __version__
00209 main.grabberInfo['search'] = True
00210 main.grabberInfo['tree'] = False
00211 main.grabberInfo['html'] = False
00212 main.grabberInfo['usage'] = __usage_examples__
00213 main.grabberInfo['SmaxPage'] = __search_max_page_items__
00214 main.grabberInfo['TmaxPage'] = __tree_max_page_items__
00215 main.main()