Skip to content

Commit

Permalink
Merge pull request #2 from fancybits/add-new-endpoints
Browse files Browse the repository at this point in the history
Add New Endpoints
  • Loading branch information
maddox authored Aug 6, 2020
2 parents 899eb51 + 895c7e1 commit e84c86e
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 21 deletions.
39 changes: 30 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,26 @@ You can control Channels with these methods.
#### Toggle Mute
client.toggle_mute

#### Toggle Captions
client.toggle_cc

#### Channel Up
client.channel_up

#### Channel Down
client.channel_down

#### Previous Channel
client.previous_channel
Jump back to the last watched channel.

#### Toggle Pause
client.toggle_pause

#### Toggle Recording
client.toggle_record
Record the program playing on the current channel

#### Pause
client.pause

Expand All @@ -125,29 +142,33 @@ Seek forward or backward on the timeline with an inputted number of seconds. Neg
client.seek_forward
Seek forward in the timeline by the set number of seconds in Channels.

#### Seek Backward
client.seek_backward
Seek backward in the timeline by the set number of seconds in Channels.

#### Skip Forward
client.skip_forward
Skip to the next chapter mark. This is for recordings made with Channels DVR that have their commercials indexed.

#### Seek Backward
client.seek_backward
Seek backward in the timeline by the set number of seconds in Channels.

#### Skip Backward
client.skip_backward
Skip to the previous chapter mark. This is for recordings made with Channels DVR that have their commercials indexed.

#### Previous Channel
client.previous_channel
Jump back to the last watched channel.

#### Play Channel
client.play_channel(channel_number)
Play a channel by passing it the channel number.

#### Play Recording
client.play_recording(recording_id)
Play a recording from Channels DVR
Play a recording from Channels.

#### Navigate
client.navigate(section)
Change to a section of the app by providing its name. EX, `Guide`, `Library`, `Live TV`

#### Notify
client.notify(title, message)
Present a notification while playing video.

## Contributions

Expand Down
51 changes: 40 additions & 11 deletions lib/rbchannels.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,34 @@ def favorite_channels
end
end

def toggle_mute
command('toggle_mute')
end

def toggle_cc
command('toggle_cc')
end

def channel_up
command('channel_up')
end

def channel_down
command('channel_down')
end

def previous_channel
command('previous_channel')
end

def toggle_pause
command('toggle_pause')
end

def toggle_record
command('toggle_record')
end

def pause
command('pause')
end
Expand Down Expand Up @@ -59,10 +83,6 @@ def skip_backward
command('skip_backward')
end

def previous_channel
command('previous_channel')
end

def toggle_mute
command('toggle_mute')
end
Expand All @@ -75,20 +95,29 @@ def play_recording(recording_id)
command("play/recording/#{recording_id}")
end

def navigate(section)
command("navigate/#{URI::encode(section)}")
end

def notify(title, message)
data = {title: title, message: message}
command("notify", data)
end

private

def request(method, path)
def request(method, path, data=nil)
headers = {"Content-Type": "application/json", "Accept": "application/json"}
begin
case method
when "GET"
response = self.class.get(path)
response = self.class.get(path, headers: headers)
when "POST"
response = self.class.post(path)
response = self.class.post(path, {body: data.to_json, headers: headers})
when "PUT"
response = self.class.put(path)
response = self.class.put(path, body: data.to_json, headers: headers)
when "DELETE"
response = self.class.delete(path)
response = self.class.delete(path, headers: headers)
end

if response
Expand All @@ -101,8 +130,8 @@ def request(method, path)
end
end

def command(named_command)
return request('POST', '/' + named_command)
def command(named_command, data=nil)
return request('POST', '/' + named_command, data)
end

end
2 changes: 1 addition & 1 deletion lib/rbchannels/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Channels
VERSION = "1.1.0"
VERSION = "1.2.0"
end

0 comments on commit e84c86e

Please sign in to comment.