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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 988e821c68bbe4f1ffc3579c64aa02647814f9aea0fb5af409d619a10e82ab71
4
- data.tar.gz: 1df5a3cea4ac46a7fb1fc7420f3f8a66244ceaed0a79a06673a6f9b9e3e6fcd0
3
+ metadata.gz: 0dd073d0e999df44e921b07f3aab1c148ee3647a584e2de13a2c070a151f7a2b
4
+ data.tar.gz: 00ac80c0f82b4bfcb0031e8cc2abf6e4c894ccff58515fcdfd08fbe1c3b7fb63
5
5
  SHA512:
6
- metadata.gz: 4cbaa96ef989fc5c9708007f623f7c272ad465670099ac3d5251b5b2621e2f02411b23ad3aa3b5864b62b91bd4a530276cb884205b8e2f180491fce3a5c74204
7
- data.tar.gz: a7aca817104f7be2f5919713cf07d40a4901f3fc6c0dc57ab248be2be0a34194b7c96f751277aaf3466561e19d83bf16ec1401c0a5765a1c0cdc51f51ec04bef
6
+ metadata.gz: b1a718355773fd1a1e12127f334f74a9bc1d9382ec47e9143a2dc776e1bb056157f4ac5ca0ec1232b14c27c8cc55bacacae1b37e0b831213af7472c2aeef16ec
7
+ data.tar.gz: e6dccd2f74a7c2f7a4790635b21f01730c88a69bfe47c6b8905b500dade3b650689506640a2428c00824ca03097658906563a7f88806aad094a3dc64d7edcf0c
data/kodi_client.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'kodi_client'
5
- spec.version = '0.5.6'
5
+ spec.version = '0.5.7'
6
6
  spec.authors = ['Christian Feier']
7
7
  spec.email = ['christian.feier@gmail.com']
8
8
 
@@ -24,7 +24,7 @@ module KodiClient
24
24
  client = def_client
25
25
  options = def_options
26
26
  set_command.call(options)
27
- client.apply_options(options)
27
+ client.apply_options_to_methods(options)
28
28
  client
29
29
  end
30
30
 
@@ -43,5 +43,7 @@ module KodiClient
43
43
  end
44
44
  @options
45
45
  end
46
+
47
+ private :def_client, :def_options, :merge_options
46
48
  end
47
49
  end
@@ -3,6 +3,7 @@
3
3
  require 'kodi_client/global_types/item_types'
4
4
  require 'kodi_client/util/comparable'
5
5
  require 'kodi_client/util/iterable'
6
+ require 'kodi_client/util/creatable'
6
7
 
7
8
  module KodiClient
8
9
  module Types
@@ -10,7 +11,7 @@ module KodiClient
10
11
 
11
12
  # Addon Types https://kodi.wiki/view/JSON-RPC_API/v12#Addon.Types
12
13
  module AddonTypes
13
- include Iterable
14
+ extend Iterable
14
15
 
15
16
  UNKNOWN = 'unknown'
16
17
  KODI_ADSP = 'kodi.adsp'
@@ -51,7 +52,8 @@ module KodiClient
51
52
 
52
53
  # Addon.Content https://kodi.wiki/view/JSON-RPC_API/v12#Addon.Content
53
54
  module AddonContent
54
- include Iterable
55
+ extend Iterable
56
+
55
57
  UNKNOWN = 'unknown'
56
58
  AUDIO = 'audio'
57
59
  EXECUTABLE = 'executable'
@@ -83,33 +85,27 @@ module KodiClient
83
85
  # represents addon dependency
84
86
  class AddonDependency
85
87
  include Comparable
88
+ extend Creatable
86
89
 
87
- attr_reader :addonid, :optional, :version
90
+ attr_reader :addon_id, :optional, :version
88
91
 
