00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 __title__ ="Nature";
00024 __mashup_title__ = "natureMashup"
00025 __author__="R.D. Vaughan"
00026 __version__="0.12"
00027
00028
00029
00030
00031
00032 __usage_examples__ ='''
00033 (Option Help)
00034 > ./nature.py -h
00035 Usage: ./nature.py -hduvlST [parameters] <search text>
00036 Version: v0.1.0 Author: R.D.Vaughan
00037
00038 For details on the MythTV Netvision plugin see the wiki page at:
00039 http://www.mythtv.org/wiki/MythNetvision
00040
00041 Options:
00042 -h, --help show this help message and exit
00043 -d, --debug Show debugging info (URLs, raw XML ... etc, info
00044 varies per grabber)
00045 -u, --usage Display examples for executing the script
00046 -v, --version Display grabber name and supported options
00047 -l LANGUAGE, --language=LANGUAGE
00048 Select data that matches the specified language fall
00049 back to English if nothing found (e.g. 'es' EspaƱol,
00050 'de' Deutsch ... etc). Not all sites or grabbers
00051 support this option.
00052 -p PAGE NUMBER, --pagenumber=PAGE NUMBER
00053 Display specific page of the search results. Default
00054 is page 1. Page number is ignored with the Tree View
00055 option (-T).
00056 -T, --treeview Display a Tree View of a sites videos
00057
00058 > ./nature.py -v
00059 <grabber>
00060 <name>Nature</name>
00061 <author>R.D. Vaughan</author>
00062 <thumbnail>nature.png</thumbnail>
00063 <command>nature.py</command>
00064 <type>video</type>
00065 <description>Mashups combines media from multiple sources to create a new work</description>
00066 <version>0.XX</version>
00067 <search>true</search>
00068 <tree>true</tree>
00069 </grabber>
00070
00071 Search:
00072 > ./nature.py -S "Lions"
00073
00074 Treeview:
00075 > ./nature.py -T
00076 '''
00077 __search_max_page_items__ = 20
00078 __tree_max_page_items__ = 20
00079
00080 import sys, os
00081
00082
00083 class OutStreamEncoder(object):
00084 """Wraps a stream with an encoder"""
00085 def __init__(self, outstream, encoding=None):
00086 self.out = outstream
00087 if not encoding:
00088 self.encoding = sys.getfilesystemencoding()
00089 else:
00090 self.encoding = encoding
00091
00092 def write(self, obj):
00093 """Wraps the output stream, encoding Unicode strings with the specified encoding"""
00094 if isinstance(obj, unicode):
00095 try:
00096 self.out.write(obj.encode(self.encoding))
00097 except IOError:
00098 pass
00099 else:
00100 try:
00101 self.out.write(obj)
00102 except IOError:
00103 pass
00104
00105 def __getattr__(self, attr):
00106 """Delegate everything but write to the stream"""
00107 return getattr(self.out, attr)
00108 sys.stdout = OutStreamEncoder(sys.stdout, 'utf8')
00109 sys.stderr = OutStreamEncoder(sys.stderr, 'utf8')
00110
00111
00112
00113
00114 try:
00115 '''Import the common python class
00116 '''
00117 import nv_python_libs.common.common_api as common_api
00118 except Exception, e:
00119 sys.stderr.write('''
00120 The subdirectory "nv_python_libs/common" containing the modules common_api.py and
00121 common_exceptions.py (v0.1.3 or greater),
00122 They should have been included with the distribution of MythNetvision
00123 Error(%s)
00124 ''' % e)
00125 sys.exit(1)
00126 if common_api.__version__ < '0.1.3':
00127 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__)
00128 sys.exit(1)
00129
00130
00131
00132
00133 try:
00134 '''Import the python mashups support classes
00135 '''
00136 import nv_python_libs.mashups.mashups_api as target
00137 except Exception, e:
00138 sys.stderr.write('''
00139 The subdirectory "nv_python_libs/mashups" containing the modules mashups_api and
00140 mashups_exceptions.py (v0.1.0 or greater),
00141 They should have been included with the distribution of nature.py.
00142 Error(%s)
00143 ''' % e)
00144 sys.exit(1)
00145 if target.__version__ < '0.1.0':
00146 sys.stderr.write("\n! Error: Your current installed mashups_api.py version is (%s)\nYou must at least have version (0.1.0) or higher.\n" % target.__version__)
00147 sys.exit(1)
00148
00149
00150 try:
00151 import nv_python_libs.mainProcess as process
00152 except Exception, e:
00153 sys.stderr.write('''
00154 The python script "nv_python_libs/mainProcess.py" must be present.
00155 Error(%s)
00156 ''' % e)
00157 sys.exit(1)
00158
00159 if process.__version__ < '0.2.0':
00160 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__)
00161 sys.exit(1)
00162
00163 if __name__ == '__main__':
00164
00165 apikey = ""
00166
00167 target.baseProcessingDir = os.path.dirname( os.path.realpath( __file__ ))
00168
00169 target.common = common_api.Common()
00170 main = process.mainProcess(target, apikey, )
00171 main.grabberInfo = {}
00172 main.grabberInfo['title'] = __title__
00173 main.grabberInfo['command'] = u'nature.py'
00174 main.grabberInfo['mashup_title'] = __mashup_title__
00175 main.grabberInfo['author'] = __author__
00176 main.grabberInfo['thumbnail'] = 'nature.png'
00177 main.grabberInfo['type'] = ['video', ]
00178 main.grabberInfo['desc'] = u"Mashups combines media from multiple sources to create a new work"
00179 main.grabberInfo['version'] = __version__
00180
00181 main.grabberInfo['search'] = target.common.checkIfDBItem('dummy', {'feedtitle': __title__, })
00182 main.grabberInfo['tree'] = True
00183 main.grabberInfo['html'] = False
00184 main.grabberInfo['usage'] = __usage_examples__
00185 main.grabberInfo['SmaxPage'] = __search_max_page_items__
00186 main.grabberInfo['TmaxPage'] = __tree_max_page_items__
00187 main.main()