on Vimeo
Andreask84
A command line tool and a simple C# class with a complete set of functions to easily upload videos on Vimeo
Introduction
Vimeo is a great platform to archive and share videos with other people; it provides a simple and complete set of APIs to control
almost all his functions (https://developer.vimeo.com/api). You may need to programmatically upload your video files here, for
instance, because you have an application that automatically produces videos that need to be shared with some user. How to deal
with this situation?
On the Internet, you can find some wrappers for the API in Java, C# and Python (https://developer.vimeo.com/api/libraries). I looked
for one to be used in my C# application but I did not find any that satisfied my expectations: open source and very simple. Vimeo
also provides a feature that allows you to pull videos automatically from your Dropbox account. It has the advantage that
theoretically for uploading a video, you just need to copy a file in a folder and that the upload is performed on a dedicated process.
The cons are that it does not provide a lot of flexibility, for instance, you cannot set the video title, description and preview or do
some actions after the upload. In addition, you do not have the exact control on when the video is uploaded and you will depend
on the Dropbox system. A nice solution for me was a "Vimeo command line tool" that can be easily started from an external
application. Therefore, I decided to create it along with a simple C# class for managing the Vimeo API that can be easily integrated
into any application. Here, I will describe these tools and you can download the full source code of both.
Background
The Vimeo HTTP API needs an authorization token to be included on the authorization header of the HTTP requests. Therefore, this
token is required also for using my command line tool and my class. To obtain the token, you need to:
1. Register your app on https://developer.vimeo.com/apps, by clicking Create new app and filling the form shown.
2. Enter your app page, click Request Upload Access and fill the form.
3. Once you get the upload access, go on your app page, open the section Authentication and press Generate token to
create it.
The command argument is required, the others are optional and depend on the command value.
You must provide a valid authorization token using the –t argument, if the token is invalid, you will receive the following error:
"The remote server returned an error: (401) Unauthorized".
For instance, you can get the list of your videos using:
Vimeouploader LV -t=<token>
You can avoid providing the token each time you call vimeouploader.exe saving its value on the registry with the following
command:
Vimeouploader ST -t=<token>
So, to get the list of videos next time, you can just call:
Vimeouploader LV
LV: List your videos. The information reported is: video URI, video name and creation time. You can get more information for
a specific video using the VINFO command (see below).
The next commands may require a video id argument: it is the video URI without the “/videos/” part.
QUOTA: Display your used and available space.
UPLOAD: Upload a video. You have to provide a valid video file name on the –f argument, optionally you can specify the
video name on the –n argument and the video description on the –d argument. Example:
Once the upload is completed, the software will display the following line: "Video Uploaded: <videoid>".
You can embed this video on your site using this URI: https://player.vimeo.com/video/<videoid>
DEL: Delete a video, you must provide the video id on the –v argument. Example:
EDT: Set the name and the description for a given video. You must provide the video id on the –v argument, the video
name on the -n argument and the video description on the -d argument. Example:
SETPIC: Set the preview picture for a given video. You must provide the video id on the –v argument, an image path on
the -pf argument. Example:
VSTATUS: Display just the status of the specified video. You must provide the video id on the –v argument.
ST: Save authorization token on the registry, in order to avoid specifying it each time. You have to specify the token on the
-t argument.
PULLFD: Check a given folder, if there is a video, it will be uploaded and moved to another folder. You have to specify the
folder to check on the -cf argument and the folder where move the uploaded videos on the -df argument.
Each video uploaded will have as title the name of the file. You can also include on the folder a picture with the same name
of the video. If the tool finds it, it will upload it as well and set it as thumbnail for the video. The check for new videos is
performed every 5 seconds by default, but you can specify a custom check interval (in milliseconds) using the -ci
argument.
HELP: Display the software version and a quick description of the available commands
The class constructor accepts as parameter the authorization token, which can be obtained as described above.
Name Description
void SetVideoMetadata(string videoId, string name, Set name and description for a given
string description) video
Points of Interest
In this article, we presented an interesting command line tool that enables you to easily upload videos on Vimeo and to control
other functions. You can use this tool on its own, or call it by another application. There may be some features that could be added
but I think that this initial version is already a powerful tool for automating the upload of video to Vimeo.
You can use also the VimeoApi C# class for this purpose. Its main advantage with respect to other C# wrappers is that it is a
single class included in a single .cs file, hence it is easy to integrate into your application, easy to debug in case of problems and
easy to change adapting it to your needs.
History
30 May 2016: Initial version
23 August 2019: Recompiled project using Net Framework 4.7.2, to avoid the error "System.Net.WebException", and forcing
the use of Vimeo API 3.2, to avoid issue during upload.
License
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)