This works by just boxing types which are nested within themselves, breaking the recursion.
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)
Everything else about the YouTube API can be found at the official documentation site.
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.live_broadcasts().control(...).doit()
let r = hub.live_broadcasts().insert(...).doit()
let r = hub.live_broadcasts().list(...).doit()
let r = hub.live_broadcasts().transition(...).doit()
let r = hub.live_broadcasts().update(...).doit()
let r = hub.live_broadcasts().delete(...).doit()
let r = hub.live_broadcasts().bind(...).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
Handling Errors
Some details
About Customization/Callbacks
About parts
- Optionals needed for Json, otherwise I'd happily drop them
- explain that examples use all response parts, even though they are shown for request values
About builder arguments
- pods are copy
- strings are &str
- request values are borrowed
- additional parameters using
param()
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.