Class: YouTube::LiveBroadcastsResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/you_tube/resources/live_broadcasts.rb

Constant Summary collapse

PARTS =
"id,snippet,contentDetails,status"

Instance Attribute Summary

Attributes inherited from Resource

#client

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from YouTube::Resource

Instance Method Details

#list(status: nil) ⇒ Object

Retrieves Live Broadcasts by ID or for the currently authenticated user



7
8
9
10
11
12
13
14
15
# File 'lib/you_tube/resources/live_broadcasts.rb', line 7

def list(status: nil)
  if status
    response = get_request("liveBroadcasts", params: {broadcastStatus: status, part: PARTS})
  else
    response = get_request("liveBroadcasts", params: {mine: true, part: PARTS})
  end

  Collection.from_response(response, type: LiveBroadcast)
end

#retrieve(id:) ⇒ Object

Retrieves a Video by the ID. This retrieves extra information so will only work on videos for an authenticated user



19
20
21
22
23
# File 'lib/you_tube/resources/live_broadcasts.rb', line 19

def retrieve(id:)
  response = get_request "liveBroadcasts", params: {id: id, part: PARTS}
  return nil if response.body["items"].count == 0
  LiveBroadcast.new(response.body["items"][0])
end