kodi_client 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -0
  3. data/kodi_client.gemspec +5 -2
  4. data/lib/kodi_client/Chainable.rb +3 -1
  5. data/lib/kodi_client/global_types/addon_types.rb +60 -48
  6. data/lib/kodi_client/global_types/application_types.rb +19 -16
  7. data/lib/kodi_client/global_types/audio_types.rb +41 -30
  8. data/lib/kodi_client/global_types/favourites_types.rb +18 -17
  9. data/lib/kodi_client/global_types/files_types.rb +82 -0
  10. data/lib/kodi_client/global_types/global_types.rb +29 -27
  11. data/lib/kodi_client/global_types/gui_types.rb +21 -15
  12. data/lib/kodi_client/global_types/input_types.rb +1 -1
  13. data/lib/kodi_client/global_types/item_types.rb +6 -2
  14. data/lib/kodi_client/global_types/list_types.rb +414 -91
  15. data/lib/kodi_client/global_types/media_types.rb +16 -11
  16. data/lib/kodi_client/global_types/player_type.rb +126 -107
  17. data/lib/kodi_client/global_types/profiles_types.rb +80 -0
  18. data/lib/kodi_client/global_types/pvr_type.rb +2 -0
  19. data/lib/kodi_client/global_types/system_types.rb +6 -9
  20. data/lib/kodi_client/global_types/video_types.rb +68 -41
  21. data/lib/kodi_client/kodi_module.rb +1 -0
  22. data/lib/kodi_client/method/addons.rb +2 -3
  23. data/lib/kodi_client/method/application.rb +1 -1
  24. data/lib/kodi_client/method/favourites.rb +1 -1
  25. data/lib/kodi_client/method/files.rb +89 -0
  26. data/lib/kodi_client/method/gui.rb +2 -2
  27. data/lib/kodi_client/method/player.rb +6 -6
  28. data/lib/kodi_client/method/profiles.rb +48 -0
  29. data/lib/kodi_client/method/system.rb +1 -1
  30. data/lib/kodi_client/util/comparable.rb +4 -1
  31. data/lib/kodi_client/util/creatable.rb +52 -0
  32. data/lib/kodi_client.rb +10 -9
  33. metadata +10 -5
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'kodi_client/global_types/item_types'
4
4
  require 'kodi_client/util/comparable'
5
+ require 'kodi_client/util/creatable'
5
6
 
6
7
  module KodiClient
7
8
  module Types
@@ -10,6 +11,7 @@ module KodiClient
10
11
  # media types
11
12
  module MediaType
12
13
  extend Iterable
14
+
13
15
  VIDEO = 'video'
14
16
  AUDIO = 'audio'
15
17
  ALL = 'all'
@@ -21,28 +23,31 @@ module KodiClient
21
23
 
22
24
  attr_reader :fan_art, :thumbnail
23
25
 
24
- def media_details_base(hash)
26
+ def media_details_base_by_hash(hash)
25
27
  @fan_art = hash['fanart']
26
28
  @thumbnail = hash['thumbnail']
27
- item_details_base(hash)
29
+ item_details_base_by_hash(hash)
30
+ end
31
+
32
+ def media_details_base(fan_art, thumbnail, label)
33
+ @fan_art = fan_art
34
+ @thumbnail = thumbnail
35
+ item_details_base(label)
28
36
  end
29
37
  end
30
38
 
31
39
  # Media.Artwork https://kodi.wiki/view/JSON-RPC_API/v12#Media.Artwork
32
40
  class MediaArtwork
33
41
  include Comparable
42
+ extend Creatable
34
43
 
35
44
  attr_reader :banner, :fan_art, :poster, :thumb
36
45
 
37
- def initialize(hash)
38
- @banner = hash['banner']
39
- @fan_art = hash['fanart']
40
- @poster = hash['poster']
41
- @thumb = hash['thumb']
42
- end
43
-
44
- def ==(other)
45
- compare(self, other)
46
+ def initialize(banner, fan_art, poster, thumb)
47
+ @banner = banner
48
+ @fan_art = fan_art
49
+ @poster = poster
50
+ @thumb = thumb
46
51
  end
