Class: Yt::Models::Account

Inherits:
Base
  • Object
show all
Defined in:
lib/yt/models/account.rb

Overview

Provides methods to interact with YouTube accounts.

Direct Known Subclasses

ContentOwner

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#channelYt::Models::Channel (readonly)

Returns the YouTube channel of the account.

Returns:



137
# File 'lib/yt/models/account.rb', line 137

has_one :channel

#content_ownersYt::Collections::ContentOwners (readonly)

Returns the content owners that the account can manage.

Returns:



126
# File 'lib/yt/models/account.rb', line 126

has_many :content_owners

#emailString (readonly)

Returns the account’s email address.

Returns:

  • (String)

    the account’s email address.



20
# File 'lib/yt/models/account.rb', line 20

delegate :email, to: :user_info

#family_nameString (readonly)

Returns the user’s family (last) name.

Returns:

  • (String)

    the user’s family (last) name.



37
# File 'lib/yt/models/account.rb', line 37

delegate :family_name, to: :user_info

#given_nameString (readonly)

Returns the user’s given (first) name.

Returns:

  • (String)

    the user’s given (first) name.



33
# File 'lib/yt/models/account.rb', line 33

delegate :given_name, to: :user_info

#idString (readonly)

Returns the (Google+) account’s ID.

Returns:

  • (String)

    the (Google+) account’s ID.



16
# File 'lib/yt/models/account.rb', line 16

delegate :id, to: :user_info

#nameString (readonly)

Returns the account’s full name.

Returns:

  • (String)

    the account’s full name.



29
# File 'lib/yt/models/account.rb', line 29

delegate :name, to: :user_info

#owner_nameString? (readonly)

The name of the content owner managing the account.

Returns:

  • (String)

    name of the CMS account, if the account is partnered.

  • (nil)

    if the account is not a partnered content owner.



131
132
133
# File 'lib/yt/models/account.rb', line 131

def owner_name
  @owner_name
end

#playlistsYt::Collections::Playlists (readonly)

Returns the playlists owned by the account.

Returns:



141
# File 'lib/yt/models/account.rb', line 141

delegate :playlists, to: :channel

Returns the playlists associated with the account, such as the playlist of uploaded or liked videos.

Returns:

See Also:



147
# File 'lib/yt/models/account.rb', line 147

delegate :related_playlists, to: :channel

#subscribed_channelsYt::Collections::SubscribedChannels (readonly)

Returns the channels that the account is subscribed to.

Returns:



152
# File 'lib/yt/models/account.rb', line 152

delegate :subscribed_channels, to: :channel

#subscribersYt::Collections::Subscribers (readonly)

Returns the channels subscribed to the account’s channel.

Returns:



161
# File 'lib/yt/models/account.rb', line 161

has_many :subscribers

#video_groupsYt::Collections::VideoGroups (readonly)

Returns the video-groups created by the account.

Returns:

  • (Yt::Collections::VideoGroups)

    the video-groups created by the account.



172
# File 'lib/yt/models/account.rb', line 172

has_many :video_groups

#videosYt::Collections::Videos (readonly)

Returns the videos owned by the account.

Returns:



156
# File 'lib/yt/models/account.rb', line 156

has_many :videos

Instance Method Details

#avatar_urlString

Returns the URL of the account’s (Google +) profile picture.

Returns:

  • (String)

    the URL of the account’s (Google +) profile picture.



45
46
47
# File 'lib/yt/models/account.rb', line 45

def avatar_url
  .picture
end

#create_playlist(params = {}) ⇒ Yt::Models::Playlist

Creates a playlist in the account’s channel.

Examples:

Create a playlist titled “My favorites”.

.create_playlist title: 'My favorites'

Parameters:

  • params (Hash) (defaults to: {})

    the attributes of the playlist.

