kodi_client 0.5.6 → 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/kodi_client.gemspec +1 -1
- 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 -29
- data/lib/kodi_client/global_types/favourites_types.rb +17 -16
- data/lib/kodi_client/global_types/global_types.rb +18 -24
- data/lib/kodi_client/global_types/gui_types.rb +21 -15
- data/lib/kodi_client/global_types/item_types.rb +6 -2
- data/lib/kodi_client/global_types/list_types.rb +188 -95
- 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 +23 -13
- data/lib/kodi_client/global_types/system_types.rb +6 -9
- data/lib/kodi_client/global_types/video_types.rb +66 -41
- 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 +2 -2
- data/lib/kodi_client/method/system.rb +1 -1
- data/lib/kodi_client/util/comparable.rb +4 -1
- data/lib/kodi_client/util/creatable.rb +52 -0
- data/lib/kodi_client.rb +5 -9
- metadata +3 -2
@@ -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
|
@@ -15,7 +15,7 @@ module KodiClient
|
|
15
15
|
def get_current_profile(properties = Types::Profiles::FieldsProfile.all_properties, kodi_id = 1)
|
16
16
|
request = KodiRequest.new(kodi_id, GET_CURRENT_PROFILE, { 'properties' => properties })
|
17
17
|
json = invoke_api(request)
|
18
|
-
result =
|
18
|
+
result = Types::Profiles::DetailsProfile.create(json['result'])
|
19
19
|
json['result'] = result
|
20
20
|
KodiResponse.new(json)
|
21
21
|
end
|
@@ -30,7 +30,7 @@ module KodiClient
|
|
30
30
|
'order' => sort.order,
|
31
31
|
'useartistsortname' => sort.use_artist_sort_name } })
|
32
32
|
json = invoke_api(request)
|
33
|
-
result =
|
33
|
+
result = Types::Profiles::GetProfilesReturned.create(json['result'])
|
34
34
|
json['result'] = result
|
35
35
|
KodiResponse.new(json)
|
36
36
|
end
|
@@ -25,7 +25,7 @@ module KodiClient
|
|
25
25
|
def get_properties(properties = Types::System::PropertyName.all_properties, kodi_id = 1)
|
26
26
|
request = KodiRequest.new(kodi_id, GET_PROPERTIES, { 'properties' => properties })
|
27
27
|
json = invoke_api(request)
|
28
|
-
result =
|
28
|
+
result = Types::System::PropertyValue.create(json['result'])
|
29
29
|
json['result'] = result
|
30
30
|
KodiResponse.new(json)
|
31
31
|
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
@@ -35,15 +35,11 @@ module KodiClient
|
|
35
35
|
@system = KodiClient::Modules::System.new
|
36
36
|
end
|
37
37
|
|
38
|
-
def
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
@player.apply_options(options)
|
44
|
-
@favourites.apply_options(options)
|
45
|
-
@profiles.apply_options(options)
|
46
|
-
@system.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
|
47
43
|
end
|
48
44
|
end
|
49
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.5.
|
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
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- lib/kodi_client/method/system.rb
|
70
70
|
- lib/kodi_client/options.rb
|
71
71
|
- lib/kodi_client/util/comparable.rb
|
72
|
+
- lib/kodi_client/util/creatable.rb
|
72
73
|
- lib/kodi_client/util/iterable.rb
|
73
74
|
homepage: https://github.com/cfe86/RubyKodiClient
|
74
75
|
licenses:
|