89
- def initialize(hash)
90
- @addonid = hash['addonid']
91
- @optional = hash['optional']
92
- @version = hash['version']
93
- end
94
-
95
- def ==(other)
96
- compare(self, other)
92
+ def initialize(addon_id, optional, version)
93
+ @addon_id = addon_id
94
+ @optional = optional
95
+ @version = version
97
96
  end
98
97
  end
99
98
 
100
99
  # represents addon extra info
101
100
  class AddonExtraInfo
102
101
  include Comparable
102
+ extend Creatable
103
103
 
104
104
  attr_reader :key, :value
105
105
 
106
- def initialize(hash)
107
- @key = hash['key']
108
- @value = hash['value']
109
- end
110
-
111
- def ==(other)
112
- compare(self, other)
106
+ def initialize(key, value)
107
+ @key = key
108
+ @value = value
113
109
  end
114
110
  end
115
111
 
@@ -117,33 +113,43 @@ module KodiClient
117
113
  class AddonDetails
118
114
  include Comparable
119
115
  include Items::ItemDetailsBase
116
+ extend Creatable
120
117
 
121
118
  attr_reader :addon_id, :author, :broken, :dependencies, :description, :disclaimer, :enabled, :extra_info,
122
119
  :fan_art, :installed, :name, :path, :rating, :summary, :thumbnail, :type, :version
123
120
 
124
- def initialize(hash)
125
- @addon_id = hash['addonid']
126
- @author = hash['author']
127
- @broken = hash['broken']
128
- @dependencies = hash['dependencies'].nil? ? nil : hash['dependencies'].map { |it| AddonDependency.new(it) }
129
- @description = hash['description']
130
- @disclaimer = hash['disclaimer']
131
- @enabled = hash['enabled']
132
- @extra_info = hash['extrainfo'].nil? ? nil : hash['extrainfo'].map { |it| AddonExtraInfo.new(it) }
133
- @fan_art = hash['fanart']
134
- @installed = hash['installed']
135
- @name = hash['name']
136
- @path = hash['path']
137
- @rating = hash['rating']
138
- @summary = hash['summary']
139
- @thumbnail = hash['thumbnail']
140
- @type = hash['type']
141
- @version = hash['version']
142
- item_details_base(hash)
121
+ def self.create(hash)
122
+ return nil if hash.nil?
123
+
124
+ dependencies = AddonDependency.create_list(hash['dependencies'])
125
+ extra_info = AddonExtraInfo.create_list(hash['extrainfo'])
126
+
127
+ new(hash['addonid'], hash['author'], hash['broken'], dependencies, hash['description'], hash['disclaimer'],
128
+ hash['enabled'], extra_info, hash['fanart'], hash['installed'], hash['name'], hash['path'],
129
+ hash['rating'], hash['summary'], hash['thumbnail'], hash['type'], hash['version'],
130
+ *hash_to_arr(hash, ['label']))
143
131
  end
144
132
 
145
- def ==(other)
146
- compare(self, other)
133
+ def initialize(addon_id, author, broken, dependencies, description, disclaimer, enabled, extra_info,
134
+ fan_art, installed, name, path, rating, summary, thumbnail, type, version, label)
135
+ @addon_id = addon_id
136
+ @author = author
137
+ @broken = broken
138
+ @dependencies = dependencies
139
+ @description = description
140
+ @disclaimer = disclaimer
141
+ @enabled = enabled
142
+ @extra_info = extra_info
143
+ @fan_art = fan_art
144
+ @installed = installed
145
+ @name = name
146
+ @path = path
147
+ @rating = rating
148
+ @summary = summary
149
+ @thumbnail = thumbnail
150
+ @type = type
151
+ @version = version
152
+ item_details_base(label)
147
153
  end
148
154
  end
149
155
 
@@ -153,13 +159,17 @@ module KodiClient
153
159
 
154
160
  attr_reader :addons, :limits
155
161
 
