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:


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

has_one :channel

#content_ownersYt::Collections::ContentOwners (readonly)

Returns the content owners that the account can manage.

Returns:


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

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.


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

def owner_name
  @owner_name
end

#playlistsYt::Collections::Playlists (readonly)

Returns the playlists owned by the account.

Returns:


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

delegate :playlists, to: :channel

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

Returns:

See Also:


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

delegate :related_playlists, to: :channel

#subscribed_channelsYt::Collections::SubscribedChannels (readonly)

Returns the channels that the account is subscribed to.

Returns:


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

delegate :subscribed_channels, to: :channel

#subscribersYt::Collections::Subscribers (readonly)

Returns the channels subscribed to the account’s channel.

Returns:


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

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.


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

has_many :video_groups

#videosYt::Collections::Videos (readonly)

Returns the videos owned by the account.

Returns:


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

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:


96
97
98
# File 'lib/yt/models/account.rb', line 96

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.


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

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

#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

#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

#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.

  • :title (Array<String>)

    The video’s tags.

  • :privacy_status (String)

    The video’s privacy status.

Returns:


71
72
73
74
75
76
77
78
# File 'lib/yt/models/account.rb', line 71

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['privacyStatus'], auth: self
  end
end