kodi_client 0.4.1 → 0.5.6

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: d626f5d559146d9c8d24b29cbcc1a87b05c0653d0b092d593bef0da9390cfded
4
- data.tar.gz: '0841f786338f19c0c8341ebc7cc71aec0131a308af374bdd7a5347ab7acd41ad'
3
+ metadata.gz: 988e821c68bbe4f1ffc3579c64aa02647814f9aea0fb5af409d619a10e82ab71
4
+ data.tar.gz: 1df5a3cea4ac46a7fb1fc7420f3f8a66244ceaed0a79a06673a6f9b9e3e6fcd0
5
5
  SHA512:
6
- metadata.gz: 357427f184bb3c50c6fb30ae226e014800cd3264726d6cad187efad951a7f724e7d37f5f728cce8c0cfaad7efdcd719be01e6097263da33f69975b4829490e15
7
- data.tar.gz: 0e6e1d0fa1b67859cfc19489bf1694c95ee432f30f8afc3c78358823c4e777c928dd3a3eb679b00d3825201363a69514f060001f11b49b9f8d793693cf73bd2b
6
+ metadata.gz: 4cbaa96ef989fc5c9708007f623f7c272ad465670099ac3d5251b5b2621e2f02411b23ad3aa3b5864b62b91bd4a530276cb884205b8e2f180491fce3a5c74204
7
+ data.tar.gz: a7aca817104f7be2f5919713cf07d40a4901f3fc6c0dc57ab248be2be0a34194b7c96f751277aaf3466561e19d83bf16ec1401c0a5765a1c0cdc51f51ec04bef
data/.rubocop.yml CHANGED
@@ -11,4 +11,6 @@ Metrics/CyclomaticComplexity:
11
11
  Metrics/MethodLength:
12
12
  Enabled: false
13
13
  Metrics/PerceivedComplexity:
14
+ Enabled: false
15
+ Style/OptionalBooleanParameter:
14
16
  Enabled: false