156
- def initialize(hash)
157
- @addons = hash['addons'].map { |it| AddonDetails.new(it) }
158
- @limits = List::ListLimitsReturned.new(hash['limits'])
162
+ def self.create(hash)
163
+ return nil if hash.nil?
164
+
165
+ addons = AddonDetails.create_list(hash['addons'])
166
+ limits = List::ListLimitsReturned.create(hash['limits'])
167
+ new(addons, limits)
159
168
  end
160
169
 
161
- def ==(other)
162
- compare(self, other)
170
+ def initialize(addons, limits)
171
+ @addons = addons
172
+ @limits = limits
163
173
  end
164
174
  end
165
175
 
@@ -169,12 +179,14 @@ module KodiClient
169
179
 
170
180
  attr_reader :addon
171
181
 
172
- def initialize(hash)
173
- @addon = AddonDetails.new(hash['addon'])
182
+ def self.create(hash)
183
+ return nil if hash.nil?
184
+
185
+ new(AddonDetails.create(hash['addon']))
174
186
  end
175
187
 
176
- def ==(other)
177
- compare(self, other)
188
+ def initialize(addon)
189
+ @addon = addon
178
190
  end
179
191
  end
180
192
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'kodi_client/util/comparable'
4
4
  require 'kodi_client/util/iterable'
5
+ require 'kodi_client/util/creatable'
5
6
 
6
7
  module KodiClient
7
8
  module Types
@@ -22,35 +23,37 @@ module KodiClient
22
23
  # Application.Property.Value https://kodi.wiki/view/JSON-RPC_API/v12#Application.Property.Value
23
24
  class PropertyValue
24
25
  include Comparable
26
+ extend Creatable
25
27
 
26
28
  attr_reader :name, :version, :muted, :volume
27
29
 
28
- def initialize(hash)
29
- @name = hash['name']
30
- @version = hash['version'].nil? ? nil : Version.new(hash['version'])
31
- @muted = hash['muted']
32
- @volume = hash['volume']
30
+ def self.create(hash)
31
+ return null if hash.nil?
32
+
33
+ version = Version.create(hash['version'])
34
+ new(hash['name'], version, hash['muted'], hash['volume'])
33
35
  end
34
36
 
35
- def ==(other)
36
- compare(self, other)
37
+ def initialize(name, version, muted, volume)
38
+ @name = name
39
+ @version = version
40
+ @muted = muted
41
+ @volume = volume
37
42
  end
38
43
  end
39
44
 
40
45
  # represent application properties version
41
46
  class Version
42
47
  include Comparable
43
- attr_reader :major, :minor, :revision, :tag
48
+ extend Creatable
44
49
 
45
- def initialize(hash)
46
- @major = hash['major']
47
- @minor = hash['minor']
48
- @revision = hash['revision']
49
- @tag = hash['tag']
50
- end
50
+ attr_reader :major, :minor, :revision, :tag
51
51
 
52
- def ==(other)
53
- compare(self, other)
52
+ def initialize(major, minor, revision, tag)
53
+ @major = major
54
+ @minor = minor
55
+ @revision = revision
56
+ @tag = tag
54
57
  end
55
58
  end
56
59
  end
@@ -3,6 +3,7 @@
3
3
  require 'kodi_client/global_types/media_types'
4
4
  require 'kodi_client/util/comparable'
5
5
  require 'kodi_client/util/iterable'
6
+ require 'kodi_client/util/creatable'
6
7
 
7
8
  module KodiClient
8
9
  module Types
@@ -11,18 +12,15 @@ module KodiClient
11
12
  # Audio.Contributor https://kodi.wiki/view/JSON-RPC_API/v12#Audio.Contributors
12
13
  class AudioContributor
13
14
  include Comparable
15
+ extend Creatable
14
16
 
15
17
  attr_reader :artist_id, :name, :role, :role_id
16
18
 
17
- def initialize(hash)
18
- @artist_id = hash['artistid']
19
- @name = hash['name']
20
- @role = hash['role']
21
- @role_id = hash['roleid']
22
- end
23
-
24
- def ==(other)
25
- compare(self, other)
19
+ def initialize(artist_id, name, role, role_id)
20
+ @artist_id = artist_id
21
+ @name = name
22
+ @role = role
23
+ @role_id = role_id
26
24
  end
