kodi_client 0.4.5 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 860eb2c3848cb508f5faaad0bf3716e330d1cb1113ebdfd6d847ccd33302d360
4
- data.tar.gz: d51f977964b4a89698985c7cfb5f78f83b83a1c00502d436eee6b84550177f28
3
+ metadata.gz: 1d7046ba7c1c40c4302d7563b33a8805b83b3275069697af432b2880a59daf05
4
+ data.tar.gz: 340843f609031566aee613714f5a0e52b65add52bee208141e6ef3eee8fe929c
5
5
  SHA512:
6
- metadata.gz: 55f60b1ad247d88fcb77ae527a3b47a43521853d8f3d06f6fbe29db07ec465fb91c29a6146ec20414dadb0c00191172e974fae29291d63d1cbabd50e2105666d
7
- data.tar.gz: dad48a6e2c40302af39190e88a531d268f7b20f08cdac4322f73406c78d5b1a02df351faa260afab5094edb1aa1f301cce4be6c2c2c2c707c32e7c59c15cbf5a
6
+ metadata.gz: 3af04fc11780d040693c50348d3ce5aded43cb67ae8ae8487498d4a9d66f6d3286b684716798d57e70bc6f58128ba4022d9fae35af635ce6ce016a7663e53c74
7
+ data.tar.gz: de5b32cc6ad5c54b3efd5bc0e75544c66444a2c566d097fd13244122019da1dc3435df15a649d0a4ebda1e8171e5f4afd6865fc2d092fcfddbe351587a67d5c3
data/README.md CHANGED
@@ -9,6 +9,7 @@ Currently implemented are the following Methods:
9
9
  * GUI
10
10
  * Input
11
11
  * Player
12
+ * System
12
13
 
13
14
  ## Installation