Options Hash (params):

  • :title (String)

    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.

  • :description (String)

    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.

  • :tags (Array<String>)

    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.

  • :privacy_status (String)

    The new playlist’s privacy status. Must be one of: private, unscheduled, public.

Returns:



102
103
104
# File 'lib/yt/models/account.rb', line 102

def create_playlist(params = {})
  playlists.insert params
end

#delete_playlists(attributes = {}) ⇒ Array<Boolean>

Deletes the account’s playlists matching all the given attributes.

Parameters:

  • attributes (Hash) (defaults to: {})

    the attributes to match the playlists by.

Options Hash (attributes):

  • :title (<String, Regexp>)

    The playlist’s title. Pass a String for perfect match or a Regexp for advanced match.

  • :description (<String, Regexp>)

    The playlist’s description. Pass a String (perfect match) or a Regexp (advanced).

  • :tags (Array<String>)

    The playlist’s tags. All tags must match exactly.

  • :privacy_status (String)

    The playlist’s privacy status.

Returns:

  • (Array<Boolean>)

    whether each playlist matching the given attributes was deleted.



119
# File 'lib/yt/models/account.rb', line 119

delegate :delete_playlists, to: :channel

#genderString

Returns the account’s gender. Possible values include, but are not limited to, ‘male’, ‘female’, ‘other’.

Returns:

  • (String)

    the account’s gender. Possible values include, but are not limited to, ‘male’, ‘female’, ‘other’.



51
# File 'lib/yt/models/account.rb', line 51

delegate :gender, to: :user_info

#has_verified_email?Boolean

Returns whether the email address is verified.

Returns:

  • (Boolean)

    whether the email address is verified.



23
24
25
# File 'lib/yt/models/account.rb', line 23

def has_verified_email?
  .verified_email
end

#hdString

Returns the hosted domain name for the user’s Google Apps account. For instance, example.com.

Returns:

  • (String)

    the hosted domain name for the user’s Google Apps account. For instance, example.com.



58
# File 'lib/yt/models/account.rb', line 58

delegate :hd, to: :user_info

#insert_playlist_item_paramsObject



253
254
255
# File 'lib/yt/models/account.rb', line 253

def insert_playlist_item_params
  {}
end

#localeString

Returns the account’s preferred locale.

Returns:

  • (String)

    the account’s preferred locale.



54
# File 'lib/yt/models/account.rb', line 54

delegate :locale, to: :user_info

#playlist_items_paramsObject



201
202
203
# File 'lib/yt/models/account.rb', line 201

def playlist_items_params
  {}
end

#profile_urlString

Returns the URL of the account’s (Google +) profile page.

Returns:

  • (String)

    the URL of the account’s (Google +) profile page.



40
41
42
# File 'lib/yt/models/account.rb', line 40

def profile_url
  .link
end

#update_playlist_paramsObject



245
246
247
# File 'lib/yt/models/account.rb', line 245

def update_playlist_params
  {}
end

#update_video_paramsObject



241
242
243
# File 'lib/yt/models/account.rb', line 241

def update_video_params
  {}
end

#upload_thumbnail_paramsObject



249
250
251
# File 'lib/yt/models/account.rb', line 249

def upload_thumbnail_params
  {}
end

#upload_video(path_or_url, params = {}) ⇒ Yt::Models::Video

Uploads a video to the account’s channel.

Parameters:

  • path_or_url (String)

    the video to upload. Can either be the path of a local file or the URL of a remote file.

  • params (Hash) (defaults to: {})

    the metadata to add to the uploaded video.

Options Hash (params):

  • :title (String)

    The video’s title.

  • :description (String)

    The video’s description.

  • :tags (Array<String>)

    The video’s tags.

  • :privacy_status (String)

    The video’s privacy status.

  • :self_declared_made_for_kids (Boolean)

    The video’s made for kids self-declaration.

Returns:



72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/yt/models/account.rb', line 72

def upload_video(path_or_url, params = {})
  file = open path_or_url, 'rb'
  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