With nearly fully randomized examples to show how it can be done. It's quite nice to see actual calls, using everything required to get a call. The only thing the user has to manage is to fill in actual values. But, it also shows that our builder pattern doesn't work yet due to ... you guessed it ... lifetime issues :D
The youtube3 library allows access to all features of YouTube.
Features
Handle the following Resources with ease ...
- activities (insert and list)
- channel banners (insert)
- channel sections (delete, insert, list and update)
- channels (list and update)
- guide categories (list)
- i18n languages (list)
- i18n regions (list)
- live broadcasts (bind, control, delete, insert, list, transition and update)
- live streams (delete, insert, list and update)
- playlist items (delete, insert, list and update)
- playlists (delete, insert, list and update)
- search (list)
- subscriptions (delete, insert and list)
- thumbnails (set)
- video categories (list)
- videos (delete, getRating, insert, list, rate and update)
- watermarks (set and unset)
Structure of this Library
The API is structured into the following primary items:
- Hub
- a central object to maintain state and allow accessing all Activities
- Resources
- primary types that you can apply Activities to
- a collection of properties and Parts
- Parts
- a collection of properties
- never directly used in Activities
- Activities
- operations to apply to Resources
Generally speaking, you can invoke Activities like this:
let r = hub.resource().activity(...).doit()
Or specifically ...
let r = hub.videos().rate(...).doit()
let r = hub.videos().getRating(...).doit()
let r = hub.videos().list(...).doit()
let r = hub.videos().insert(...).doit()
let r = hub.videos().update(...).doit()
let r = hub.videos().delete(...).doit()
The resource() and activity(...) calls create builders. The second one dealing with Activities
supports various methods to configure the impending operation (not shown here). It is made such that all required arguments have to be
specified right away (i.e. (...)), whereas all optional ones can be build up as desired.
The doit() method performs the actual communication with the server and returns the respective result.
Usage (TODO)
Instantiating the Hub
extern crate hyper;
extern crate "yup-oauth2" as oauth2;
extern crate "rustc-serialize" as rustc_serialize;
extern crate youtube3;
use std::default::Default;
use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
# use youtube3::YouTube;
// Get an ApplicationSecret instance by some means. It contains the `client_id` and `client_secret`,
// among other things.
let secret: ApplicationSecret = Default::default();
// Instantiate the authenticator. It will choose a suitable authentication flow for you,
// unless you replace `None` with the desired Flow
// Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about what's going on
// You probably want to bring in your own `TokenStorage` to persist tokens and retrieve them from storage.
let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
hyper::Client::new(),
<MemoryStorage as Default>::default(), None);
let mut hub = YouTube::new(hyper::Client::new(), auth);
TODO Example calls - there should soon be a generator able to do that with proper inputs
About error handling
About Customization/Callbacks
License
The youtube3 library was generated by Sebastian Thiel, and is placed under the MIT license. You can read the full text at the repository's license file.