Class: Kodipity::PVRRecording
- Inherits:
-
Object
- Object
- Kodipity::PVRRecording
- Defined in:
- lib/kodipity/models.rb
Instance Attribute Summary collapse
-
#channel ⇒ Object
Returns the value of attribute channel.
-
#file ⇒ Object
Returns the value of attribute file.
-
#genre ⇒ Object
Returns the value of attribute genre.
-
#id ⇒ Object
Returns the value of attribute id.
-
#json ⇒ Object
Returns the value of attribute json.
-
#play_count ⇒ Object
Returns the value of attribute play_count.
-
#plot ⇒ Object
Returns the value of attribute plot.
-
#plot_outline ⇒ Object
Returns the value of attribute plot_outline.
-
#run_time ⇒ Object
Returns the value of attribute run_time.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(recording_id, fetch_data = false) ⇒ PVRRecording
constructor
json = ‘2.0’, id: 1, method: ‘PVR.GetRecordingDetails’, params: { properties: [‘title’,‘plot’,‘plotoutline’,‘file’] }.
- #metadata ⇒ Object
- #play ⇒ Object
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
#channel ⇒ Object
Returns the value of attribute channel.
8 9 10 |
# File 'lib/kodipity/models.rb', line 8 def channel @channel end |
#file ⇒ Object
Returns the value of attribute file.
8 9 10 |
# File 'lib/kodipity/models.rb', line 8 def file @file end |
#genre ⇒ Object
Returns the value of attribute genre.
8 9 10 |
# File 'lib/kodipity/models.rb', line 8 def genre @genre end |
#id ⇒ Object
Returns the value of attribute id.
8 9 10 |
# File 'lib/kodipity/models.rb', line 8 def id @id end |
#json ⇒ Object
Returns the value of attribute json.
8 9 10 |
# File 'lib/kodipity/models.rb', line 8 def json @json end |
#play_count ⇒ Object
Returns the value of attribute play_count.
8 9 10 |
# File 'lib/kodipity/models.rb', line 8 def play_count @play_count end |
#plot ⇒ Object
Returns the value of attribute plot.
8 9 10 |
# File 'lib/kodipity/models.rb', line 8 def plot @plot end |
#plot_outline ⇒ Object
Returns the value of attribute plot_outline.
8 9 10 |
# File 'lib/kodipity/models.rb', line 8 def plot_outline @plot_outline end |
#run_time ⇒ Object
Returns the value of attribute run_time.
8 9 10 |
# File 'lib/kodipity/models.rb', line 8 def run_time @run_time end |
#start_time ⇒ Object
Returns the value of attribute start_time.
8 9 10 |
# File 'lib/kodipity/models.rb', line 8 def start_time @start_time end |
#title ⇒ Object
Returns the value of attribute title.
8 9 10 |
# File 'lib/kodipity/models.rb', line 8 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
8 9 10 |
# File 'lib/kodipity/models.rb', line 8 def url @url end |
Instance Method Details
#metadata ⇒ Object
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 |
#play ⇒ Object
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 |