kodi_client 0.6.0 → 0.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/kodi_client.gemspec +1 -1
- data/lib/kodi_client/extensions/chainable.rb +71 -0
- data/lib/kodi_client/extensions/comparable.rb +29 -0
- data/lib/kodi_client/extensions/creatable.rb +137 -0
- data/lib/kodi_client/extensions/iterable.rb +14 -0
- data/lib/kodi_client/kodi_error.rb +14 -0
- data/lib/kodi_client/kodi_method.rb +34 -0
- data/lib/kodi_client/{options.rb → kodi_options.rb} +1 -1
- data/lib/kodi_client/kodi_request.rb +16 -0
- data/lib/kodi_client/kodi_response.rb +21 -0
- data/lib/kodi_client/{method → methods}/addons.rb +9 -24
- data/lib/kodi_client/{method → methods}/application.rb +2 -5
- data/lib/kodi_client/methods/audio_library.rb +46 -0
- data/lib/kodi_client/{method → methods}/favourites.rb +2 -5
- data/lib/kodi_client/{method → methods}/files.rb +2 -6
- data/lib/kodi_client/{method → methods}/gui.rb +2 -5
- data/lib/kodi_client/{method → methods}/input.rb +2 -6
- data/lib/kodi_client/{method → methods}/player.rb +2 -7
- data/lib/kodi_client/{method → methods}/profiles.rb +2 -5
- data/lib/kodi_client/{method → methods}/system.rb +2 -6
- data/lib/kodi_client/types/addons/addon_content_type.rb +18 -0
- data/lib/kodi_client/types/addons/addon_dependency_type.rb +21 -0
- data/lib/kodi_client/types/addons/addon_details_type.rb +44 -0
- data/lib/kodi_client/types/addons/addon_extra_info_type.rb +20 -0
- data/lib/kodi_client/types/addons/addon_fields_type.rb +28 -0
- data/lib/kodi_client/types/addons/addon_types_type.rb +48 -0
- data/lib/kodi_client/types/addons/get_addon_returned_type.rb +21 -0
- data/lib/kodi_client/types/addons/get_addons_returned_type.rb +22 -0
- data/lib/kodi_client/types/application/property_name_type.rb +19 -0
- data/lib/kodi_client/types/application/property_value_type.rb +24 -0
- data/lib/kodi_client/types/application/version_type.rb +22 -0
- data/lib/kodi_client/types/audio/audio_album_release_type_type.rb +15 -0
- data/lib/kodi_client/types/audio/audio_contributor_type.rb +22 -0
- data/lib/kodi_client/types/audio/audio_details_base_type.rb +31 -0
- data/lib/kodi_client/types/audio/audio_details_media_type.rb +45 -0
- data/lib/kodi_client/types/audio/audio_fields_album_type.rb +51 -0
- data/lib/kodi_client/types/audio/details_album_type.rb +58 -0
- data/lib/kodi_client/types/audio/genre_type.rb +20 -0
- data/lib/kodi_client/types/audio/get_albums_returned_type.rb +22 -0
- data/lib/kodi_client/types/favourites/details_favourite_type.rb +24 -0
- data/lib/kodi_client/types/favourites/fields_favourite_type.rb +17 -0
- data/lib/kodi_client/types/favourites/get_favourite_returned_type.rb +22 -0
- data/lib/kodi_client/types/favourites/type_type.rb +18 -0
- data/lib/kodi_client/types/files/file_label_type.rb +20 -0
- data/lib/kodi_client/types/files/get_directory_returned_type.rb +22 -0
- data/lib/kodi_client/types/files/get_sources_returned_type.rb +22 -0
- data/lib/kodi_client/types/files/media_type.rb +18 -0
- data/lib/kodi_client/types/files/prepare_download_returned_type.rb +21 -0
- data/lib/kodi_client/types/global/direction_type.rb +17 -0
- data/lib/kodi_client/types/global/global_time_type.rb +22 -0
- data/lib/kodi_client/types/global/id_label_type.rb +20 -0
- data/lib/kodi_client/types/global/id_name_type.rb +20 -0
- data/lib/kodi_client/types/global/increment_decrement_type.rb +15 -0
- data/lib/kodi_client/types/global/next_prev_type.rb +17 -0
- data/lib/kodi_client/types/global/password_encryption_type.rb +16 -0
- data/lib/kodi_client/types/global/rotate_type.rb +15 -0
- data/lib/kodi_client/types/global/toggle_type.rb +16 -0
- data/lib/kodi_client/types/gui/gui_window_type.rb +124 -0
- data/lib/kodi_client/types/gui/property_name_type.rb +18 -0
- data/lib/kodi_client/types/gui/property_value_type.rb +26 -0
- data/lib/kodi_client/types/gui/stereoscopy_mode_type.rb +31 -0
- data/lib/kodi_client/types/input/input_action_type.rb +212 -0
- data/lib/kodi_client/{global_types/item_types.rb → types/items/item_details_base_type.rb} +5 -3
- data/lib/kodi_client/types/list/list_field_files_type.rb +83 -0
- data/lib/kodi_client/types/list/list_fields_all_type.rb +96 -0
- data/lib/kodi_client/types/list/list_item_all_type.rb +73 -0
- data/lib/kodi_client/types/list/list_item_base_type.rb +138 -0
- data/lib/kodi_client/types/list/list_item_file_type.rb +68 -0
- data/lib/kodi_client/types/list/list_limits_returned_type.rb +23 -0
- data/lib/kodi_client/types/list/list_limits_type.rb +19 -0
- data/lib/kodi_client/types/list/list_sort_method_type.rb +54 -0
- data/lib/kodi_client/types/list/list_sort_type.rb +22 -0
- data/lib/kodi_client/types/list/sort_order_type.rb +15 -0
- data/lib/kodi_client/types/media/media_artwork_type.rb +22 -0
- data/lib/kodi_client/types/media/media_details_base_type.rb +28 -0
- data/lib/kodi_client/types/media/media_type_type.rb +16 -0
- data/lib/kodi_client/types/player/audio_stream_type.rb +29 -0
- data/lib/kodi_client/types/player/player_position_time_type.rb +22 -0
- data/lib/kodi_client/types/player/player_repeat_type.rb +17 -0
- data/lib/kodi_client/types/player/player_speed_type.rb +26 -0
- data/lib/kodi_client/types/player/player_type.rb +24 -0
- data/lib/kodi_client/types/player/player_type_type.rb +16 -0
- data/lib/kodi_client/types/player/player_view_mode_type.rb +23 -0
- data/lib/kodi_client/types/player/player_visibility_type.rb +16 -0
- data/lib/kodi_client/types/player/property_name_type.rb +38 -0
- data/lib/kodi_client/types/player/property_value_type.rb +60 -0
- data/lib/kodi_client/types/player/seek_jump_type.rb +17 -0
- data/lib/kodi_client/types/player/seek_returned_type.rb +23 -0
- data/lib/kodi_client/types/player/subtitle_type.rb +24 -0
- data/lib/kodi_client/types/player/video_stream_type.rb +26 -0
- data/lib/kodi_client/types/player/view_mode_type.rb +22 -0
- data/lib/kodi_client/types/player/zoom_type.rb +15 -0
- data/lib/kodi_client/types/profiles/details_profile_type.rb +24 -0
- data/lib/kodi_client/types/profiles/fields_profile_type.rb +15 -0
- data/lib/kodi_client/types/profiles/get_profiles_returned_type.rb +22 -0
- data/lib/kodi_client/types/profiles/profile_password_type.rb +20 -0
- data/lib/kodi_client/{global_types/pvr_type.rb → types/pvr/channel_type_type.rb} +2 -6
- data/lib/kodi_client/types/system/property_name_type.rb +17 -0
- data/lib/kodi_client/{global_types/system_types.rb → types/system/property_value_type.rb} +2 -16
- data/lib/kodi_client/types/video/stream_details_type.rb +24 -0
- data/lib/kodi_client/types/video/video_cast_type.rb +22 -0
- data/lib/kodi_client/types/video/video_details_base_type.rb +29 -0
- data/lib/kodi_client/types/video/video_details_file_type.rb +37 -0
- data/lib/kodi_client/types/video/video_details_item_type.rb +32 -0
- data/lib/kodi_client/types/video/video_details_media_type.rb +28 -0
- data/lib/kodi_client/types/video/video_resume_type.rb +20 -0
- data/lib/kodi_client.rb +137 -23
- metadata +107 -33
- data/lib/kodi_client/Chainable.rb +0 -49
- data/lib/kodi_client/global_types/addon_types.rb +0 -194
- data/lib/kodi_client/global_types/application_types.rb +0 -61
- data/lib/kodi_client/global_types/audio_types.rb +0 -88
- data/lib/kodi_client/global_types/favourites_types.rb +0 -70
- data/lib/kodi_client/global_types/files_types.rb +0 -82
- data/lib/kodi_client/global_types/global_types.rb +0 -106
- data/lib/kodi_client/global_types/gui_types.rb +0 -191
- data/lib/kodi_client/global_types/input_types.rb +0 -216
- data/lib/kodi_client/global_types/list_types.rb +0 -569
- data/lib/kodi_client/global_types/media_types.rb +0 -55
- data/lib/kodi_client/global_types/player_type.rb +0 -319
- data/lib/kodi_client/global_types/profiles_types.rb +0 -80
- data/lib/kodi_client/global_types/video_types.rb +0 -145
- data/lib/kodi_client/kodi_module.rb +0 -87
- data/lib/kodi_client/util/comparable.rb +0 -20
- data/lib/kodi_client/util/creatable.rb +0 -52
- data/lib/kodi_client/util/iterable.rb +0 -11
@@ -1,319 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'kodi_client/global_types/item_types'
|
4
|
-
require 'kodi_client/global_types/global_types'
|
5
|
-
require 'kodi_client/util/comparable'
|
6
|
-
require 'kodi_client/util/iterable'
|
7
|
-
|
8
|
-
module KodiClient
|
9
|
-
module Types
|
10
|
-
module Player
|
11
|
-
|
12
|
-
# enum for in/out zoom
|
13
|
-
module Zoom
|
14
|
-
extend Iterable
|
15
|
-
|
16
|
-
IN = 'in'
|
17
|
-
OUT = 'out'
|
18
|
-
end
|
19
|
-
|
20
|
-
# Player.ViewMode https://kodi.wiki/view/JSON-RPC_API/v12#Player.ViewMode
|
21
|
-
module ViewMode
|
22
|
-
extend Iterable
|
23
|
-
|
24
|
-
NORMAL = 'normal'
|
25
|
-
ZOOM = 'zoom'
|
26
|
-
STRETCH_4x3 = 'strech4x3'
|
27
|
-
WIDE_ZOOM = 'widezoom'
|
28
|
-
STRETCH_16x9 = 'stretch16x9'
|
29
|
-
ORIGINAL = 'original'
|
30
|
-
STRETCH_16x9_NONLIN = 'stretch16x9nonline'
|
31
|
-
ZOOM_120_WIDTH = 'zoom120width'
|
32
|
-
ZOOM_110_WIDTH = 'zoom110width'
|
33
|
-
end
|
34
|
-
|
35
|
-
# player types
|
36
|
-
module PlayerVisibilityType
|
37
|
-
extend Iterable
|
38
|
-
|
39
|
-
INTERNAL = 'internal'
|
40
|
-
EXTERNAL = 'external'
|
41
|
-
REMOTE = 'remote'
|
42
|
-
end
|
43
|
-
|
44
|
-
# Player.Type https://kodi.wiki/view/JSON-RPC_API/v12#Player.Type
|
45
|
-
module PlayerType
|
46
|
-
extend Iterable
|
47
|
-
|
48
|
-
VIDEO = 'video'
|
49
|
-
AUDIO = 'audio'
|
50
|
-
PICTURE = 'picture'
|
51
|
-
end
|
52
|
-
|
53
|
-
# Player.Repeat https://kodi.wiki/view/JSON-RPC_API/v12#Player.Repeat
|
54
|
-
module PlayerRepeat
|
55
|
-
extend Iterable
|
56
|
-
|
57
|
-
OFF = 'off'
|
58
|
-
ONE = 'one'
|
59
|
-
ALL = 'all'
|
60
|
-
CYCLE = 'cycle'
|
61
|
-
end
|
62
|
-
|
63
|
-
# player speed enum, -32 to 32
|
64
|
-
module PlayerSpeed
|
65
|
-
extend Iterable
|
66
|
-
|
67
|
-
MINUS_32 = -32
|
68
|
-
MINUS_16 = -16
|
69
|
-
MINUS_8 = -8
|
70
|
-
MINUS_4 = -4
|
71
|
-
MINUS_2 = -2
|
72
|
-
MINUS_1 = -1
|
73
|
-
NEUTRAL = 0
|
74
|
-
PLUS_1 = 1
|
75
|
-
PLUS_2 = 2
|
76
|
-
PLUS_4 = 4
|
77
|
-
PLUS_8 = 8
|
78
|
-
PLUS_16 = 16
|
79
|
-
PLUS_32 = 32
|
80
|
-
end
|
81
|
-
|
82
|
-
# player id and type
|
83
|
-
class Player
|
84
|
-
include Comparable
|
85
|
-
extend Creatable
|
86
|
-
|
87
|
-
attr_reader :player_id, :player_type, :type, :name, :plays_audio, :plays_video
|
88
|
-
|
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
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
# Player Subtitle https://kodi.wiki/view/JSON-RPC_API/v12#Player.Subtitle
|
100
|
-
class Subtitle
|
101
|
-
include Comparable
|
102
|
-
extend Creatable
|
103
|
-
|
104
|
-
attr_reader :index, :is_default, :is_forced, :is_impaired, :language, :name
|
105
|
-
|
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
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
# Player.Audio.Stream https://kodi.wiki/view/JSON-RPC_API/v12#Player.Audio.Stream
|
117
|
-
class AudioStream
|
118
|
-
include Comparable
|
119
|
-
extend Creatable
|
120
|
-
|
121
|
-
attr_reader :bitrate, :channels, :codec, :index, :is_default, :is_forced, :is_original, :language,
|
122
|
-
:name, :sample_rate
|
123
|
-
|
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
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
# Player.Video.Stream https://kodi.wiki/view/JSON-RPC_API/v12#Player.Video.Stream
|
139
|
-
class VideoStream
|
140
|
-
include Comparable
|
141
|
-
extend Creatable
|
142
|
-
|
143
|
-
attr_reader :codec, :height, :index, :language, :name, :width, :duration, :aspect
|
144
|
-
|
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
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
# Player.Property.Name https://kodi.wiki/view/JSON-RPC_API/v12#Player.Property.Name
|
158
|
-
module PropertyName
|
159
|
-
extend Iterable
|
160
|
-
|
161
|
-
AUDIOSTREAMS = 'audiostreams'
|
162
|
-
CANCHANGESPEED = 'canchangespeed'
|
163
|
-
CANMOVE = 'canmove'
|
164
|
-
CANREPEAT = 'canrepeat'
|
165
|
-
CANROTATE = 'canrotate'
|
166
|
-
CANSEEK = 'canseek'
|
167
|
-
CANSHUFFLE = 'canshuffle'
|
168
|
-
CANZOOM = 'canzoom'
|
169
|
-
CURRENTAUDIOSTREAM = 'currentaudiostream'
|
170
|
-
CURRENTSUBTITLE = 'currentsubtitle'
|
171
|
-
CURRENTVIDEOSTREAM = 'currentvideostream'
|
172
|
-
LIVE = 'live'
|
173
|
-
PARTYMODE = 'partymode'
|
174
|
-
PERCENTAGE = 'percentage'
|
175
|
-
PLAYLISTID = 'playlistid'
|
176
|
-
POSITION = 'position'
|
177
|
-
REPEAT = 'repeat'
|
178
|
-
SHUFFLED = 'shuffled'
|
179
|
-
SPEED = 'speed'
|
180
|
-
SUBTITLEENABLED = 'subtitleenabled'
|
181
|
-
SUBTITLES = 'subtitles'
|
182
|
-
TIME = 'time'
|
183
|
-
TOTALTIME = 'totaltime'
|
184
|
-
TYPE = 'type'
|
185
|
-
VIDEOSTREAMS = 'videostreams'
|
186
|
-
end
|
187
|
-
|
188
|
-
# Player.Property.Value https://kodi.wiki/view/JSON-RPC_API/v12#Player.Property.Name
|
189
|
-
class PropertyValue
|
190
|
-
include Comparable
|
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)
|
221
|
-
end
|
222
|
-
|
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
|
253
|
-
end
|
254
|
-
end
|
255
|
-
|
256
|
-
# return value for Player.GetViewMode
|
257
|
-
class PlayerViewMode
|
258
|
-
include Comparable
|
259
|
-
extend Creatable
|
260
|
-
|
261
|
-
attr_reader :nonlinear_stretch, :pixel_ratio, :vertical_shift, :view_mode, :zoom
|
262
|
-
|
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
|
269
|
-
end
|
270
|
-
end
|
271
|
-
|
272
|
-
# Player.Position.Time https://kodi.wiki/view/JSON-RPC_API/v12#Player.Position.Time
|
273
|
-
class PlayerPositionTime
|
274
|
-
include Comparable
|
275
|
-
extend Creatable
|
276
|
-
|
277
|
-
attr_reader :hours, :minutes, :seconds, :milliseconds
|
278
|
-
|
279
|
-
def initialize(hours, minutes, seconds, milliseconds)
|
280
|
-
@hours = hours
|
281
|
-
@minutes = minutes
|
282
|
-
@seconds = seconds
|
283
|
-
@milliseconds = milliseconds
|
284
|
-
end
|
285
|
-
end
|
286
|
-
|
287
|
-
# defines the jump size for seek
|
288
|
-
module SeekJump
|
289
|
-
include Iterable
|
290
|
-
|
291
|
-
SMALL_FORWARD = 'smallforward'
|
292
|
-
SMALL_BACKWARD = 'smallbackward'
|
293
|
-
BIG_FORWARD = 'bigforward'
|
294
|
-
BIG_BACKWARD = 'bigbackward'
|
295
|
-
end
|
296
|
-
|
297
|
-
# return value of Player.Seek
|
298
|
-
class SeekReturned
|
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'])
|
307
|
-
|
308
|
-
new(hash['percentage'], time, total_time)
|
309
|
-
end
|
310
|
-
|
311
|
-
def initialize(percentage, time, total_time)
|
312
|
-
@percentage = percentage
|
313
|
-
@time = time
|
314
|
-
@total_time = total_time
|
315
|
-
end
|
316
|
-
end
|
317
|
-
end
|
318
|
-
end
|
319
|
-
end
|
@@ -1,80 +0,0 @@
|
|
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
|
@@ -1,145 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'kodi_client/global_types/media_types'
|
4
|
-
require 'kodi_client/global_types/player_type'
|
5
|
-
require 'kodi_client/util/comparable'
|
6
|
-
require 'kodi_client/util/creatable'
|
7
|
-
|
8
|
-
module KodiClient
|
9
|
-
module Types
|
10
|
-
module Video
|
11
|
-
|
12
|
-
# Video.Details.Base https://kodi.wiki/view/JSON-RPC_API/v12#Video.Details.Base
|
13
|
-
module VideoDetailsBase
|
14
|
-
include Media::MediaDetailsBase
|
15
|
-
|
16
|
-
attr_reader :art, :play_count
|
17
|
-
|
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)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# Video.Cast https://kodi.wiki/view/JSON-RPC_API/v12#Video.Cast
|
31
|
-
class VideoCast
|
32
|
-
include Comparable
|
33
|
-
extend Creatable
|
34
|
-
|
35
|
-
attr_reader :name, :order, :role, :thumbnail
|
36
|
-
|
37
|
-
def initialize(name, order, role, thumbnail)
|
38
|
-
@name = name
|
39
|
-
@order = order
|
40
|
-
@role = role
|
41
|
-
@thumbnail = thumbnail
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
# Video.Details.Media https://kodi.wiki/view/JSON-RPC_API/v12#Video.Details.Media
|
46
|
-
module VideoDetailsMedia
|
47
|
-
include VideoDetailsBase
|
48
|
-
|
49
|
-
attr_reader :title
|
50
|
-
|
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)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
# Video.Details.Item https://kodi.wiki/view/JSON-RPC_API/v12#Video.Details.Item
|
63
|
-
module VideoDetailsItem
|
64
|
-
include VideoDetailsMedia
|
65
|
-
|
66
|
-
attr_reader :date_added, :file, :last_played, :plot
|
67
|
-
|
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)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
# Video.Details.File https://kodi.wiki/view/JSON-RPC_API/v12#Video.Details.File
|
84
|
-
module VideoDetailsFile
|
85
|
-
include VideoDetailsItem
|
86
|
-
|
87
|
-
attr_reader :director, :resume, :runtime, :stream_details
|
88
|
-
|
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)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
# Video.Resume https://kodi.wiki/view/JSON-RPC_API/v12#Video.Resume
|
109
|
-
class VideoResume
|
110
|
-
include Comparable
|
111
|
-
extend Creatable
|
112
|
-
|
113
|
-
attr_reader :position, :total
|
114
|
-
|
115
|
-
def initialize(position, total)
|
116
|
-
@position = position
|
117
|
-
@total = total
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
# Video.Streams https://kodi.wiki/view/JSON-RPC_API/v12#Video.Streams
|
122
|
-
class Streams
|
123
|
-
include Comparable
|
124
|
-
extend Creatable
|
125
|
-
|
126
|
-
attr_reader :audio, :subtitle, :video
|
127
|
-
|
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)
|
135
|
-
end
|
136
|
-
|
137
|
-
def initialize(audio, subtitle, video)
|
138
|
-
@audio = audio
|
139
|
-
@subtitle = subtitle
|
140
|
-
@video = video
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
@@ -1,87 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'http'
|
4
|
-
require 'kodi_client/util/comparable'
|
5
|
-
|
6
|
-
module KodiClient
|
7
|
-
|
8
|
-
# the client that stores
|
9
|
-
class KodiModule
|
10
|
-
|
11
|
-
def apply_options(options)
|
12
|
-
@endpoint_url = "#{options.tls ? 'https://' : 'http://'}#{options.ip}:#{options.port}/jsonrpc"
|
13
|
-
@options = options
|
14
|
-
end
|
15
|
-
|
16
|
-
def invoke_api(request)
|
17
|
-
h = request.instance_variables.each_with_object({}) do |var, hash|
|
18
|
-
hash[var.to_s.delete('@')] = request.instance_variable_get(var)
|
19
|
-
end
|
20
|
-
|
21
|
-
@http_client ||= build_client
|
22
|
-
response = @http_client.post(@endpoint_url, json: h).to_s
|
23
|
-
JSON.parse(response)
|
24
|
-
end
|
25
|
-
|
26
|
-
def build_client
|
27
|
-
client = HTTP.headers(Content_Type: 'application/json')
|
28
|
-
if !@options.username.nil? && !@options.password.nil?
|
29
|
-
client = client.basic_auth({ user: @options.username, pass: @options.password })
|
30
|
-
end
|
31
|
-
|
32
|
-
client
|
33
|
-
end
|
34
|
-
|
35
|
-
private :build_client
|
36
|
-
end
|
37
|
-
|
38
|
-
# represents an error response
|
39
|
-
class KodiError
|
40
|
-
|
41
|
-
attr_reader :code, :message
|
42
|
-
|
43
|
-
def initialize(hash)
|
44
|
-
@code = hash['code']
|
45
|
-
@message = hash['message']
|
46
|
-
end
|
47
|
-
|
48
|
-
def ==(other)
|
49
|
-
@code == other.code && @message == other.message
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
# represents a kodi requests
|
54
|
-
class KodiRequest
|
55
|
-
|
56
|
-
attr_accessor :id, :jsonrpc, :method, :params
|
57
|
-
|
58
|
-
def initialize(kodi_id, method, params = {}, jsonrpc = '2.0')
|
59
|
-
@id = kodi_id
|
60
|
-
@jsonrpc = jsonrpc
|
61
|
-
@method = method
|
62
|
-
@params = params
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
# represents a kodi response
|
67
|
-
class KodiResponse
|
68
|
-
include Comparable
|
69
|
-
|
70
|
-
attr_reader :id, :jsonrpc, :result, :error
|
71
|
-
|
72
|
-
def initialize(hash)
|
73
|
-
@id = hash['id']
|
74
|
-
@jsonrpc = hash['jsonrpc']
|
75
|
-
@result = hash['result']
|
76
|
-
@error = KodiError.new(hash['error']) unless hash['error'].nil?
|
77
|
-
end
|
78
|
-
|
79
|
-
def error?
|
80
|
-
!@error.nil?
|
81
|
-
end
|
82
|
-
|
83
|
-
def ==(other)
|
84
|
-
compare(self, other)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module KodiClient
|
4
|
-
|
5
|
-
# offers compare methods
|
6
|
-
module Comparable
|
7
|
-
def compare(obj1, obj2)
|
8
|
-
is_same = true
|
9
|
-
obj1.instance_variables.each do |it|
|
10
|
-
is_same = false if obj1.instance_variable_get(it) != obj2.instance_variable_get(it)
|
11
|
-
end
|
12
|
-
|
13
|
-
is_same
|
14
|
-
end
|
15
|
-
|
16
|
-
def ==(other)
|
17
|
-
compare(self, other)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,52 +0,0 @@
|
|
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
|