All Projects â†’ vimeo â†’ Vimeo.py

vimeo / Vimeo.py

Licence: apache-2.0
Official Python library for the Vimeo API.

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Vimeo.py

Raspberrycast
📺 Transform your Raspberry Pi into a streaming device. Videos can be sent from mobile devices or computers (Chrome extension).
Stars: ✭ 726 (+317.24%)
Mutual labels:  vimeo
Network Avatar Picker
A npm module that returns user's social network avatar. Supported providers: facebook, instagram, twitter, tumblr, vimeo, github, youtube and gmail
Stars: ✭ 74 (-57.47%)
Mutual labels:  vimeo
Alltube
Web GUI for youtube-dl
Stars: ✭ 1,925 (+1006.32%)
Mutual labels:  vimeo
Richtextview
iOS Text View (UIView) that Properly Displays LaTeX, HTML, Markdown, and YouTube/Vimeo Links
Stars: ✭ 953 (+447.7%)
Mutual labels:  vimeo
Unity Videoplayer Helper
Simple helper for the Video Player in Unity
Stars: ✭ 49 (-71.84%)
Mutual labels:  vimeo
Plyr React
A simple, accessible and customisable react media player for Video, Audio, YouTube and Vimeo
Stars: ✭ 89 (-48.85%)
Mutual labels:  vimeo
Podsync
Turn YouTube or Vimeo channels, users, or playlists into podcast feeds
Stars: ✭ 657 (+277.59%)
Mutual labels:  vimeo
Gatsby Remark Oembed
A GatsbyJS Plugin that transforms oembed links into its corresponding embed code.
Stars: ✭ 154 (-11.49%)
Mutual labels:  vimeo
Player.js
Interact with and control an embedded Vimeo Player.
Stars: ✭ 1,093 (+528.16%)
Mutual labels:  vimeo
Vime
Customizable, extensible, accessible and framework agnostic media player. Modern alternative to Video.js and Plyr. Supports HTML5, HLS, Dash, YouTube, Vimeo, Dailymotion...
Stars: ✭ 1,928 (+1008.05%)
Mutual labels:  vimeo
Plyr
Plyr Mediaplayer (Video und Audio) im Front- und Backend
Stars: ✭ 30 (-82.76%)
Mutual labels:  vimeo
Kaku
🎧 Kaku is a highly integrated music player supports different online platform like YouTube, SoundCloud, Vimeo and more. Available on Mac, Windows and Linux.
Stars: ✭ 1,028 (+490.8%)
Mutual labels:  vimeo
Socialcounters
jQuery/PHP - Collection of Social Media APIs that display number of your social media fans. Facebook Likes, Twitter Followers, Instagram Followers, YouTube Subscribers, etc..
Stars: ✭ 104 (-40.23%)
Mutual labels:  vimeo
Vimeo Download Link
Class returns an object with video info for different resolutions and direct video download link
Stars: ✭ 11 (-93.68%)
Mutual labels:  vimeo
Jekyll Embed Video
Embed videos in Jekyll webpages without a plugin (Youtube, Vimeo, Twitch, Streamable, Mixer, Google Drive clips + more)
Stars: ✭ 135 (-22.41%)
Mutual labels:  vimeo
Bigpicture
Lightweight JavaScript image / video viewer. Supports Youtube, Vimeo, etc.
Stars: ✭ 722 (+314.94%)
Mutual labels:  vimeo
Ac D3
Javascript Library for building Audiovisual Charts in D3
Stars: ✭ 76 (-56.32%)
Mutual labels:  vimeo
Vimeo Unity Sdk
Easily stream your Vimeo videos into Unity or record and publish out to Vimeo.
Stars: ✭ 159 (-8.62%)
Mutual labels:  vimeo
Workflowshare
Workflow实例分享
Stars: ✭ 137 (-21.26%)
Mutual labels:  vimeo
React Modal Video
Accessible React Modal Video Component
Stars: ✭ 105 (-39.66%)
Mutual labels:  vimeo

PyPi License

This is a simple Python library for interacting with the Vimeo API.

Get started with the Vimeo API

There is a lot of information about the Vimeo API at https://developer.vimeo.com/api/start. Most of your questions are answered there!

Direct Help

Installation

This package is called PyVimeo on PyPI. Install using:

pip install PyVimeo

Usage

import vimeo

v = vimeo.VimeoClient(
    token=YOUR_ACCESS_TOKEN,
    key=YOUR_CLIENT_ID,
    secret=YOUR_CLIENT_SECRET
)

# Make the request to the server for the "/me" endpoint.
about_me = v.get('/me')

# Make sure we got back a successful response.
assert about_me.status_code == 200

# Load the body's JSON data.
print about_me.json()

Note: You can find the app tokens and an authenticated bearer token in the OAuth 2 tab for your app on the Vimeo developer site.

Authentication

There are two main types of authentication in the Vimeo API:

  • Unauthenticated - Access tokens without a user. These tokens can view only public data.
  • Authenticated - Access tokens with a user. These tokens interact on behalf of the authenticated user.

