kodi_client 0.5.7 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/kodi_client.gemspec +3 -3
- data/lib/kodi_client/Chainable.rb +1 -2
- data/lib/kodi_client/kodi_module.rb +0 -7
- data/lib/kodi_client/method/addons.rb +6 -21
- data/lib/kodi_client/method/application.rb +1 -4
- data/lib/kodi_client/method/audio_library.rb +46 -0
- data/lib/kodi_client/method/favourites.rb +1 -4
- data/lib/kodi_client/method/files.rb +85 -0
- data/lib/kodi_client/method/gui.rb +1 -4
- data/lib/kodi_client/method/input.rb +1 -5
- data/lib/kodi_client/method/player.rb +1 -6
- data/lib/kodi_client/method/profiles.rb +1 -4
- data/lib/kodi_client/method/system.rb +1 -5
- data/lib/kodi_client/{global_types → types}/addon_types.rb +9 -26
- data/lib/kodi_client/{global_types → types}/application_types.rb +16 -25
- data/lib/kodi_client/types/audio_types.rb +221 -0
- data/lib/kodi_client/{global_types → types}/favourites_types.rb +1 -10
- data/lib/kodi_client/types/files_types.rb +63 -0
- data/lib/kodi_client/{global_types → types}/global_types.rb +0 -4
- data/lib/kodi_client/{global_types → types}/gui_types.rb +2 -14
- data/lib/kodi_client/{global_types → types}/input_types.rb +0 -2
- data/lib/kodi_client/{global_types → types}/item_types.rb +5 -1
- data/lib/kodi_client/{global_types → types}/list_types.rb +193 -64
- data/lib/kodi_client/{global_types → types}/media_types.rb +5 -7
- data/lib/kodi_client/{global_types → types}/player_type.rb +11 -36
- data/lib/kodi_client/{global_types → types}/profiles_types.rb +2 -17
- data/lib/kodi_client/{global_types → types}/pvr_type.rb +0 -2
- data/lib/kodi_client/{global_types → types}/system_types.rb +0 -3
- data/lib/kodi_client/{global_types → types}/video_types.rb +32 -25
- data/lib/kodi_client/util/creatable.rb +69 -15
- data/lib/kodi_client.rb +37 -9
- metadata +23 -20
- data/lib/kodi_client/global_types/audio_types.rb +0 -88
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23953ca4422d697b3b13a223f63b339acc5d4d4fdb8c7accccdc5f0b7f85f9cb
|
4
|
+
data.tar.gz: 92e3d514686cdddddcc16a1be9046ba56a8d31e039316fb98ab98dca45a864db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 734b5574d16a2deac4a88f81f6d3b94f4a5cd9c769fbda34034a6f3b614c4a03b5c44f40060ad100d24e1a2e032de8ceb35107f6922a51fdc396d19db4207204
|
7
|
+
data.tar.gz: 1cbb33466f364232765025183bb4336c03913ff1f1ff9887a18cd7f221b4cd5fac2640671a3213e2049533888044b551b5a4738ce7c2f0219b1fe21b6c15d3b6
|
data/README.md
CHANGED
data/kodi_client.gemspec
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'kodi_client'
|
5
|
-
spec.version = '0.
|
5
|
+
spec.version = '0.6.3'
|
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
|
11
|
-
'
|
10
|
+
spec.description = 'A client for the Kodi JSON API v12, currently implemented methods are Addons, Application, '\
|
11
|
+
'Favourites, Files, GUI, Input, Player, Profiles and System (more will be added with the time). '\
|
12
12
|
'For more information how to use it and how to activate Remote Control in Kodi, '\
|
13
13
|
'please check the github page https://github.com/cfe86/RubyKodiClient'
|
14
14
|
spec.homepage = 'https://github.com/cfe86/RubyKodiClient'
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'kodi_client/options'
|
4
|
-
|
5
3
|
module KodiClient
|
6
4
|
# Offers methods like connect, auth and tls to be chained together
|
7
5
|
module Chainable
|
@@ -9,6 +7,7 @@ module KodiClient
|
|
9
7
|
attr_accessor :options, :client
|
10
8
|
|
11
9
|
def connect(ip, port)
|
10
|
+
@client = KodiClient::Client.new
|
12
11
|
merge_options(->(options) { options.with_connection(ip, port) })
|
13
12
|
end
|
14
13
|
|
@@ -1,8 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'http'
|
4
|
-
require 'kodi_client/util/comparable'
|
5
|
-
|
6
3
|
module KodiClient
|
7
4
|
|
8
5
|
# the client that stores
|
@@ -79,9 +76,5 @@ module KodiClient
|
|
79
76
|
def error?
|
80
77
|
!@error.nil?
|
81
78
|
end
|
82
|
-
|
83
|
-
def ==(other)
|
84
|
-
compare(self, other)
|
85
|
-
end
|
86
79
|
end
|
87
80
|
end
|
@@ -1,11 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'kodi_client/kodi_module'
|
4
|
-
require 'kodi_client/global_types/addon_types'
|
5
|
-
require 'kodi_client/global_types/list_types'
|
6
|
-
|
7
3
|
module KodiClient
|
8
|
-
module
|
4
|
+
module Method
|
9
5
|
# contains all Kodi Application methods
|
10
6
|
class Addons < KodiModule
|
11
7
|
|
@@ -34,11 +30,8 @@ module KodiClient
|
|
34
30
|
end
|
35
31
|
|
36
32
|
def get_addon_details(addon_id = nil, properties = [], kodi_id = 1)
|
37
|
-
request = KodiRequest.new(kodi_id, GET_ADDON_DETAILS,
|
38
|
-
|
39
|
-
'addonid' => addon_id,
|
40
|
-
'properties' => properties
|
41
|
-
})
|
33
|
+
request = KodiRequest.new(kodi_id, GET_ADDON_DETAILS, { 'addonid' => addon_id,
|
34
|
+
'properties' => properties })
|
42
35
|
json = invoke_api(request)
|
43
36
|
|
44
37
|
result = Types::Addons::Addon.create(json['result'])
|
@@ -47,22 +40,14 @@ module KodiClient
|
|
47
40
|
end
|
48
41
|
|
49
42
|
def execute_addon(addon_id = nil, params = '', wait = false, kodi_id = 1)
|
50
|
-
request = KodiRequest.new(kodi_id, EXECUTE_ADDON,
|
51
|
-
|
52
|
-
'addonid' => addon_id,
|
53
|
-
'params' => params,
|
54
|
-
'wait' => wait
|
55
|
-
})
|
43
|
+
request = KodiRequest.new(kodi_id, EXECUTE_ADDON, { 'addonid' => addon_id, 'params' => params,
|
44
|
+
'wait' => wait })
|
56
45
|
json = invoke_api(request)
|
57
46
|
KodiResponse.new(json)
|
58
47
|
end
|
59
48
|
|
60
49
|
def set_addon_enabled(addon_id = nil, enabled = Types::Global::Toggle::TOGGLE, kodi_id = 1)
|
61
|
-
request = KodiRequest.new(kodi_id, SET_ADDON_ENABLED,
|
62
|
-
{
|
63
|
-
'addonid' => addon_id,
|
64
|
-
'enabled' => enabled
|
65
|
-
})
|
50
|
+
request = KodiRequest.new(kodi_id, SET_ADDON_ENABLED, { 'addonid' => addon_id, 'enabled' => enabled })
|
66
51
|
json = invoke_api(request)
|
67
52
|
KodiResponse.new(json)
|
68
53
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module KodiClient
|
4
|
+
module Method
|
5
|
+
# contains all Kodi Application methods
|
6
|
+
class AudioLibrary < KodiModule
|
7
|
+
|
8
|
+
CLEAN = 'AudioLibrary.Clean'
|
9
|
+
EXPORT = 'AudioLibrary.Export'
|
10
|
+
GET_ALBUM_DETAILS = 'AudioLibrary.GetAlbumDetails'
|
11
|
+
GET_ALBUMS = 'AudioLibrary.GetAlbums'
|
12
|
+
|
13
|
+
def clean(show_dialogs = true, kodi_id = 1)
|
14
|
+
request = KodiRequest.new(kodi_id, CLEAN, { 'showdialogs' => show_dialogs })
|
15
|
+
json = invoke_api(request)
|
16
|
+
KodiResponse.new(json)
|
17
|
+
end
|
18
|
+
|
19
|
+
def export(path, kodi_id = 1)
|
20
|
+
request = KodiRequest.new(kodi_id, EXPORT, { 'options' => { 'path' => path } })
|
21
|
+
json = invoke_api(request)
|
22
|
+
KodiResponse.new(json)
|
23
|
+
end
|
24
|
+
|
25
|
+
def get_album_details(album_id, properties = Types::Audio::AudioFieldsAlbum.all_properties, kodi_id = 1)
|
26
|
+
request = KodiRequest.new(kodi_id, GET_ALBUM_DETAILS, { 'albumid' => album_id, 'properties' => properties })
|
27
|
+
json = invoke_api(request)
|
28
|
+
KodiResponse.new(json)
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_albums(properties = Types::Audio::AudioFieldsAlbum.all_properties,
|
32
|
+
limits = Types::List::ListLimits.new(0, 50),
|
33
|
+
sort = Types::List::ListSort.new, include_singles = false, all_roles = false, kodi_id = 1)
|
34
|
+
request = KodiRequest.new(kodi_id, GET_ALBUMS,
|
35
|
+
{ 'properties' => properties,
|
36
|
+
'limits' => { 'start' => limits.list_start, 'end' => limits.list_end },
|
37
|
+
'sort' => { 'ignorearticle' => sort.ignore_article, 'method' => sort.method,
|
38
|
+
'order' => sort.order,
|
39
|
+
'useartistsortname' => sort.use_artist_sort_name },
|
40
|
+
'includesingles' => include_singles, 'allroles' => all_roles })
|
41
|
+
json = invoke_api(request)
|
42
|
+
KodiResponse.new(json)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module KodiClient
|
4
|
+
module Method
|
5
|
+
# contains all Kodi Application methods
|
6
|
+
class Files < KodiModule
|
7
|
+
|
8
|
+
GET_DIRECTORY = 'Files.GetDirectory'
|
9
|
+
GET_FILE_DETAILS = 'Files.GetFileDetails'
|
10
|
+
GET_SOURCES = 'Files.GetSources'
|
11
|
+
PREPARE_DOWNLOAD = 'Files.PrepareDownload'
|
12
|
+
SET_FILE_DETAILS = 'Files.SetFileDetails'
|
13
|
+
|
14
|
+
def get_directory(directory, media = Types::Files::Media::FILES,
|
15
|
+
properties = Types::List::ListFieldFiles.all_properties,
|
16
|
+
sort = Types::List::ListSort.new,
|
17
|
+
limits = Types::List::ListLimits.new(0, 50), kodi_id = 1)
|
18
|
+
request = KodiRequest.new(kodi_id, GET_DIRECTORY,
|
19
|
+
{
|
20
|
+
'directory' => directory,
|
21
|
+
'media' => media,
|
22
|
+
'properties' => properties,
|
23
|
+
'sort' => { 'ignorearticle' => sort.ignore_article, 'method' => sort.method,
|
24
|
+
'order' => sort.order,
|
25
|
+
'useartistsortname' => sort.use_artist_sort_name },
|
26
|
+
'limits' => { 'start' => limits.list_start, 'end' => limits.list_end }
|
27
|
+
})
|
28
|
+
json = invoke_api(request)
|
29
|
+
result = KodiClient::Types::Files::GetDirectoryReturned.create(json['result'])
|
30
|
+
json['result'] = result
|
31
|
+
KodiResponse.new(json)
|
32
|
+
end
|
33
|
+
|
34
|
+
def get_file_details(file, media = Types::Files::Media::FILES,
|
35
|
+
properties = Types::List::ListFieldFiles.all_properties, kodi_id = 1)
|
36
|
+
request = KodiRequest.new(kodi_id, GET_FILE_DETAILS,
|
37
|
+
{
|
38
|
+
'file' => file,
|
39
|
+
'media' => media,
|
40
|
+
'properties' => properties
|
41
|
+
})
|
42
|
+
json = invoke_api(request)
|
43
|
+
result = KodiClient::Types::List::ListItemFile.create(json['result'])
|
44
|
+
json['result'] = result
|
45
|
+
KodiResponse.new(json)
|
46
|
+
end
|
47
|
+
|
48
|
+
def get_sources(media = Types::Files::Media::FILES,
|
49
|
+
sort = Types::List::ListSort.new,
|
50
|
+
limits = Types::List::ListLimits.new(0, 50), kodi_id = 1)
|
51
|
+
request = KodiRequest.new(kodi_id, GET_SOURCES,
|
52
|
+
{
|
53
|
+
'media' => media,
|
54
|
+
'sort' => { 'ignorearticle' => sort.ignore_article, 'method' => sort.method,
|
55
|
+
'order' => sort.order,
|
56
|
+
'useartistsortname' => sort.use_artist_sort_name },
|
57
|
+
'limits' => { 'start' => limits.list_start, 'end' => limits.list_end }
|
58
|
+
})
|
59
|
+
json = invoke_api(request)
|
60
|
+
result = KodiClient::Types::Files::GetSourcesReturned.create(json['result'])
|
61
|
+
json['result'] = result
|
62
|
+
KodiResponse.new(json)
|
63
|
+
end
|
64
|
+
|
65
|
+
def prepare_download(path, kodi_id = 1)
|
66
|
+
request = KodiRequest.new(kodi_id, PREPARE_DOWNLOAD, { 'path' => path })
|
67
|
+
json = invoke_api(request)
|
68
|
+
result = KodiClient::Types::Files::PrepareDownloadReturned.create(json['result'])
|
69
|
+
json['result'] = result
|
70
|
+
KodiResponse.new(json)
|
71
|
+
end
|
72
|
+
|
73
|
+
def set_file_details(file, media = Types::Files::Media::VIDEO, play_count = nil, last_played = nil,
|
74
|
+
resume = nil, kodi_id = 1)
|
75
|
+
params = { 'file' => file, 'media' => media}
|
76
|
+
params['playcount'] = play_count unless play_count.nil?
|
77
|
+
params['lastplayed'] = last_played unless last_played.nil?
|
78
|
+
params['resume'] = resume unless resume.nil?
|
79
|
+
request = KodiRequest.new(kodi_id, SET_FILE_DETAILS, params)
|
80
|
+
json = invoke_api(request)
|
81
|
+
KodiResponse.new(json)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -1,11 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
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
3
|
module KodiClient
|
8
|
-
module
|
4
|
+
module Method
|
9
5
|
# contains all Kodi Input methods
|
10
6
|
class Input < KodiModule
|
11
7
|
|
@@ -1,12 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'kodi_client/kodi_module'
|
4
|
-
require 'kodi_client/global_types/addon_types'
|
5
|
-
require 'kodi_client/global_types/list_types'
|
6
|
-
require 'kodi_client/global_types/player_type'
|
7
|
-
|
8
3
|
module KodiClient
|
9
|
-
module
|
4
|
+
module Method
|
10
5
|
# contains all Kodi Application methods
|
11
6
|
class Player < KodiModule
|
12
7
|
|
@@ -1,11 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
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
3
|
module KodiClient
|
8
|
-
module
|
4
|
+
module Method
|
9
5
|
# contains all Kodi System methods
|
10
6
|
class System < KodiModule
|
11
7
|
|
@@ -1,9 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'kodi_client/
|
4
|
-
require 'kodi_client/
|
5
|
-
require 'kodi_client/util/iterable'
|
6
|
-
require 'kodi_client/util/creatable'
|
3
|
+
require 'kodi_client/types/item_types'
|
4
|
+
require 'kodi_client/types/list_types'
|
7
5
|
|
8
6
|
module KodiClient
|
9
7
|
module Types
|
@@ -118,17 +116,10 @@ module KodiClient
|
|
118
116
|
attr_reader :addon_id, :author, :broken, :dependencies, :description, :disclaimer, :enabled, :extra_info,
|
119
117
|
:fan_art, :installed, :name, :path, :rating, :summary, :thumbnail, :type, :version
|
120
118
|
|
121
|
-
|
122
|
-
|
119
|
+
fields_to_map %w[addon_id author broken dependencies description disclaimer enabled extra_info fan_art
|
120
|
+
installed name path rating summary thumbnail type version label]
|
123
121
|
|
124
|
-
|
125
|
-
extra_info = AddonExtraInfo.create_list(hash['extrainfo'])
|
126
|
-
|
127
|
-
new(hash['addonid'], hash['author'], hash['broken'], dependencies, hash['description'], hash['disclaimer'],
|
128
|
-
hash['enabled'], extra_info, hash['fanart'], hash['installed'], hash['name'], hash['path'],
|
129
|
-
hash['rating'], hash['summary'], hash['thumbnail'], hash['type'], hash['version'],
|
130
|
-
*hash_to_arr(hash, ['label']))
|
131
|
-
end
|
122
|
+
type_mapping ['dependencies', AddonDependency, true], ['extrainfo', AddonExtraInfo, true]
|
132
123
|
|
133
124
|
def initialize(addon_id, author, broken, dependencies, description, disclaimer, enabled, extra_info,
|
134
125
|
fan_art, installed, name, path, rating, summary, thumbnail, type, version, label)
|
@@ -156,16 +147,11 @@ module KodiClient
|
|
156
147
|
# getAddons return
|
157
148
|
class Addons
|
158
149
|
include Comparable
|
150
|
+
extend Creatable
|
159
151
|
|
160
152
|
attr_reader :addons, :limits
|
161
153
|
|
162
|
-
|
163
|
-
return nil if hash.nil?
|
164
|
-
|
165
|
-
addons = AddonDetails.create_list(hash['addons'])
|
166
|
-
limits = List::ListLimitsReturned.create(hash['limits'])
|
167
|
-
new(addons, limits)
|
168
|
-
end
|
154
|
+
type_mapping ['addons', AddonDetails, true], ['limits', List::ListLimitsReturned]
|
169
155
|
|
170
156
|
def initialize(addons, limits)
|
171
157
|
@addons = addons
|
@@ -176,14 +162,11 @@ module KodiClient
|
|
176
162
|
# getAddon return
|
177
163
|
class Addon
|
178
164
|
include Comparable
|
165
|
+
extend Creatable
|
179
166
|
|
180
167
|
attr_reader :addon
|
181
168
|
|
182
|
-
|
183
|
-
return nil if hash.nil?
|
184
|
-
|
185
|
-
new(AddonDetails.create(hash['addon']))
|
186
|
-
end
|
169
|
+
type_mapping ['addon', AddonDetails]
|
187
170
|
|
188
171
|
def initialize(addon)
|
189
172
|
@addon = addon
|
@@ -1,9 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'kodi_client/util/comparable'
|
4
|
-
require 'kodi_client/util/iterable'
|
5
|
-
require 'kodi_client/util/creatable'
|
6
|
-
|
7
3
|
module KodiClient
|
8
4
|
module Types
|
9
5
|
module Application
|
@@ -20,6 +16,21 @@ module KodiClient
|
|
20
16
|
LANGUAGE = 'language'
|
21
17
|
end
|
22
18
|
|
19
|
+
# represent application properties version
|
20
|
+
class Version
|
21
|
+
include Comparable
|
22
|
+
extend Creatable
|
23
|
+
|
24
|
+
attr_reader :major, :minor, :revision, :tag
|
25
|
+
|
26
|
+
def initialize(major, minor, revision, tag)
|
27
|
+
@major = major
|
28
|
+
@minor = minor
|
29
|
+
@revision = revision
|
30
|
+
@tag = tag
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
23
34
|
# Application.Property.Value https://kodi.wiki/view/JSON-RPC_API/v12#Application.Property.Value
|
24
35
|
class PropertyValue
|
25
36
|
include Comparable
|
@@ -27,12 +38,7 @@ module KodiClient
|
|
27
38
|
|
28
39
|
attr_reader :name, :version, :muted, :volume
|
29
40
|
|
30
|
-
|
31
|
-
return null if hash.nil?
|
32
|
-
|
33
|
-
version = Version.create(hash['version'])
|
34
|
-
new(hash['name'], version, hash['muted'], hash['volume'])
|
35
|
-
end
|
41
|
+
type_mapping ['version', Version]
|
36
42
|
|
37
43
|
def initialize(name, version, muted, volume)
|
38
44
|
@name = name
|
@@ -41,21 +47,6 @@ module KodiClient
|
|
41
47
|
@volume = volume
|
42
48
|
end
|
43
49
|
end
|
44
|
-
|
45
|
-
# represent application properties version
|
46
|
-
class Version
|
47
|
-
include Comparable
|
48
|
-
extend Creatable
|
49
|
-
|
50
|
-
attr_reader :major, :minor, :revision, :tag
|
51
|
-
|
52
|
-
def initialize(major, minor, revision, tag)
|
53
|
-
@major = major
|
54
|
-
@minor = minor
|
55
|
-
@revision = revision
|
56
|
-
@tag = tag
|
57
|
-
end
|
58
|
-
end
|
59
50
|
end
|
60
51
|
end
|
61
52
|
end
|