47
52
  end
48
53
  end
@@ -20,6 +20,7 @@ module KodiClient
20
20
  # Player.ViewMode https://kodi.wiki/view/JSON-RPC_API/v12#Player.ViewMode
21
21
  module ViewMode
22
22
  extend Iterable
23
+
23
24
  NORMAL = 'normal'
24
25
  ZOOM = 'zoom'
25
26
  STRETCH_4x3 = 'strech4x3'
@@ -34,6 +35,7 @@ module KodiClient
34
35
  # player types
35
36
  module PlayerVisibilityType
36
37
  extend Iterable
38
+
37
39
  INTERNAL = 'internal'
38
40
  EXTERNAL = 'external'
39
41
  REMOTE = 'remote'
@@ -80,87 +82,75 @@ module KodiClient
80
82
  # player id and type
81
83
  class Player
82
84
  include Comparable
85
+ extend Creatable
83
86
 
84
87
  attr_reader :player_id, :player_type, :type, :name, :plays_audio, :plays_video
85
88
 
86
- def initialize(hash)
87
- @player_id = hash['playerid']
88
- @player_type = hash['playertype']
89
- @type = hash['type']
90
- @name = hash['name']
91
- @plays_audio = hash['playsaudio']
92
- @plays_video = hash['playsvideo']
93
- end
94
-
95
- def ==(other)
96
- compare(self, other)
89
+ def initialize(player_id, player_type, type, name, plays_audio, plays_video)
90
+ @player_id = player_id
91
+ @player_type = player_type
92
+ @type = type
93
+ @name = name
94
+ @plays_audio = plays_audio
95
+ @plays_video = plays_video
97
96
  end
98
97
  end
99
98
 
100
99
  # Player Subtitle https://kodi.wiki/view/JSON-RPC_API/v12#Player.Subtitle
101
100
  class Subtitle
102
101
  include Comparable
102
+ extend Creatable
103
103
 
104
104
  attr_reader :index, :is_default, :is_forced, :is_impaired, :language, :name
105
105
 
106
- def initialize(hash)
107
- @index = hash['index']
108
- @is_default = hash['isdefault']
109
- @is_forced = hash['isforced']
110
- @is_impaired = hash['isimpaired']
111
- @language = hash['language']
112
- @name = hash['name']
113
- end
114
-
115
- def ==(other)
116
- compare(self, other)
106
+ def initialize(index, is_default, is_forced, is_impaired, language, name)
107
+ @index = index
108
+ @is_default = is_default
109
+ @is_forced = is_forced
110
+ @is_impaired = is_impaired
111
+ @language = language
112
+ @name = name
117
113
  end
118
114
  end
119
115
 
120
116
  # Player.Audio.Stream https://kodi.wiki/view/JSON-RPC_API/v12#Player.Audio.Stream
121
117
  class AudioStream
122
118
  include Comparable
119
+ extend Creatable
123
120
 
124
121
  attr_reader :bitrate, :channels, :codec, :index, :is_default, :is_forced, :is_original, :language,
125
122
  :name, :sample_rate
126
123
 
127
- def initialize(hash)
128
- @bitrate = hash['bitrate']
129
- @channels = hash['channels']
130
- @codec = hash['codec']
131
- @index = hash['index']
132
- @is_default = hash['isdefault']
133
- @is_forced = hash['isforced']
134
- @is_original = hash['isoriginal']
135
- @language = hash['language']
136
- @name = hash['name']
137
- @sample_rate = hash['samplerate']
138
- end
139
-
140
- def ==(other)
141
- compare(self, other)
124
+ def initialize(bitrate, channels, codec, index, is_default, is_forced, is_original, language, name, sample_rate)
125
+ @bitrate = bitrate
126
+ @channels = channels
127
+ @codec = codec
128
+ @index = index
129
+ @is_default = is_default
130
+ @is_forced = is_forced
131
+ @is_original = is_original
132
+ @language = language
133
+ @name = name
134
+ @sample_rate = sample_rate
142
135
  end