Note: Both types of authentication require you go to the Vimeo developer site and register an application with Vimeo.

Unauthenticated

Unauthenticated API requests must generate an access token. You should not generate a new access token for each request. Instead, request an access token once and use it forever.

try:
    # `scope` is an array of permissions your token needs to access.
    # You can read more at https://developer.vimeo.com/api/authentication#supported-scopes
    token = v.load_client_credentials(scope)

    # usable access token
    print 'token=%s' % token
except vimeo.auth.GrantFailed:
    # Handle the failure to get a token from the provided code and redirect.

Authenticated

Getting a bearer token via the authorization code method is a bit more involved. Here are the basic steps:

  1. We send the user to a web page where they can choose to accept or reject the permissions we are asking for.
  2. When the user makes their selection and accepts or rejects your app, the user is redirected to a webpage specified by you.
  3. If the user authorized your app, you can exchange the provided code for the bearer token.

This can be done with this library using some basic helper functions, as the following code demonstrates. Notice that there are two sections: first, where you redirect the user to Vimeo; and second, where the user returns so that you can perform the final step.

"""This section is used to determine where to direct the user."""
v = vimeo.VimeoClient(
    key=YOUR_CLIENT_ID,
    secret=YOUR_CLIENT_SECRET
)

vimeo_authorization_url = v.auth_url(
    ['public', 'private'],
    'https://example.com'
)

# Your application should now redirect to `vimeo_authorization_url`.
"""This section completes the authentication for the user."""
v = vimeo.VimeoClient(
    key=YOUR_CLIENT_ID,
    secret=YOUR_CLIENT_SECRET
)

# You should retrieve the "code" from the URL string Vimeo redirected
# to. Here, that's named `CODE_FROM_URL`.
try:
    token, user, scope = v.exchange_code(CODE_FROM_URL, 'https://example.com')
except vimeo.auth.GrantFailed:
    # Handle the failure to get a token from the provided code and redirect.

# Store the token, scope and any additional user data you require in
# your database so users do not have to re-authorize your application
# repeatedly.

This process is straightforward in theory, but it does require a little more effort than the client credentials grant to make work properly. Remember that you may ask for scopes that the user decides not to give you, and your application must gracefully handle that.

Make requests

PyVimeo at its core is a wrapper for Requests, so you can interact with the library as you would any other object from Requests.

  • GET: response = v.get(uri), or with parameters v.get(uri, data={...})
  • PATCH: response = v.patch(uri, data={...})
  • POST: response = v.post(uri, data={...})
  • PUT: response = v.put(uri, data={...})
  • DELETE: response = v.delete(uri)

JSON Filtering

The Vimeo API supports JSON filtering to let you return only the data that you need from an API call. To utilize this with PyVimeo, you can add a fields variable into your endpoint payload, like:

about_me = v.get('/me', params={"fields": "uri,name,pictures"})

Then with this response, you will receive only uri, name, and the pictures object.

Uploading videos

Uploading a new video

Once you have an authenticated instance of the VimeoClient class, uploading is a single function call away with upload. Internally, this library provides the tus upload and sends a local file to the server with the tus upload protocol and tus-python-client.

video_uri = v.upload('your-filename.mp4')

If you wish to add metadata to your video as it's being uploaded, you can supply a data object to .upload().

video_uri = v.upload(
    'your-filename.mp4',
    data={'name': 'Video title', 'description': '...'}
)

Alternatively, you can do this after the video has been uploaded with a PATCH call.

video_uri = v.upload('your-filename.mp4')

v.patch(video_uri, data={'name': 'Video title', 'description': '...'})

Replacing a video source file

Once you have an authenticated instance of the VimeoClient class, you can also replace the source file of an existing video.

video_uri = v.replace(
    video_uri='video_uri',
    filename='your-filename.mp4'
)

Upload images

Once you have an authenticated instance of the VimeoClient class, uploading a picture requires only the target object (for instance, the video for which you would like to replace the thumbnail).

v = vimeo.VimeoClient(
    key=YOUR_CLIENT_ID,
    secret=YOUR_CLIENT_SECRET
)

v.upload_picture('/videos/12345', 'your-image.jpg', activate=True)

Note: The activate=True in v.upload_picture sets this picture as the active one for all users. The activate keyword argument defaults to False, so without it you need to activate the picture yourself.

Upload a text track

Once you have an authenticated instance of the VimeoClient class, uploading a text track requires the video URI of the video the text track will be added to, text track type, text track language, and text track filename.

v = vimeo.VimeoClient(
    key=YOUR_CLIENT_ID,
    secret=YOUR_CLIENT_SECRET
)

v.upload_texttrack('/videos/12345', 'captions', 'en-US', 'your-texttrack.vtt')

Troubleshooting

If you have any questions or problems, create a ticket or contact us.

Legacy Python Library

An earlier version of this library used a different, more involved ORM syntax. This library is still available from this GitHub repo via the orm-tornado tag.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].