00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 __title__ ="Space";
00024 __mashup_title__ = "spaceMashup"
00025 __author__="R.D. Vaughan"
00026 __version__="v0.10"
00027
00028
00029 __usage_examples__ ='''
00030 (Option Help)
00031 > ./space.py -h
00032 Usage: ./space.py -hduvlST [parameters] <search text>
00033 Version: v0.1.0 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 > ./space.py -v
00056 Space Mashup|T
00057
00058
00059 > ./space.py -T
00060 '''
00061 __search_max_page_items__ = 20
00062 __tree_max_page_items__ = 20
00063
00064 import sys, os
00065
00066
00067 class OutStreamEncoder(object):
00068 """Wraps a stream with an encoder"""
00069 def __init__(self, outstream, encoding=None):
00070 self.out = outstream
00071 if not encoding:
00072 self.encoding = sys.getfilesystemencoding()
00073 else:
00074 self.encoding = encoding
00075
00076 def write(self, obj):
00077 """Wraps the output stream, encoding Unicode strings with the specified encoding"""
00078 if isinstance(obj, unicode):
00079 try:
00080 self.out.write(obj.encode(self.encoding))
00081 except IOError:
00082 pass
00083 else:
00084 try:
00085 self.out.write(obj)
00086 except IOError:
00087 pass
00088
00089 def __getattr__(self, attr):
00090 """Delegate everything but write to the stream"""
00091 return getattr(self.out, attr)
00092 sys.stdout = OutStreamEncoder(sys.stdout, 'utf8')
00093 sys.stderr = OutStreamEncoder(sys.stderr, 'utf8')
00094
00095
00096
00097
00098
00099 try:
00100 '''Import the common python class
00101 '''
00102 import nv_python_libs.common.common_api as common_api
00103 except Exception, e:
00104 sys.stderr.write('''
00105 The subdirectory "nv_python_libs/common" containing the modules mashups_api.py and
00106 mashups_exceptions.py (v0.1.3 or greater),
00107 They should have been included with the distribution of MythNetvision
00108 Error(%s)
00109 ''' % e)
00110 sys.exit(1)
00111
00112 if common_api.__version__ < '0.1.3':
00113 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__)
00114 sys.exit(1)
00115
00116
00117
00118 try:
00119 '''Import the python mashups support classes
00120 '''
00121 import nv_python_libs.mashups.mashups_api as target
00122 except Exception, e:
00123 sys.stderr.write('''
00124 The subdirectory "nv_python_libs/mashups" containing the modules mashups_api and
00125 mashups_exceptions.py (v0.1.0 or greater),
00126 They should have been included with the distribution of space.py.
00127 Error(%s)
00128 ''' % e)
00129 sys.exit(1)
00130 if target.__version__ < '0.1.0':
00131 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__)
00132 sys.exit(1)
00133
00134
00135 try:
00136 import nv_python_libs.mainProcess as process
00137 except Exception, e:
00138 sys.stderr.write('''
00139 The python script "nv_python_libs/mainProcess.py" must be present.
00140 Error(%s)
00141 ''' % e)
00142 sys.exit(1)
00143
00144 if process.__version__ < '0.2.0':
00145 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__)
00146 sys.exit(1)
00147
00148 if __name__ == '__main__':
00149
00150 apikey = ""
00151
00152 target.baseProcessingDir = os.path.dirname( os.path.realpath( __file__ ))
00153
00154 target.common = common_api.Common()
00155 main = process.mainProcess(target, apikey, )
00156 main.grabberInfo = {}
00157 main.grabberInfo['title'] = __title__
00158 main.grabberInfo['command'] = u'space.py'
00159 main.grabberInfo['mashup_title'] = __mashup_title__
00160 main.grabberInfo['author'] = __author__
00161 main.grabberInfo['thumbnail'] = 'space.png'
00162 main.grabberInfo['type'] = ['video', ]
00163 main.grabberInfo['desc'] = u"Mashups combines media from multiple sources to create a new work"
00164 main.grabberInfo['version'] = __version__
00165 main.grabberInfo['search'] = target.common.checkIfDBItem('dummy', {'feedtitle': __title__, })
00166 main.grabberInfo['tree'] = True
00167 main.grabberInfo['html'] = False
00168 main.grabberInfo['usage'] = __usage_examples__
00169 main.grabberInfo['SmaxPage'] = __search_max_page_items__
00170 main.grabberInfo['TmaxPage'] = __tree_max_page_items__
00171 main.main()