143
136
  end
144
137
 
145
138
  # Player.Video.Stream https://kodi.wiki/view/JSON-RPC_API/v12#Player.Video.Stream
146
139
  class VideoStream
147
140
  include Comparable
141
+ extend Creatable
148
142
 
149
143
  attr_reader :codec, :height, :index, :language, :name, :width, :duration, :aspect
150
144
 
151
- def initialize(hash)
152
- @codec = hash['codec']
153
- @height = hash['height']
154
- @index = hash['index']
155
- @language = hash['language']
156
- @name = hash['name']
157
- @width = hash['width']
158
- @duration = hash['duration']
159
- @aspect = hash['aspect']
160
- end
161
-
162
- def ==(other)
163
- compare(self, other)
145
+ def initialize(codec, height, index, language, name, width, duration, aspect)
146
+ @codec = codec
147
+ @height = height
148
+ @index = index
149
+ @language = language
150
+ @name = name
151
+ @width = width
152
+ @duration = duration
153
+ @aspect = aspect
164
154
  end
165
155
  end
166
156
 
@@ -198,76 +188,99 @@ module KodiClient
198
188
  # Player.Property.Value https://kodi.wiki/view/JSON-RPC_API/v12#Player.Property.Name
199
189
  class PropertyValue
200
190
  include Comparable
201
-
202
- def initialize(hash)
203
- @audio_streams = hash['audiostreams'].map { |it| AudioStream.new(it) }
204
- @cache_percentage = hash['cachepercentage']
205
- @can_change_speed = hash['canchangespeed']
206
- @can_move = hash['canmove']
207
- @can_repeat = hash['canrepeat']
208
- @can_rotate = hash['canrotate']
209
- @can_seek = hash['canseek']
210
- @can_shuffle = hash['canshuffle']
211
- @can_zoom = hash['canzoom']
212
- @current_audio_stream = AudioStream.new(hash['currentaudiostream'])
213
- @current_subtitle = Subtitle.new(hash['currentsubtitle'])
214
- @current_video_stream = VideoStream.new(hash['currentvideostream'])
215
- @live = hash['live']
216
- @party_mode = hash['partymode']
217
- @percentage = hash['percentage']
218
- @playlist_id = hash['playlistid'].nil? ? -1 : hash['playlistid']
219
- @position = hash['position'].nil? ? -1 : hash['position']
220
- @position = hash['position'].nil? ? -1 : hash['position']
221
- @repeat = hash['repeat'].nil? ? PlayerRepeat::OFF : hash['repeat']
222
- @shuffled = hash['shuffled']
223
- @speed = hash['speed']
224
- @subtitle_enabled = hash['subtitleenabled']
225
- @subtitles = hash['subtitles'].map { |it| Subtitle.new(it) }
226
- @time = Types::Global::GlobalTime.new(hash['time'])
227
- @total_time = Types::Global::GlobalTime.new(hash['totaltime'])
228
- @type = hash['type'].nil? ? PlayerType::VIDEO : hash['type']
229
- @video_streams = hash['videostreams'].map { |it| VideoStream.new(it) }
191
+ extend Creatable
192
+
193
+ attr_reader :audio_streams, :cache_percentage, :can_change_speed, :can_move, :can_repeat, :can_rotate,
194
+ :can_seek, :can_shuffle, :can_zoom, :current_audio_stream, :current_subtitle, :current_video_stream,
195
+ :live, :party_mode, :percentage, :playlist_id, :position, :repeat, :shuffled, :speed,
196
+ :subtitle_enabled, :subtitles, :time, :total_time, :type, :video_streams
197
+
198
+ def self.create(hash)
199
+ return nil if hash.nil?
200
+
201
+ audio_streams = AudioStream.create_list(hash['audiostreams'])
202
+ current_audio_stream = AudioStream.create(hash['currentaudiostream'])
203
+ current_subtitle = Subtitle.create(hash['currentsubtitle'])
204
+ current_video_stream = VideoStream.create(hash['currentvideostream'])
205
+ subtitles = Subtitle.create_list(hash['subtitles'])
206
+ time = Types::Global::GlobalTime.create(hash['time'])
207
+ total_time = Types::Global::GlobalTime.create(hash['totaltime'])
208
+ video_streams = VideoStream.create_list(hash['videostreams'])
209
+
210
+ hash['type'] = PlayerType::VIDEO if hash['type'].nil?
211
+ hash['playlistid'] = -1 if hash['playlistid'].nil?
212
+ hash['position'] = -1 if hash['position'].nil?
213
+ hash['repeat'] = PlayerRepeat::OFF if hash['repeat'].nil?
214
+
215
+ new(audio_streams, *Creatable.hash_to_arr(hash, %w[cache_percentage can_change_speed can_move
216
+ can_repeat can_rotate can_seek can_shuffle can_zoom]),
217
+ current_audio_stream, current_subtitle, current_video_stream,
218
+ *Creatable.hash_to_arr(hash, %w[live party_mode percentage playlist_id position repeat
219
+ shuffled speed subtitle_enabled]), subtitles, time, total_time,
220
+ hash['type'], video_streams)
230
221
  end
