kodi_client 0.5.6 → 0.6.2
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.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/kodi_client.gemspec +3 -3
- data/lib/kodi_client/Chainable.rb +4 -1
- data/lib/kodi_client/global_types/addon_types.rb +50 -52
- data/lib/kodi_client/global_types/application_types.rb +21 -23
- data/lib/kodi_client/global_types/audio_types.rb +179 -29
- data/lib/kodi_client/global_types/favourites_types.rb +14 -17
- data/lib/kodi_client/global_types/files_types.rb +68 -0
- data/lib/kodi_client/global_types/global_types.rb +18 -24
- data/lib/kodi_client/global_types/gui_types.rb +15 -16
- data/lib/kodi_client/global_types/item_types.rb +10 -2
- data/lib/kodi_client/global_types/list_types.rb +326 -98
- data/lib/kodi_client/global_types/media_types.rb +21 -13
- data/lib/kodi_client/global_types/player_type.rb +110 -110
- data/lib/kodi_client/global_types/profiles_types.rb +14 -14
- data/lib/kodi_client/global_types/system_types.rb +7 -9
- data/lib/kodi_client/global_types/video_types.rb +80 -43
- data/lib/kodi_client/method/addons.rb +7 -19
- data/lib/kodi_client/method/application.rb +1 -1
- data/lib/kodi_client/method/audio_library.rb +49 -0
- data/lib/kodi_client/method/favourites.rb +1 -1
- data/lib/kodi_client/method/files.rb +89 -0
- 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 +106 -0
- data/lib/kodi_client.rb +10 -10
- metadata +9 -5
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
require 'kodi_client/global_types/item_types'
|
4
4
|
require 'kodi_client/util/comparable'
|
5
|
+
require 'kodi_client/util/creatable'
|
6
|
+
require 'kodi_client/util/iterable'
|
5
7
|
|
6
8
|
module KodiClient
|
7
9
|
module Types
|
@@ -10,6 +12,7 @@ module KodiClient
|
|
10
12
|
# media types
|
11
13
|
module MediaType
|
12
14
|
extend Iterable
|
15
|
+
|
13
16
|
VIDEO = 'video'
|
14
17
|
AUDIO = 'audio'
|
15
18
|
ALL = 'all'
|
@@ -21,28 +24,33 @@ module KodiClient
|
|
21
24
|
|
22
25
|
attr_reader :fan_art, :thumbnail
|
23
26
|
|
24
|
-
def
|
25
|
-
|
26
|
-
|
27
|
-
|
27
|
+
def media_details_base_mappings
|
28
|
+
item_details_base_mappings
|
29
|
+
end
|
30
|
+
|
31
|
+
def media_details_base_by_hash(hash)
|
32
|
+
media_details_base(*Creatable.hash_to_arr(hash, %w[fan_art thumbnail label]), media_details_base_mappings)
|
33
|
+
end
|
34
|
+
|
35
|
+
def media_details_base(fan_art, thumbnail, label)
|
36
|
+
@fan_art = fan_art
|
37
|
+
@thumbnail = thumbnail
|
38
|
+
item_details_base(label)
|
28
39
|
end
|
29
40
|
end
|
30
41
|
|
31
42
|
# Media.Artwork https://kodi.wiki/view/JSON-RPC_API/v12#Media.Artwork
|
32
43
|
class MediaArtwork
|
33
44
|
include Comparable
|
45
|
+
extend Creatable
|
34
46
|
|
35
47
|
attr_reader :banner, :fan_art, :poster, :thumb
|
36
48
|
|
37
|
-
def initialize(
|
38
|
-
@banner =
|
39
|
-
@fan_art =
|
40
|
-
@poster =
|
41
|
-
@thumb =
|
42
|
-
end
|
43
|
-
|
44
|
-
def ==(other)
|
45
|
-
compare(self, other)
|
49
|
+
def initialize(banner, fan_art, poster, thumb)
|
50
|
+
@banner = banner
|
51
|
+
@fan_art = fan_art
|
52
|
+
@poster = poster
|
53
|
+
@thumb = thumb
|
46
54
|
end
|
47
55
|
end
|
48
56
|
end
|
@@ -4,6 +4,7 @@ require 'kodi_client/global_types/item_types'
|
|
4
4
|
require 'kodi_client/global_types/global_types'
|
5
5
|
require 'kodi_client/util/comparable'
|
6
6
|
require 'kodi_client/util/iterable'
|
7
|
+
require 'kodi_client/util/creatable'
|
7
8
|
|
8
9
|
module KodiClient
|
9
10
|
module Types
|
@@ -20,6 +21,7 @@ module KodiClient
|
|
20
21
|
# Player.ViewMode https://kodi.wiki/view/JSON-RPC_API/v12#Player.ViewMode
|
21
22
|
module ViewMode
|
22
23
|
extend Iterable
|
24
|
+
|
23
25
|
NORMAL = 'normal'
|
24
26
|
ZOOM = 'zoom'
|
25
27
|
STRETCH_4x3 = 'strech4x3'
|
@@ -34,6 +36,7 @@ module KodiClient
|
|
34
36
|
# player types
|
35
37
|
module PlayerVisibilityType
|
36
38
|
extend Iterable
|
39
|
+
|
37
40
|
INTERNAL = 'internal'
|
38
41
|
EXTERNAL = 'external'
|
39
42
|
REMOTE = 'remote'
|
@@ -80,87 +83,75 @@ module KodiClient
|
|
80
83
|
# player id and type
|
81
84
|
class Player
|
82
85
|
include Comparable
|
86
|
+
extend Creatable
|
83
87
|
|
84
88
|
attr_reader :player_id, :player_type, :type, :name, :plays_audio, :plays_video
|
85
89
|
|
86
|
-
def initialize(
|
87
|
-
@player_id =
|
88
|
-
@player_type =
|
89
|
-
@type =
|
90
|
-
@name =
|
91
|
-
@plays_audio =
|
92
|
-
@plays_video =
|
93
|
-
end
|
94
|
-
|
95
|
-
def ==(other)
|
96
|
-
compare(self, other)
|
90
|
+
def initialize(player_id, player_type, type, name, plays_audio, plays_video)
|
91
|
+
@player_id = player_id
|
92
|
+
@player_type = player_type
|
93
|
+
@type = type
|
94
|
+
@name = name
|
95
|
+
@plays_audio = plays_audio
|
96
|
+
@plays_video = plays_video
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
100
|
# Player Subtitle https://kodi.wiki/view/JSON-RPC_API/v12#Player.Subtitle
|
101
101
|
class Subtitle
|
102
102
|
include Comparable
|
103
|
+
extend Creatable
|
103
104
|
|
104
105
|
attr_reader :index, :is_default, :is_forced, :is_impaired, :language, :name
|
105
106
|
|
106
|
-
def initialize(
|
107
|
-
@index =
|
108
|
-
@is_default =
|
109
|
-
@is_forced =
|
110
|
-
@is_impaired =
|
111
|
-
@language =
|
112
|
-
@name =
|
113
|
-
end
|
114
|
-
|
115
|
-
def ==(other)
|
116
|
-
compare(self, other)
|
107
|
+
def initialize(index, is_default, is_forced, is_impaired, language, name)
|
108
|
+
@index = index
|
109
|
+
@is_default = is_default
|
110
|
+
@is_forced = is_forced
|
111
|
+
@is_impaired = is_impaired
|
112
|
+
@language = language
|
113
|
+
@name = name
|
117
114
|
end
|
118
115
|
end
|
119
116
|
|
120
117
|
# Player.Audio.Stream https://kodi.wiki/view/JSON-RPC_API/v12#Player.Audio.Stream
|
121
118
|
class AudioStream
|
122
119
|
include Comparable
|
120
|
+
extend Creatable
|
123
121
|
|
124
122
|
attr_reader :bitrate, :channels, :codec, :index, :is_default, :is_forced, :is_original, :language,
|
125
123
|
:name, :sample_rate
|
126
124
|
|
127
|
-
def initialize(
|
128
|
-
@bitrate =
|
129
|
-
@channels =
|
130
|
-
@codec =
|
131
|
-
@index =
|
132
|
-
@is_default =
|
133
|
-
@is_forced =
|
134
|
-
@is_original =
|
135
|
-
@language =
|
136
|
-
@name =
|
137
|
-
@sample_rate =
|
138
|
-
end
|
139
|
-
|
140
|
-
def ==(other)
|
141
|
-
compare(self, other)
|
125
|
+
def initialize(bitrate, channels, codec, index, is_default, is_forced, is_original, language, name, sample_rate)
|
126
|
+
@bitrate = bitrate
|
127
|
+
@channels = channels
|
128
|
+
@codec = codec
|
129
|
+
@index = index
|
130
|
+
@is_default = is_default
|
131
|
+
@is_forced = is_forced
|
132
|
+
@is_original = is_original
|
133
|
+
@language = language
|
134
|
+
@name = name
|
135
|
+
@sample_rate = sample_rate
|
142
136
|
end
|
143
137
|
end
|
144
138
|
|
145
139
|
# Player.Video.Stream https://kodi.wiki/view/JSON-RPC_API/v12#Player.Video.Stream
|
146
140
|
class VideoStream
|
147
141
|
include Comparable
|
142
|
+
extend Creatable
|
148
143
|
|
149
144
|
attr_reader :codec, :height, :index, :language, :name, :width, :duration, :aspect
|
150
145
|
|
151
|
-
def initialize(
|
152
|
-
@codec =
|
153
|
-
@height =
|
154
|
-
@index =
|
155
|
-
@language =
|
156
|
-
@name =
|
157
|
-
@width =
|
158
|
-
@duration =
|
159
|
-
@aspect =
|
160
|
-
end
|
161
|
-
|
162
|
-
def ==(other)
|
163
|
-
compare(self, other)
|
146
|
+
def initialize(codec, height, index, language, name, width, duration, aspect)
|
147
|
+
@codec = codec
|
148
|
+
@height = height
|
149
|
+
@index = index
|
150
|
+
@language = language
|
151
|
+
@name = name
|
152
|
+
@width = width
|
153
|
+
@duration = duration
|
154
|
+
@aspect = aspect
|
164
155
|
end
|
165
156
|
end
|
166
157
|
|
@@ -198,76 +189,84 @@ module KodiClient
|
|
198
189
|
# Player.Property.Value https://kodi.wiki/view/JSON-RPC_API/v12#Player.Property.Name
|
199
190
|
class PropertyValue
|
200
191
|
include Comparable
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
@
|
223
|
-
@
|
224
|
-
@
|
225
|
-
@
|
226
|
-
@
|
227
|
-
@
|
228
|
-
@
|
229
|
-
@
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
192
|
+
extend Creatable
|
193
|
+
|
194
|
+
attr_reader :audio_streams, :cache_percentage, :can_change_speed, :can_move, :can_repeat, :can_rotate,
|
195
|
+
:can_seek, :can_shuffle, :can_zoom, :current_audio_stream, :current_subtitle, :current_video_stream,
|
196
|
+
:live, :party_mode, :percentage, :playlist_id, :position, :repeat, :shuffled, :speed,
|
197
|
+
:subtitle_enabled, :subtitles, :time, :total_time, :type, :video_streams
|
198
|
+
|
199
|
+
type_mapping ['audiostreams', AudioStream, true], ['currentaudiostream', AudioStream],
|
200
|
+
['currentsubtitle', Subtitle], ['currentvideostream', VideoStream],
|
201
|
+
['subtitles', Subtitle, true], ['time', Global::GlobalTime],
|
202
|
+
['totaltime', Global::GlobalTime], ['videostreams', VideoStream, true]
|
203
|
+
|
204
|
+
def initialize(audio_streams, cache_percentage, can_change_speed, can_move, can_repeat, can_rotate, can_seek,
|
205
|
+
can_shuffle, can_zoom, current_audio_stream, current_subtitle, current_video_stream, live,
|
206
|
+
party_mode, percentage, playlist_id, position, repeat, shuffled, speed,
|
207
|
+
subtitle_enabled, subtitles, time, total_time, type, video_streams)
|
208
|
+
type = type.nil? ? PlayerType::VIDEO : type
|
209
|
+
playlist_id = playlist_id.nil? ? -1 : playlist_id
|
210
|
+
position = position.nil? ? -1 : position
|
211
|
+
repeat = repeat.nil? ? PlayerRepeat::OFF : repeat
|
212
|
+
|
213
|
+
@audio_streams = audio_streams
|
214
|
+
@cache_percentage = cache_percentage
|
215
|
+
@can_change_speed = can_change_speed
|
216
|
+
@can_move = can_move
|
217
|
+
@can_repeat = can_repeat
|
218
|
+
@can_rotate = can_rotate
|
219
|
+
@can_seek = can_seek
|
220
|
+
@can_shuffle = can_shuffle
|
221
|
+
@can_zoom = can_zoom
|
222
|
+
@current_audio_stream = current_audio_stream
|
223
|
+
@current_subtitle = current_subtitle
|
224
|
+
@current_video_stream = current_video_stream
|
225
|
+
@live = live
|
226
|
+
@party_mode = party_mode
|
227
|
+
@percentage = percentage
|
228
|
+
@playlist_id = playlist_id
|
229
|
+
@position = position
|
230
|
+
@repeat = repeat
|
231
|
+
@shuffled = shuffled
|
232
|
+
@speed = speed
|
233
|
+
@subtitle_enabled = subtitle_enabled
|
234
|
+
@subtitles = subtitles
|
235
|
+
@time = time
|
236
|
+
@total_time = total_time
|
237
|
+
@type = type
|
238
|
+
@video_streams = video_streams
|
234
239
|
end
|
235
240
|
end
|
236
241
|
|
237
242
|
# return value for Player.GetViewMode
|
238
243
|
class PlayerViewMode
|
239
244
|
include Comparable
|
245
|
+
extend Creatable
|
240
246
|
|
241
247
|
attr_reader :nonlinear_stretch, :pixel_ratio, :vertical_shift, :view_mode, :zoom
|
242
248
|
|
243
|
-
def initialize(
|
244
|
-
@nonlinear_stretch =
|
245
|
-
@pixel_ratio =
|
246
|
-
@vertical_shift =
|
247
|
-
@view_mode =
|
248
|
-
@zoom =
|
249
|
-
end
|
250
|
-
|
251
|
-
def ==(other)
|
252
|
-
compare(self, other)
|
249
|
+
def initialize(nonlinear_stretch, pixel_ratio, vertical_shift, view_mode, zoom)
|
250
|
+
@nonlinear_stretch = nonlinear_stretch
|
251
|
+
@pixel_ratio = pixel_ratio
|
252
|
+
@vertical_shift = vertical_shift
|
253
|
+
@view_mode = view_mode
|
254
|
+
@zoom = zoom
|
253
255
|
end
|
254
256
|
end
|
255
257
|
|
256
258
|
# Player.Position.Time https://kodi.wiki/view/JSON-RPC_API/v12#Player.Position.Time
|
257
259
|
class PlayerPositionTime
|
258
260
|
include Comparable
|
261
|
+
extend Creatable
|
259
262
|
|
260
263
|
attr_reader :hours, :minutes, :seconds, :milliseconds
|
261
264
|
|
262
|
-
def initialize(
|
263
|
-
@hours =
|
264
|
-
@minutes =
|
265
|
-
@seconds =
|
266
|
-
@milliseconds =
|
267
|
-
end
|
268
|
-
|
269
|
-
def ==(other)
|
270
|
-
compare(self, other)
|
265
|
+
def initialize(hours, minutes, seconds, milliseconds)
|
266
|
+
@hours = hours
|
267
|
+
@minutes = minutes
|
268
|
+
@seconds = seconds
|
269
|
+
@milliseconds = milliseconds
|
271
270
|
end
|
272
271
|
end
|
273
272
|
|
@@ -282,17 +281,18 @@ module KodiClient
|
|
282
281
|
end
|
283
282
|
|
284
283
|
# return value of Player.Seek
|
285
|
-
class
|
284
|
+
class SeekReturned
|
286
285
|
include Comparable
|
286
|
+
extend Creatable
|
287
287
|
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
@total_time = Types::Global::GlobalTime.new(hash['totaltime'])
|
292
|
-
end
|
288
|
+
attr_reader :percentage, :time, :total_time
|
289
|
+
|
290
|
+
type_mapping ['time', Global::GlobalTime], ['totaltime', Global::GlobalTime]
|
293
291
|
|
294
|
-
def
|
295
|
-
|
292
|
+
def initialize(percentage, time, total_time)
|
293
|
+
@percentage = percentage
|
294
|
+
@time = time
|
295
|
+
@total_time = total_time
|
296
296
|
end
|
297
297
|
end
|
298
298
|
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/item_types'
|
6
7
|
|
7
8
|
module KodiClient
|
@@ -20,13 +21,16 @@ module KodiClient
|
|
20
21
|
class DetailsProfile
|
21
22
|
include Comparable
|
22
23
|
include Items::ItemDetailsBase
|
24
|
+
extend Creatable
|
23
25
|
|
24
26
|
attr_reader :lock_mode, :thumbnail
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
fields_to_map %w[lock_mode thumbnail label]
|
29
|
+
|
30
|
+
def initialize(lock_mode, thumbnail, label)
|
31
|
+
@lock_mode = lock_mode
|
32
|
+
@thumbnail = thumbnail
|
33
|
+
item_details_base(label)
|
30
34
|
end
|
31
35
|
|
32
36
|
def ==(other)
|
@@ -37,22 +41,22 @@ module KodiClient
|
|
37
41
|
# return type for Profiles.GetProfiles
|
38
42
|
class GetProfilesReturned
|
39
43
|
include Comparable
|
44
|
+
extend Creatable
|
40
45
|
|
41
46
|
attr_reader :limits, :profiles
|
42
47
|
|
43
|
-
|
44
|
-
@limits = Types::List::ListLimitsReturned.new(hash['limits'])
|
45
|
-
@profiles = hash['profiles'].nil? ? [] : hash['profiles'].map { |it| Types::Profiles::DetailsProfile.new(it) }
|
46
|
-
end
|
48
|
+
type_mapping ['limits', List::ListLimitsReturned], ['profiles', DetailsProfile, true]
|
47
49
|
|
48
|
-
def
|
49
|
-
|
50
|
+
def initialize(limits, profiles)
|
51
|
+
@limits = limits
|
52
|
+
@profiles = profiles
|
50
53
|
end
|
51
54
|
end
|
52
55
|
|
53
56
|
# Profiles.Password https://kodi.wiki/view/JSON-RPC_API/v12#Profiles.Password
|
54
57
|
class ProfilePassword
|
55
58
|
include Comparable
|
59
|
+
extend Creatable
|
56
60
|
|
57
61
|
attr_reader :value, :encryption
|
58
62
|
|
@@ -60,10 +64,6 @@ module KodiClient
|
|
60
64
|
@value = value
|
61
65
|
@encryption = encryption
|
62
66
|
end
|
63
|
-
|
64
|
-
def ==(other)
|
65
|
-
compare(self, other)
|
66
|
-
end
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'kodi_client/util/iterable'
|
4
4
|
require 'kodi_client/util/comparable'
|
5
|
+
require 'kodi_client/util/creatable'
|
5
6
|
|
6
7
|
module KodiClient
|
7
8
|
module Types
|
@@ -20,18 +21,15 @@ module KodiClient
|
|
20
21
|
# System.Property.Value https://kodi.wiki/view/JSON-RPC_API/v12#System.Property.Value
|
21
22
|
class PropertyValue
|
22
23
|
include Comparable
|
24
|
+
extend Creatable
|
23
25
|
|
24
26
|
attr_reader :can_hibernate, :can_reboot, :can_shutdown, :can_suspend
|
25
27
|
|
26
|
-
def initialize(
|
27
|
-
@can_hibernate =
|
28
|
-
@can_reboot =
|
29
|
-
@can_shutdown =
|
30
|
-
@can_suspend =
|
31
|
-
end
|
32
|
-
|
33
|
-
def ==(other)
|
34
|
-
compare(self, other)
|
28
|
+
def initialize(can_hibernate, can_reboot, can_shutdown, can_suspend)
|
29
|
+
@can_hibernate = can_hibernate
|
30
|
+
@can_reboot = can_reboot
|
31
|
+
@can_shutdown = can_shutdown
|
32
|
+
@can_suspend = can_suspend
|
35
33
|
end
|
36
34
|
end
|
37
35
|
end
|
@@ -3,39 +3,45 @@
|
|
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
|
9
10
|
module Video
|
10
|
-
|
11
11
|
# Video.Details.Base https://kodi.wiki/view/JSON-RPC_API/v12#Video.Details.Base
|
12
12
|
module VideoDetailsBase
|
13
13
|
include Media::MediaDetailsBase
|
14
14
|
|
15
15
|
attr_reader :art, :play_count
|
16
16
|
|
17
|
-
def
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
def video_details_base_mappings
|
18
|
+
media_details_base_mappings
|
19
|
+
end
|
20
|
+
|
21
|
+
def video_details_base_by_hash(hash)
|
22
|
+
video_details_base(*Creatable.hash_to_arr(hash, %w[art play_count fan_art thumbnail label],
|
23
|
+
video_details_base_mappings))
|
24
|
+
end
|
25
|
+
|
26
|
+
def video_details_base(art, play_count, fan_art, thumbnail, label)
|
27
|
+
@art = art
|
28
|
+
@play_count = play_count
|
29
|
+
media_details_base(fan_art, thumbnail, label)
|
21
30
|
end
|
22
31
|
end
|
23
32
|
|
24
33
|
# Video.Cast https://kodi.wiki/view/JSON-RPC_API/v12#Video.Cast
|
25
34
|
class VideoCast
|
26
35
|
include Comparable
|
36
|
+
extend Creatable
|
27
37
|
|
28
38
|
attr_reader :name, :order, :role, :thumbnail
|
29
39
|
|
30
|
-
def initialize(
|
31
|
-
@name =
|
32
|
-
@order =
|
33
|
-
@role =
|
34
|
-
@thumbnail =
|
35
|
-
end
|
36
|
-
|
37
|
-
def ==(other)
|
38
|
-
compare(self, other)
|
40
|
+
def initialize(name, order, role, thumbnail)
|
41
|
+
@name = name
|
42
|
+
@order = order
|
43
|
+
@role = role
|
44
|
+
@thumbnail = thumbnail
|
39
45
|
end
|
40
46
|
end
|
41
47
|
|
@@ -45,9 +51,18 @@ module KodiClient
|
|
45
51
|
|
46
52
|
attr_reader :title
|
47
53
|
|
48
|
-
def
|
49
|
-
|
50
|
-
|
54
|
+
def video_details_media_mappings
|
55
|
+
video_details_base_mappings
|
56
|
+
end
|
57
|
+
|
58
|
+
def video_details_media_by_hash(hash)
|
59
|
+
video_details_media(*Creatable.hash_to_arr(hash, %w[title art play_count fan_art thumbnail label]),
|
60
|
+
video_details_base_mappings)
|
61
|
+
end
|
62
|
+
|
63
|
+
def video_details_media(title, art, play_count, fan_art, thumbnail, label)
|
64
|
+
@title = title
|
65
|
+
video_details_base(art, play_count, fan_art, thumbnail, label)
|
51
66
|
end
|
52
67
|
end
|
53
68
|
|
@@ -57,12 +72,22 @@ module KodiClient
|
|
57
72
|
|
58
73
|
attr_reader :date_added, :file, :last_played, :plot
|
59
74
|
|
60
|
-
def
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
75
|
+
def video_details_item_mappings
|
76
|
+
video_details_media_mappings
|
77
|
+
end
|
78
|
+
|
79
|
+
def video_details_item_by_hash(hash)
|
80
|
+
video_details_item(*Creatable.hash_to_arr(hash, %w[date_added file last_played plot title art
|
81
|
+
play_count fan_art thumbnail label],
|
82
|
+
video_details_item_mappings))
|
83
|
+
end
|
84
|
+
|
85
|
+
def video_details_item(date_added, file, last_played, plot, title, art, play_count, fan_art, thumbnail, label)
|
86
|
+
@date_added = date_added
|
87
|
+
@file = file
|
88
|
+
@last_played = last_played
|
89
|
+
@plot = plot
|
90
|
+
video_details_media(title, art, play_count, fan_art, thumbnail, label)
|
66
91
|
end
|
67
92
|
end
|
68
93
|
|
@@ -72,45 +97,57 @@ module KodiClient
|
|
72
97
|
|
73
98
|
attr_reader :director, :resume, :runtime, :stream_details
|
74
99
|
|
75
|
-
def
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
100
|
+
def video_details_file_mappings
|
101
|
+
mappings = {
|
102
|
+
'resume' => Creatable::CreateMap.new(VideoResume),
|
103
|
+
'streamdetails' => Creatable::CreateMap.new(Streams)
|
104
|
+
}
|
105
|
+
mappings.merge(video_details_item_mappings)
|
106
|
+
end
|
107
|
+
|
108
|
+
def video_details_file_by_hash(hash)
|
109
|
+
video_details_file(*Creatable.hash_to_arr(hash, %w[director resume runtime stream_details date_added
|
110
|
+
file last_played plot title art play_count fan_art
|
111
|
+
thumbnail label], video_details_file_mappings))
|
112
|
+
end
|
113
|
+
|
114
|
+
def video_details_file(director, resume, runtime, stream_details, date_added, file, last_played, plot, title,
|
115
|
+
art, play_count, fan_art, thumbnail, label)
|
116
|
+
@director = director
|
117
|
+
@resume = resume
|
118
|
+
@runtime = runtime
|
119
|
+
@stream_details = stream_details
|
120
|
+
video_details_item(date_added, file, last_played, plot, title, art, play_count, fan_art, thumbnail, label)
|
81
121
|
end
|
82
122
|
end
|
83
123
|
|
84
124
|
# Video.Resume https://kodi.wiki/view/JSON-RPC_API/v12#Video.Resume
|
85
125
|
class VideoResume
|
86
126
|
include Comparable
|
127
|
+
extend Creatable
|
87
128
|
|
88
129
|
attr_reader :position, :total
|
89
130
|
|
90
|
-
def initialize(
|
91
|
-
@position =
|
92
|
-
@total =
|
93
|
-
end
|
94
|
-
|
95
|
-
def ==(other)
|
96
|
-
compare(self, other)
|
131
|
+
def initialize(position, total)
|
132
|
+
@position = position
|
133
|
+
@total = total
|
97
134
|
end
|
98
135
|
end
|
99
136
|
|
100
137
|
# Video.Streams https://kodi.wiki/view/JSON-RPC_API/v12#Video.Streams
|
101
138
|
class Streams
|
102
139
|
include Comparable
|
140
|
+
extend Creatable
|
103
141
|
|
104
142
|
attr_reader :audio, :subtitle, :video
|
105
143
|
|
106
|
-
|
107
|
-
|
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) }
|
110
|
-
end
|
144
|
+
type_mapping ['audio', Player::AudioStream, true], ['subtitle', Player::Subtitle, true],
|
145
|
+
['video', Player::VideoStream, true]
|
111
146
|
|
112
|
-
def
|
113
|
-
|
147
|
+
def initialize(audio, subtitle, video)
|
148
|
+
@audio = audio
|
149
|
+
@subtitle = subtitle
|
150
|
+
@video = video
|
114
151
|
end
|
115
152
|
end
|
116
153
|
end
|