Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ doc/
.yardoc/
_site/
TODO.md

spec/cassettes
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Available resources
Yt::Account
-----------

Check [fullscreen.github.io/yt](http://fullscreen.github.io/yt/accounts.html) for the list of methods available for `Yt::Account`.
Check [nullscreen.github.io/yt](http://nullscreen.github.io/yt/accounts.html) for the list of methods available for `Yt::Account`.


Yt::ContentOwner
Expand Down
15 changes: 15 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "bundler/setup"
require "yt"

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.

# (If you use this, don't forget to add pry to your Gemfile!)
require "pry"
Pry.start

# require "irb"
# IRB.start(__FILE__)
1 change: 1 addition & 0 deletions lib/yt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
require 'yt/models/comment_thread'
require 'yt/models/ownership'
require 'yt/models/advertising_options_set'
require 'yt/models/caption'

# An object-oriented Ruby client for YouTube.
# Helps creating applications that need to interact with YouTube objects.
Expand Down
30 changes: 30 additions & 0 deletions lib/yt/collections/captions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require 'yt/collections/base'

module Yt
module Collections
# Provides methods to interact with a collection of video captions.
class Captions < Resources

private

def attributes_for_new_item(data)
{id: data['id'], snippet: data['snippet'], auth: @auth}
end

def list_params
super.tap do |params|
params[:path] = "/youtube/v3/captions"
params[:params] = captions_params
end
end

def captions_params
{}.tap do |params|
params[:part] = 'snippet'
params[:video_id] = @parent.id if @parent
apply_where_params! params
end
end
end
end
end
19 changes: 19 additions & 0 deletions lib/yt/models/caption.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'yt/models/resource'

module Yt
module Models
# Provides methods to interact with YouTube video captions.
# @see https://developers.google.com/youtube/v3/docs/captions
class Caption < Resource

# @return [String] the ID used to identify the caption.
has_attribute :id

delegate :video_id, to: :snippet
delegate :last_updated, to: :snippet
delegate :language, to: :snippet
delegate :name, to: :snippet
delegate :status, to: :snippet
end
end
end
5 changes: 5 additions & 0 deletions lib/yt/models/snippet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ def initialize(options = {})
has_attribute :like_count, type: Integer
has_attribute :updated_at, type: Time

has_attribute :last_updated, type: Time
has_attribute :language
has_attribute :name
has_attribute :status

def thumbnail_url(size = :default)
thumbnails.fetch(size.to_s, {})['url']
end
Expand Down
4 changes: 4 additions & 0 deletions lib/yt/models/video.rb
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,10 @@ def claim
# player that will play the video.
delegate :embed_html, to: :player

### CAPTION ###

has_many :captions

### ACTIONS (UPLOAD, UPDATE, DELETE) ###

# Uploads a thumbnail
Expand Down

This file was deleted.

Loading