27
25
  end
28
26
 
@@ -40,11 +38,16 @@ module KodiClient
40
38
 
41
39
  attr_reader :art, :date_added, :genre
42
40
 
43
- def audio_details_base(hash)
44
- @art = Types::Media::MediaArtwork.new(hash['art'])
45
- @date_added = hash['date_added']
46
- @genre = hash['genre']
47
- media_details_base(hash)
41
+ def audio_details_base_by_hash(hash)
42
+ audio_details_base(Types::Media::MediaArtwork.create(hash['art']), hash['date_added'], hash['genre'],
43
+ *Creatable.hash_to_arr(hash, %w[fan_art thumbnail label]))
44
+ end
45
+
46
+ def audio_details_base(art, date_added, genre, fan_art, thumbnail, label)
47
+ @art = art
48
+ @date_added = date_added
49
+ @genre = genre
50
+ media_details_base(fan_art, thumbnail, label)
48
51
  end
49
52
  end
50
53
 
@@ -52,23 +55,32 @@ module KodiClient
52
55
  module AudioDetailsMedia
53
56
  include AudioDetailsBase
54
57
 
55
- attr_reader :artist, :artist_id, :display_artist, :musicbrainz_albumartist_id, :original_date, :rating,
58
+ attr_reader :artist, :artist_id, :display_artist, :musicbrainz_album_artist_id, :original_date, :rating,
56
59
  :release_date, :sort_artist, :title, :user_rating, :votes, :year
57
60
 
58
- def audio_details_media(hash)
59
- @artist = hash['artist']
60
- @artist_id = hash['artistid']
61
- @display_artist = hash['displayartist']
62
- @musicbrainz_albumartist_id = hash['musicbrainzalbumartistid']
63
- @original_date = hash['originaldate']
64
- @rating = hash['rating']
65
- @release_date = hash['releasedate']
66
- @sort_artist = hash['sortartist']
67
- @title = hash['title']
68
- @user_rating = hash['userrating']
69
- @votes = hash['votes']
70
- @year = hash['year']
71
- audio_details_base(hash)
61
+ def audio_details_media_by_hash(hash)
62
+ audio_details_media(hash['artist'], hash['artistid'], hash['displayartist'], hash['musicbrainzalbumartistid'],
63
+ hash['originaldate'], hash['rating'], hash['releasedate'], hash['sortartist'],
64
+ hash['title'], hash['userrating'], hash['votes'], hash['year'],
65
+ *Creatable.hash_to_arr(hash, %w[art date_added genre fan_art thumbnail label]))
66
+ end
67
+
68
+ def audio_details_media(artist, artist_id, display_artist, musicbrainz_album_artist_id, original_date,
69
+ rating, release_date, sort_artist, title, user_rating, votes, year,
70
+ art, date_added, genre, fan_art, thumbnail, label)
71
+ @artist = artist
72
+ @artist_id = artist_id
73
+ @display_artist = display_artist
74
+ @musicbrainz_album_artist_id = musicbrainz_album_artist_id
75
+ @original_date = original_date
76
+ @rating = rating
77
+ @release_date = release_date
78
+ @sort_artist = sort_artist
79
+ @title = title
80
+ @user_rating = user_rating
81
+ @votes = votes
82
+ @year = year
83
+ audio_details_base(art, date_added, genre, fan_art, thumbnail, label)
72
84
  end
73
85
  end
74
86
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'kodi_client/util/comparable'
4
4
  require 'kodi_client/util/iterable'
5
+ require 'kodi_client/util/creatable'
5
6
  require 'kodi_client/global_types/list_types'
6
7
 
7
8
  module KodiClient
