Class: Kodipity::PVRRecording

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(recording_id, fetch_data = false) ⇒ PVRRecording

json = ‘2.0’, id: 1, method: ‘PVR.GetRecordingDetails’, params: { properties: [‘title’,‘plot’,‘plotoutline’,‘file’] }



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/kodipity/models.rb', line 12

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

Instance Attribute Details

#channelObject

Returns the value of attribute channel.



8
9
10
# File 'lib/kodipity/models.rb', line 8

def channel
  @channel
end

#fileObject

Returns the value of attribute file.



8
9
10
# File 'lib/kodipity/models.rb', line 8

def file
  @file
end

#genreObject

Returns the value of attribute genre.



8
9
10
# File 'lib/kodipity/models.rb', line 8

def genre
  @genre
end

#idObject

Returns the value of attribute id.



8
9
10
# File 'lib/kodipity/models.rb', line 8

def id
  @id
end

#jsonObject

Returns the value of attribute json.



8
9
10
# File 'lib/kodipity/models.rb', line 8

def json
  @json
end

#play_countObject

Returns the value of attribute play_count.



8
9
10
# File 'lib/kodipity/models.rb', line 8

def play_count
  @play_count
end

#plotObject

Returns the value of attribute plot.



8
9
10
# File 'lib/kodipity/models.rb', line 8

def plot
  @plot
end

#plot_outlineObject

Returns the value of attribute plot_outline.



8
9
10
# File 'lib/kodipity/models.rb', line 8

def plot_outline
  @plot_outline
end

#run_timeObject

Returns the value of attribute run_time.



8
9
10
# File 'lib/kodipity/models.rb', line 8

def run_time
  @run_time
end

#start_timeObject

Returns the value of attribute start_time.



8
9
10
# File 'lib/kodipity/models.rb', line 8

def start_time
  @start_time
end

#titleObject

Returns the value of attribute title.



8
9
10
# File 'lib/kodipity/models.rb', line 8

def title
  @title
end

#urlObject

Returns the value of attribute url.



8
9
10
# File 'lib/kodipity/models.rb', line 8

def url
  @url
end

Instance Method Details

#metadataObject



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/kodipity/models.rb', line 24

def 
  response = HTTParty.post(@url, headers: @headers, body: @json.to_json)['result']['recordingdetails']
  @title = response['title']
  @plot_outline = response['plotoutline']
  @file = response['file']
  @channel = response['channel']
  @run_time = response['runtime']
  @genre = response['genre']
  @play_count = response['playcount']
  @start_time = response['starttime']
  self
end

#playObject



37
38
39
40
41
# File 'lib/kodipity/models.rb', line 37

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