class Kodipity::PVRRecording

Attributes

channel[RW]
file[RW]
genre[RW]
id[RW]
json[RW]
play_count[RW]
plot[RW]
plot_outline[RW]
run_time[RW]
start_time[RW]
title[RW]
url[RW]

Public Class Methods

new(recording_id, fetch_data = false) click to toggle source

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

# 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
        metadata if fetch_data
end

Public Instance Methods

metadata() click to toggle source
# File lib/kodipity/models.rb, line 24
def metadata
        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
name() click to toggle source
# File lib/kodipity/models.rb, line 43
def name
        @file.scan(/\/\/\/(...*), TV/)[0][0]
end
play() click to toggle source
# 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