@@ -32,36 +33,36 @@ module KodiClient
32
33
  # Favourite.Details.Favourite https://kodi.wiki/view/JSON-RPC_API/v12#Favourite.Details.Favourite
33
34
  class DetailsFavourite
34
35
  include Comparable
36
+ extend Creatable
35
37
 
36
38
  attr_reader :path, :thumbnail, :title, :type, :window, :window_parameter
37
39
 
38
- def initialize(hash)
39
- @path = hash['path']
40
- @thumbnail = hash['thumbnail']
41
- @title = hash['title']
42
- @type = hash['type']
43
- @window = hash['window']
44
- @window_parameter = hash['windowparameter']
45
- end
46
-
47
- def ==(other)
48
- compare(self, other)
40
+ def initialize(path, thumbnail, title, type, window, window_parameter)
41
+ @path = path
42
+ @thumbnail = thumbnail
43
+ @title = title
44
+ @type = type
45
+ @window = window
46
+ @window_parameter = window_parameter
49
47
  end
50
48
  end
51
49
 
52
50
  # return type for Favourites.GetFavourites
53
51
  class GetFavouriteReturned
54
52
  include Comparable
53
+ extend Creatable
55
54
 
56
55
  attr_reader :favourites, :limits
57
56
 
58
- def initialize(hash)
59
- @favourites = hash['favourites'].map { |it| DetailsFavourite.new(it) }
60
- @limits = Types::List::ListLimitsReturned.new(hash['limits'])
57
+ def self.create(hash)
58
+ favourites = DetailsFavourite.create_list(hash['favourites'])
59
+ limits = Types::List::ListLimitsReturned.create(hash['limits'])
60
+ new(favourites, limits)
61
61
  end
62
62
 
63
- def ==(other)
64
- compare(self, other)
63
+ def initialize(favourites, limits)
64
+ @favourites = favourites
65
+ @limits = limits
65
66
  end
66
67
  end
67
68
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'kodi_client/util/comparable'
4
4
  require 'kodi_client/util/iterable'
5
+ require 'kodi_client/util/creatable'
5
6
 
6
7
  module KodiClient
7
8
  module Types
@@ -9,7 +10,7 @@ module KodiClient
9
10
 
10
11
  # Global.Toggle https://kodi.wiki/view/JSON-RPC_API/v12#Global.Toggle
11
12
  module Toggle
12
- include Iterable
13
+ extend Iterable
13
14
 
14
15
  TOGGLE = 'toggle'
15
16
  TRUE = true
@@ -55,48 +56,41 @@ module KodiClient
55
56
  # id/label type
56
57
  class IdLabel
57
58
  include Comparable
58
- attr_reader :id, :label
59
+ extend Creatable
59
60
 
60
- def initialize(hash)
61
- @id = hash['id']
62
- @label = hash['label']
63
- end
61
+ attr_reader :id, :label
64
62
 
65
- def ==(other)
66
- compare(self, other)
63
+ def initialize(id, label)
64
+ @id = id
65
+ @label = label
67
66
  end
68
67
  end
69
68
 
70
69
  # id/name type
71
70
  class IdName
72
71
  include Comparable
73
- attr_reader :id, :name
72
+ extend Creatable
74
73
 
75
- def initialize(hash)
76
- @id = hash['id']
77
- @name = hash['name']
78
- end
74
+ attr_reader :id, :name
79
75
 
80
- def ==(other)
81
- compare(self, other)
76
+ def initialize(id, name)
77
+ @id = id
78
+ @name = name
82
79
  end
83
80
  end
84
81
 
85
82
  # Global.Time https://kodi.wiki/view/JSON-RPC_API/v12#Global.Time
86
83
  class GlobalTime
87
84
  include Comparable
85
+ extend Creatable
88
86
 
89
87
  attr_reader :hours, :minutes, :seconds, :milliseconds
90
88
 
