class Yt::Models::Account
Provides methods to interact with YouTube accounts. @see developers.google.com/youtube/v3/guides/authentication
Attributes
The name of the content owner managing the account. @return [String] name of the CMS account, if the account is partnered. @return [nil] if the account is not a partnered content owner.
Public Class Methods
Source
# File lib/yt/models/account.rb, line 179 def initialize(options = {}) super options if options[:user_info] @user_info = UserInfo.new data: options[:user_info] end end
@private Initialize user info if included in the response
Public Instance Methods
Source
# File lib/yt/models/account.rb, line 44 def avatar_url user_info.picture end
@return [String] the URL
of the account’s (Google +) profile picture.
Source
# File lib/yt/models/account.rb, line 101 def create_playlist(params = {}) playlists.insert params end
Creates a playlist in the account’s channel. @return [Yt::Models::Playlist] the newly created playlist. @param [Hash] params the attributes of the playlist. @option params [String] :title The new playlist’s title.
Cannot have more than 100 characters. Can include the characters < and >, which are replaced to ‹ › in order to be accepted by YouTube.
@option params [String] :description The new playlist’s description.
Cannot have more than 5000 bytes. Can include the characters < and >, which are replaced to ‹ › in order to be accepted by YouTube.
@option params [Array<String>] :tags The new playlist’s tags.
Cannot have more than 500 characters. Can include the characters < and >, which are replaced to ‹ › in order to be accepted by YouTube.
@option params [String] :privacy_status The new playlist’s privacy
status. Must be one of: private, unscheduled, public.
@example Create a playlist titled “My favorites”.
account.create_playlist title: 'My favorites'
Source
# File lib/yt/models/account.rb, line 22 def has_verified_email? user_info.verified_email end
@return [Boolean] whether the email address is verified.
Source
# File lib/yt/models/account.rb, line 252 def insert_playlist_item_params {} end
Source
# File lib/yt/models/account.rb, line 200 def playlist_items_params {} end
Source
# File lib/yt/models/account.rb, line 39 def profile_url user_info.link end
@return [String] the URL
of the account’s (Google +) profile page.
Source
# File lib/yt/models/account.rb, line 244 def update_playlist_params {} end
Source
# File lib/yt/models/account.rb, line 240 def update_video_params {} end
Source
# File lib/yt/models/account.rb, line 219 def upload_body(params = {}) {}.tap do |body| snippet = params.slice :title, :description, :tags, :category_id snippet[:categoryId] = snippet.delete(:category_id) if snippet[:category_id] body[:snippet] = snippet if snippet.any? privacy_status = params[:privacy_status] self_declared_made_for_kids = params[:self_declared_made_for_kids] body[:status] = {} body[:status][:privacyStatus] = privacy_status if privacy_status body[:status][:selfDeclaredMadeForKids] = self_declared_made_for_kids unless self_declared_made_for_kids.nil? end end
@private Tells ‘has_many :resumable_sessions` what metadata to set in the object associated to the uploaded file.
Source
# File lib/yt/models/account.rb, line 236 def upload_content_type 'video/*' end
@private Tells ‘has_many :resumable_sessions` what type of file can be uploaded.
Source
# File lib/yt/models/account.rb, line 212 def upload_params {part: 'snippet,status'} end
@private Tells ‘has_many :resumable_sessions` what params are set for the object associated to the uploaded file.
Source
# File lib/yt/models/account.rb, line 206 def upload_path '/upload/youtube/v3/videos' end
@private Tells ‘has_many :resumable_sessions` what path to hit to upload a file.
Source
# File lib/yt/models/account.rb, line 248 def upload_thumbnail_params {} end
Source
# File lib/yt/models/account.rb, line 71 def upload_video(path_or_url, params = {}) file = URI.open(path_or_url) session = resumable_sessions.insert file.size, upload_body(params) session.update(body: file) do |data| Yt::Video.new( id: data['id'], snippet: data['snippet'], status: data['status'], auth: self ) end end
Uploads a video to the account’s channel. @param [String] path_or_url the video to upload. Can either be the
path of a local file or the URL of a remote file.
@param [Hash] params the metadata to add to the uploaded video. @option params [String] :title The video’s title. @option params [String] :description The video’s description. @option params [Array<String>] :tags The video’s tags. @option params [String] :privacy_status The video’s privacy status. @option params [Boolean] :self_declared_made_for_kids The video’s made for kids self-declaration. @return [Yt::Models::Video] the newly uploaded video.
Source
# File lib/yt/models/account.rb, line 196 def video_groups_params {mine: true} end
@private Tells ‘has_many :video_groups` that content_owner.groups should return all the video-groups *owned by* the account
Source
# File lib/yt/models/account.rb, line 189 def videos_params {for_mine: true} end
@private Tells ‘has_many :videos` that account.videos should return all the videos *owned by* the account (public, private, unlisted).