MythTV master
vimeo.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2# -*- coding: UTF-8 -*-
3# ----------------------
4# Name: vimeo.py
5# Python Script
6# Author: R.D. Vaughan
7# Purpose:
8# This python script is intended to perform vimeo.com lookups for the MythTV Netvision plugin
9# based on information found on the http://vimeo.com/ website. It
10# follows the MythTV Netvision grabber standards.
11# This script uses the python module vimeo.py which should be included
12# with this script.
13# The vimeo.py module uses the full access API v2 api published by
14# http://vimeo.com/ see: http://vimeo.com/api/docs/advanced-api
15# Users of this script are encouraged to populate vimeo.com with your own Videos. The richer the source the
16# more valuable the script.
17# Command example:
18# See help (-u and -h) options
19#
20# Design:
21# 1) Import the specific target site API library.
22# 2) Set the title for the scrips and the API optional key for the target video site
23# 3) Call the common processing routine
24#
25#
26# License:Creative Commons GNU GPL v2
27# (http://creativecommons.org/licenses/GPL/2.0/)
28#-------------------------------------
29__title__ ="Vimeo";
30__author__="R.D. Vaughan"
31__version__="0.23"
32# 0.1.0 Initial development
33# 0.1.1 Added the Tree view option
34# 0.1.2 Documentation review
35# 0.2.0 Public release
36# 0.2.1 Improved error display messages on an exception abort
37# 0.22 Change to support xml version information display
38# 0.23 Added the "command" tag to the xml version information display
39
40__usage_examples__ ='''
41> ./vimeo.py -h
42Usage: ./vimeo.py -hduvlST [parameters] <search text>
43Version: v0.22 Author: R.D.Vaughan
44
45For details on the MythTV Netvision plugin see the wiki page at:
46http://www.mythtv.org/wiki/MythNetvision
47
48Options:
49 -h, --help show this help message and exit
50 -d, --debug Show debugging info (URLs, raw XML ... etc, info
51 varies per grabber)
52 -u, --usage Display examples for executing the script
53 -v, --version Display grabber name and supported options
54 -l LANGUAGE, --language=LANGUAGE
55 Select data that matches the specified language fall
56 back to English if nothing found (e.g. 'es' Español,
57 'de' Deutsch ... etc). Not all sites or grabbers
58 support this option.
59 -p PAGE NUMBER, --pagenumber=PAGE NUMBER
60 Display specific page of the search results. Default
61 is page 1. Page number is ignored with the Tree View
62 option (-T).
63 -S, --search Search for videos
64 -T, --treeview Display a Tree View of a sites videos
65
66
67(Search for all videos identified with the word "Dragon")
68> ./vimeo.py -p 1 -S "Dragon"
69<?xml version="1.0" encoding="UTF-8"?>
70<rss version="2.0"
71xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
72xmlns:content="http://purl.org/rss/1.0/modules/content/"
73xmlns:cnettv="http://cnettv.com/mrss/"
74xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
75xmlns:media="http://search.yahoo.com/mrss/"
76xmlns:atom="http://www.w3.org/2005/Atom"
77xmlns:amp="http://www.adobe.com/amp/1.0"
78xmlns:dc="http://purl.org/dc/elements/1.1/">
79 <channel>
80 <title>Vimeo</title>
81 <link>http://vimeo.com</link>
82 <description>Vimeo is a respectful community of creative people who are passionate about sharing the videos they make.</description>
83 <numresults>4856</numresults>
84 <returned>20</returned>
85 <startindex>20</startindex>
86 <item>
87 <title>Typophile Film Festival 5 Opening Titles</title>
88 <author>Brent Barson</author>
89 <pubDate>Tue, 01 Sep 2009 12:27:46 GMT</pubDate>
90 <description>Handcrafted with love by BYU design students and faculty, for the 5th Typophile Film Festival. A visual typographic feast about the five senses, and how they contribute to and enhance our creativity. Everything in the film is real—no CG effects! Shot with a RED One, a Canon EOS 5D Mark II, a Canon EOS 40D, and a Nikon D80. Stop motion created with Dragon Stop Motion. Creative Director &amp; Faculty Mentor: Brent Barson Writing &amp; Storyboarding: Brent Barson, Jessica Blackham, Analisa Estrada, Meg Gallagher, John Jensen, Regan Fred Johnson, Colin “The Pin” Pinegar Construction, Paint &amp; Glue: Brent Barson, Wynn Burton, Analisa Estrada, Meg Gallagher, Olivia Juarez Knudsen, Casey Lewis, Reeding Roberts, Deven Stephens, Brian Christensen (Brain Sculpture) Animators: Brent Barson, Wynn Burton, Analisa Estrada, Meg Gallagher, Olivia Juarez Knudsen, Reeding Roberts, Deven Stephens Cinematographer: Wynn Burton Editing: Brent Barson, Wynn Burton, Analisa Estrada, Meg Gallagher, Reeding Roberts Hand Models: Analisa Estrada, Meg Gallagher, Olivia Juarez Knudsen, Deven Stephens, Michelle Stephens Original Music: micah dahl anderson - www.micahdahl.com Special thanks to Joe, Jared, Zara, and the Punchut/Typophile crew for enabling this!</description>
91 <link>http://vimeo.com/moogaloop.swf?clip_id=6382511&amp;autoplay=1</link>
92 <media:group>
93 <media:thumbnail url='http://ats.vimeo.com/238/418/23841853_200.jpg'/>
94 <media:content url='http://vimeo.com/moogaloop.swf?clip_id=6382511&amp;autoplay=1' duration='221' width='640' height='352' lang=''/>
95 </media:group>
96 <rating>3233</rating>
97 </item>
98...
99 <item>
100 <title>"The Dragon's Claw" by Justice of the Unicorns</title>
101 <author>Robert Bruce</author>
102 <pubDate>Mon, 20 Apr 2009 08:10:32 GMT</pubDate>
103 <description>"The Dragon's Claw" The official music video for Justice of the Unicorns from the album "Angels with Uzis". Winner of Best Music Video at the 2009 Animation Block Party. http://justiceoftheunicorns.com Animated in Flash. Composited in Combustion. Get your free Cubeecraft Bunny Toy! http://robbruce.blogspot.com/2009/05/mutant-pmp-bunny-of-your-very-own.html robthebruce.com Please feel free to email me for rate quotes, questions, answers, weather reports, cookie recipes, or just to say hi. rob@robthebruce.com</description>
104 <link>http://vimeo.com/moogaloop.swf?clip_id=4239300&amp;autoplay=1</link>
105 <media:group>
106 <media:thumbnail url='http://ats.vimeo.com/926/443/9264438_200.jpg'/>
107 <media:content url='http://vimeo.com/moogaloop.swf?clip_id=4239300&amp;autoplay=1' duration='206' width='640' height='368' lang=''/>
108 </media:group>
109 <rating>47</rating>
110 </item>
111 </channel>
112</rss>
113
114(Option return Tree view)
115> ./vimeo.py -T
116<?xml version="1.0" encoding="UTF-8"?>
117<rss version="2.0"
118xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
119xmlns:content="http://purl.org/rss/1.0/modules/content/"
120xmlns:cnettv="http://cnettv.com/mrss/"
121xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
122xmlns:media="http://search.yahoo.com/mrss/"
123xmlns:atom="http://www.w3.org/2005/Atom"
124xmlns:amp="http://www.adobe.com/amp/1.0"
125xmlns:dc="http://purl.org/dc/elements/1.1/">
126 <channel>
127 <title>Vimeo</title>
128 <link>http://vimeo.com</link>
129 <description>Vimeo is a respectful community of creative people who are passionate about sharing the videos they make.</description>
130 <numresults>18</numresults>
131 <returned>1</returned>
132 <startindex>0</startindex>
133 <directory name="Newest Channels/Most ..." thumbnail="/usr/local/share/mythtv/mythnetvision/icons/vimeo.png">
134 <directory name="Most Recent Channels" thumbnail="/usr/local/share/mythtv/mythnetvision/icons/directories/topics/most_recent.png">
135 <item>
136 <title>PSA 1: Family Meal is a Healthy Meal</title>
137 <author>Kevin Shermach</author>
138 <pubDate>Tue, 05 Jan 2010 13:08:56 GMT</pubDate>
139 <description>Channel "NYC YMCA new PSA Campaign": :30, :15 and :10</description>
140 <link>http://vimeo.com/moogaloop.swf?clip_id=8557253&amp;autoplay=1</link>
141 <media:group>
142 <media:thumbnail url='http://ts.vimeo.com.s3.amazonaws.com/402/131/40213146_200.jpg'/>
143 <media:content url='http://vimeo.com/moogaloop.swf?clip_id=8557253&amp;autoplay=1' duration='60' width='480' height='272' lang=''/>
144 </media:group>
145 <rating>0</rating>
146 </item>
147...
148 <item>
149 <title>NIN Sydney 2.24.09 - Mid-show Power Outage [HD]</title>
150 <author>Nine Inch Nails</author>
151 <pubDate>Tue, 24 Feb 2009 13:58:19 GMT</pubDate>
152 <description>Power in the Hordern Pavilion went out midway through the set, forcing the show to stop for 40 minutes and nearly causing it to be canceled. Filmed by Rob Sheridan with the Canon 5D Mark II.</description>
153 <link>http://vimeo.com/moogaloop.swf?clip_id=3353364&amp;autoplay=1</link>
154 <media:group>
155 <media:thumbnail url='http://ats.vimeo.com/240/077/2400771_200.jpg'/>
156 <media:content url='http://vimeo.com/moogaloop.swf?clip_id=3353364&amp;autoplay=1' duration='268' width='504' height='284' lang=''/>
157 </media:group>
158 <rating>216</rating>
159 </item>
160 </directory>
161 </directory>
162 </directory>
163 </channel>
164</rss>
165'''
166__search_max_page_items__ = 20
167__tree_max_page_items__ = 20
168
169import sys, os
170import io
171
172class OutStreamEncoder(object):
173 """Wraps a stream with an encoder
174 """
175 def __init__(self, outstream, encoding=None):
176 self.out = outstream
177 if not encoding:
178 self.encoding = sys.getfilesystemencoding()
179 else:
180 self.encoding = encoding
181
182 def write(self, obj):
183 """Wraps the output stream, encoding Unicode strings with the specified encoding"""
184 if isinstance(obj, str):
185 obj = obj.encode(self.encoding)
186 self.out.buffer.write(obj)
187
188 def __getattr__(self, attr):
189 """Delegate everything but write to the stream"""
190 return getattr(self.out, attr)
191
192# Sub class sys.stdout and sys.stderr as a utf8 stream. Deals with print and stdout unicode issues
193if isinstance(sys.stdout, io.TextIOWrapper):
194 sys.stdout = OutStreamEncoder(sys.stdout, 'utf8')
195 sys.stderr = OutStreamEncoder(sys.stderr, 'utf8')
196
197# Makes it easier to debug. Comment out for production
198#import nv_python_libs.vimeo.vimeo_api as target
199
200# Verify that the tmdb_api modules are installed and accessible
201try:
202 import nv_python_libs.vimeo.vimeo_api as target
203except Exception as e:
204 sys.stderr.write('''
205The subdirectory "nv_python_libs/vimeo" containing the modules vimeo_api.py (v0.2.0 or greater),
206They should have been included with the distribution of vimeo.py.
207Error(%s)
208''' % e)
209 sys.exit(1)
210
211if target.__version__ < '0.2.0':
212 sys.stderr.write("\n! Error: Your current installed vimeo_api.py version is (%s)\nYou must at least have version (0.2.0) or higher.\n" % target.__version__)
213 sys.exit(1)
214
215
216# Makes it easier to debug. Comment out for production
217import nv_python_libs.mainProcess as process
218
219
220# Verify that the common process modules are installed and accessible
221try:
222 import nv_python_libs.mainProcess as process
223except Exception as e:
224 sys.stderr.write('''
225The python script "nv_python_libs/mainProcess.py" must be present.
226Error(%s)
227''' % e)
228 sys.exit(1)
229
230if process.__version__ < '0.2.0':
231 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__)
232 sys.exit(1)
233
234if __name__ == '__main__':
235 # No api key is required
236 apikey = ""
237 main = process.mainProcess(target, apikey, )
238 main.grabberInfo = {}
239 main.grabberInfo['enabled'] = True
240 main.grabberInfo['title'] = __title__
241 main.grabberInfo['command'] = 'vimeo.py'
242 main.grabberInfo['author'] = __author__
243 main.grabberInfo['thumbnail'] = 'vimeo.png'
244 main.grabberInfo['type'] = ['video']
245 main.grabberInfo['desc'] = "Vimeo is a respectful community of creative people who are passionate about sharing the videos they make."
246 main.grabberInfo['version'] = __version__
247 main.grabberInfo['search'] = True
248 main.grabberInfo['tree'] = True
249 main.grabberInfo['html'] = False
250 main.grabberInfo['usage'] = __usage_examples__
251 main.grabberInfo['SmaxPage'] = __search_max_page_items__
252 main.grabberInfo['TmaxPage'] = __tree_max_page_items__
253 main.main()
def __getattr__(self, attr)
Definition: vimeo.py:188
def __init__(self, outstream, encoding=None)
Definition: vimeo.py:175
def write(self, obj)
Definition: vimeo.py:182