91
- def initialize(hash)
92
- @hours = hash['hours']
93
- @minutes = hash['minutes']
94
- @seconds = hash['seconds']
95
- @milliseconds = hash['milliseconds']
96
- end
97
-
98
- def ==(other)
99
- compare(self, other)
89
+ def initialize(hours, minutes, seconds, milliseconds)
90
+ @hours = hours
91
+ @minutes = minutes
92
+ @seconds = seconds
93
+ @milliseconds = milliseconds
100
94
  end
101
95
  end
102
96
 
@@ -3,6 +3,7 @@
3
3
  require 'kodi_client/global_types/global_types'
4
4
  require 'kodi_client/util/comparable'
5
5
  require 'kodi_client/util/iterable'
6
+ require 'kodi_client/util/creatable'
6
7
 
7
8
  module KodiClient
8
9
  module Types
@@ -10,6 +11,7 @@ module KodiClient
10
11
 
11
12
  # GUI.Window https://kodi.wiki/view/JSON-RPC_API/v12#GUI.Window
12
13
  module GUIWindow
14
+ extend Iterable
13
15
 
14
16
  ACCESSPOINTS = 'accesspoints'
15
17
  ADDON = 'addon'
@@ -139,6 +141,7 @@ module KodiClient
139
141
  class StereoscopyMode
140
142
  include Comparable
141
143
  include Iterable
144
+ extend Creatable
142
145
 
143
146
  attr_reader :label, :mode
144
147
 
@@ -152,32 +155,35 @@ module KodiClient
152
155
  ANAGLYPH_YELLOW_BLUE = 'anaglyph_yellow_blue'
153
156
  MONSCOPIC = 'monoscopic'
154
157
 
155
- def initialize(hash)
156
- @label = hash['label']
157
- @mode = hash['mode']
158
- end
159
-
160
- def ==(other)
161
- compare(self, other)
158
+ def initialize(label, mode)
159
+ @label = label
160
+ @mode = mode
162
161
  end
163
162
  end
164
163
 
165
164
  # GUI.Property.Value https://kodi.wiki/view/JSON-RPC_API/v12#GUI.Property.Value
166
165
  class PropertyValue
167
166
  include Comparable
167
+ extend Creatable
168
168
 
169
169
  attr_reader :current_control, :current_window, :fullscreen, :skin, :stereoscopic_mode
170
170
 
171
- def initialize(hash)
172
- @current_control = Global::IdLabel.new(hash['currentcontrol'])
173
- @current_window = Global::IdLabel.new(hash['currentwindow'])
174
- @fullscreen = hash['fullscreen']
175
- @skin = Global::IdName.new(hash['skin'])
176
- @stereoscopic_mode = StereoscopyMode.new(hash['stereoscopicmode'])
171
+ def self.create(hash)
172
+ return nil if hash.nil?
173
+
174
+ current_control = Global::IdLabel.create(hash['currentcontrol'])
175
+ current_window = Global::IdLabel.create(hash['currentwindow'])
176
+ skin = Global::IdName.create(hash['skin'])
177
+ stereoscopic_mode = StereoscopyMode.create(hash['stereoscopicmode'])
178
+ new(current_control, current_window, hash['fullscreen'], skin, stereoscopic_mode)
177
179
  end
178
180
 
179
- def ==(other)
180
- compare(self, other)
181
+ def initialize(current_control, current_window, fullscreen, skin, stereoscopic_mode)
182
+ @current_control = current_control
183
+ @current_window = current_window
184
+ @fullscreen = fullscreen
185
+ @skin = skin
186
+ @stereoscopic_mode = stereoscopic_mode
181
187
  end
182
188
  end
183
189
  end
@@ -9,8 +9,12 @@ module KodiClient
9
9
 
10
10
  attr_reader :label
11
11
 
12
- def item_details_base(hash)
13
- @label = hash['label']
12
+ def item_details_base_by_hash(hash)
13
+ item_details_base(hash['label'])
14
+ end
15
+
16
+ def item_details_base(label)
17
+ @label = label
14
18
  end
15
19
  end
16
20
  end