Support for Live Broadcasts - #462
Conversation
|
@gmarziou thank you for opening a pr! I will try and get back to you |
kangkyu
left a comment
There was a problem hiding this comment.
params and body can be handled differently, I think we can use more existing methods. For example:
def insert_params
super.tap {|p| p[:part] = "snippet,status"}
end| def insert_parts | ||
| snippet = {keys: [:title, :description], sanitize_brackets: true} | ||
| status = {keys: [:privacy_status]} | ||
| {snippet: snippet, status: status} | ||
| end |
There was a problem hiding this comment.
I think you might have wanted to use insert_parts in insert method in this class.
There was a problem hiding this comment.
I must admit that I did not understand how this worked in other classes.
I looked at other collections and they seemed to use slightly different patterns.
Could you point me to a class that is a good example that I could study?
There was a problem hiding this comment.
Thank you. @gmarziou
I was wondering if this part could be used and simplify insert method above, how do you think? If you don't mind, could you please try something like following code, for me to learn more?
def insert_parts
snippet = {keys: [:title, :description, :scheduled_start_time, :scheduled_end_time, :default_language], sanitize_brackets: true}
status = {keys: [:privacy_status, :self_declared_made_for_kids]}
{snippet: snippet, status: status}
end| def insert | ||
| do_insert | ||
| end |
There was a problem hiding this comment.
I think this insert method may not be used.
17ae0b1 to
57f5631
Compare
|
I think I applied your suggestions and tested, it works. |
|
Oops, I found that maybe the issue could come from the fact that LiveBroadcasts inherits from Base while it should inherit from Resources Could you explain why some classes use Base super class (e.g. LiveCuepoints) while some like Playlists use Resources? |
|
I think Resources have title and description for them. (Yes, that's why) If you prefer |
|
When I use def sanitize_brackets!(source)
case source
when String then source.gsub('<', '‹').gsub('>', '›')
when Array then source.map{|string| sanitize_brackets! string}
when Hash then source.each{|k,v| source[k] = sanitize_brackets! v}
end
endI think that def sanitize_brackets!(source)
case source
when String then source.gsub('<', '‹').gsub('>', '›')
when Array then source.map{|string| sanitize_brackets! string}
when Hash then source.each{|k,v| source[k] = sanitize_brackets! v}
# Don't sanitize other types of objects
else source
end
endI tested it, it works fine for creating LiveBroadcasts. |
This PR implements LiveBroadcast resource and collection.
To create a alive broadcast:
```ruby
params = {
title: title, description: description, privacy_status: privacy_status,
scheduled_start_time: scheduled_start_time, scheduled_end_time: scheduled_end_time,
default_language: "en"
}
account.create_live_broadcast(**params)
```
To list all live broadcasts of an account/channel:
```ruby
account(email).live_broadcasts
```
Fix claudiob#461
|
Great, I just squashed the 3 commits on my branch. |
This PR implements LiveBroadcast resource and collection.
To create a alive broadcast:
To list all live broadcasts of an account/channel:
Fix #461