14
15
  from [rubygems](https://rubygems.org/gems/kodi_client) using
data/kodi_client.gemspec CHANGED
@@ -2,12 +2,12 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'kodi_client'
5
- spec.version = '0.4.5'
5
+ spec.version = '0.5.0'
6
6
  spec.authors = ['Christian Feier']
7
7
  spec.email = ['christian.feier@gmail.com']
8
8
 
9
9
  spec.summary = 'A work-in-progress client for Kodi JSON API v2.'
10
- spec.description = 'A client for the Kodi JSON API v12, currently implemented methods are addons, application, Favourites, gui, Input and player (more will be added with the time). For more information how to use it and how to activate Remote Control in Kodi, please check the github page https://github.com/cfe86/RubyKodiClient'
10
+ spec.description = 'A client for the Kodi JSON API v12, currently implemented methods are addons, application, favourites, gui, input, player and system (more will be added with the time). For more information how to use it and how to activate Remote Control in Kodi, please check the github page https://github.com/cfe86/RubyKodiClient'
11
11
  spec.homepage = 'https://github.com/cfe86/RubyKodiClient'
12
12
  spec.license = 'MIT'
13
13
  spec.required_ruby_version = '>= 2.5.0'
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'kodi_client/util/iterable'
4
+ require 'kodi_client/util/comparable'
5
+
6
+ module KodiClient
7
+ module Types
8
+ module System
9
+
10
+ # System.Property.Name https://kodi.wiki/view/JSON-RPC_API/v12#System.Property.Name
11
+ module PropertyName
12
+ extend Iterable
13
+
14
+ CAN_SHUTDOWN = 'canshutdown'
15
+ CAN_SUSPEND = 'cansuspend'
16
+ CAN_HIBERNATE = 'canhibernate'
17
+ CAN_REBOOT = 'canreboot'
18
+ end
19
+
20
+ # System.Property.Value https://kodi.wiki/view/JSON-RPC_API/v12#System.Property.Value
21
+ class PropertyValue
22
+ include Comparable
23
+
24
+ attr_reader :can_hibernate, :can_reboot, :can_shutdown, :can_suspend
25
+
26
+ def initialize(hash)
27
+ @can_hibernate = hash['canhibernate']
28
+ @can_reboot = hash['canreboot']
29
+ @can_shutdown = hash['canshutdown']
30
+ @can_suspend = hash['cansuspend']
31
+ end
32
+
33
+ def ==(other)
34
+ compare(self, other)
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'kodi_client/global_types/gui_types'
4
+ require 'kodi_client/kodi_module'
5
+ require 'kodi_client/global_types/system_types'
6
+
7
+ module KodiClient
8
+ module Modules
9
+ # contains all Kodi System methods
10
+ class System < KodiModule
11
+
12
+ EJECT_OPTICAL_DRIVE = 'System.EjectOpticalDrive'
13
+ GET_PROPERTIES = 'System.GetProperties'
14
+ HIBERNATE = 'System.Hibernate'
15
+ REBOOT = 'System.Reboot'
16
+ SHUTDOWN = 'System.Shutdown'
17
+ SUSPEND = 'System.Suspend'
18
+
19
+ def eject_optical_drive(kodi_id = 1)
20
+ request = KodiRequest.new(kodi_id, EJECT_OPTICAL_DRIVE, {})
21
+ json = invoke_api(request)
22
+ KodiResponse.new(json)
23
+ end
24
+
25
+ def get_properties(properties = Types::System::PropertyName.all_properties, kodi_id = 1)
26
+ request = KodiRequest.new(kodi_id, GET_PROPERTIES, { 'properties' => properties })
27
+ json = invoke_api(request)
28
+ result = json['result'].nil? ? nil : Types::System::PropertyValue.new(json['result'])
29
+ json['result'] = result
30
+ KodiResponse.new(json)
31
+ end
32
+
33
+ def hibernate(kodi_id = 1)
34
+ request = KodiRequest.new(kodi_id, HIBERNATE, {})
35
+ json = invoke_api(request)
36
+ KodiResponse.new(json)
37
+ end
38
+
39
+ def reboot(kodi_id = 1)
40
+ request = KodiRequest.new(kodi_id, REBOOT, {})
41
+ json = invoke_api(request)
42
+ KodiResponse.new(json)
43
+ end
44
+
45
+ def shutdown(kodi_id = 1)
46
+ request = KodiRequest.new(kodi_id, SHUTDOWN, {})
47
+ json = invoke_api(request)
48
+ KodiResponse.new(json)
49
+ end
50
+
51
+ def suspend(kodi_id = 1)
52
+ request = KodiRequest.new(kodi_id, SUSPEND, {})
53
+ json = invoke_api(request)
54
+ KodiResponse.new(json)
55
+ end
56
+ end
57
+ end
58
+ end
data/lib/kodi_client.rb CHANGED
@@ -10,6 +10,7 @@ require 'kodi_client/method/favourites'
10
10
  require 'kodi_client/method/gui'
11
11
  require 'kodi_client/method/input'
12
12
  require 'kodi_client/method/player'
13
+ require 'kodi_client/method/system'
13
14
 
14
15
 
15
16
  # client for Kodi rest api https://kodi.wiki/view/JSON-RPC_API/v12
@@ -20,7 +21,7 @@ module KodiClient
20
21
  class Client
21
22
  include Chainable
22
23
 
23
- attr_reader :addons, :application, :gui, :player, :input, :favourites
24
+ attr_reader :addons, :application, :gui, :player, :input, :favourites, :system
24
25
 
25
26
  def initialize
26
27
  @addons = KodiClient::Modules::Addons.new
@@ -29,6 +30,7 @@ module KodiClient
29
30
  @gui = KodiClient::Modules::GUI.new
30
31
  @input = KodiClient::Modules::Input.new
31
32
  @player = KodiClient::Modules::Player.new
33
+ @system = KodiClient::Modules::System.new
32
34
  end
33
35
 
34
36
  def apply_options(options)
@@ -38,6 +40,7 @@ module KodiClient
38
40
  @input.apply_options(options)
39
41
  @player.apply_options(options)
40
42
  @favourites.apply_options(options)
43
+ @system.apply_options(options)
41
44
  end
42
45
  end
43
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kodi_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Feier
@@ -25,8 +25,8 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 5.0.4
27
27
  description: A client for the Kodi JSON API v12, currently implemented methods are
28
- addons, application, Favourites, gui, Input and player (more will be added with
29
- the time). For more information how to use it and how to activate Remote Control
28
+ addons, application, favourites, gui, input, player and system (more will be added
29
+ with the time). For more information how to use it and how to activate Remote Control
30
30
  in Kodi, please check the github page https://github.com/cfe86/RubyKodiClient
31
31
  email:
32
32
  - christian.feier@gmail.com
@@ -55,6 +55,7 @@ files:
55
55
  - lib/kodi_client/global_types/media_types.rb
56
56
  - lib/kodi_client/global_types/player_type.rb
57
57
  - lib/kodi_client/global_types/pvr_type.rb
58
+ - lib/kodi_client/global_types/system_types.rb
58
59
  - lib/kodi_client/global_types/video_types.rb
59
60
  - lib/kodi_client/kodi_module.rb
60
61
  - lib/kodi_client/method/addons.rb
@@ -63,6 +64,7 @@ files:
63
64
  - lib/kodi_client/method/gui.rb
64
65
  - lib/kodi_client/method/input.rb
65
66
  - lib/kodi_client/method/player.rb
67
+ - lib/kodi_client/method/system.rb
66
68
  - lib/kodi_client/options.rb
67
69
  - lib/kodi_client/util/comparable.rb
68
70
  - lib/kodi_client/util/iterable.rb