vimeo / vimeo.py Goto Github PK
View Code? Open in Web Editor NEWOfficial Python library for the Vimeo API.
Home Page: https://developer.vimeo.com
License: Apache License 2.0
Official Python library for the Vimeo API.
Home Page: https://developer.vimeo.com
License: Apache License 2.0
It would be nice to have real exceptions I can catch, instead of asserts. For instance, when uploading a video, something like UploadTicketCreationFailure
and VideoCreationFailure
exceptions, with the information from the server. The server returns a proper error ("Your video file is not valid..." in mine case, because I was testing how it responds with non-video files), but those messages are not handled in any way.
Currently a puttable resource does not allow for you to provide a body. This should be corrected so that cases that require this can be changed.
I am writing a command line localhost utility for interacting with vimeo. I was wondering what is the proper/easiest way to handle the URI redirect for authenticating with vimeo and for other people to use the command line utility.
Hi,
I have small problem, (maybe trivial for you).
I'm trying to get pictures of given video so handler would be
GEThttps://api.vimeo.com/videos/{video_id}/pictures , but how I can build requst using vimeo.py
So I need somenting like
v_client.videos.video_id.pictures, were video_id is variable.
Please can you provide me some example
Thanks
We should add a note about configuring test_vimeo.py
.
There are several settings in there that need to be configured, and some of them aren't immediately obvious (in that some have a "YOUR XX HERE" but some have fixed values).
Add some comments to the section and link to it in the readme.
How can I get response headers:
I get only this ones:
content-length = 7147
x-timer = S1442913390.912739,VS0,VE611
x-cache = MISS, MISS
content-encoding = gzip
set-cookie = clip_v=1; expires=Sat, 21 Nov 2015 09:16:31 GMT; path=/;, clip_v=1; expires=Sat, 21 Nov 2015 09:16:31 GMT; path=/;
accept-ranges = bytes
strict-transport-security = max-age=15120000; includeSubDomains
vary = Accept,Vimeo-Client-Id,Accept-Encoding
expires = Fri, 19 Sep 2025 09:16:30 GMT
server = nginx
cache-control = no-cache, max-age=315360000
connection = keep-alive
via = 1.1 varnish, 1.1 varnish
x-cache-hits = 0, 0
x-served-by = cache-iad2139-IAD, cache-fra1229-FRA
fastly-debug-digest = 551e06b55f98b01aae2910d55fe60c590f357fc5b3d8ae00ac02869b8b306953
date = Tue, 22 Sep 2015 09:16:31 GMT
content-type = application/vnd.vimeo.user+json
age = 0
Hi!
Just tried to use this library to automatically upload my video files. But I get the following error:
video_uri = v.upload('Z:/OUTPUT/CCCCCCCC-00-TESTTEST.mp4')
Traceback (most recent call last):
File "<pyshell#6>", line 1, in
video_uri = v.upload('Z:/OUTPUT/CCCCCCCC-00-TESTTEST.mp4')
File "C:\Python34\lib\site-packages\pyvimeo-0.2.0-py3.4.egg\vimeo\upload.py", line 22, in upload
return self._perform_upload(filename, ticket)
File "C:\Python34\lib\site-packages\pyvimeo-0.2.0-py3.4.egg\vimeo\upload.py", line 48, in _perform_upload
self._make_pass(target, f, size, last_byte)
File "C:\Python34\lib\site-packages\pyvimeo-0.2.0-py3.4.egg\vimeo\upload.py", line 88, in _make_pass
}, data=f)
File "C:\Python34\lib\site-packages\pyvimeo-0.2.0-py3.4.egg\vimeo\client.py", line 75, in caller
*_kwargs)
File "C:\Python34\lib\site-packages\requests-2.4.3-py3.4.egg\requests\api.py", line 105, in put
return request('put', url, data=data, *_kwargs)
File "C:\Python34\lib\site-packages\requests-2.4.3-py3.4.egg\requests\api.py", line 49, in request
return session.request(method=method, url=url, *_kwargs)
File "C:\Python34\lib\site-packages\requests-2.4.3-py3.4.egg\requests\sessions.py", line 457, in request
resp = self.send(prep, *_send_kwargs)
File "C:\Python34\lib\site-packages\requests-2.4.3-py3.4.egg\requests\sessions.py", line 569, in send
r = adapter.send(request, *_kwargs)
File "C:\Python34\lib\site-packages\requests-2.4.3-py3.4.egg\requests\adapters.py", line 362, in send
timeout=timeout
File "C:\Python34\lib\site-packages\requests-2.4.3-py3.4.egg\requests\packages\urllib3\connectionpool.py", line 516, in urlopen
body=body, headers=headers)
File "C:\Python34\lib\site-packages\requests-2.4.3-py3.4.egg\requests\packages\urllib3\connectionpool.py", line 308, in _make_request
conn.request(method, url, *_httplib_request_kw)
File "C:\Python34\lib\http\client.py", line 1090, in request
self._send_request(method, url, body, headers)
File "C:\Python34\lib\http\client.py", line 1128, in _send_request
self.endheaders(body)
File "C:\Python34\lib\http\client.py", line 1086, in endheaders
self._send_output(message_body)
File "C:\Python34\lib\http\client.py", line 928, in _send_output
self.send(message_body)
File "C:\Python34\lib\http\client.py", line 882, in send
datablock = data.read(blocksize)
File "C:\Python34\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8f in position 4224: character maps to undefined
File is a standard MP4 created with After Effects. Tried it with several different MP4 with same result.
Thanks for your help,
Klaus
pip install git+https://github.com/vimeo/vimeo.py
>>> import vimeo
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/Users/lorddaedra/.pyenv/versions/hotelsbank/lib/python3.4/site-packages/vimeo/__init__.py", line 6, in <module>
from client import VimeoClient
ImportError: No module named 'client'```
Python 3.4.2 (default, Oct 16 2014, 02:44:19)
How can I add a tag to all videos in an album?
Are there any examples of a patch request in practice? I may have the incorrect syntax but when I try something like (for some video_id of mine): v.patch('https://api.vimeo.com/videos/video_id', {"data":{"privacy":{"view":"anybody"}}}) I get a 200 response but it doesn't actually change the privacy setting. Is this a bug or am I doing something wrong?
I'm running the command below on a vagrant machine (with debian powered)
(MY_ENV)vagrant@machine:/srv/www/<MY_PROJECT>$ pip install PyVimeo
Downloading/unpacking PyVimeo
Downloading PyVimeo-0.3.0.macosx-10.10-intel.tar.gz
Running setup.py egg_info for package PyVimeo
Traceback (most recent call last):
File "<string>", line 14, in <module>
IOError: [Errno 2] No such file or directory: '/srv/env/<MY_PROJECT>/build/PyVimeo/setup.py'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 14, in <module>
IOError: [Errno 2] No such file or directory: '/srv/env/<MY_PROJECT>/build/PyVimeo/setup.py'
----------------------------------------
Command python setup.py egg_info failed with error code 1 in /srv/env/<MY_PROJECT>/build/PyVimeo
Storing complete log in /home/vagrant/.pip/pip.log
But, if i run this command:
pip install https://github.com/vimeo/vimeo.py/archive/master.zip
it's works fine.
At the moment when I initialise my client
import vimeo
v = vimeo.VimeoClient(x,y,z)
v.me.videos()
The output of that command contains:
u'page': 1,
u'paging': {u'first': u'/users/26623265/videos/?page=1',
u'last': u'/users/26623265/videos/?page=6',
u'next': u'/users/26623265/videos/?page=2',
u'previous': None},
u'per_page': 25,
u'total': 131},
so it looks like it's giving the information in pages (which makes sense with a web page, just not in python). This can be fixed by setting the per_page variable to something ridiculously high (say 9001).
TL;DR It would be great if .me.videos() produced a list of all videos from a user.
http://vimeoapi.tumblr.com/post/80815606701
Can we use this technique with this library?
Does not have open ssl pre-installed: https://blog.bekt.net/p/gae-ssl/
import vimeo
from configparser import ConfigParser
import os
CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
config = ConfigParser()
config.read(os.path.join(CURRENT_DIR, 'config.ini'))
token = config['Vimeo']['Access_Token']
key = config['Vimeo']['Client_ID']
secret = config['Vimeo']['Client_Secret']
v = vimeo.VimeoClient(token=token, key=key, secret=secret)
about_me = v.get('/me')
assert about_me.status_code == 200
video_uri = v.upload('vid.mp4')
print(video_uri)
Running this code gives me a traceback:
Traceback (most recent call last):
File "tester_vimeo.py", line 20, in <module>
video_uri = v.upload('vid.mp4')
File "/home/kwikadi/github/venv/lib/python3.4/site-packages/vimeo/upload.py", line 23, in upload
return self._perform_upload(filename, ticket)
File "/home/kwikadi/github/venv/lib/python3.4/site-packages/vimeo/upload.py", line 38, in _perform_upload
assert ticket.status_code == 201, "Failed to create an upload ticket"
AssertionError: Failed to create an upload ticket
I'm using Python 3.4 on Ubuntu 14.04. PyVimeo version 0.3.0
I use Python 3.4 with Django 1.7.
What I tried to do - get plays stats for all videos on page in admin:
# models.py
class Video(models.Model):
"""
Video
"""
...
def get_stats_plays(self): # this method gets play statistics for current video
stats_plays = vimeo_connect().get('/videos/{}'.format(self.vimeo)).json()["stats"]["plays"] # self.vimeo is just vimeo id number
return stats_plays
# admin.py
@admin.register(Video)
class VideoAdmin(ModelAdmin):
"""
Video admin
"""
...
list_display = (..., 'get_stats_plays', ...) # so it show stats_plays for every of 50 videos in list (50 items per page)
# utils.py
@lru_cache(maxsize=32) # I need to connect once and next just use this connection
def vimeo_connect():
v = vimeo.VimeoClient(key=VIMEO_KEY, secret=VIMEO_SECRET, token=VIMEO_TOKEN)
return v
This code works on my local Mac (but 40 seconds per page load!!), but do not work on server (deploy Django using uWSGI)...
I got 500 error
requests.adapters in send
ConnectionError: ('Connection aborted.', timeout('_ssl.c:582: The handshake operation timed out',))
Stacktrace (most recent call last):
File "django/core/handlers/base.py", line 137, in get_response
response = response.render()
File "django/template/response.py", line 103, in render
self.content = self.rendered_content
File "django/template/response.py", line 80, in rendered_content
content = template.render(context)
File "django/template/base.py", line 148, in render
return self._render(context)
File "django/test/utils.py", line 88, in instrumented_test_render
return self.nodelist.render(context)
File "django/template/base.py", line 844, in render
bit = self.render_node(node, context)
File "django/template/base.py", line 858, in render_node
return node.render(context)
File "django/template/loader_tags.py", line 126, in render
return compiled_parent._render(context)
File "django/test/utils.py", line 88, in instrumented_test_render
return self.nodelist.render(context)
File "django/template/base.py", line 844, in render
bit = self.render_node(node, context)
File "django/template/base.py", line 858, in render_node
return node.render(context)
File "django/template/loader_tags.py", line 126, in render
return compiled_parent._render(context)
File "django/test/utils.py", line 88, in instrumented_test_render
return self.nodelist.render(context)
File "django/template/base.py", line 844, in render
bit = self.render_node(node, context)
File "django/template/base.py", line 858, in render_node
return node.render(context)
File "django/template/loader_tags.py", line 65, in render
result = block.nodelist.render(context)
File "django/template/base.py", line 844, in render
bit = self.render_node(node, context)
File "django/template/base.py", line 858, in render_node
return node.render(context)
File "django/template/loader_tags.py", line 65, in render
result = block.nodelist.render(context)
File "django/template/base.py", line 844, in render
bit = self.render_node(node, context)
File "django/template/base.py", line 858, in render_node
return node.render(context)
File "django/template/base.py", line 1207, in render
_dict = func(*resolved_args, **resolved_kwargs)
File "django/contrib/admin/templatetags/admin_list.py", line 316, in result_list
'results': list(results(cl))}
File "django/contrib/admin/templatetags/admin_list.py", line 292, in results
yield ResultList(None, items_for_result(cl, res, None))
File "django/contrib/admin/templatetags/admin_list.py", line 283, in __init__
super(ResultList, self).__init__(*items)
File "django/contrib/admin/templatetags/admin_list.py", line 198, in items_for_result
f, attr, value = lookup_field(field_name, result, cl.model_admin)
File "django/contrib/admin/utils.py", line 280, in lookup_field
value = attr()
File "hotelsbankbase/models.py", line 234, in get_stats_plays
stats_plays = vimeo_connect().get('/videos/{}'.format(self.vimeo)).json()["stats"]["plays"]
File "vimeo/client.py", line 75, in caller
**kwargs)
File "requests/api.py", line 60, in get
return request('get', url, **kwargs)
File "requests/api.py", line 49, in request
return session.request(method=method, url=url, **kwargs)
File "requests/sessions.py", line 457, in request
resp = self.send(prep, **send_kwargs)
File "requests/sessions.py", line 569, in send
r = adapter.send(request, **kwargs)
File "requests/adapters.py", line 407, in send
raise ConnectionError(err, request=request)
I'm not sure, is it server uwsgi limits or something else...
Anyway, we really need API to get many videos data at once by id.
I have pyvimeo 0.3 as you can see here in pip freeze
$ pip freeze
Flask==0.10.1
itsdangerous==0.24
Jinja2==2.7.3
MarkupSafe==0.23
pyimgur==0.5.2
pyodbc==3.0.10
PyVimeo==0.3.0
requests==2.7.0
six==1.9.0
Werkzeug==0.10.4
wheel==0.24.0
but when i tried to upload a video I got this error.
Traceback (most recent call last):
File "client_secrets1.py", line 22, in <module>
video_uri = v.upload('small.m4a')
File "F:\Env\lib\site-packages\vimeo\upload.py", line 23, in upload
return self._perform_upload(filename, ticket)
File "F:\Env\lib\site-packages\vimeo\upload.py", line 38, in _perform_upload
assert ticket.status_code == 201, "Failed to create an upload ticket"
AssertionError: Failed to create an upload ticket
Currently, tags with spaces in are not put onto Vimeo, but you can put tags with spaces into Vimeo.com. Tags without spaces work fine. Below is what happens,
In [11]: getattr(v.videos, uri).tags.put('test tag')
---------------------------------------------------------------------------
HTTPError Traceback (most recent call last)
<ipython-input-11-86f8a6b6aab0> in <module>()
----> 1 getattr(v.videos, uri).tags.put('test tag')
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/vimeo/vimeoresource.pyc in put(self, name, _callback)
728 def put(self, name, _callback=None):
729 self._request_path(self.config, endpoint=name, _callback=_callback, async=async,
--> 730 method="PUT")
731
732
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/vimeo/vimeoresource.pyc in _request_path(self, config, _callback, async, method, endpoint, body, querys, url_override, extra_headers)
269 else:
270 result = HTTPClient().fetch(url, method=method, headers=headers,
--> 271 validate_cert=not self.config['dev'], body=body)
272 return self._parse_response_body(result.body, headers=result.headers)
273
/Library/Python/2.7/site-packages/tornado/httpclient.pyc in fetch(self, request, **kwargs)
83 """
84 response = self._io_loop.run_sync(functools.partial(
---> 85 self._async_client.fetch, request, **kwargs))
86 response.rethrow()
87 return response
/Library/Python/2.7/site-packages/tornado/ioloop.pyc in run_sync(self, func, timeout)
387 if not future_cell[0].done():
388 raise TimeoutError('Operation timed out after %s seconds' % timeout)
--> 389 return future_cell[0].result()
390
391 def time(self):
/Library/Python/2.7/site-packages/tornado/concurrent.pyc in result(self, timeout)
129 raise_exc_info(self.__exc_info)
130 else:
--> 131 return super(TracebackFuture, self).result(timeout=timeout)
132
133
/Library/Python/2.7/site-packages/tornado/concurrent.pyc in result(self, timeout)
63 self._check_done()
64 if self._exception:
---> 65 raise self._exception
66 return self._result
67
HTTPError: HTTP 599: [Errno 54] Connection reset by peer
Hi. Could you please tell me why the data dictionary is not respected (v variable returns default values like 25 videos per page and so on)
v = vimeo.get('/me/videos', data = { 'per_page':'1', 'query':'Untitled', 'sort':'date' , 'direction':'desc'})
thank you
Radek
Look
https://github.com/vimeo/vimeo.py/blob/master/vimeo/upload.py#L131
Exception if all OK
The default is a list (1, 30), however, it must be an integer or float. This raises an exception in python requests. A temporary workaround is to always pass the timeout parameter when calling get.
Pls update pip package because its depricated... if I use PIP package for my application it would not work... ever time server response 404. But if I use github package it works.
After installing the vimeo library with sudo ./setup.py install
, the example fails as:
Traceback (most recent call last):
File "/Users/nasfarley88/Dropbox/eclipse_projects/vimeo-editor-qt/main.py", line 4, in <module>
import vimeo
File "build/bdist.macosx-10.9-x86_64/egg/vimeo/__init__.py", line 6, in <module>
File "build/bdist.macosx-10.9-x86_64/egg/vimeo/client.py", line 7, in <module>
ImportError: No module named client_credentials
My OS is Mac OS X Mavericks (latest update as of 2014-10-05)
Using PyVimeo to replace 8 videos automatically on a daily basis and worked fine for months.
Did not change anything, but it does not run anymore since 12th November 2015.
Suspect Vimeo having changed something.
Here the error I get:
Traceback (most recent call last):
File "./vimeo_replacer.py", line 43, in
video_uri = v.upload('/home/daniel/MEGA_ORYX_TIMELAPSE_OUTPUT_FOLDER/1448723322/332_from_01-01-2015_to_27-11-2015_60s.mp4')
File "/usr/local/lib/python2.7/dist-packages/vimeo/upload.py", line 28, in upload
return self._perform_upload(filename, ticket)
File "/usr/local/lib/python2.7/dist-packages/vimeo/upload.py", line 44, in _perform_upload
raise VideoTicketCreationFailure(ticket, "Failed to create an upload ticket")
NameError: global name 'VideoTicketCreationFailure' is not defined
UPDATE 30.11.2015
Uploading goes fine; no "upload ticket" error
UPDATE 02.12.2015
Resolved, something needed to be fixed on Vimeo's side
Hello, I'm having trouble using the Vimeo API using the vimeo.py official client (commit 0717e96) to upload and activate the picture. It seems that while the picture is uploaded successfully, it never gets activated, even though the API responds with no error. Activating the picture manually from the settings page works.
Here's a sample output:
from vimeo import VimeoClient
v = VimeoClient(open("oath2-token.txt").read().strip())
video_id = '105326301'
video = v.videos.get(video_id)
v.uploadpicture(str(video), '/Users/orestis/Desktop/profile.jpg')
# no error here, but the image is not activated.
# Trying to go step-by-step:
picture_create_uri = str(video) + v.uploadpicture.PICTURE_CREATE_PATH_EXTENSION
upload_target, picture_uri = v.uploadpicture.create_picture(picture_create_uri)
v.uploadpicture.upload_file(upload_target, v.uploadpicture.read_file('/Users/orestis/Desktop/profile.jpg'))
# OUT: True
picture_uri
# OUT: u'/videos/105326301/pictures/488091924'
v.uploadpicture.activate_picture(picture_uri)
# OUT: True
video.pictures.get('488091924')
# OUT: {'body': {u'active': False, u'uri': u'/videos/105326301/pictures/488091924', u'sizes': [{u'width': 100, u'link': u'https://i.vimeocdn.com/video/488091924_100
# OUT: x75.jpg', u'height': 75}, {u'width': 200, u'link': u'https://i.vimeocdn.com/video/488091924_200x150.jpg', u'height': 150}, {u'width': 295, u'link': u'https:/
# OUT: /i.vimeocdn.com/video/488091924_295x166.jpg', u'height': 166}]}, 'headers': {'X-Consumed-Content-Encoding': 'gzip', 'Content-Length': '176', 'Expires': 'Mon,
# OUT: 02 Sep 2024 08:58:36 GMT', 'Vary': 'Accept,Vimeo-Client-Id,Accept-Encoding', 'Keep-Alive': 'timeout=100, max=99', 'Server': 'Apache', 'Connection': 'Keep-Al
# OUT: ive', 'Cache-Control': 'no-cache, max-age=315360000', 'Date': 'Fri, 05 Sep 2014 08:58:36 GMT', 'Content-Type': 'application/vnd.vimeo.picture+json'}}
Example
vimeo.me.videos.put('#video#id').tag('#tag')
When a user GET
s a resource and wants to modify it on the server, they currently have to do some interesting parsing to get a proper handle for the PATCH
or PUT
request.
This should be improved so that there is a clean method to go from the existing object or URI key to a handle that can have .patch() or .put() called on it.
The existing workaround can be described for updating a user's video in this gist.
Can i just edit the upload function and change the "type: streaming" to "type:pull" and do upload directly from URL ?
It seems that the upload uses the default HTTP timeout for Tornado and therefore causes a timeout after 20 seconds.
vimeo.upload("./Downloads/trailer_1080p_1.mp4")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/joebloggs/.virtualenvs/vimeo/lib/python2.7/site-packages/vimeo/uploads.py", line 79, in __call__
return do_upload()
File "/Users/joebloggs/.virtualenvs/vimeo/lib/python2.7/site-packages/vimeo/uploads.py", line 70, in do_upload
self.upload_segment(upload_uri, _range, video_data, filetype or 'mp4')
File "/Users/joebloggs/.virtualenvs/vimeo/lib/python2.7/site-packages/vimeo/uploads.py", line 135, in upload_segment
body=data, headers=request_headers)
File "/Users/joebloggs/.virtualenvs/vimeo/lib/python2.7/site-packages/tornado/httpclient.py", line 96, in fetch
self._async_client.fetch, request, **kwargs))
File "/Users/joebloggs/.virtualenvs/vimeo/lib/python2.7/site-packages/tornado/ioloop.py", line 418, in run_sync
return future_cell[0].result()
File "/Users/joebloggs/.virtualenvs/vimeo/lib/python2.7/site-packages/tornado/concurrent.py", line 111, in result
raise self._exception
tornado.httpclient.HTTPError: HTTP 599: Timeout
import vimeo
ID="""ID"""
SEC="""SECRET"""
v = vimeo.VimeoClient(
key=ID,
secret=SEC)
try:
token = v.load_client_credentials()
except vimeo.auth.GrantFailed:
print("FAIL...")
Makes...
Traceback (most recent call last):
File "test.py", line 11, in <module>
token = v.load_client_credentials()
File "/usr/local/lib/python2.7/dist-packages/vimeo/auth/client_credentials.py", line 18, in load_client_credentials
{"grant_type": "client_credentials"})
File "/usr/local/lib/python2.7/dist-packages/vimeo/auth/base.py", line 23, in call_grant
return resp.status_code, resp.headers, resp.json()
File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 819, in json
return json.loads(self.text, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/simplejson/__init__.py", line 516, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python2.7/dist-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/usr/local/lib/python2.7/dist-packages/simplejson/decoder.py", line 400, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Hi...I recently used to this Python wrapper for the Vimeo API. There is apparently negligible documentation. I shall be glad to take this up and work on this and will be grateful for assistance and pointers.
We need to add support for uploading Text Tracks.
In the _perform_upload
method, attempts are made to upload a chunk of the video (or the complete video in one go, I'm not quite sure about that), and a request is made to check the progress. The goal is to continue with other chunks if something happened, like a timeout, but the check to see if it needs to do a new attempt can't possibly work because it's comparing two different types.
See
Line 46 in e677e2e
last_byte
is a str
because it comes from a header of the progress request, while size
is a long
. An easy fix would be to simply run int()
over last_byte
.I'm attempting to upload a video to my Vimeo account. I have created an access token from the Vimeo API page.
# requirements.txt
--index-url https://pypi.python.org/simple/
python-dotenv==0.1.2
PyVimeo==0.2.1
import os
import dotenv
dotenv_path = os.path.join(os.path.dirname(__file__), '.env')
dotenv.load_dotenv(dotenv_path)
import vimeo
v = vimeo.VimeoClient(
token = os.environ.get("VIMEO_ACCESS_TOKEN"),
key = os.environ.get("VIMEO_CLIENT_ID"),
secret = os.environ.get("VIMEO_CLIENT_SECRET")
)
about_me = v.get('/me')
assert about_me.status_code == 200
video_uri = v.upload('small.mp4')
Traceback (most recent call last):
File "upload.py", line 18, in <module>
video_uri = v.upload('small.mp4')
File "/Users/rd/.pyenv/versions/3.4.3/lib/python3.4/site-packages/vimeo/upload.py", line 22, in upload
return self._perform_upload(filename, ticket)
File "/Users/rd/.pyenv/versions/3.4.3/lib/python3.4/site-packages/vimeo/upload.py", line 37, in _perform_upload
assert ticket.status_code == 201, "Failed to create an upload ticket"
AssertionError: Failed to create an upload ticket
Not sure what was the intention of kwargs['timeout'] = kwargs.get('timeout', (1, 30))
(ln 66 client.py)
But if I don't specify timeout in the vimeo_obj.get(url)
I'm getting
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/vimeo/client.py", line 75, in caller
**kwargs)
File "/usr/lib/python2.7/dist-packages/requests/api.py", line 55, in get
return request('get', url, **kwargs)
File "/usr/lib/python2.7/dist-packages/requests/api.py", line 44, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 455, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 558, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 316, in send
timeout = TimeoutSauce(connect=timeout, read=timeout)
File "/usr/lib/python2.7/dist-packages/urllib3/util.py", line 116, in __init__
self._connect = self._validate_timeout(connect, 'connect')
File "/usr/lib/python2.7/dist-packages/urllib3/util.py", line 147, in _validate_timeout
"int or float." % (name, value))
ValueError: Timeout value connect was (1, 30), but it must be an int or float.
Maybe it worked with an older version of requests?
When trying to sudo python setup.py install
I'm getting a:
SyntaxError: ('invalid syntax', ('/usr/lib/python2.6/site-packages/PyVimeo-0.2.0-py2.6.egg/vimeo/client.py', 17, 27, " HTTP_METHODS = {'head', 'get', 'post', 'put', 'patch', 'options', 'delete'}\n"))
env:
Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
The API documentation at https://developer.vimeo.com/api/authentication#generate-redirect says that the "state" param is required and should be validated by the client, but I don't see where the Python library is setting it or validating it.
Can anyone help me do more with this API than uploading a file?
It seems like I can only upload a file with this API and not even change the name of the video, as it gets uploaded as "Untitled".
If it's only that, this would render this API not very useful.
this part of readme file:
video_uri = v.replace(
video_uri='video_uri',
filename='your-filename.mp4',
upgrade_to_1080=False)
may suggest that video_uri is expected after successful upload. In fact it returns None.
It would be nice to be able to pass in a file object rather than a file name to the various upload functions, I'm having to generating temporary files for my use-case and it's pretty kludgy.
Happy to write a patch if you think this would be useful!
This may be related to a dependancy, however reporting in case this can be controlled.
I installed the Vimeo SDK via pip which appeared to complete successfully, however I quickly started seeing SSL issues from requests with another app in my project. I quickly discovered that the recent version of requests had been removed and replaced with 0.13.1, which was causing all kinds of issues. I've since upgraded requests and all appears to be running fine again.
Hi. I checked the code but cannot find the answer.
Is it possible to replace the video file?
If yes, please provide an example.
thank you very much
Radek
While trying to upload captions, I keep getting ReadTimeout exceptions.
Can someone shade a light on how to solve this?
Here is my upload function:
def upload_vimeo_track(uri, lang, track_file):
v = vimeo.VimeoClient(
token="removed",
key="removed",
secret="removed")
track = "./caption_files/%s" % track_file
while True:
try:
response = v.upload_texttrack(uri, 'captions', lang, track)
return response
except (ReadTimeout, ConnectTimeout) as e:
print e
time.sleep(30)
pass
Here it is the connection log:
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): api.vimeo.com
send: 'POST /videos/106328451/texttracks HTTP/1.1\r\nHost: api.vimeo.com\r\nContent-Length: 63\r\nAccept-Encoding: gzip, deflate\r\nAccept: application/vnd.vimeo.*;version=3.2\r\nUser-Agent: pyvimeo 0.1; (http://developer.vimeo.com/api/docs)\r\nConnection: keep-alive\r\nContent-Type: application/json\r\nAuthorization: Bearer removed\r\n\r\n{"type": "captions", "name": "-B8Fqmkbl5I_0", "language": "en"}'
reply: 'HTTP/1.1 201 Created\r\n'
header: Date: Sun, 25 Jan 2015 10:34:46 GMT
header: Server: Apache
header: Vary: Accept,Vimeo-Client-Id,Accept-Encoding
header: Cache-Control: no-cache, max-age=315360000
header: Location: /texttracks/2176007
header: Expires: Wed, 22 Jan 2025 10:34:46 GMT
header: Content-Encoding: gzip
header: Content-Length: 263
header: Keep-Alive: timeout=100, max=100
header: Connection: Keep-Alive
header: Content-Type: application/vnd.vimeo.video.texttrack+json
header: Via: 1.1 dca1-10
DEBUG:requests.packages.urllib3.connectionpool:"POST /videos/106328451/texttracks HTTP/1.1" 201 263
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): captions.cloud.vimeo.com
send: 'PUT /captions/2176007?expires=1422182586&sig=removedHTTP/1.1\r\nHost: captions.cloud.vimeo.com\r\nContent-Length: 6119\r\nAccept-Encoding: gzip, deflate\r\nAccept: application/vnd.vimeo.*;version=3.2\r\nUser-Agent: pyvimeo 0.1; (http://developer.vimeo.com/api/docs)\r\nConnection: keep-alive\r\nAuthorization: Bearer removed\r\n\r\n'
send: <open file './caption_files/-B8Fqmkbl5I_0', mode 'r' at 0x0293B968>
sendIng a read()able
HTTPSConnectionPool(host='captions.cloud.vimeo.com', port=443): Read timed out. (read timeout=30)
One more information. Despite the timeout, most likely caused by an error on the Vimeo server, the caption is uploaded to it's related video.
I just checked and in reality the caption information is shown at the "Advanced" tab, but no caption file is linked to it, therefore the file upload is not successful.
Just the first step of the captions upload process is successful, the second step, the file upload itself, is not.
Hi there - thanks for this!
There is an error in Python3 (works in Python2) triggered with v.upload_picture
:
File "/usr/local/lib/python3.4/site-packages/vimeo/upload.py", line 105, in upload_picture
if isinstance(obj, basestring):
NameError: name 'basestring' is not defined
I think this can be fixed fairly easily with a try/except
statement upon import ... is it something you would be willing to fix? I can create a pull request if that would help.
Could use this as a model: oxplot/fysom#1
Damon
Line https://github.com/vimeo/vimeo.py/blob/master/vimeo/client.py#L16 in the package is:
API_ROOT = "http://api.vimeo.dev"
This causes the connections without a full URL path to fail with a 404.
Looks like the source was tested in the dev
environment and the URL was not changed back to the production one before being packaged.
Hi. While replacing the file i'm getting:
Traceback (most recent call last):
File "replace.py", line 24, in
upgrade_to_1080=False)
File "upload.py", line 30, in replace
self._perform_upload(filename, ticket)
File "upload.py", line 35, in _perform_upload
assert ticket.status_code == 201, "Failed to create an upload ticket"
AssertionError: Failed to create an upload ticket
part of the code:
video_uri = v.replace(
video_uri='https://vimeo.com/88526096',
filename='test.mp4',
upgrade_to_1080=False)
thank you
Radek
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.