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
00026
00027
00028 __title__ ="blip.tv";
00029 __author__="R.D. Vaughan"
00030 __version__="0.23"
00031
00032
00033
00034
00035
00036
00037
00038
00039 __usage_examples__ ='''
00040 > ./bliptv.py -h
00041 Usage: ./bliptv.py -hduvlST [parameters] <search text>
00042
00043 For details on the MythTV Netvision plugin see the wiki page at:
00044 http://www.mythtv.org/wiki/MythNetvision
00045 Version: v0.22 Author: R.D.Vaughan
00046
00047 Options:
00048 -h, --help show this help message and exit
00049 -d, --debug Show debugging info (URLs, raw XML ... etc, info
00050 varies per grabber)
00051 -u, --usage Display examples for executing the script
00052 -v, --version Display grabber name and supported options
00053 -l LANGUAGE, --language=LANGUAGE
00054 Select data that matches the specified language fall
00055 back to English if nothing found (e.g. 'es' Español,
00056 'de' Deutsch ... etc). Not all sites or grabbers
00057 support this option.
00058 -p PAGE NUMBER, --pagenumber=PAGE NUMBER
00059 Display specific page of the search results. Default
00060 is page 1. Page number is ignored with the Tree
00061 View option (-T).
00062 -S, --search Search for videos
00063 -T, --treeview Display a Tree View of a sites videos
00064
00065
00066 (Search for all videos identified with the word "flute")
00067 >./bliptv.py -p 1 -S "flute"
00068 <?xml version="1.0" encoding="UTF-8"?>
00069 <rss version="2.0"
00070 xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
00071 xmlns:content="http://purl.org/rss/1.0/modules/content/"
00072 xmlns:cnettv="http://cnettv.com/mrss/"
00073 xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
00074 xmlns:media="http://search.yahoo.com/mrss/"
00075 xmlns:atom="http://www.w3.org/2005/Atom"
00076 xmlns:amp="http://www.adobe.com/amp/1.0"
00077 xmlns:dc="http://purl.org/dc/elements/1.1/">
00078 <channel>
00079 <title>blip.tv</title>
00080 <link>http://blip.tv</link>
00081 <description>We're the next generation television network</description>
00082 <numresults>21</numresults>
00083 <returned>20</returned>
00084 <startindex>20</startindex>
00085 <item>
00086 <title>空中散歩</title>
00087 <author>flute</author>
00088 <pubDate>Sun, 25 May 2008 02:39:49 +0000</pubDate>
00089 <description>test</description>
00090 <link>http://blip.tv/file/933615</link>
00091 <media:group>
00092 <media:thumbnail url='http://a.images.blip.tv/Flute-416-140-781.jpg'/>
00093 <media:content url='http://blip.tv/file/get/Flute-416.avi' duration='30' width='' height='' lang='en'/>
00094 </media:group>
00095 <rating>0.0</rating>
00096 </item>
00097 ...
00098 <item>
00099 <title>Bright Sunny Place (music video excerpt)</title>
00100 <author>tokyosax</author>
00101 <pubDate>Mon, 24 Sep 2007 11:05:46 +0000</pubDate>
00102 <description>A brief snippet of my flute work from a larger video composition viewable at http://www.youtube.com/profile?user=japanjazzman. Original tune, original forehead.</description>
00103 <link>http://blip.tv/file/394159</link>
00104 <media:group>
00105 <media:thumbnail url='http://a.images.blip.tv/Arnoldbaruch-BrightSunnyPlace503-931.jpg'/>
00106 <media:content url='http://blip.tv/file/get/Arnoldbaruch-BrightSunnyPlace310.mov' duration='45' width='' height='' lang='en'/>
00107 </media:group>
00108 <rating>0.0</rating>
00109 </item>
00110 </channel>
00111 </rss>
00112
00113 (Create a Blip.tv Tree view)
00114 >./bliptv.py -T
00115 <?xml version="1.0" encoding="UTF-8"?>
00116 <rss version="2.0"
00117 xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
00118 xmlns:content="http://purl.org/rss/1.0/modules/content/"
00119 xmlns:cnettv="http://cnettv.com/mrss/"
00120 xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
00121 xmlns:media="http://search.yahoo.com/mrss/"
00122 xmlns:atom="http://www.w3.org/2005/Atom"
00123 xmlns:amp="http://www.adobe.com/amp/1.0"
00124 xmlns:dc="http://purl.org/dc/elements/1.1/">
00125 <channel>
00126 <title>blip.tv</title>
00127 <link>http://blip.tv</link>
00128 <description>We're the next generation television network</description>
00129 <numresults>0</numresults>
00130 <returned>1</returned>
00131 <startindex>0</startindex>
00132 <directory name="Popular/Recent/Features/Random ..." thumbnail="/usr/local/share/mythtv//mythnetvision/icons/bliptv.png">
00133 <directory name="Most Comments" thumbnail="/usr/local/share/mythtv//mythnetvision/icons/directories/topics/most_comments.png">
00134 <item>
00135 <title>VIDEO: Eritrea Movie Timali (Part 24)</title>
00136 <author>asmarino5</author>
00137 <pubDate>Mon, 04 Jan 2010 05:30:21 +0000</pubDate>
00138 <description>VIDEO: Eritrea Movie Timali (Part 24)</description>
00139 <link>http://blip.tv/file/3043223</link>
00140 <media:group>
00141 <media:thumbnail url='http://a.images.blip.tv/Asmarino5-VIDEOEritreaMovieTimaliPart24121-227.jpg'/>
00142 <media:content url='http://blip.tv/file/get/Asmarino5-VIDEOEritreaMovieTimaliPart24121.wmv' duration='2216' width='320' height='240' lang='en'/>
00143 </media:group>
00144 <rating>0.0</rating>
00145 </item>
00146 ...
00147 <item>
00148 <title>informest</title>
00149 <author>fluido</author>
00150 <pubDate>Sun, 03 Jan 2010 22:23:56 +0000</pubDate>
00151 <description>informest</description>
00152 <link>http://blip.tv/file/3042202</link>
00153 <media:group>
00154 <media:thumbnail url='http://a.images.blip.tv/Fluido-informest458-244.jpg'/>
00155 <media:content url='http://blip.tv/file/get/Fluido-informest458.mp4' duration='310' width='720' height='576' lang='en'/>
00156 </media:group>
00157 <rating>0.0</rating>
00158 </item>
00159 </directory>
00160 </directory>
00161 </channel>
00162 </rss>
00163 '''
00164
00165 __max_page_items__ = 20
00166
00167 import sys, os
00168
00169 class OutStreamEncoder(object):
00170 """Wraps a stream with an encoder"""
00171 def __init__(self, outstream, encoding=None):
00172 self.out = outstream
00173 if not encoding:
00174 self.encoding = sys.getfilesystemencoding()
00175 else:
00176 self.encoding = encoding
00177
00178 def write(self, obj):
00179 """Wraps the output stream, encoding Unicode strings with the specified encoding"""
00180 if isinstance(obj, unicode):
00181 try:
00182 self.out.write(obj.encode(self.encoding))
00183 except IOError:
00184 pass
00185 else:
00186 try:
00187 self.out.write(obj)
00188 except IOError:
00189 pass
00190
00191 def __getattr__(self, attr):
00192 """Delegate everything but write to the stream"""
00193 return getattr(self.out, attr)
00194 sys.stdout = OutStreamEncoder(sys.stdout, 'utf8')
00195 sys.stderr = OutStreamEncoder(sys.stderr, 'utf8')
00196
00197
00198
00199
00200
00201
00202 try:
00203 import nv_python_libs.bliptv.bliptv_api as target
00204 except Exception, e:
00205 sys.stderr.write('''
00206 The subdirectory "nv_python_libs/bliptv" containing the modules bliptv_api.py (v0.2.0 or greater),
00207 They should have been included with the distribution of bliptv.py.
00208 Error(%s)
00209 ''' % e)
00210 sys.exit(1)
00211
00212 if target.__version__ < '0.2.0':
00213 sys.stderr.write("\n! Error: Your current installed bliptv_api.py version is (%s)\nYou must at least have version (0.2.0) or higher.\n" % target.__version__)
00214 sys.exit(1)
00215
00216
00217
00218 try:
00219 import nv_python_libs.mainProcess as process
00220 except Exception, e:
00221 sys.stderr.write('''
00222 The python script "nv_python_libs/mainProcess.py" must be present.
00223 Error(%s)
00224 ''' % e)
00225 sys.exit(1)
00226
00227 if process.__version__ < '0.2.0':
00228 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__)
00229 sys.exit(1)
00230
00231 if __name__ == '__main__':
00232
00233 apikey = ""
00234 main = process.mainProcess(target, apikey, )
00235 main.grabberInfo = {}
00236 main.grabberInfo['title'] = __title__
00237 main.grabberInfo['command'] = u'bliptv.py'
00238 main.grabberInfo['author'] = __author__
00239 main.grabberInfo['thumbnail'] = 'bliptv.png'
00240 main.grabberInfo['type'] = ['video']
00241 main.grabberInfo['desc'] = u"We're the next generation television network."
00242 main.grabberInfo['version'] = __version__
00243 main.grabberInfo['search'] = True
00244 main.grabberInfo['tree'] = True
00245 main.grabberInfo['html'] = False
00246 main.grabberInfo['usage'] = __usage_examples__
00247 main.grabberInfo['SmaxPage'] = __max_page_items__
00248 main.grabberInfo['TmaxPage'] = __max_page_items__
00249 main.main()