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