YouTubeRB
This library is a work in progress
YouTubeRB is a Ruby library for interacting with the YouTube Data v3 API.
Installation
Add this line to your application's Gemfile:
gem 'youtuberb'
Usage
Set Client Details
Firstly you'll need to set an API Key. A user Access Token is required to access private data.
An Access Token will be an OAuth2 token generated after authentication.
@client = YouTube::Client.new(api_key: "")
@client = YouTube::Client.new(api_key: "", access_token: "")
Channels
@client.channels.mine
@client.channels.retrieve(id: "channel_id")
@client.channels.retrieve(username: "username")
Videos
@client.videos.list(id: "abc123")
@client.videos.list(ids: ["abc123", "123abc"])
@client.videos.liked
@client.videos.retrieve(id: "abc123")
Getting a list of Videos for a Channel
channel = @client.channels.retrieve(id: "channel_id")
@client.playlist_items.list playlist_id: channel.contentDetails.relatedPlaylists.uploads
@client.search.list channelId: channel.id
Playlists
@client.playlists.list
@client.playlists.list(channel_id: "channel")
@client.playlists.list(max_results: 5, page_token: "page_token")
@client.playlists.retrieve(id: "playlist_id")
@client.playlists.create(title: "My Playlist")
@client.playlists.update(id: "playlist_id", title: "My Playlist", privacy_status: "public")
@client.playlists.delete(id: "playlist_id")
Playlist Items
@client.playlist_items.list(playlist_id: "playlist_id")
@client.playlist_items.retrieve(id: "playlist_item_id")
@client.playlist_items.create(playlist_id: "playlist_id", video_id: "video_id")
@client.playlist_items.update(id: "playlist_item_id", playlist_id: "playlist_id", video_id: "video_id")
@client.playlist_items.delete(id: "playlist_id")
Search
For a full list of parameters, see the YouTube API Docs.
@client.search.list(q: "search term")
@client.search.list(channelId: "channel")
@client.search.list(channelId: "channel", type: "video", order: "date")
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/deanpcmad/youtuberb.
License
The gem is available as open source under the terms of the MIT License.