231
222
 
232
- def ==(other)
233
- compare(self, other)
223
+ def initialize(audio_streams, cache_percentage, can_change_speed, can_move, can_repeat, can_rotate, can_seek,
224
+ can_shuffle, can_zoom, current_audio_stream, current_subtitle, current_video_stream, live,
225
+ party_mode, percentage, playlist_id, position, repeat, shuffled, speed,
226
+ subtitle_enabled, subtitles, time, total_time, type, video_streams)
227
+ @audio_streams = audio_streams
228
+ @cache_percentage = cache_percentage
229
+ @can_change_speed = can_change_speed
230
+ @can_move = can_move
231
+ @can_repeat = can_repeat
232
+ @can_rotate = can_rotate
233
+ @can_seek = can_seek
234
+ @can_shuffle = can_shuffle
235
+ @can_zoom = can_zoom
236
+ @current_audio_stream = current_audio_stream
237
+ @current_subtitle = current_subtitle
238
+ @current_video_stream = current_video_stream
239
+ @live = live
240
+ @party_mode = party_mode
241
+ @percentage = percentage
242
+ @playlist_id = playlist_id
243
+ @position = position
244
+ @repeat = repeat
245
+ @shuffled = shuffled
246
+ @speed = speed
247
+ @subtitle_enabled = subtitle_enabled
248
+ @subtitles = subtitles
249
+ @time = time
250
+ @total_time = total_time
251
+ @type = type
252
+ @video_streams = video_streams
234
253
  end
235
254
  end
236
255
 
237
256
  # return value for Player.GetViewMode
238
257
  class PlayerViewMode
239
258
  include Comparable
259
+ extend Creatable
240
260
 
241
261
  attr_reader :nonlinear_stretch, :pixel_ratio, :vertical_shift, :view_mode, :zoom
242
262
 
243
- def initialize(hash)
244
- @nonlinear_stretch = hash['nonlinearstretch']
245
- @pixel_ratio = hash['pixelratio']
246
- @vertical_shift = hash['verticalshift']
247
- @view_mode = hash['viewed']
248
- @zoom = hash['zoom']
249
- end
250
-
251
- def ==(other)
252
- compare(self, other)
263
+ def initialize(nonlinear_stretch, pixel_ratio, vertical_shift, view_mode, zoom)
264
+ @nonlinear_stretch = nonlinear_stretch
265
+ @pixel_ratio = pixel_ratio
266
+ @vertical_shift = vertical_shift
267
+ @view_mode = view_mode
268
+ @zoom = zoom
253
269
  end
254
270
  end
255
271
 
256
272
  # Player.Position.Time https://kodi.wiki/view/JSON-RPC_API/v12#Player.Position.Time
257
273
  class PlayerPositionTime
258
274
  include Comparable
275
+ extend Creatable
259
276
 
260
277
  attr_reader :hours, :minutes, :seconds, :milliseconds
261
278
 
