kodi_client 0.4.5 → 0.5.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/kodi_client.gemspec +5 -2
- data/lib/kodi_client/Chainable.rb +3 -1
- data/lib/kodi_client/global_types/addon_types.rb +60 -48
- data/lib/kodi_client/global_types/application_types.rb +19 -16
- data/lib/kodi_client/global_types/audio_types.rb +41 -30
- data/lib/kodi_client/global_types/favourites_types.rb +18 -17
- data/lib/kodi_client/global_types/global_types.rb +29 -27
- data/lib/kodi_client/global_types/gui_types.rb +21 -15
- data/lib/kodi_client/global_types/input_types.rb +1 -1
- data/lib/kodi_client/global_types/item_types.rb +6 -2
- data/lib/kodi_client/global_types/list_types.rb +256 -89
- data/lib/kodi_client/global_types/media_types.rb +16 -11
- data/lib/kodi_client/global_types/player_type.rb +126 -107
- data/lib/kodi_client/global_types/profiles_types.rb +80 -0
- data/lib/kodi_client/global_types/pvr_type.rb +2 -0
- data/lib/kodi_client/global_types/system_types.rb +36 -0
- data/lib/kodi_client/global_types/video_types.rb +66 -41
- data/lib/kodi_client/kodi_module.rb +1 -0
- data/lib/kodi_client/method/addons.rb +2 -3
- data/lib/kodi_client/method/application.rb +1 -1
- data/lib/kodi_client/method/favourites.rb +1 -1
- data/lib/kodi_client/method/gui.rb +2 -2
- data/lib/kodi_client/method/player.rb +6 -6
- data/lib/kodi_client/method/profiles.rb +48 -0
- data/lib/kodi_client/method/system.rb +58 -0
- data/lib/kodi_client/util/comparable.rb +4 -1
- data/lib/kodi_client/util/creatable.rb +52 -0
- data/lib/kodi_client.rb +10 -8
- metadata +10 -5
@@ -24,7 +24,7 @@ module KodiClient
|
|
24
24
|
def get_properties(properties = Types::GUI::PropertyName.all_properties, kodi_id = 1)
|
25
25
|
request = KodiRequest.new(kodi_id, GET_PROPERTIES, { 'properties' => properties })
|
26
26
|
json = invoke_api(request)
|
27
|
-
result =
|
27
|
+
result = KodiClient::Types::GUI::PropertyValue.create(json['result'])
|
28
28
|
json['result'] = result
|
29
29
|
KodiResponse.new(json)
|
30
30
|
end
|
@@ -32,7 +32,7 @@ module KodiClient
|
|
32
32
|
def get_stereoscopic_modes(kodi_id = 1)
|
33
33
|
request = KodiRequest.new(kodi_id, GET_STEREOSCOPIC_MODES, {})
|
34
34
|
json = invoke_api(request)
|
35
|
-
result =
|
35
|
+
result = Types::GUI::StereoscopyMode.create_list(json['result']['stereoscopicmodes'])
|
36
36
|
json['result'] = result
|
37
37
|
KodiResponse.new(json)
|
38
38
|
end
|
@@ -41,7 +41,7 @@ module KodiClient
|
|
41
41
|
def get_active_players(kodi_id = 1)
|
42
42
|
request = KodiRequest.new(kodi_id, GET_ACTIVE_PLAYER, {})
|
43
43
|
json = invoke_api(request)
|
44
|
-
result =
|
44
|
+
result = Types::Player::Player.create_list(json['result'])
|
45
45
|
json['result'] = result
|
46
46
|
KodiResponse.new(json)
|
47
47
|
end
|
@@ -57,7 +57,7 @@ module KodiClient
|
|
57
57
|
request = KodiRequest.new(kodi_id, GET_ITEM, { 'playerid' => player_id,
|
58
58
|
'properties' => properties })
|
59
59
|
json = invoke_api(request)
|
60
|
-
result = Types::List::ListItemAll.
|
60
|
+
result = Types::List::ListItemAll.create(json['result']['item'])
|
61
61
|
json['result'] = result
|
62
62
|
KodiResponse.new(json)
|
63
63
|
end
|
@@ -65,7 +65,7 @@ module KodiClient
|
|
65
65
|
def get_players(media = Types::Media::MediaType::ALL, kodi_id = 1)
|
66
66
|
request = KodiRequest.new(kodi_id, GET_PLAYERS, { 'media' => media })
|
67
67
|
json = invoke_api(request)
|
68
|
-
result =
|
68
|
+
result = Types::Player::Player.create_list(json['result'])
|
69
69
|
json['result'] = result
|
70
70
|
KodiResponse.new(json)
|
71
71
|
end
|
@@ -74,7 +74,7 @@ module KodiClient
|
|
74
74
|
request = KodiRequest.new(kodi_id, GET_PROPERTIES, { 'playerid' => player_id,
|
75
75
|
'properties' => properties })
|
76
76
|
json = invoke_api(request)
|
77
|
-
result = Types::Player::PropertyValue.
|
77
|
+
result = Types::Player::PropertyValue.create(json['result'])
|
78
78
|
json['result'] = result
|
79
79
|
KodiResponse.new(json)
|
80
80
|
end
|
@@ -82,7 +82,7 @@ module KodiClient
|
|
82
82
|
def get_view_mode(kodi_id = 1)
|
83
83
|
request = KodiRequest.new(kodi_id, GET_VIEW_MODE, {})
|
84
84
|
json = invoke_api(request)
|
85
|
-
result = Types::Player::PlayerViewMode.
|
85
|
+
result = Types::Player::PlayerViewMode.create(json['result'])
|
86
86
|
json['result'] = result
|
87
87
|
KodiResponse.new(json)
|
88
88
|
end
|
@@ -130,7 +130,7 @@ module KodiClient
|
|
130
130
|
def seek(player_id, value, kodi_id = 1)
|
131
131
|
request = KodiRequest.new(kodi_id, SEEK, { 'playerid' => player_id, 'value' => value })
|
132
132
|
json = invoke_api(request)
|
133
|
-
result = Types::Player::
|
133
|
+
result = Types::Player::SeekReturned.create(json['result'])
|
134
134
|
json['result'] = result
|
135
135
|
KodiResponse.new(json)
|
136
136
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'kodi_client/kodi_module'
|
4
|
+
require 'kodi_client/global_types/profiles_types'
|
5
|
+
|
6
|
+
module KodiClient
|
7
|
+
module Modules
|
8
|
+
# contains all Kodi Application methods
|
9
|
+
class Profiles < KodiModule
|
10
|
+
|
11
|
+
GET_CURRENT_PROFILE = 'Profiles.GetCurrentProfile'
|
12
|
+
GET_PROFILES = 'Profiles.GetProfiles'
|
13
|
+
LOAD_PROFILE = 'Profiles.LoadProfile'
|
14
|
+
|
15
|
+
def get_current_profile(properties = Types::Profiles::FieldsProfile.all_properties, kodi_id = 1)
|
16
|
+
request = KodiRequest.new(kodi_id, GET_CURRENT_PROFILE, { 'properties' => properties })
|
17
|
+
json = invoke_api(request)
|
18
|
+
result = Types::Profiles::DetailsProfile.create(json['result'])
|
19
|
+
json['result'] = result
|
20
|
+
KodiResponse.new(json)
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_profiles(properties = Types::Profiles::FieldsProfile.all_properties,
|
24
|
+
limit = Types::List::ListLimits.new(0, 50),
|
25
|
+
sort = Types::List::ListSort.new, kodi_id = 1)
|
26
|
+
request = KodiRequest.new(kodi_id, GET_PROFILES,
|
27
|
+
{ 'properties' => properties,
|
28
|
+
'limits' => { 'start' => limit.list_start, 'end' => limit.list_end },
|
29
|
+
'sort' => { 'ignorearticle' => sort.ignore_article, 'method' => sort.method,
|
30
|
+
'order' => sort.order,
|
31
|
+
'useartistsortname' => sort.use_artist_sort_name } })
|
32
|
+
json = invoke_api(request)
|
33
|
+
result = Types::Profiles::GetProfilesReturned.create(json['result'])
|
34
|
+
json['result'] = result
|
35
|
+
KodiResponse.new(json)
|
36
|
+
end
|
37
|
+
|
38
|
+
def load_profile(profile_name, password, prompt = false, kodi_id = 1)
|
39
|
+
request = KodiRequest.new(kodi_id, LOAD_PROFILE,
|
40
|
+
{ 'profile' => profile_name,
|
41
|
+
'password' => { 'value' => password.value, 'encryption' => password.encryption },
|
42
|
+
'prompt' => prompt })
|
43
|
+
json = invoke_api(request)
|
44
|
+
KodiResponse.new(json)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
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 = Types::System::PropertyValue.create(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
|
@@ -4,7 +4,6 @@ module KodiClient
|
|
4
4
|
|
5
5
|
# offers compare methods
|
6
6
|
module Comparable
|
7
|
-
|
8
7
|
def compare(obj1, obj2)
|
9
8
|
is_same = true
|
10
9
|
obj1.instance_variables.each do |it|
|
@@ -13,5 +12,9 @@ module KodiClient
|
|
13
12
|
|
14
13
|
is_same
|
15
14
|
end
|
15
|
+
|
16
|
+
def ==(other)
|
17
|
+
compare(self, other)
|
18
|
+
end
|
16
19
|
end
|
17
20
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module KodiClient
|
4
|
+
|
5
|
+
# creates a create and create_list method by hash
|
6
|
+
module Creatable
|
7
|
+
|
8
|
+
def attr_accessor(*args)
|
9
|
+
attr_reader(*args)
|
10
|
+
attr_writer(*args)
|
11
|
+
end
|
12
|
+
|
13
|
+
def attr_reader(*args)
|
14
|
+
@kodi_fields = args.map { |it| it.to_s.gsub('_', '') }
|
15
|
+
|
16
|
+
args.each do |it|
|
17
|
+
inst_variable_name = "@#{it}".to_sym
|
18
|
+
define_method it do
|
19
|
+
instance_variable_get(inst_variable_name)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def attr_writer(*args)
|
25
|
+
args.each do |it|
|
26
|
+
inst_variable_name = "@#{it}".to_sym
|
27
|
+
define_method "#{it}=" do |new_value|
|
28
|
+
instance_variable_set(inst_variable_name, new_value)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def create_list(hash)
|
34
|
+
hash.nil? ? [] : hash.map { |it| create(it) }
|
35
|
+
end
|
36
|
+
|
37
|
+
def create(hash)
|
38
|
+
return nil if hash.nil?
|
39
|
+
return nil if @kodi_fields.none? { |it| !hash[it].nil? }
|
40
|
+
|
41
|
+
new(*@kodi_fields.map { |it| hash[it] })
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.hash_to_arr(hash, fields)
|
45
|
+
fields.map { |it| hash[it.to_s.gsub('_', '')].nil? ? nil : hash[it.to_s.gsub('_', '')] }
|
46
|
+
end
|
47
|
+
|
48
|
+
def hash_to_arr(hash, fields)
|
49
|
+
Creatable.hash_to_arr(hash, fields)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/kodi_client.rb
CHANGED
@@ -10,6 +10,8 @@ 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/profiles'
|
14
|
+
require 'kodi_client/method/system'
|
13
15
|
|
14
16
|
|
15
17
|
# client for Kodi rest api https://kodi.wiki/view/JSON-RPC_API/v12
|
@@ -20,7 +22,7 @@ module KodiClient
|
|
20
22
|
class Client
|
21
23
|
include Chainable
|
22
24
|
|
23
|
-
attr_reader :addons, :application, :gui, :player, :input, :favourites
|
25
|
+
attr_reader :addons, :application, :gui, :player, :input, :favourites, :system, :profiles
|
24
26
|
|
25
27
|
def initialize
|
26
28
|
@addons = KodiClient::Modules::Addons.new
|
@@ -29,15 +31,15 @@ module KodiClient
|
|
29
31
|
@gui = KodiClient::Modules::GUI.new
|
30
32
|
@input = KodiClient::Modules::Input.new
|
31
33
|
@player = KodiClient::Modules::Player.new
|
34
|
+
@profiles = KodiClient::Modules::Profiles.new
|
35
|
+
@system = KodiClient::Modules::System.new
|
32
36
|
end
|
33
37
|
|
34
|
-
def
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
@player.apply_options(options)
|
40
|
-
@favourites.apply_options(options)
|
38
|
+
def apply_options_to_methods(options)
|
39
|
+
instance_variables.each do |it|
|
40
|
+
mod = instance_variable_get(it)
|
41
|
+
mod.apply_options(options) if mod.is_a?(KodiClient::KodiModule)
|
42
|
+
end
|
41
43
|
end
|
42
44
|
end
|
43
45
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kodi_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Feier
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -25,9 +25,9 @@ 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,
|
29
|
-
the time). For more information how to use it and how to activate
|
30
|
-
in Kodi, please check the github page https://github.com/cfe86/RubyKodiClient
|
28
|
+
addons, application, favourites, gui, input, player, profile and system (more will
|
29
|
+
be added with the time). For more information how to use it and how to activate
|
30
|
+
Remote Control in Kodi, please check the github page https://github.com/cfe86/RubyKodiClient
|
31
31
|
email:
|
32
32
|
- christian.feier@gmail.com
|
33
33
|
executables: []
|
@@ -54,7 +54,9 @@ files:
|
|
54
54
|
- lib/kodi_client/global_types/list_types.rb
|
55
55
|
- lib/kodi_client/global_types/media_types.rb
|
56
56
|
- lib/kodi_client/global_types/player_type.rb
|
57
|
+
- lib/kodi_client/global_types/profiles_types.rb
|
57
58
|
- lib/kodi_client/global_types/pvr_type.rb
|
59
|
+
- lib/kodi_client/global_types/system_types.rb
|
58
60
|
- lib/kodi_client/global_types/video_types.rb
|
59
61
|
- lib/kodi_client/kodi_module.rb
|
60
62
|
- lib/kodi_client/method/addons.rb
|
@@ -63,8 +65,11 @@ files:
|
|
63
65
|
- lib/kodi_client/method/gui.rb
|
64
66
|
- lib/kodi_client/method/input.rb
|
65
67
|
- lib/kodi_client/method/player.rb
|
68
|
+
- lib/kodi_client/method/profiles.rb
|
69
|
+
- lib/kodi_client/method/system.rb
|
66
70
|
- lib/kodi_client/options.rb
|
67
71
|
- lib/kodi_client/util/comparable.rb
|
72
|
+
- lib/kodi_client/util/creatable.rb
|
68
73
|
- lib/kodi_client/util/iterable.rb
|
69
74
|
homepage: https://github.com/cfe86/RubyKodiClient
|
70
75
|
licenses:
|