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)


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

has_one :channel

#content_ownersYt::Collections::ContentOwners (readonly)


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

has_many :content_owners

#emailString (readonly)


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

delegate :email, to: :user_info

#family_nameString (readonly)


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

delegate :family_name, to: :user_info

#given_nameString (readonly)


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

delegate :given_name, to: :user_info

#idString (readonly)


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

delegate :id, to: :user_info

#nameString (readonly)


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.


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

def owner_name
  @owner_name
end

#playlistsYt::Collections::Playlists (readonly)


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.


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

delegate :related_playlists, to: :channel

#subscribed_channelsYt::Collections::SubscribedChannels (readonly)


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

delegate :subscribed_channels, to: :channel

#subscribersYt::Collections::Subscribers (readonly)


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

has_many :subscribers

#video_groupsYt::Collections::VideoGroups (readonly)


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

has_many :video_groups

#videosYt::Collections::Videos (readonly)


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

has_many :videos

Instance Method Details

#avatar_urlString


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'

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.


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.

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.


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

delegate :delete_playlists, to: :channel

#genderString


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

delegate :gender, to: :user_info

#has_verified_email?Boolean


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

def has_verified_email?
  .verified_email
end

#hdString


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

delegate :hd, to: :user_info

#localeString


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

delegate :locale, to: :user_info

#profile_urlString


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.

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.


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