262
- def initialize(hash)
263
- @hours = hash['hours']
264
- @minutes = hash['minutes']
265
- @seconds = hash['seconds']
266
- @milliseconds = hash['milliseconds']
267
- end
268
-
269
- def ==(other)
270
- compare(self, other)
279
+ def initialize(hours, minutes, seconds, milliseconds)
280
+ @hours = hours
281
+ @minutes = minutes
282
+ @seconds = seconds
283
+ @milliseconds = milliseconds
271
284
  end
272
285
  end
273
286
 
@@ -282,17 +295,23 @@ module KodiClient
282
295
  end
283
296
 
284
297
  # return value of Player.Seek
285
- class SeekReturnValue
298
+ class SeekReturned
286
299
  include Comparable
300
+ extend Creatable
301
+
302
+ def self.create(hash)
303
+ return nil if hash.nil?
304
+
305
+ time = Types::Global::GlobalTime.create(hash['time'])
306
+ total_time = Types::Global::GlobalTime.create(hash['totaltime'])
287
307
 
288
- def initialize(hash)
289
- @percentage = hash['percentage']
290
- @time = Types::Global::GlobalTime.new(hash['time'])
291
- @total_time = Types::Global::GlobalTime.new(hash['totaltime'])
308
+ new(hash['percentage'], time, total_time)
292
309
  end
293
310
 
294
- def ==(other)
295
- compare(self, other)
311
+ def initialize(percentage, time, total_time)
312
+ @percentage = percentage
313
+ @time = time
314
+ @total_time = total_time
296
315
  end
297
316
  end
298
317
  end
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'kodi_client/util/comparable'
4
+ require 'kodi_client/util/iterable'
5
+ require 'kodi_client/global_types/item_types'
6
+
7
+ module KodiClient
8
+ module Types
9
+ module Profiles
10
+
11
+ # Profiles.Fields.Profile https://kodi.wiki/view/JSON-RPC_API/v12#Profiles.Fields.Profile
12
+ module FieldsProfile
13
+ extend Iterable
14
+
15
+ LOCK_MODE = 'lockmode'
16
+ THUMBNAIL = 'thumbnail'
17
+ end
18
+
19
+ # Profiles.Details.Profile https://kodi.wiki/view/JSON-RPC_API/v12#Profiles.Details.Profile
20
+ class DetailsProfile
21
+ include Comparable
22
+ include Items::ItemDetailsBase
23
+ extend Creatable
24
+
25
+ attr_reader :lock_mode, :thumbnail
26
+
27
+ def self.create(hash)
28
+ return nil if hash.nil?
29
+
30
+ new(*Creatable.hash_to_arr(hash, %w[lock_mode thumbnail label]))
31
+ end
32
+
33
+ def initialize(lock_mode, thumbnail, label)
34
+ @lock_mode = lock_mode
35
+ @thumbnail = thumbnail
36
+ item_details_base(label)
37
+ end
38
+
39
+ def ==(other)
40
+ compare(self, other)
41
+ end
42
+ end
43
+
44
+ # return type for Profiles.GetProfiles
45
+ class GetProfilesReturned
46
+ include Comparable
47
+ extend Creatable
48
+
49
+ attr_reader :limits, :profiles
50
+
51
+ def self.create(hash)
52
+ return nil if hash.nil?
53
+
54
+ limits = Types::List::ListLimitsReturned.create(hash['limits'])
55
+ profiles = Types::Profiles::DetailsProfile.create_list(hash['profiles'])
56
+
57
+ new(limits, profiles)
58
+ end
59
+
60
+ def initialize(limits, profiles)
61
+ @limits = limits
62
+ @profiles = profiles
63
+ end
64
+ end
65
+
66
+ # Profiles.Password https://kodi.wiki/view/JSON-RPC_API/v12#Profiles.Password
67
+ class ProfilePassword
68
+ include Comparable
69
+ extend Creatable
70
+
71
+ attr_reader :value, :encryption
72
+
73
+ def initialize(value, encryption = Types::Global::PasswordEncryption::MD5)
74
+ @value = value
75
+ @encryption = encryption
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -8,6 +8,8 @@ module KodiClient
8
8
 