data/README.md CHANGED
@@ -5,8 +5,12 @@ RubyKodiClient is a work-in-progress client for [Kodi JSON API v12](https://kodi
5
5
  Currently implemented are the following Methods:
6
6
  * Addons
7
7
  * Application
8
+ * Favourites
8
9
  * GUI
10
+ * Input
9
11
  * Player
12
+ * Profile
13
+ * System
10
14
 
11
15
  ## Installation
12
16
  from [rubygems](https://rubygems.org/gems/kodi_client) using
@@ -19,7 +23,7 @@ gem build kodi-client.gemspec
19
23
  ```
20
24
  and then execute
21
25
  ```shell
22
- gem build kodi-client-0.4.0.gemspec
26
+ gem build kodi-client-x.x.x.gemspec
23
27
  ```
24
28
 
25
29
  ## Enable Kodi Remote Control
data/kodi_client.gemspec CHANGED
@@ -2,12 +2,15 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'kodi_client'
5
- spec.version = '0.4.1'
5
+ spec.version = '0.5.6'
6
6
  spec.authors = ['Christian Feier']
7
7
  spec.email = ['christian.feier@gmail.com']
8
8
 
9
9
  spec.summary = 'A work-in-progress client for Kodi JSON API v2.'
10
- spec.description = 'A client for the Kodi JSON API v12, currently implemented methods are addons, application, gui and player (more will be added with the time). For more information how to use it and how to activate Remote Control in Kodi, please check the github page https://github.com/cfe86/RubyKodiClient'
10
+ spec.description = 'A client for the Kodi JSON API v12, currently implemented methods are addons, application, '\
11
+ 'favourites, gui, input, player, profile and system (more will be added with the time). '\
12
+ 'For more information how to use it and how to activate Remote Control in Kodi, '\
13
+ 'please check the github page https://github.com/cfe86/RubyKodiClient'
11
14
  spec.homepage = 'https://github.com/cfe86/RubyKodiClient'
12
15
  spec.license = 'MIT'
13
16
  spec.required_ruby_version = '>= 2.5.0'
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'kodi_client/global_types/media_types'
4
- require 'kodi_client/global_types/player_type'
5
4
  require 'kodi_client/util/comparable'
6
5
  require 'kodi_client/util/iterable'
7
6
 
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'kodi_client/util/comparable'
4
+ require 'kodi_client/util/iterable'
5
+ require 'kodi_client/global_types/list_types'
6
+
7
+ module KodiClient
8
+ module Types
9
+ module Favourites
10
+
11
+ # Favourite.Type https://kodi.wiki/view/JSON-RPC_API/v12#Favourite.Type
12
+ module Type
13
+ extend Iterable
14
+
15
+ MEDIA = 'media'
16
+ WINDOW = 'window'
17
+ SCRIPT = 'script'
18
+ ANDROID_APP = 'androidapp'
19
+ UNKNOWN = 'unknown'
20
+ end
21
+
22
+ # Favourite.Fields.Favourite https://kodi.wiki/view/JSON-RPC_API/v12#Favourite.Fields.Favourite
23
+ module FieldsFavourite
24
+ extend Iterable
25
+
26
+ WINDOW = 'window'
27
+ WINDOW_PARAMETER = 'windowparameter'
28
+ THUMBNAIL = 'thumbnail'
29
+ PATH = 'path'
30
+ end
31
+
32
+ # Favourite.Details.Favourite https://kodi.wiki/view/JSON-RPC_API/v12#Favourite.Details.Favourite
33
+ class DetailsFavourite
34
+ include Comparable
35
+
36
+ attr_reader :path, :thumbnail, :title, :type, :window, :window_parameter
37
+
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)
49
+ end
50
+ end
51
+
52
+ # return type for Favourites.GetFavourites
53
+ class GetFavouriteReturned
54
+ include Comparable
55
+
56
+ attr_reader :favourites, :limits
57
+
58
+ def initialize(hash)
59
+ @favourites = hash['favourites'].map { |it| DetailsFavourite.new(it) }
60
+ @limits = Types::List::ListLimitsReturned.new(hash['limits'])
61
+ end
62
+
63
+ def ==(other)
64
+ compare(self, other)
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -18,7 +18,7 @@ module KodiClient
18
18
 
19
19
  # rotate for clockwise and counter clockwise
20
20
  module Rotate
21
- include Iterable
21
+ extend Iterable
22
22
 
23
23
  CLOCKWISE = 'clockwise'
24
24
  COUNTER_CLOCKWISE = 'counterclockwise'
@@ -26,7 +26,7 @@ module KodiClient
26
26
 
27
27
  # direction for left, right, up, down
28
28
  module Direction
29
- include Iterable
29
+ extend Iterable
30
30
 
31
31
  LEFT = 'left'
32
32
  RIGHT = 'right'
@@ -36,7 +36,7 @@ module KodiClient
36
36
 
37
37
  # enum for prev/next
38
38
  module NextPrev
39
- include Iterable
39
+ extend Iterable
40
40
 
41
41
  NEXT = 'next'
42
42
  PREV = 'previous'
@@ -46,7 +46,7 @@ module KodiClient
46
46
 
47
47
  # Global.IncrementDecrement https://kodi.wiki/view/JSON-RPC_API/v12#Global.IncrementDecrement
48
48
  module IncrementDecrement
49
- include Iterable
49
+ extend Iterable
50
50
 
51
51
  INCREMENT = 'increment'
52
52
  DECREMENT = 'decrement'
@@ -99,6 +99,14 @@ module KodiClient
99
99
  compare(self, other)
100
100
  end
101
101
  end
102
+
103
+ # available Password Encryptions
104
+ module PasswordEncryption
105
+ extend Iterable
106
+
107
+ NONE = 'none'
108
+ MD5 = 'md5'
109
+ end
102
110
  end
103
111
  end
104
112
  end
@@ -0,0 +1,216 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'kodi_client/util/iterable'
4
+
5
+ module KodiClient
6
+ module Types
7
+ module Input
8
+
9
+ # Input.Action https://kodi.wiki/view/JSON-RPC_API/v12#Input.Action
10
+ module InputAction
11
+ extend Iterable
12
+
13
+ ANALOGFASTFORWARD = 'analogfastforward'
14
+ ANALOGMOVE = 'analogmove'
15
+ ANALOGMOVEX = 'analogmovex'
16
+ ANALOGMOVEY = 'analogmovey'
17
+ ANALOGREWIND = 'analogrewind'
18
+ ANALOGSEEKBACK = 'analogseekback'
19
+ ANALOGSEEKFORWARD = 'analogseekforward'
20
+ ASPECTRATIO = 'aspectratio'
21
+ AUDIODELAY = 'audiodelay'
22
+ AUDIODELAYMINUS = 'audiodelayminus'
23
+ AUDIODELAYPLUS = 'audiodelayplus'
24
+ AUDIONEXTLANGUAGE = 'audionextlanguage'
25
+ AUDIOTOGGLEDIGITAL = 'audiotoggledigital'
26
+ BACK = 'back'
27
+ BACKSPACE = 'backspace'
28
+ BIGSTEPBACK = 'bigstepback'
29
+ BIGSTEPFORWARD = 'bigstepforward'
30
+ BLUE = 'blue'
31
+ CHANNELDOWN = 'channeldown'
32
+ CHANNELUP = 'channelup'
33
+ CHAPTERORBIGSTEPBACK = 'chapterorbigstepback'
34
+ CHAPTERORBIGSTEPFORWARD = 'chapterorbigstepforward'
35
+ CLOSE = 'close'
36
+ CODECINFO = 'codecinfo'
37
+ CONTEXTMENU = 'contextmenu'
38
+ COPY = 'copy'
39
+ CREATEBOOKMARK = 'createbookmark'
40
+ CREATEEPISODEBOOKMARK = 'createepisodebookmark'
41
+ CURSORLEFT = 'cursorleft'
42
+ CURSORRIGHT = 'cursorright'
43
+ CYCLESUBTITLE = 'cyclesubtitle'
44
+ DECREASEPAR = 'decreasepar'
45
+ DECREASERATING = 'decreaserating'
46
+ DECREASEVISRATING = 'decreasevisrating'
47
+ DELETE = 'delete'
48
+ DOUBLECLICK = 'doubleclick'
49
+ DOWN = 'down'
50
+ ENTER = 'enter'
51
+ ERROR = 'error'
52
+ FASTFORWARD = 'fastforward'
53
+ FILTER = 'filter'
54
+ FILTERCLEAR = 'filterclear'
55
+ FILTERSMS2 = 'filtersms2'
56
+ FILTERSMS3 = 'filtersms3'
57
+ FILTERSMS4 = 'filtersms4'
58
+ FILTERSMS5 = 'filtersms5'
59
+ FILTERSMS6 = 'filtersms6'
60
+ FILTERSMS7 = 'filtersms7'
61
+ FILTERSMS8 = 'filtersms8'
62
+ FILTERSMS9 = 'filtersms9'
63
+ FIRSTPAGE = 'firstpage'
64
+ FULLSCREEN = 'fullscreen'
65
+ GREEN = 'green'
66
+ GUIPROFILE = 'guiprofile'
67
+ HIGHLIGHT = 'highlight'
68
+ INCREASEPAR = 'increasepar'
69
+ INCREASERATING = 'increaserating'
70
+ INCREASEVISRATING = 'increasevisrating'
71
+ INFO = 'info'
72
+ JUMPSMS2 = 'jumpsms2'
73
+ JUMPSMS3 = 'jumpsms3'
74
+ JUMPSMS4 = 'jumpsms4'
75
+ JUMPSMS5 = 'jumpsms5'
76
+ JUMPSMS6 = 'jumpsms6'
77
+ JUMPSMS7 = 'jumpsms7'
78
+ JUMPSMS8 = 'jumpsms8'
79
+ JUMPSMS9 = 'jumpsms9'
80
+ LASTPAGE = 'lastpage'
81
+ LEFT = 'left'
82
+ LEFTCLICK = 'leftclick'
83
+ LOCKPRESET = 'lockpreset'
84
+ LONGCLICK = 'longclick'
85
+ LONGPRESS = 'longpress'
86
+ MENU = 'menu'
87
+ MIDDLECLICK = 'middleclick'
88
+ MOUSEDRAG = 'mousedrag'
89
+ MOUSEMOVE = 'mousemove'
90
+ MOVE = 'move'
91
+ MOVEITEMDOWN = 'moveitemdown'
92
+ MOVEITEMUP = 'moveitemup'
93
+ MUTE = 'mute'
94
+ NEXTCALIBRATION = 'nextcalibration'
95
+ NEXTCHANNELGROUP = 'nextchannelgroup'
96
+ NEXTLETTER = 'nextletter'
97
+ NEXTPICTURE = 'nextpicture'
98
+ NEXTPRESET = 'nextpreset'
99
+ NEXTRESOLUTION = 'nextresolution'
100
+ NEXTSCENE = 'nextscene'
101
+ NEXTSTEREOMODE = 'nextstereomode'
102
+ NEXTSUBTITLE = 'nextsubtitle'
103
+ NOOP = 'noop'
104
+ NUMBER0 = 'number0'
105
+ NUMBER1 = 'number1'
106
+ NUMBER2 = 'number2'
107
+ NUMBER3 = 'number3'
108
+ NUMBER4 = 'number4'
109
+ NUMBER5 = 'number5'
110
+ NUMBER6 = 'number6'
111
+ NUMBER7 = 'number7'
112
+ NUMBER8 = 'number8'
113
+ NUMBER9 = 'number9'
114
+ OSD = 'osd'
115
+ PAGEDOWN = 'pagedown'
116
+ PAGEUP = 'pageup'
117
+ PANGESTURE = 'pangesture'
118
+ PARENTDIR = 'parentdir'
119
+ PARENTFOLDER = 'parentfolder'
120
+ PAUSE = 'pause'
121
+ PLAY = 'play'
122
+ PLAYERDEBUG = 'playerdebug'
123
+ PLAYERPROCESSINFO = 'playerprocessinfo'
124
+ PLAYLIST = 'playlist'
125
+ PLAYPAUSE = 'playpause'
126
+ PLAYPVR = 'playpvr'
127
+ PLAYPVRRADIO = 'playpvrradio'
128
+ PLAYPVRTV = 'playpvrtv'
129
+ PREVIOUSCHANNELGROUP = 'previouschannelgroup'
130
+ PREVIOUSMENU = 'previousmenu'
131
+ PREVIOUSPICTURE = 'previouspicture'
132
+ PREVIOUSPRESET = 'previouspreset'
133
+ PREVIOUSSCENE = 'previousscene'
134
+ PREVIOUSSTEREOMODE = 'previousstereomode'
135
+ PREVLETTER = 'prevletter'
136
+ QUEUE = 'queue'
137
+ RANDOMPRESET = 'randompreset'
138
+ RECORD = 'record'
139
+ RED = 'red'
140
+ RELOADKEYMAPS = 'reloadkeymaps'
141
+ RENAME = 'rename'
142
+ RESETCALIBRATION = 'resetcalibration'
143
+ REWIND = 'rewind'
144
+ RIGHT = 'right'
145
+ RIGHTCLICK = 'rightclick'
146
+ ROTATE = 'rotate'
147
+ ROTATECCW = 'rotateccw'
148
+ ROTATEGESTURE = 'rotategesture'
149
+ SCANITEM = 'scanitem'
150
+ SCREENSHOT = 'screenshot'
151
+ SCROLLDOWN = 'scrolldown'
152
+ SCROLLUP = 'scrollup'
153
+ SELECT = 'select'
154
+ SETRATING = 'setrating'
155
+ SETTINGSLEVELCHANGE = 'settingslevelchange'
156
+ SETTINGSRESET = 'settingsreset'
157
+ SHIFT = 'shift'
158
+ SHOWPRESET = 'showpreset'
159
+ SHOWSUBTITLES = 'showsubtitles'
160
+ SHOWTIME = 'showtime'
161
+ SHOWTIMERRULE = 'showtimerrule'
162
+ SHOWVIDEOMENU = 'showvideomenu'
163
+ SKIPNEXT = 'skipnext'
164
+ SKIPPREVIOUS = 'skipprevious'
165
+ SMALLSTEPBACK = 'smallstepback'
166
+ STEPBACK = 'stepback'
167
+ STEPFORWARD = 'stepforward'
168
+ STEREOMODE = 'stereomode'
169
+ STEREOMODETOMONO = 'stereomodetomono'
170
+ STOP = 'stop'
171
+ SUBTITLEALIGN = 'subtitlealign'
172
+ SUBTITLEDELAY = 'subtitledelay'
173
+ SUBTITLEDELAYMINUS = 'subtitledelayminus'
174
+ SUBTITLEDELAYPLUS = 'subtitledelayplus'
175
+ SUBTITLESHIFTDOWN = 'subtitleshiftdown'
176
+ SUBTITLESHIFTUP = 'subtitleshiftup'
177
+ SWIPEDOWN = 'swipedown'
178
+ SWIPELEFT = 'swipeleft'
179
+ SWIPERIGHT = 'swiperight'
180
+ SWIPEUP = 'swipeup'
181
+ SWITCHPLAYER = 'switchplayer'
182
+ SYMBOLS = 'symbols'
183
+ TAP = 'tap'
184
+ TOGGLECOMMSKIP = 'togglecommskip'
185
+ TOGGLEFULLSCREEN = 'togglefullscreen'
186
+ TOGGLESTEREOMODE = 'togglestereomode'
187
+ TOGGLEWATCHED = 'togglewatched'
188
+ UP = 'up'
189
+ VERTICALSHIFTDOWN = 'verticalshiftdown'
190
+ VERTICALSHIFTUP = 'verticalshiftup'
191
+ VOLAMPDOWN = 'volampdown'
192
+ VOLAMPUP = 'volampup'
193
+ VOLUMEAMPLIFICATION = 'volumeamplification'
194
+ VOLUMEDOWN = 'volumedown'
195
+ VOLUMEUP = 'volumeup'
196
+ WHEELDOWN = 'wheeldown'
197
+ WHEELUP = 'wheelup'
198
+ YELLOW = 'yellow'
199
+ ZOOMGESTURE = 'zoomgesture'
200
+ ZOOMIN = 'zoomin'
201
+ ZOOMLEVEL1 = 'zoomlevel1'
202
+ ZOOMLEVEL2 = 'zoomlevel2'
203
+ ZOOMLEVEL3 = 'zoomlevel3'
204
+ ZOOMLEVEL4 = 'zoomlevel4'
205
+ ZOOMLEVEL5 = 'zoomlevel5'
206
+ ZOOMLEVEL6 = 'zoomlevel6'
207
+ ZOOMLEVEL7 = 'zoomlevel7'
208
+ ZOOMLEVEL8 = 'zoomlevel8'
209
+ ZOOMLEVEL9 = 'zoomlevel9'
210
+ ZOOMNORMAL = 'zoomnormal'
211
+ ZOOMOUT = 'zoomout'
212
+ end
213
+ end
214
+ end
215
+ end
216
+
@@ -41,6 +41,33 @@ module KodiClient
41
41
  end
42
42
  end
43
43
 
44
+ # ascending/descending for sorting
45
+ module SortOrder
46
+ extend Iterable
47
+
48
+ ASCENDING = 'ascending'
49
+ DESCENDING = 'descending'
50
+ end
51
+
52
+ # List.Sort https://kodi.wiki/view/JSON-RPC_API/v12#List.Sort
53
+ class ListSort
54
+ include Comparable
55
+
56
+ attr_reader :ignore_article, :method, :order, :use_artist_sort_name
57
+
58
+ def initialize(ignore_article = false, method = ListSortMethod::NONE,
59
+ sortOrder = SortOrder::ASCENDING, use_artist_sort_name = false)
60
+ @ignore_article = ignore_article
61
+ @method = method
62
+ @order = SortOrder::ASCENDING
63
+ @use_artist_sort_name = use_artist_sort_name
64
+ end
65
+
66
+ def ==(other)
67
+ compare(self, other)
68
+ end
69
+ end
70
+
44
71
  # List.Fields.All https://kodi.wiki/view/JSON-RPC_API/v12#List.Fields.All
45
72
  module ListFieldsAll
46
73
  extend Iterable
@@ -241,6 +268,53 @@ module KodiClient
241
268
  compare(self, other)
242
269
  end
243
270
  end
271
+
272
+ # methods for list sorting
273
+ module ListSortMethod
274
+ extend Iterable
275
+
276
+ NONE = 'none'
277
+ LABEL = 'label'
278
+ DATE = 'date'
279
+ SIZE = 'size'
280
+ FILE = 'file'
281
+ PATH = 'path'
282
+ DRIVE_TYPE = 'drivetype'
283
+ TITLE = 'title'
284
+ TRACK = 'track'
285
+ TIME = 'time'
286
+ ARTIST = 'artist'
287
+ ALBUM = 'album'
288
+ ALBUM_TYPE = 'albumtype'
289
+ GENRE = 'genre'
290
+ COUNTRY = 'country'
291
+ YEAR = 'year'
292
+ RATING = 'rating'
293
+ USER_RATING = 'userrating'
294
+ VOTES = 'votes'
295
+ TOP_250 = 'top250'
296
+ PROGRAM_COUNT = 'programcount'
297
+ PLAYLIST = 'playlist'
298
+ EPISODE = 'episode'
299
+ SEASON = 'season'
300
+ TOTAL_EPISODES = 'totalepisodes'
301
+ WATCHED_EPISODES = 'watchedepisodes'
302
+ TV_SHOW_STATUS = 'tvshowstatus'
303
+ TV_SHOW_TITLE = 'tvshowtitle'
304
+ SORT_TITLE = 'sorttitle'
305
+ PRODUCTION_CODE = 'productioncode'
306
+ MPAA = 'mpaa'
307
+ STUDIO = 'studio'
308
+ DATE_ADDED = 'dateadded'
309
+ LAST_PLAYED = 'lastplayed'
310
+ PLAY_COUNT = 'playcount'
311
+ LISTENERS = 'listeners'
312
+ BITRATE = 'bitrate'
313
+ RANDOM = 'random'
314
+ TOTAL_DISCS = 'totaldiscs'
315
+ ORIGINAL_DATE = 'originaldate'
316
+ BPM = 'bpm'
317
+ end
244
318
  end
245
319
  end
246
320
  end
@@ -0,0 +1,70 @@
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
+
24
+ attr_reader :lock_mode, :thumbnail
25
+
26
+ def initialize(hash)
27
+ @lock_mode = hash['lockmode']
28
+ @thumbnail = hash['thumbnail']
29
+ item_details_base(hash)
30
+ end
31
+
32
+ def ==(other)
33
+ compare(self, other)
34
+ end
35
+ end
36
+
37
+ # return type for Profiles.GetProfiles
38
+ class GetProfilesReturned
39
+ include Comparable
40
+
41
+ attr_reader :limits, :profiles
42
+
43
+ def initialize(hash)
44
+ @limits = Types::List::ListLimitsReturned.new(hash['limits'])
45
+ @profiles = hash['profiles'].nil? ? [] : hash['profiles'].map { |it| Types::Profiles::DetailsProfile.new(it) }
46
+ end
47
+
48
+ def ==(other)
49
+ compare(self, other)
50
+ end
51
+ end
52
+
53
+ # Profiles.Password https://kodi.wiki/view/JSON-RPC_API/v12#Profiles.Password
54
+ class ProfilePassword
55
+ include Comparable
56
+
57
+ attr_reader :value, :encryption
58
+
59
+ def initialize(value, encryption = Types::Global::PasswordEncryption::MD5)
60
+ @value = value
61
+ @encryption = encryption
62
+ end
63
+
64
+ def ==(other)
65
+ compare(self, other)
66
+ end
67
+ end
68
+ end
69
+ end
70
+ 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
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'kodi_client/util/iterable'
4
+ require 'kodi_client/util/comparable'
5
+
6
+ module KodiClient
7
+ module Types
8
+ module System
9
+
10
+ # System.Property.Name https://kodi.wiki/view/JSON-RPC_API/v12#System.Property.Name
11
+ module PropertyName
12
+ extend Iterable
13
+
14
+ CAN_SHUTDOWN = 'canshutdown'
15
+ CAN_SUSPEND = 'cansuspend'
16
+ CAN_HIBERNATE = 'canhibernate'
17
+ CAN_REBOOT = 'canreboot'
18
+ end
19
+
20
+ # System.Property.Value https://kodi.wiki/view/JSON-RPC_API/v12#System.Property.Value
21
+ class PropertyValue
22
+ include Comparable
23
+
24
+ attr_reader :can_hibernate, :can_reboot, :can_shutdown, :can_suspend
25
+
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)
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -17,6 +17,7 @@ module KodiClient
17
17
  h = request.instance_variables.each_with_object({}) do |var, hash|
18
18
  hash[var.to_s.delete('@')] = request.instance_variable_get(var)
19
19
  end
20
+
20
21
  @http_client ||= build_client
21
22
  response = @http_client.post(@endpoint_url, json: h).to_s
22
23
  JSON.parse(response)
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'kodi_client/kodi_module'
4
+ require 'kodi_client/global_types/favourites_types'
5
+
6
+ module KodiClient
7
+ module Modules
8
+ # contains all Kodi Application methods
9
+ class Favourites < KodiModule
10
+
11
+ ADD_FAVOURITE = 'Favourites.AddFavourite'
12
+ GET_FAVOURITES = 'Favourites.GetFavourites'
13
+
14
+ def add_favourite(title, type = Types::Favourites::Type::UNKNOWN, path = nil, window = nil,
15
+ window_parameter = nil, thumbnail = nil, kodi_id = 1)
16
+ params = { 'title' => title, 'type' => type }
17
+ params['path'] = path unless path.nil?
18
+ params['window'] = window unless window.nil?
19
+ params['windowparameter'] = window_parameter unless window_parameter.nil?
20
+ params['thumbnail'] = thumbnail unless thumbnail.nil?
21
+ request = KodiRequest.new(kodi_id, ADD_FAVOURITE, params)
22
+ json = invoke_api(request)
23
+ KodiResponse.new(json)
24
+ end
25
+
26
+ def get_favourites(properties = Types::Favourites::FieldsFavourite.all_properties, type = nil, kodi_id = 1)
27
+ params = { 'properties' => properties }
28
+ params['type'] = type unless type.nil?
29
+ request = KodiRequest.new(kodi_id, GET_FAVOURITES, params)
30
+ json = invoke_api(request)
31
+ result = json['result'].nil? ? nil : Types::Favourites::GetFavouriteReturned.new(json['result'])
32
+ json['result'] = result
33
+ KodiResponse.new(json)
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ # 'path' => path,
40
+ # 'window' => window, 'windowparameter' => windowparameter,
41
+ # 'thumbnail' => thumbnail
@@ -0,0 +1,112 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'kodi_client/global_types/gui_types'
4
+ require 'kodi_client/kodi_module'
5
+ require 'kodi_client/global_types/input_types'
6
+
7
+ module KodiClient
8
+ module Modules
9
+ # contains all Kodi Input methods
10
+ class Input < KodiModule
11
+
12
+ BACK = 'Input.Back'
13
+ CONTEXT_MENU = 'Input.ContextMenu'
14
+ DOWN = 'Input.Down'
15
+ EXECUTE_ACTION = 'Input.ExecuteAction'
16
+ HOME = 'Input.Home'
17
+ INFO = 'Input.Info'
18
+ LEFT = 'Input.Left'
19
+ RIGHT = 'Input.Right'
20
+ SELECT = 'Input.Select'
21
+ SEND_TEXT = 'Input.SendText'
22
+ SHOW_CODEC = 'Input.ShowCodec'
23
+ SHOW_OSD = 'Input.ShowOSD'
24
+ SHOW_PLAYER_PROCESS_INFO = 'Input.ShowPlayerProcessInfo'
25
+ UP = 'Input.Up'
26
+
27
+ def back(kodi_id = 1)
28
+ request = KodiRequest.new(kodi_id, BACK, {})
29
+ json = invoke_api(request)
30
+ KodiResponse.new(json)
31
+ end
32
+
33
+ def context_menu(kodi_id = 1)
34
+ request = KodiRequest.new(kodi_id, CONTEXT_MENU, {})
35
+ json = invoke_api(request)
36
+ KodiResponse.new(json)
37
+ end
38
+
39
+ def down(kodi_id = 1)
40
+ request = KodiRequest.new(kodi_id, DOWN, {})
41
+ json = invoke_api(request)
42
+ KodiResponse.new(json)
43
+ end
44
+
45
+ def execute_action(action = Types::Input::InputAction::BACK, kodi_id = 1)
46
+ request = KodiRequest.new(kodi_id, EXECUTE_ACTION, { 'action' => action })
47
+ json = invoke_api(request)
48
+ KodiResponse.new(json)
49
+ end
50
+
51
+ def home(kodi_id = 1)
52
+ request = KodiRequest.new(kodi_id, HOME, {})
53
+ json = invoke_api(request)
54
+ KodiResponse.new(json)
55
+ end
56
+
57
+ def info(kodi_id = 1)
58
+ request = KodiRequest.new(kodi_id, INFO, {})
59
+ json = invoke_api(request)
60
+ KodiResponse.new(json)
61
+ end
62
+
63
+ def left(kodi_id = 1)
64
+ request = KodiRequest.new(kodi_id, LEFT, {})
65
+ json = invoke_api(request)
66
+ KodiResponse.new(json)
67
+ end
68
+
69
+ def right(kodi_id = 1)
70
+ request = KodiRequest.new(kodi_id, RIGHT, {})
71
+ json = invoke_api(request)
72
+ KodiResponse.new(json)
73
+ end
74
+
75
+ def select(kodi_id = 1)
76
+ request = KodiRequest.new(kodi_id, SELECT, {})
77
+ json = invoke_api(request)
78
+ KodiResponse.new(json)
79
+ end
80
+
81
+ def send_text(text, done = true, kodi_id = 1)
82
+ request = KodiRequest.new(kodi_id, SEND_TEXT, { 'text' => text, 'done' => done})
83
+ json = invoke_api(request)
84
+ KodiResponse.new(json)
85
+ end
86
+
87
+ def show_codec(kodi_id = 1)
88
+ request = KodiRequest.new(kodi_id, SHOW_CODEC, {})
89
+ json = invoke_api(request)
90
+ KodiResponse.new(json)
91
+ end
92
+
93
+ def show_osd(kodi_id = 1)
94
+ request = KodiRequest.new(kodi_id, SHOW_OSD, {})
95
+ json = invoke_api(request)
96
+ KodiResponse.new(json)
97
+ end
98
+
99
+ def show_player_process_info(kodi_id = 1)
100
+ request = KodiRequest.new(kodi_id, SHOW_PLAYER_PROCESS_INFO, {})
101
+ json = invoke_api(request)
102
+ KodiResponse.new(json)
103
+ end
104
+
105
+ def up(kodi_id = 1)
106
+ request = KodiRequest.new(kodi_id, UP, {})
107
+ json = invoke_api(request)
108
+ KodiResponse.new(json)
109
+ end
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'kodi_client/kodi_module'
4
+ require 'kodi_client/global_types/profiles_types'
5
+
6
+ module KodiClient
7
+ module Modules
8
+ # contains all Kodi Application methods
9
+ class Profiles < KodiModule
10
+
11
+ GET_CURRENT_PROFILE = 'Profiles.GetCurrentProfile'
12
+ GET_PROFILES = 'Profiles.GetProfiles'
13
+ LOAD_PROFILE = 'Profiles.LoadProfile'
14
+
15
+ def get_current_profile(properties = Types::Profiles::FieldsProfile.all_properties, kodi_id = 1)
16
+ request = KodiRequest.new(kodi_id, GET_CURRENT_PROFILE, { 'properties' => properties })
17
+ json = invoke_api(request)
18
+ result = json['result'].nil? ? nil : Types::Profiles::DetailsProfile.new(json['result'])
19
+ json['result'] = result
20
+ KodiResponse.new(json)
21
+ end
22
+
23
+ def get_profiles(properties = Types::Profiles::FieldsProfile.all_properties,
24
+ limit = Types::List::ListLimits.new(0, 50),
25
+ sort = Types::List::ListSort.new, kodi_id = 1)
26
+ request = KodiRequest.new(kodi_id, GET_PROFILES,
27
+ { 'properties' => properties,
28
+ 'limits' => { 'start' => limit.list_start, 'end' => limit.list_end },
29
+ 'sort' => { 'ignorearticle' => sort.ignore_article, 'method' => sort.method,
30
+ 'order' => sort.order,
31
+ 'useartistsortname' => sort.use_artist_sort_name } })
32
+ json = invoke_api(request)
33
+ result = json['result'].nil? ? nil : Types::Profiles::GetProfilesReturned.new(json['result'])
34
+ json['result'] = result
35
+ KodiResponse.new(json)
36
+ end
37
+
38
+ def load_profile(profile_name, password, prompt = false, kodi_id = 1)
39
+ request = KodiRequest.new(kodi_id, LOAD_PROFILE,
40
+ { 'profile' => profile_name,
41
+ 'password' => { 'value' => password.value, 'encryption' => password.encryption },
42
+ 'prompt' => prompt })
43
+ json = invoke_api(request)
44
+ KodiResponse.new(json)
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'kodi_client/global_types/gui_types'
4
+ require 'kodi_client/kodi_module'
5
+ require 'kodi_client/global_types/system_types'
6
+
7
+ module KodiClient
8
+ module Modules
9
+ # contains all Kodi System methods
10
+ class System < KodiModule
11
+
12
+ EJECT_OPTICAL_DRIVE = 'System.EjectOpticalDrive'
13
+ GET_PROPERTIES = 'System.GetProperties'
14
+ HIBERNATE = 'System.Hibernate'
15
+ REBOOT = 'System.Reboot'
16
+ SHUTDOWN = 'System.Shutdown'
17
+ SUSPEND = 'System.Suspend'
18
+
19
+ def eject_optical_drive(kodi_id = 1)
20
+ request = KodiRequest.new(kodi_id, EJECT_OPTICAL_DRIVE, {})
21
+ json = invoke_api(request)
22
+ KodiResponse.new(json)
23
+ end
24
+
25
+ def get_properties(properties = Types::System::PropertyName.all_properties, kodi_id = 1)
26
+ request = KodiRequest.new(kodi_id, GET_PROPERTIES, { 'properties' => properties })
27
+ json = invoke_api(request)
28
+ result = json['result'].nil? ? nil : Types::System::PropertyValue.new(json['result'])
29
+ json['result'] = result
30
+ KodiResponse.new(json)
31
+ end
32
+
33
+ def hibernate(kodi_id = 1)
34
+ request = KodiRequest.new(kodi_id, HIBERNATE, {})
35
+ json = invoke_api(request)
36
+ KodiResponse.new(json)
37
+ end
38
+
39
+ def reboot(kodi_id = 1)
40
+ request = KodiRequest.new(kodi_id, REBOOT, {})
41
+ json = invoke_api(request)
42
+ KodiResponse.new(json)
43
+ end
44
+
45
+ def shutdown(kodi_id = 1)
46
+ request = KodiRequest.new(kodi_id, SHUTDOWN, {})
47
+ json = invoke_api(request)
48
+ KodiResponse.new(json)
49
+ end
50
+
51
+ def suspend(kodi_id = 1)
52
+ request = KodiRequest.new(kodi_id, SUSPEND, {})
53
+ json = invoke_api(request)
54
+ KodiResponse.new(json)
55
+ end
56
+ end
57
+ end
58
+ end
data/lib/kodi_client.rb CHANGED
@@ -6,8 +6,12 @@ require 'json'
6
6
  require 'kodi_client/Chainable'
7
7
  require 'kodi_client/method/addons'
8
8
  require 'kodi_client/method/application'
9
+ require 'kodi_client/method/favourites'
9
10
  require 'kodi_client/method/gui'
11
+ require 'kodi_client/method/input'
10
12
  require 'kodi_client/method/player'
13
+ require 'kodi_client/method/profiles'
14
+ require 'kodi_client/method/system'
11
15
 
12
16
 
13
17
  # client for Kodi rest api https://kodi.wiki/view/JSON-RPC_API/v12
@@ -18,20 +22,28 @@ module KodiClient
18
22
  class Client
19
23
  include Chainable
20
24
 
21
- attr_reader :addons, :application, :gui, :player
25
+ attr_reader :addons, :application, :gui, :player, :input, :favourites, :system, :profiles
22
26
 
23
27
  def initialize
24
28
  @addons = KodiClient::Modules::Addons.new
25
29
  @application = KodiClient::Modules::Application.new
30
+ @favourites = KodiClient::Modules::Favourites.new
26
31
  @gui = KodiClient::Modules::GUI.new
32
+ @input = KodiClient::Modules::Input.new
27
33
  @player = KodiClient::Modules::Player.new
34
+ @profiles = KodiClient::Modules::Profiles.new
35
+ @system = KodiClient::Modules::System.new
28
36
  end
29
37
 
30
38
  def apply_options(options)
31
39
  @addons.apply_options(options)
32
40
  @application.apply_options(options)
33
41
  @gui.apply_options(options)
42
+ @input.apply_options(options)
34
43
  @player.apply_options(options)
44
+ @favourites.apply_options(options)
45
+ @profiles.apply_options(options)
46
+ @system.apply_options(options)
35
47
  end
36
48
  end
37
- end
49
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kodi_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Feier
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-15 00:00:00.000000000 Z
11
+ date: 2021-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -25,9 +25,9 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 5.0.4
27
27
  description: A client for the Kodi JSON API v12, currently implemented methods are
28
- addons, application, gui and player (more will be added with the time). For more
29
- information how to use it and how to activate Remote Control in Kodi, please check
30
- the github page https://github.com/cfe86/RubyKodiClient
28
+ addons, application, favourites, gui, input, player, profile and system (more will
29
+ be added with the time). For more information how to use it and how to activate
30
+ Remote Control in Kodi, please check the github page https://github.com/cfe86/RubyKodiClient
31
31
  email:
32
32
  - christian.feier@gmail.com
33
33
  executables: []
@@ -46,19 +46,27 @@ files:
46
46
  - lib/kodi_client/global_types/addon_types.rb
47
47
  - lib/kodi_client/global_types/application_types.rb
48
48
  - lib/kodi_client/global_types/audio_types.rb
49
+ - lib/kodi_client/global_types/favourites_types.rb
49
50
  - lib/kodi_client/global_types/global_types.rb
50
51
  - lib/kodi_client/global_types/gui_types.rb
52
+ - lib/kodi_client/global_types/input_types.rb
51
53
  - lib/kodi_client/global_types/item_types.rb
52
54
  - lib/kodi_client/global_types/list_types.rb
53
55
  - lib/kodi_client/global_types/media_types.rb
54
56
  - lib/kodi_client/global_types/player_type.rb
57
+ - lib/kodi_client/global_types/profiles_types.rb
55
58
  - lib/kodi_client/global_types/pvr_type.rb
59
+ - lib/kodi_client/global_types/system_types.rb
56
60
  - lib/kodi_client/global_types/video_types.rb
57
61
  - lib/kodi_client/kodi_module.rb
58
62
  - lib/kodi_client/method/addons.rb
59
63
  - lib/kodi_client/method/application.rb
64
+ - lib/kodi_client/method/favourites.rb
60
65
  - lib/kodi_client/method/gui.rb
66
+ - lib/kodi_client/method/input.rb
61
67
  - lib/kodi_client/method/player.rb
68
+ - lib/kodi_client/method/profiles.rb
69
+ - lib/kodi_client/method/system.rb
62
70
  - lib/kodi_client/options.rb
63
71
  - lib/kodi_client/util/comparable.rb
64
72
  - lib/kodi_client/util/iterable.rb