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