9
9
  # PVR.Channel.Type https://kodi.wiki/view/JSON-RPC_API/v12#PVR.Channel.Type
10
10
  module ChannelType
11
+ extend Iterable
12
+
11
13
  TV = 'TV'
12
14
  RADIO = 'Radio'
13
15
  end
@@ -20,18 +20,15 @@ module KodiClient
20
20
  # System.Property.Value https://kodi.wiki/view/JSON-RPC_API/v12#System.Property.Value
21
21
  class PropertyValue
22
22
  include Comparable
23
+ extend Creatable
23
24
 
24
25
  attr_reader :can_hibernate, :can_reboot, :can_shutdown, :can_suspend
25
26
 
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)
27
+ def initialize(can_hibernate, can_reboot, can_shutdown, can_suspend)
28
+ @can_hibernate = can_hibernate
29
+ @can_reboot = can_reboot
30
+ @can_shutdown = can_shutdown
31
+ @can_suspend = can_suspend
35
32
  end
36
33
  end
37
34
  end
@@ -3,6 +3,7 @@
3
3
  require 'kodi_client/global_types/media_types'
4
4
  require 'kodi_client/global_types/player_type'
5
5
  require 'kodi_client/util/comparable'
6
+ require 'kodi_client/util/creatable'
6
7
 
7
8
  module KodiClient
8
9
  module Types
@@ -14,28 +15,30 @@ module KodiClient
14
15
 
15
16
  attr_reader :art, :play_count
16
17
 
17
- def video_details_base(hash)
18
- @art = Types::Media::MediaArtwork.new(hash['art'])
19
- @play_count = ['playcount']
20
- media_details_base(hash)
18
+ def video_details_base_by_hash(hash)
19
+ @art = Types::Media::MediaArtwork.create(hash['art'])
20
+ video_details_base(art, ['playcount'], *Creatable.hash_to_arr(hash, %w[fan_art thumbnail label]))
21
+ end
22
+
23
+ def video_details_base(art, play_count, fan_art, thumbnail, label)
24
+ @art = art
25
+ @play_count = play_count
26
+ media_details_base(fan_art, thumbnail, label)
21
27
  end
22
28
  end
23
29
 
24
30
  # Video.Cast https://kodi.wiki/view/JSON-RPC_API/v12#Video.Cast
25
31
  class VideoCast
26
32
  include Comparable
33
+ extend Creatable
27
34
 
28
35
  attr_reader :name, :order, :role, :thumbnail
29
36
 
30
- def initialize(hash)
31
- @name = hash['name']
32
- @order = hash['order']
33
- @role = hash['role']
34
- @thumbnail = hash['thumbnail']
35
- end
36
-
37
- def ==(other)
38
- compare(self, other)
37
+ def initialize(name, order, role, thumbnail)
38
+ @name = name
39
+ @order = order
40
+ @role = role
41
+ @thumbnail = thumbnail
39
42
  end
40
43
  end
41
44
 
@@ -45,9 +48,14 @@ module KodiClient
45
48
 
46
49
  attr_reader :title
47
50
 
48
- def video_details_media(hash)
49
- @title = hash['title']
50
- video_details_base(hash)
51
+ def video_details_media_by_hash(hash)
52
+ art = Types::Media::MediaArtwork.create(hash['art'])
53
+ video_details_media(hash['title'], art, *Creatable.hash_to_arr(hash, %w[play_count fan_art thumbnail label]))
54
+ end
55
+
56
+ def video_details_media(title, art, play_count, fan_art, thumbnail, label)
57
+ @title = title
58
+ video_details_base(art, play_count, fan_art, thumbnail, label)
51
59
  end
52
60
  end
53
61
 
@@ -57,12 +65,18 @@ module KodiClient
57
65
 
58
66
  attr_reader :date_added, :file, :last_played, :plot
59
67
 
