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__ ="Hulu";
00026 __mashup_title__ = "hulu"
00027 __author__="R.D. Vaughan"
00028 __version__="0.13"
00029
00030
00031
00032
00033
00034 __usage_examples__ ='''
00035 (Option Help)
00036 > ./hulu.py -h
00037 Usage: ./hulu.py -hduvlST [parameters] <search text>
00038 Version: v0.1.1 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 -T, --treeview Display a Tree View of a sites videos
00060
00061 > ./hulu.py -v
00062 <grabber>
00063 <name>Hulu</name>
00064 <author>R.D.Vaughan</author>
00065 <thumbnail>hulu.png</thumbnail>
00066 <type>video</type>
00067 <description>Hulu.com is a free online video service that offers hit TV shows including Family Guy, 30 Rock, and the Daily Show with Jon Stewart, etc.</description>
00068 <version>v0.11</version>
00069 <search>true</search>
00070 <tree>true</tree>
00071 </grabber>
00072
00073 > ./hulu.py -S "Burn Notice"
00074 <?xml version="1.0" encoding="UTF-8"?>
00075 <rss version="2.0" xmlns:amp="http://www.adobe.com/amp/1.0"
00076 xmlns:atom="http://www.w3.org/2005/Atom"
00077 xmlns:cnettv="http://cnettv.com/mrss/"
00078 xmlns:content="http://purl.org/rss/1.0/modules/content/"
00079 xmlns:creativecommons="http://backend.userland.com/creativeCommonsRssModule"
00080 xmlns:dc="http://purl.org/dc/elements/1.1/"
00081 xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:media="http://search.yahoo.com/mrss/">
00082 <channel>
00083 <title>Hulu</title>
00084 <link>http://hulu.com</link>
00085 <description>Hulu.com is a free online video service that offers hit TV shows including Family Guy, 30 Rock, and the Daily Show with Jon Stewart, etc.</description>
00086 <numresults>25</numresults>
00087 <returned>21</returned>
00088 <startindex>21</startindex>
00089 <item>
00090 <title>Burn Notice - A Dark Road</title>
00091 <author>USA</author>
00092 <pubDate>Mon, 25 Jan 2010 17:45:06 GMT</pubDate>
00093 <description>Commentary with Matt Nix</description>
00094 <link>http://www.hulu.com/watch/122855/burn-notice-a-dark-road#http%3A%2F%2Fwww.hulu.com%2Ffeed%2Fsearch%3Fquery%3DBurn%2BNotice%2Bdate%253Anewest%26sort_by%3Drelevance%26st%3D0</link>
00095 <mrss:group xmlns:mrss="http://search.yahoo.com/mrss/">
00096 <mrss:thumbnail url="http://thumbnails.hulu.com/231/50029231/140025_145x80_generated.jpg"/>
00097 <mrss:content duration="05:19" height="" lang=""
00098 url="http://www.hulu.com/watch/122855/burn-notice-a-dark-road#http%3A%2F%2Fwww.hulu.com%2Ffeed%2Fsearch%3Fquery%3DBurn%2BNotice%2Bdate%253Anewest%26sort_by%3Drelevance%26st%3D0" width=""/>
00099 </mrss:group>
00100 <rating>4.1</rating>
00101 </item>
00102 ...
00103 <item>
00104 <title>Burn Notice - s3 | e15 - Good Intentions</title>
00105 <author>USA</author>
00106 <pubDate>Sat, 27 Feb 2010 03:05:06 GMT</pubDate>
00107 <description>Fiona seems to get more than she bargained for when she becomes involved with a paranoid kidnapper, only to discover that he's more than what he appears.</description>
00108 <link>http://www.hulu.com/watch/131000/burn-notice-good-intentions#http%3A%2F%2Fwww.hulu.com%2Ffeed%2Fsearch%3Fquery%3DBurn%2BNotice%2Bdate%253Anewest%26sort_by%3Drelevance%26st%3D0</link>
00109 <mrss:group xmlns:mrss="http://search.yahoo.com/mrss/">
00110 <mrss:thumbnail url="http://thumbnails.hulu.com/183/50037183/148491_145x80_generated.jpg"/>
00111 <mrss:content duration="43:32" height="" lang=""
00112 url="http://www.hulu.com/watch/131000/burn-notice-good-intentions#http%3A%2F%2Fwww.hulu.com%2Ffeed%2Fsearch%3Fquery%3DBurn%2BNotice%2Bdate%253Anewest%26sort_by%3Drelevance%26st%3D0" width=""/>
00113 </mrss:group>
00114 <rating>4.5</rating>
00115 </item>
00116 </channel>
00117 </rss>
00118
00119 > ./hulu.py -T
00120 <?xml version="1.0" encoding="UTF-8"?>
00121 <rss version="2.0" xmlns:amp="http://www.adobe.com/amp/1.0"
00122 xmlns:atom="http://www.w3.org/2005/Atom"
00123 xmlns:cnettv="http://cnettv.com/mrss/"
00124 xmlns:content="http://purl.org/rss/1.0/modules/content/"
00125 xmlns:creativecommons="http://backend.userland.com/creativeCommonsRssModule"
00126 xmlns:dc="http://purl.org/dc/elements/1.1/"
00127 xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:media="http://search.yahoo.com/mrss/">
00128 <channel>
00129 <title>Hulu</title>
00130 <link>http://hulu.com</link>
00131 <description>Hulu.com is a free online video service that offers hit TV shows including Family Guy, 30 Rock, and the Daily Show with Jon Stewart, etc.</description>
00132 <numresults>1</numresults>
00133 <returned>1</returned>
00134 <startindex>1</startindex>
00135 <directory name="Hulu" thumbnail="/usr/local/share/mythtv/mythnetvision/icons/hulu.png">
00136 <directory name="Hulu - Recently added videos" thumbnail="/usr/local/share/mythtv/mythnetvision/icons/hulu.png">
00137 <item>
00138 <title>NBC TODAY Show - Mood Meds Pose ‘Weighty’ Issue</title>
00139 <author>MSNBC</author>
00140 <pubDate>Wed, 07 Apr 2010 14:54:05 GMT</pubDate>
00141 <description>While battling depression, Lauren Slater faced a tough choice: She could take a prescription that would improve her mood, but it would make her gain weight. She discusses her experience with psychiatrist Dr. Catherine Birndorf and Dr. Nancy Snyderman.</description>
00142 <link>http://rss.hulu.com/~r/HuluRecentlyAddedVideos/~3/ExUXTu_hOTo/nbc-today-show-mood-meds-pose-%E2%80%98weighty%E2%80%99-issue</link>
00143 <mrss:group xmlns:mrss="http://search.yahoo.com/mrss/">
00144 <mrss:thumbnail url="http://thumbnails.hulu.com/931/50046931/159024_145x80_generated.jpg"/>
00145 <mrss:content duration="05:05" height="" lang=""
00146 url="http://rss.hulu.com/~r/HuluRecentlyAddedVideos/~3/ExUXTu_hOTo/nbc-today-show-mood-meds-pose-%E2%80%98weighty%E2%80%99-issue" width=""/>
00147 </mrss:group>
00148 <rating>0.0</rating>
00149 </item>
00150 ...
00151 <item>
00152 <title>X-Play - Top 4 Open World Games of 2008</title>
00153 <author>G4</author>
00154 <pubDate>Thu, 10 Apr 2008 04:06:27 GMT</pubDate>
00155 <description>X-Play brings you their list of the most anticipated sandbox games for this year.</description>
00156 <link>http://www.hulu.com/watch/16729/x-play-top-4-open-world-games-of-2008#http%3A%2F%2Fwww.hulu.com%2Ffeed%2Fexpiring%2Fvideos</link>
00157 <mrss:group xmlns:mrss="http://search.yahoo.com/mrss/">
00158 <mrss:thumbnail url="http://thumbnails.hulu.com/7/827/18906_145x80_manicured__6DZDj36Oa0GlHMbezc3SfA.jpg"/>
00159 <mrss:content duration="02:14" height="" lang=""
00160 url="http://www.hulu.com/watch/16729/x-play-top-4-open-world-games-of-2008#http%3A%2F%2Fwww.hulu.com%2Ffeed%2Fexpiring%2Fvideos" width=""/>
00161 </mrss:group>
00162 <rating>4.1</rating>
00163 </item>
00164 </directory>
00165 </directory>
00166 </channel>
00167 </rss>
00168 '''
00169 __search_max_page_items__ = 20
00170 __tree_max_page_items__ = 20
00171
00172 import sys, os
00173
00174
00175 class OutStreamEncoder(object):
00176 """Wraps a stream with an encoder"""
00177 def __init__(self, outstream, encoding=None):
00178 self.out = outstream
00179 if not encoding:
00180 self.encoding = sys.getfilesystemencoding()
00181 else:
00182 self.encoding = encoding
00183
00184 def write(self, obj):
00185 """Wraps the output stream, encoding Unicode strings with the specified encoding"""
00186 if isinstance(obj, unicode):
00187 try:
00188 self.out.write(obj.encode(self.encoding))
00189 except IOError:
00190 pass
00191 else:
00192 try:
00193 self.out.write(obj)
00194 except IOError:
00195 pass
00196
00197 def __getattr__(self, attr):
00198 """Delegate everything but write to the stream"""
00199 return getattr(self.out, attr)
00200 sys.stdout = OutStreamEncoder(sys.stdout, 'utf8')
00201 sys.stderr = OutStreamEncoder(sys.stderr, 'utf8')
00202
00203
00204
00205
00206 try:
00207 '''Import the common python class
00208 '''
00209 import nv_python_libs.common.common_api as common_api
00210 except Exception, e:
00211 sys.stderr.write('''
00212 The subdirectory "nv_python_libs/common" containing the modules common_api.py and
00213 common_exceptions.py (v0.1.3 or greater),
00214 They should have been included with the distribution of MythNetvision
00215 Error(%s)
00216 ''' % e)
00217 sys.exit(1)
00218 if common_api.__version__ < '0.1.3':
00219 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__)
00220 sys.exit(1)
00221
00222
00223
00224 try:
00225 '''Import the python hulu support classes
00226 '''
00227 import nv_python_libs.hulu.hulu_api as target
00228 except Exception, e:
00229 sys.stderr.write('''
00230 The subdirectory "nv_python_libs/hulu" containing the modules hulu_api and
00231 hulu_exceptions.py (v0.1.0 or greater),
00232 They should have been included with the distribution of hulu.py.
00233 Error(%s)
00234 ''' % e)
00235 sys.exit(1)
00236 if target.__version__ < '0.1.0':
00237 sys.stderr.write("\n! Error: Your current installed hulu_api.py version is (%s)\nYou must at least have version (0.1.0) or higher.\n" % target.__version__)
00238 sys.exit(1)
00239
00240
00241 try:
00242 import nv_python_libs.mainProcess as process
00243 except Exception, e:
00244 sys.stderr.write('''
00245 The python script "nv_python_libs/mainProcess.py" must be present.
00246 Error(%s)
00247 ''' % e)
00248 sys.exit(1)
00249
00250 if process.__version__ < '0.2.0':
00251 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__)
00252 sys.exit(1)
00253
00254 if __name__ == '__main__':
00255
00256 apikey = ""
00257
00258 target.baseProcessingDir = os.path.dirname( os.path.realpath( __file__ ))
00259
00260 target.common = common_api.Common()
00261 main = process.mainProcess(target, apikey, )
00262 main.grabberInfo = {}
00263 main.grabberInfo['title'] = __title__
00264 main.grabberInfo['command'] = u'hulu.py'
00265 main.grabberInfo['mashup_title'] = __mashup_title__
00266 main.grabberInfo['author'] = __author__
00267 main.grabberInfo['thumbnail'] = 'hulu.png'
00268 main.grabberInfo['type'] = ['video', ]
00269 main.grabberInfo['desc'] = u"Hulu.com is a free online video service that offers hit TV shows including Family Guy, 30 Rock, and the Daily Show with Jon Stewart."
00270 main.grabberInfo['version'] = __version__
00271 main.grabberInfo['search'] = True
00272 main.grabberInfo['tree'] = True
00273 main.grabberInfo['html'] = False
00274 main.grabberInfo['usage'] = __usage_examples__
00275 main.grabberInfo['SmaxPage'] = __search_max_page_items__
00276 main.grabberInfo['TmaxPage'] = __tree_max_page_items__
00277 main.main()