Class: Kodipity::Channel

Inherits:
Object
  • Object
show all
Defined in:
lib/kodipity/models.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, channel_id) ⇒ Channel

Returns a new instance of Channel.



47
48
49
50
51
52
53
# File 'lib/kodipity/models.rb', line 47

def initialize(name, channel_id)
  @name = name
  @channel_id = channel_id
  @url = 'http://rpi-osmc.lan/jsonrpc'
  @headers = {"Content-Type" => 'application/json'}
  @json = {jsonrpc: '2.0', id: 1, method: 'PVR.GetRecordingDetails', params: { properties: ['title','plot','plotoutline','file', 'channel','runtime', 'genre', 'playcount','starttime'] } }
end

Instance Attribute Details

#channel_idObject

Returns the value of attribute channel_id.



45
46
47
# File 'lib/kodipity/models.rb', line 45

def channel_id
  @channel_id
end

#nameObject

Returns the value of attribute name.



45
46
47
# File 'lib/kodipity/models.rb', line 45

def name
  @name
end

Instance Method Details

#playObject



55
56
57
58
59
# File 'lib/kodipity/models.rb', line 55

def play
  @json[:method] = 'Player.Open'
  @json[:params] = { item: { channelid: @channel_id } }
  HTTParty.post @url, headers: @headers, body: @json.to_json
end