60
- def video_details_item(hash)
61
- @date_added = hash['dateadded']
62
- @file = hash['file']
63
- @last_played = hash['lastplayed']
64
- @plot = hash['plot']
65
- video_details_media(hash)
68
+ def video_details_item_by_hash(hash)
69
+ art = Types::Media::MediaArtwork.create(hash['art'])
70
+ video_details_item(*Creatable.hash_to_arr(hash, %w[date_added file last_played plot title]), art,
71
+ *Creatable.hash_to_arr(hash, %w[play_count fan_art thumbnail label]))
72
+ end
73
+
74
+ def video_details_item(date_added, file, last_played, plot, title, art, play_count, fan_art, thumbnail, label)
75
+ @date_added = date_added
76
+ @file = file
77
+ @last_played = last_played
78
+ @plot = plot
79
+ video_details_media(title, art, play_count, fan_art, thumbnail, label)
66
80
  end
67
81
  end
68
82
 
@@ -72,45 +86,58 @@ module KodiClient
72
86
 
73
87
  attr_reader :director, :resume, :runtime, :stream_details
74
88
 
75
- def video_details_file(hash)
76
- @director = hash['director']
77
- @resume = VideoResume.new(hash['resume'])
78
- @runtime = hash['runtime']
79
- @stream_details = Streams.new(hash['streamdetails'])
80
- video_details_item(hash)
89
+ def video_details_file_by_hash(hash)
90
+ resume = VideoResume.create(hash['resume'])
91
+ stream_details = Streams.create(hash['streamdetails'])
92
+ art = Types::Media::MediaArtwork.create(hash['art'])
93
+ video_details_file(hash['director'], resume, hash['runtime'], stream_details,
94
+ *Creatable.hash_to_arr(hash, %w[date_added file last_played plot title]), art,
95
+ *Creatable.hash_to_arr(hash, %w[play_count fan_art thumbnail label]))
96
+ end
97
+
98
+ def video_details_file(director, resume, runtime, stream_details, date_added, file, last_played, plot, title,
99
+ art, play_count, fan_art, thumbnail, label)
100
+ @director = director
101
+ @resume = resume
102
+ @runtime = runtime
103
+ @stream_details = stream_details
104
+ video_details_item(date_added, file, last_played, plot, title, art, play_count, fan_art, thumbnail, label)
81
105
  end
82
106
  end
83
107
 
84
108
  # Video.Resume https://kodi.wiki/view/JSON-RPC_API/v12#Video.Resume
85
109
  class VideoResume
86
110
  include Comparable
111
+ extend Creatable
87
112
 
88
113
  attr_reader :position, :total
89
114
 
90
- def initialize(hash)
91
- @position = hash['position']
92
- @total = hash['total']
93
- end
94
-
95
- def ==(other)
96
- compare(self, other)
115
+ def initialize(position, total)
116
+ @position = position
117
+ @total = total
97
118
  end
98
119
  end
99
120
 
100
121
  # Video.Streams https://kodi.wiki/view/JSON-RPC_API/v12#Video.Streams
101
122
  class Streams
102
123
  include Comparable
124
+ extend Creatable
103
125
 
104
126
  attr_reader :audio, :subtitle, :video
105
127
 
106
- def initialize(hash)
107
- @audio = hash['audio'].nil? ? [] : hash['audio'].map { |it| Types::Player::AudioStream.new(it) }
108
- @subtitle = hash['subtitle'].nil? ? [] : hash['subtitle'].map { |it| Types::Player::Subtitle.new(it) }
109
- @video = hash['video'].nil? ? [] : hash['video'].map { |it| Types::Player::VideoStream.new(it) }
128
+ def self.create(hash)
129
+ return nil if hash.nil?
130
+
131
+ audio = Types::Player::AudioStream.create_list(hash['audio'])
132
+ subtitle = Types::Player::Subtitle.create_list(hash['subtitle'])
133
+ video = Types::Player::VideoStream.create_list(hash['video'])
134
+ new(audio, subtitle, video)
110
135
  end
111
136
 
112
- def ==(other)
113
- compare(self, other)
137
+ def initialize(audio, subtitle, video)
138
+ @audio = audio
139
+ @subtitle = subtitle
140
+ @video = video
114
141
  end
115
142
  end
116
143
  end