kodi_client 0.6.0 → 0.6.1
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/kodi_client.gemspec +1 -1
- data/lib/kodi_client/global_types/addon_types.rb +8 -22
- data/lib/kodi_client/global_types/application_types.rb +16 -21
- data/lib/kodi_client/global_types/audio_types.rb +144 -6
- data/lib/kodi_client/global_types/favourites_types.rb +1 -5
- data/lib/kodi_client/global_types/files_types.rb +2 -16
- data/lib/kodi_client/global_types/gui_types.rb +2 -9
- data/lib/kodi_client/global_types/item_types.rb +5 -1
- data/lib/kodi_client/global_types/list_types.rb +65 -86
- data/lib/kodi_client/global_types/media_types.rb +6 -3
- data/lib/kodi_client/global_types/player_type.rb +12 -31
- data/lib/kodi_client/global_types/profiles_types.rb +3 -13
- data/lib/kodi_client/global_types/system_types.rb +1 -0
- data/lib/kodi_client/global_types/video_types.rb +32 -22
- data/lib/kodi_client/method/addons.rb +5 -16
- data/lib/kodi_client/method/audio_library.rb +49 -0
- data/lib/kodi_client/util/creatable.rb +69 -15
- data/lib/kodi_client.rb +3 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fea7dad06fe723225e4d8bf268db09490af87c98a74f653e5966f170d1156fd
|
4
|
+
data.tar.gz: a4d8a3dfcac1a85abbf1c073b0c2f6016de9de9d07249eabc5067fe47c829727
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 031fcbe6dc03750fa90d3b8d395f903082d6b2b8586f3fe49ff3d9d5ca3375501e2b8e34305808399026de10bd62a5cfc00bf3ad5fc505cb5043e47ba2cdc85f
|
7
|
+
data.tar.gz: 6e9622971b0e8737130feddefca5ac49a8efd4073dd4ec9719b524c2cb7ba3781e915322a03bd1ffac63fe4ab48b3ed1428a83135a69223add9a041b8ff1288d
|
data/kodi_client.gemspec
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'kodi_client/global_types/item_types'
|
4
|
+
require 'kodi_client/global_types/list_types'
|
4
5
|
require 'kodi_client/util/comparable'
|
5
6
|
require 'kodi_client/util/iterable'
|
6
7
|
require 'kodi_client/util/creatable'
|
@@ -118,17 +119,10 @@ module KodiClient
|
|
118
119
|
attr_reader :addon_id, :author, :broken, :dependencies, :description, :disclaimer, :enabled, :extra_info,
|
119
120
|
:fan_art, :installed, :name, :path, :rating, :summary, :thumbnail, :type, :version
|
120
121
|
|
121
|
-
|
122
|
-
|
122
|
+
fields_to_map %w[addon_id author broken dependencies description disclaimer enabled extra_info fan_art
|
123
|
+
installed name path rating summary thumbnail type version label]
|
123
124
|
|
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
|
125
|
+
type_mapping ['dependencies', AddonDependency, true], ['extrainfo', AddonExtraInfo, true]
|
132
126
|
|
133
127
|
def initialize(addon_id, author, broken, dependencies, description, disclaimer, enabled, extra_info,
|
134
128
|
fan_art, installed, name, path, rating, summary, thumbnail, type, version, label)
|
@@ -156,16 +150,11 @@ module KodiClient
|
|
156
150
|
# getAddons return
|
157
151
|
class Addons
|
158
152
|
include Comparable
|
153
|
+
extend Creatable
|
159
154
|
|
160
155
|
attr_reader :addons, :limits
|
161
156
|
|
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
|
157
|
+
type_mapping ['addons', AddonDetails, true], ['limits', List::ListLimitsReturned]
|
169
158
|
|
170
159
|
def initialize(addons, limits)
|
171
160
|
@addons = addons
|
@@ -176,14 +165,11 @@ module KodiClient
|
|
176
165
|
# getAddon return
|
177
166
|
class Addon
|
178
167
|
include Comparable
|
168
|
+
extend Creatable
|
179
169
|
|
180
170
|
attr_reader :addon
|
181
171
|
|
182
|
-
|
183
|
-
return nil if hash.nil?
|
184
|
-
|
185
|
-
new(AddonDetails.create(hash['addon']))
|
186
|
-
end
|
172
|
+
type_mapping ['addon', AddonDetails]
|
187
173
|
|
188
174
|
def initialize(addon)
|
189
175
|
@addon = addon
|
@@ -20,6 +20,21 @@ module KodiClient
|
|
20
20
|
LANGUAGE = 'language'
|
21
21
|
end
|
22
22
|
|
23
|
+
# represent application properties version
|
24
|
+
class Version
|
25
|
+
include Comparable
|
26
|
+
extend Creatable
|
27
|
+
|
28
|
+
attr_reader :major, :minor, :revision, :tag
|
29
|
+
|
30
|
+
def initialize(major, minor, revision, tag)
|
31
|
+
@major = major
|
32
|
+
@minor = minor
|
33
|
+
@revision = revision
|
34
|
+
@tag = tag
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
23
38
|
# Application.Property.Value https://kodi.wiki/view/JSON-RPC_API/v12#Application.Property.Value
|
24
39
|
class PropertyValue
|
25
40
|
include Comparable
|
@@ -27,12 +42,7 @@ module KodiClient
|
|
27
42
|
|
28
43
|
attr_reader :name, :version, :muted, :volume
|
29
44
|
|
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
|
45
|
+
type_mapping ['version', Version]
|
36
46
|
|
37
47
|
def initialize(name, version, muted, volume)
|
38
48
|
@name = name
|
@@ -41,21 +51,6 @@ module KodiClient
|
|
41
51
|
@volume = volume
|
42
52
|
end
|
43
53
|
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
54
|
end
|
60
55
|
end
|
61
56
|
end
|
@@ -38,9 +38,14 @@ module KodiClient
|
|
38
38
|
|
39
39
|
attr_reader :art, :date_added, :genre
|
40
40
|
|
41
|
+
def audio_details_base_mappings
|
42
|
+
mappings = { 'art' => Creatable::CreateMap.new(Types::Media::MediaArtwork) }
|
43
|
+
mappings.merge(media_details_base_mappings)
|
44
|
+
end
|
45
|
+
|
41
46
|
def audio_details_base_by_hash(hash)
|
42
|
-
audio_details_base(
|
43
|
-
|
47
|
+
audio_details_base(*Creatable.hash_to_arr(hash, %w[art date_added genre fan_art thumbnail label]),
|
48
|
+
audio_details_base_mappings)
|
44
49
|
end
|
45
50
|
|
46
51
|
def audio_details_base(art, date_added, genre, fan_art, thumbnail, label)
|
@@ -58,11 +63,16 @@ module KodiClient
|
|
58
63
|
attr_reader :artist, :artist_id, :display_artist, :musicbrainz_album_artist_id, :original_date, :rating,
|
59
64
|
:release_date, :sort_artist, :title, :user_rating, :votes, :year
|
60
65
|
|
66
|
+
def audio_details_media_mappings
|
67
|
+
audio_details_base_mappings
|
68
|
+
end
|
69
|
+
|
61
70
|
def audio_details_media_by_hash(hash)
|
62
|
-
audio_details_media(hash
|
63
|
-
|
64
|
-
|
65
|
-
|
71
|
+
audio_details_media(*Creatable.hash_to_arr(hash, %w[artist artist_id display_artist
|
72
|
+
musicbrainz_album_artist_id original_date rating
|
73
|
+
release_date sort_artist title user_rating votes year art
|
74
|
+
date_added genre fan_art thumbnail label],
|
75
|
+
audio_details_base_mappings))
|
66
76
|
end
|
67
77
|
|
68
78
|
def audio_details_media(artist, artist_id, display_artist, musicbrainz_album_artist_id, original_date,
|
@@ -83,6 +93,134 @@ module KodiClient
|
|
83
93
|
audio_details_base(art, date_added, genre, fan_art, thumbnail, label)
|
84
94
|
end
|
85
95
|
end
|
96
|
+
|
97
|
+
# Audio.Fields.Album https://kodi.wiki/view/JSON-RPC_API/v12#Audio.Fields.Album
|
98
|
+
module AudioFieldsAlbum
|
99
|
+
extend Iterable
|
100
|
+
|
101
|
+
#album id
|
102
|
+
ALBUM_DURATION = 'albumduration'
|
103
|
+
ALBUM_LABEL = 'albumlabel'
|
104
|
+
ALBUM_STATUS = 'albumstatus'
|
105
|
+
ART = 'art'
|
106
|
+
ARTIST = 'artist'
|
107
|
+
ARTIST_ID = 'artistid'
|
108
|
+
COMPILATION = 'compilation'
|
109
|
+
DATE_ADDED = 'dateadded'
|
110
|
+
DATE_MODIFIED = 'datemodified'
|
111
|
+
DATE_NEW = 'datenew'
|
112
|
+
DESCRIPTION = 'description'
|
113
|
+
DISPLAY_ARTIST = 'displayartist'
|
114
|
+
FAN_ART = 'fanart'
|
115
|
+
GENRE = 'genre'
|
116
|
+
IS_BOX_SET = 'isboxset'
|
117
|
+
LAST_PLAYED = 'lastplayed'
|
118
|
+
MOOD = 'mood'
|
119
|
+
MUSICBRAINZ_ALBUM_ARTIST_ID = 'musicbrainzalbumartistid'
|
120
|
+
MUSICBRAINZ_ALBUM_ID = 'musicbrainzalbumid'
|
121
|
+
MUSICBRAINZ_RELEASE_GROUP_ID = 'musicbrainzreleasegroupid'
|
122
|
+
ORIGINAL_DATE = 'originaldate'
|
123
|
+
PLAY_COUNT = 'playcount'
|
124
|
+
RATING = 'rating'
|
125
|
+
RELEASE_DATE = 'releasedate'
|
126
|
+
RELEASE_TYPE = 'releasetype'
|
127
|
+
SONG_GENRES = 'songgenres'
|
128
|
+
SORT_ARTIST = 'sortartist'
|
129
|
+
SOURCE_ID = 'sourceid'
|
130
|
+
STYLE = 'style'
|
131
|
+
THEME = 'theme'
|
132
|
+
THUMBNAIL = 'thumbnail'
|
133
|
+
TITLE = 'title'
|
134
|
+
TOTAL_DISCS = 'totaldiscs'
|
135
|
+
TYPE = 'type'
|
136
|
+
USER_RATING = 'userrating'
|
137
|
+
VOTES = 'votes'
|
138
|
+
YEAR = 'year'
|
139
|
+
end
|
140
|
+
|
141
|
+
# Audio.Details.Genres https://kodi.wiki/view/JSON-RPC_API/v12#Audio.Details.Genres
|
142
|
+
class Genre
|
143
|
+
include Comparable
|
144
|
+
extend Creatable
|
145
|
+
|
146
|
+
attr_reader :genre_id, :title
|
147
|
+
|
148
|
+
def initialize(genre_id, title)
|
149
|
+
@genre_id = genre_id
|
150
|
+
@title = title
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
# Audio.Details.Album https://kodi.wiki/view/JSON-RPC_API/v12#Audio.Details.Album
|
155
|
+
class DetailsAlbum
|
156
|
+
include AudioDetailsMedia
|
157
|
+
include Comparable
|
158
|
+
extend Creatable
|
159
|
+
|
160
|
+
attr_reader :album_duration, :album_id, :album_label, :album_status, :compilation, :date_modified, :date_new,
|
161
|
+
:description, :is_box_set, :last_played, :mood, :musicbrainz_album_id, :musicbrainz_release_group_id,
|
162
|
+
:play_count, :release_type, :song_genres, :source_id, :style, :theme, :total_discs, :type
|
163
|
+
|
164
|
+
fields_to_map %w[album_duration album_id album_label album_status art artist artist_id compilation date_added
|
165
|
+
date_modified date_new description display_artist fan_art genre is_box_set label last_played
|
166
|
+
mood musicbrainz_album_artist_id musicbrainz_album_id musicbrainz_release_group_id
|
167
|
+
original_date play_count rating release_date release_type song_genres sort_artist source_id
|
168
|
+
style theme thumbnail title total_discs type user_rating votes year]
|
169
|
+
|
170
|
+
type_mapping ['songgenres', Genre, true], ['art', Types::Media::MediaArtwork]
|
171
|
+
|
172
|
+
def initialize(album_duration, album_id, album_label, album_status, art, artist, artist_id, compilation,
|
173
|
+
date_added, date_modified, date_new, description, display_artist, fan_art, genre, is_box_set,
|
174
|
+
label, last_played, mood, musicbrainz_album_artist_id, musicbrainz_album_id,
|
175
|
+
musicbrainz_release_group_id, original_date, play_count, rating, release_date, release_type,
|
176
|
+
song_genres, sort_artist, source_id, style, theme, thumbnail, title, total_discs, type,
|
177
|
+
user_rating, votes, year)
|
178
|
+
@album_duration = album_duration
|
179
|
+
@album_id = album_id
|
180
|
+
@album_label = album_label
|
181
|
+
@album_status = album_status
|
182
|
+
@compilation = compilation
|
183
|
+
@date_modified = date_modified
|
184
|
+
@date_new = date_new
|
185
|
+
@description = description
|
186
|
+
@is_box_set = is_box_set
|
187
|
+
@last_played = last_played
|
188
|
+
@mood = mood
|
189
|
+
@musicbrainz_album_id = musicbrainz_album_id
|
190
|
+
@musicbrainz_release_group_id = musicbrainz_release_group_id
|
191
|
+
@play_count = play_count
|
192
|
+
@release_type = release_type
|
193
|
+
@song_genres = song_genres
|
194
|
+
@source_id = source_id
|
195
|
+
@style = style
|
196
|
+
@theme = theme
|
197
|
+
@total_discs = total_discs
|
198
|
+
@type = type
|
199
|
+
audio_details_media(artist, artist_id, display_artist, musicbrainz_album_artist_id, original_date,
|
200
|
+
rating, release_date, sort_artist, title, user_rating, votes, year,
|
201
|
+
art, date_added, genre, fan_art, thumbnail, label)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
# return type for AudioLibrary.GetAlbums
|
206
|
+
class GetAlbumsReturned
|
207
|
+
include Comparable
|
208
|
+
extend Creatable
|
209
|
+
|
210
|
+
attr_reader :albums, :limits
|
211
|
+
|
212
|
+
def self.lazy_type_mapping
|
213
|
+
{
|
214
|
+
'albums' => Creatable::CreateMap.new(DetailsAlbum, true),
|
215
|
+
'limits' => Creatable::CreateMap.new(List::ListLimitsReturned)
|
216
|
+
}
|
217
|
+
end
|
218
|
+
|
219
|
+
def initialize(albums, limits)
|
220
|
+
@albums = albums
|
221
|
+
@limits = limits
|
222
|
+
end
|
223
|
+
end
|
86
224
|
end
|
87
225
|
end
|
88
226
|
end
|
@@ -54,11 +54,7 @@ module KodiClient
|
|
54
54
|
|
55
55
|
attr_reader :favourites, :limits
|
56
56
|
|
57
|
-
|
58
|
-
favourites = DetailsFavourite.create_list(hash['favourites'])
|
59
|
-
limits = Types::List::ListLimitsReturned.create(hash['limits'])
|
60
|
-
new(favourites, limits)
|
61
|
-
end
|
57
|
+
type_mapping ['favourites', DetailsFavourite, true], ['limits', Types::List::ListLimitsReturned]
|
62
58
|
|
63
59
|
def initialize(favourites, limits)
|
64
60
|
@favourites = favourites
|
@@ -27,14 +27,7 @@ module KodiClient
|
|
27
27
|
|
28
28
|
attr_reader :files, :limits
|
29
29
|
|
30
|
-
|
31
|
-
return nil if hash.nil?
|
32
|
-
|
33
|
-
files = Types::List::ListItemFile.create_list(hash['files'])
|
34
|
-
limits = Types::List::ListLimitsReturned.create(hash['limits'])
|
35
|
-
|
36
|
-
new(files, limits)
|
37
|
-
end
|
30
|
+
type_mapping ['files', List::ListItemFile, true], ['limits', List::ListLimitsReturned]
|
38
31
|
|
39
32
|
def initialize(files, limits)
|
40
33
|
@files = files
|
@@ -49,14 +42,7 @@ module KodiClient
|
|
49
42
|
|
50
43
|
attr_reader :sources, :limits
|
51
44
|
|
52
|
-
|
53
|
-
return nil if hash.nil?
|
54
|
-
|
55
|
-
sources = Types::List::FileLabel.create_list(hash['sources'])
|
56
|
-
limits = Types::List::ListLimitsReturned.create(hash['limits'])
|
57
|
-
|
58
|
-
new(sources, limits)
|
59
|
-
end
|
45
|
+
type_mapping ['sources', List::FileLabel, true], ['limits', List::ListLimitsReturned]
|
60
46
|
|
61
47
|
def initialize(sources, limits)
|
62
48
|
@sources = sources
|
@@ -168,15 +168,8 @@ module KodiClient
|
|
168
168
|
|
169
169
|
attr_reader :current_control, :current_window, :fullscreen, :skin, :stereoscopic_mode
|
170
170
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
current_control = Global::IdLabel.create(hash['currentcontrol'])
|
175
|
-
current_window = Global::IdLabel.create(hash['currentwindow'])
|
176
|
-
skin = Global::IdName.create(hash['skin'])
|
177
|
-
stereoscopic_mode = StereoscopyMode.create(hash['stereoscopicmode'])
|
178
|
-
new(current_control, current_window, hash['fullscreen'], skin, stereoscopic_mode)
|
179
|
-
end
|
171
|
+
type_mapping ['currentcontrol', Global::IdLabel], ['currentwindow', Global::IdLabel],
|
172
|
+
['skin', Global::IdName], ['stereoscopicmode', StereoscopyMode]
|
180
173
|
|
181
174
|
def initialize(current_control, current_window, fullscreen, skin, stereoscopic_mode)
|
182
175
|
@current_control = current_control
|
@@ -9,8 +9,12 @@ module KodiClient
|
|
9
9
|
|
10
10
|
attr_reader :label
|
11
11
|
|
12
|
+
def item_details_base_mappings
|
13
|
+
{}
|
14
|
+
end
|
15
|
+
|
12
16
|
def item_details_base_by_hash(hash)
|
13
|
-
item_details_base(hash[
|
17
|
+
item_details_base(*Creatable.hash_to_arr(hash, %w[label], item_details_base_mappings))
|
14
18
|
end
|
15
19
|
|
16
20
|
def item_details_base(label)
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'kodi_client/util/comparable'
|
4
4
|
require 'kodi_client/util/creatable'
|
5
|
+
require 'kodi_client/util/iterable'
|
5
6
|
require 'kodi_client/global_types/video_types'
|
6
7
|
require 'kodi_client/global_types/audio_types'
|
7
8
|
|
@@ -28,11 +29,7 @@ module KodiClient
|
|
28
29
|
|
29
30
|
attr_reader :list_start, :list_end, :total
|
30
31
|
|
31
|
-
|
32
|
-
return nil if hash.nil?
|
33
|
-
|
34
|
-
new(hash['start'], hash['end'], hash['total'])
|
35
|
-
end
|
32
|
+
fields_to_map %w[start end total]
|
36
33
|
|
37
34
|
def initialize(list_start, list_end, total)
|
38
35
|
@list_start = list_start
|
@@ -257,31 +254,34 @@ module KodiClient
|
|
257
254
|
:special_sort_season, :studio, :style, :tag, :tag_line, :theme, :top250, :total_discs, :track,
|
258
255
|
:trailer, :tv_show_id, :type, :unique_id, :votes, :watched_episodes, :writer
|
259
256
|
|
257
|
+
def list_item_base_mappings
|
258
|
+
mappings = {
|
259
|
+
'cast' => Creatable::CreateMap.new(Video::VideoCast, true),
|
260
|
+
'contributors' => Creatable::CreateMap.new(Audio::AudioContributor, true),
|
261
|
+
'resume' => Creatable::CreateMap.new(Video::VideoResume),
|
262
|
+
'streamdetails' => Creatable::CreateMap.new(Video::Streams),
|
263
|
+
'art' => Creatable::CreateMap.new(Media::MediaArtwork)
|
264
|
+
}
|
265
|
+
mappings.merge(video_details_file_mappings).merge(audio_details_media_mappings)
|
266
|
+
end
|
267
|
+
|
260
268
|
def list_item_base_by_hash(hash)
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
special_sort_episode special_sort_season studio style tag
|
278
|
-
tag_line theme top250 total_discs track trailer tv_show_id
|
279
|
-
type unique_id votes watched_episodes writer director]),
|
280
|
-
resume, hash['runtime'], stream_details,
|
281
|
-
*Creatable.hash_to_arr(hash, %w[date_added file last_played plot title]), art,
|
282
|
-
*Creatable.hash_to_arr(hash, %w[play_count fan_art thumbnail label artist artist_id
|
283
|
-
display_artist musicbrainz_album_artist_id rating sort_artist
|
284
|
-
user_rating year genre]))
|
269
|
+
return nil if hash.nil?
|
270
|
+
|
271
|
+
list_item_base(*Creatable.hash_to_arr(
|
272
|
+
hash, %w[album album_artist album_artist_id album_id album_release_type album_status bit_rate
|
273
|
+
bpm cast channels comment compilation contributors country description disc
|
274
|
+
disc_title display_composer display_conductor display_lyricist display_orchestra
|
275
|
+
duration dyn_path episode episode_guide first_aired id imdb_number is_box_set
|
276
|
+
lyrics media_path mood mpaa musicbrainz_artist_id musicbrainz_track_id original_date
|
277
|
+
original_title plot_outline premiered production_code release_date release_type
|
278
|
+
sample_rate season set set_id show_link show_title sort_title special_sort_episode
|
279
|
+
special_sort_season studio style tag tag_line theme top250 total_discs track
|
280
|
+
trailer tv_show_id type unique_id votes watched_episodes writer director resume
|
281
|
+
runtime stream_details date_added file last_played plot title art play_count
|
282
|
+
fan_art thumbnail label artist artist_id display_artist musicbrainz_album_artist_id
|
283
|
+
rating sort_artist user_rating year genre], list_item_base_mappings
|
284
|
+
))
|
285
285
|
end
|
286
286
|
|
287
287
|
def list_item_base(album, album_artist, album_artist_id, album_id, album_release_type, album_status, bit_rate,
|
@@ -375,38 +375,27 @@ module KodiClient
|
|
375
375
|
include ListItemBase
|
376
376
|
include Comparable
|
377
377
|
extend Creatable
|
378
|
+
extend ListItemBase
|
378
379
|
|
379
380
|
attr_reader :channel, :channel_number, :channel_type, :end_time, :hidden, :locked, :start_time,
|
380
381
|
:sub_channel_number
|
381
382
|
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
is_box_set lyrics media_path mood mpaa musicbrainz_artist_id
|
399
|
-
musicbrainz_track_id original_date original_title plot_outline
|
400
|
-
premiered production_code release_date release_type sample_rate
|
401
|
-
season set set_id show_link show_title sort_title
|
402
|
-
special_sort_episode special_sort_season studio style tag
|
403
|
-
tag_line theme top250 total_discs track trailer tv_show_id
|
404
|
-
type unique_id votes watched_episodes writer director]),
|
405
|
-
resume, hash['runtime'], stream_details,
|
406
|
-
*Creatable.hash_to_arr(hash, %w[date_added file last_played plot title]), art,
|
407
|
-
*Creatable.hash_to_arr(hash, %w[play_count fan_art thumbnail label artist artist_id
|
408
|
-
display_artist musicbrainz_album_artist_id rating sort_artist
|
409
|
-
user_rating year genre]))
|
383
|
+
fields_to_map %w[channel channel_number channel_type end_time hidden locked start_time sub_channel_number
|
384
|
+
album album_artist album_artist_id album_id album_release_type album_status bit_rate
|
385
|
+
bpm cast channels comment compilation contributors country description disc
|
386
|
+
disc_title display_composer display_conductor display_lyricist display_orchestra
|
387
|
+
duration dyn_path episode episode_guide first_aired id imdb_number is_box_set
|
388
|
+
lyrics media_path mood mpaa musicbrainz_artist_id musicbrainz_track_id original_date
|
389
|
+
original_title plot_outline premiered production_code release_date release_type
|
390
|
+
sample_rate season set set_id show_link show_title sort_title special_sort_episode
|
391
|
+
special_sort_season studio style tag tag_line theme top250 total_discs track
|
392
|
+
trailer tv_show_id type unique_id votes watched_episodes writer director resume
|
393
|
+
runtime stream_details date_added file last_played plot title art play_count
|
394
|
+
fan_art thumbnail label artist artist_id display_artist musicbrainz_album_artist_id
|
395
|
+
rating sort_artist user_rating year genre]
|
396
|
+
|
397
|
+
def self.lazy_type_mapping
|
398
|
+
list_item_base_mappings
|
410
399
|
end
|
411
400
|
|
412
401
|
def initialize(channel, channel_number, channel_type, end_time, hidden, locked, start_time, sub_channel_number,
|
@@ -422,7 +411,6 @@ module KodiClient
|
|
422
411
|
runtime, stream_details, date_added, file, last_played, plot, title, art, play_count,
|
423
412
|
fan_art, thumbnail, label, artist, artist_id, display_artist, musicbrainz_album_artist_id,
|
424
413
|
rating, sort_artist, user_rating, year, genre)
|
425
|
-
|
426
414
|
@channel = channel
|
427
415
|
@channel_number = channel_number
|
428
416
|
@channel_type = channel_type
|
@@ -431,6 +419,7 @@ module KodiClient
|
|
431
419
|
@locked = locked
|
432
420
|
@start_time = start_time
|
433
421
|
@sub_channel_number = sub_channel_number
|
422
|
+
type = type.nil? ? 'unknown' : type
|
434
423
|
|
435
424
|
list_item_base(album, album_artist, album_artist_id, album_id, album_release_type, album_status, bit_rate,
|
436
425
|
bpm, cast, channels, comment, compilation, contributors, country, description, disc,
|
@@ -452,37 +441,26 @@ module KodiClient
|
|
452
441
|
include ListItemBase
|
453
442
|
include Comparable
|
454
443
|
extend Creatable
|
444
|
+
extend ListItemBase
|
455
445
|
|
456
446
|
attr_reader :file, :file_type, :last_modified, :mime_type, :size
|
457
447
|
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
is_box_set lyrics media_path mood mpaa musicbrainz_artist_id
|
475
|
-
musicbrainz_track_id original_date original_title plot_outline
|
476
|
-
premiered production_code release_date release_type sample_rate
|
477
|
-
season set set_id show_link show_title sort_title
|
478
|
-
special_sort_episode special_sort_season studio style tag
|
479
|
-
tag_line theme top250 total_discs track trailer tv_show_id
|
480
|
-
type unique_id votes watched_episodes writer director]),
|
481
|
-
resume, hash['runtime'], stream_details,
|
482
|
-
*Creatable.hash_to_arr(hash, %w[date_added file last_played plot title]), art,
|
483
|
-
*Creatable.hash_to_arr(hash, %w[play_count fan_art thumbnail label artist artist_id
|
484
|
-
display_artist musicbrainz_album_artist_id rating sort_artist
|
485
|
-
user_rating year genre]))
|
448
|
+
fields_to_map %w[file_type last_modified mime_type size
|
449
|
+
album album_artist album_artist_id album_id album_release_type album_status bit_rate
|
450
|
+
bpm cast channels comment compilation contributors country description disc
|
451
|
+
disc_title display_composer display_conductor display_lyricist display_orchestra
|
452
|
+
duration dyn_path episode episode_guide first_aired id imdb_number is_box_set
|
453
|
+
lyrics media_path mood mpaa musicbrainz_artist_id musicbrainz_track_id original_date
|
454
|
+
original_title plot_outline premiered production_code release_date release_type
|
455
|
+
sample_rate season set set_id show_link show_title sort_title special_sort_episode
|
456
|
+
special_sort_season studio style tag tag_line theme top250 total_discs track
|
457
|
+
trailer tv_show_id type unique_id votes watched_episodes writer director resume
|
458
|
+
runtime stream_details date_added file last_played plot title art play_count
|
459
|
+
fan_art thumbnail label artist artist_id display_artist musicbrainz_album_artist_id
|
460
|
+
rating sort_artist user_rating year genre]
|
461
|
+
|
462
|
+
def self.lazy_type_mapping
|
463
|
+
list_item_base_mappings
|
486
464
|
end
|
487
465
|
|
488
466
|
def initialize(file_type, last_modified, mime_type, size,
|
@@ -503,6 +481,7 @@ module KodiClient
|
|
503
481
|
@last_modified = last_modified
|
504
482
|
@mime_type = mime_type
|
505
483
|
@size = size
|
484
|
+
type = type.nil? ? 'unknown' : type
|
506
485
|
list_item_base(album, album_artist, album_artist_id, album_id, album_release_type, album_status, bit_rate,
|
507
486
|
bpm, cast, channels, comment, compilation, contributors, country, description, disc,
|
508
487
|
disc_title, display_composer, display_conductor, display_lyricist, display_orchestra,
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'kodi_client/global_types/item_types'
|
4
4
|
require 'kodi_client/util/comparable'
|
5
5
|
require 'kodi_client/util/creatable'
|
6
|
+
require 'kodi_client/util/iterable'
|
6
7
|
|
7
8
|
module KodiClient
|
8
9
|
module Types
|
@@ -23,10 +24,12 @@ module KodiClient
|
|
23
24
|
|
24
25
|
attr_reader :fan_art, :thumbnail
|
25
26
|
|
27
|
+
def media_details_base_mappings
|
28
|
+
item_details_base_mappings
|
29
|
+
end
|
30
|
+
|
26
31
|
def media_details_base_by_hash(hash)
|
27
|
-
|
28
|
-
@thumbnail = hash['thumbnail']
|
29
|
-
item_details_base_by_hash(hash)
|
32
|
+
media_details_base(*Creatable.hash_to_arr(hash, %w[fan_art thumbnail label]), media_details_base_mappings)
|
30
33
|
end
|
31
34
|
|
32
35
|
def media_details_base(fan_art, thumbnail, label)
|
@@ -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
|
@@ -195,35 +196,20 @@ module KodiClient
|
|
195
196
|
:live, :party_mode, :percentage, :playlist_id, :position, :repeat, :shuffled, :speed,
|
196
197
|
:subtitle_enabled, :subtitles, :time, :total_time, :type, :video_streams
|
197
198
|
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
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
|
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]
|
222
203
|
|
223
204
|
def initialize(audio_streams, cache_percentage, can_change_speed, can_move, can_repeat, can_rotate, can_seek,
|
224
205
|
can_shuffle, can_zoom, current_audio_stream, current_subtitle, current_video_stream, live,
|
225
206
|
party_mode, percentage, playlist_id, position, repeat, shuffled, speed,
|
226
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
|
+
|
227
213
|
@audio_streams = audio_streams
|
228
214
|
@cache_percentage = cache_percentage
|
229
215
|
@can_change_speed = can_change_speed
|
@@ -299,14 +285,9 @@ module KodiClient
|
|
299
285
|
include Comparable
|
300
286
|
extend Creatable
|
301
287
|
|
302
|
-
|
303
|
-
return nil if hash.nil?
|
288
|
+
attr_reader :percentage, :time, :total_time
|
304
289
|
|
305
|
-
|
306
|
-
total_time = Types::Global::GlobalTime.create(hash['totaltime'])
|
307
|
-
|
308
|
-
new(hash['percentage'], time, total_time)
|
309
|
-
end
|
290
|
+
type_mapping ['time', Global::GlobalTime], ['totaltime', Global::GlobalTime]
|
310
291
|
|
311
292
|
def initialize(percentage, time, total_time)
|
312
293
|
@percentage = percentage
|
@@ -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
|
@@ -24,11 +25,7 @@ module KodiClient
|
|
24
25
|
|
25
26
|
attr_reader :lock_mode, :thumbnail
|
26
27
|
|
27
|
-
|
28
|
-
return nil if hash.nil?
|
29
|
-
|
30
|
-
new(*Creatable.hash_to_arr(hash, %w[lock_mode thumbnail label]))
|
31
|
-
end
|
28
|
+
fields_to_map %w[lock_mode thumbnail label]
|
32
29
|
|
33
30
|
def initialize(lock_mode, thumbnail, label)
|
34
31
|
@lock_mode = lock_mode
|
@@ -48,14 +45,7 @@ module KodiClient
|
|
48
45
|
|
49
46
|
attr_reader :limits, :profiles
|
50
47
|
|
51
|
-
|
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
|
48
|
+
type_mapping ['limits', List::ListLimitsReturned], ['profiles', DetailsProfile, true]
|
59
49
|
|
60
50
|
def initialize(limits, profiles)
|
61
51
|
@limits = limits
|
@@ -8,16 +8,19 @@ require 'kodi_client/util/creatable'
|
|
8
8
|
module KodiClient
|
9
9
|
module Types
|
10
10
|
module Video
|
11
|
-
|
12
11
|
# Video.Details.Base https://kodi.wiki/view/JSON-RPC_API/v12#Video.Details.Base
|
13
12
|
module VideoDetailsBase
|
14
13
|
include Media::MediaDetailsBase
|
15
14
|
|
16
15
|
attr_reader :art, :play_count
|
17
16
|
|
17
|
+
def video_details_base_mappings
|
18
|
+
media_details_base_mappings
|
19
|
+
end
|
20
|
+
|
18
21
|
def video_details_base_by_hash(hash)
|
19
|
-
|
20
|
-
|
22
|
+
video_details_base(*Creatable.hash_to_arr(hash, %w[art play_count fan_art thumbnail label],
|
23
|
+
video_details_base_mappings))
|
21
24
|
end
|
22
25
|
|
23
26
|
def video_details_base(art, play_count, fan_art, thumbnail, label)
|
@@ -48,9 +51,13 @@ module KodiClient
|
|
48
51
|
|
49
52
|
attr_reader :title
|
50
53
|
|
54
|
+
def video_details_media_mappings
|
55
|
+
video_details_base_mappings
|
56
|
+
end
|
57
|
+
|
51
58
|
def video_details_media_by_hash(hash)
|
52
|
-
|
53
|
-
|
59
|
+
video_details_media(*Creatable.hash_to_arr(hash, %w[title art play_count fan_art thumbnail label]),
|
60
|
+
video_details_base_mappings)
|
54
61
|
end
|
55
62
|
|
56
63
|
def video_details_media(title, art, play_count, fan_art, thumbnail, label)
|
@@ -65,10 +72,14 @@ module KodiClient
|
|
65
72
|
|
66
73
|
attr_reader :date_added, :file, :last_played, :plot
|
67
74
|
|
75
|
+
def video_details_item_mappings
|
76
|
+
video_details_media_mappings
|
77
|
+
end
|
78
|
+
|
68
79
|
def video_details_item_by_hash(hash)
|
69
|
-
|
70
|
-
|
71
|
-
|
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))
|
72
83
|
end
|
73
84
|
|
74
85
|
def video_details_item(date_added, file, last_played, plot, title, art, play_count, fan_art, thumbnail, label)
|
@@ -86,13 +97,18 @@ module KodiClient
|
|
86
97
|
|
87
98
|
attr_reader :director, :resume, :runtime, :stream_details
|
88
99
|
|
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
|
+
|
89
108
|
def video_details_file_by_hash(hash)
|
90
|
-
|
91
|
-
|
92
|
-
|
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]))
|
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))
|
96
112
|
end
|
97
113
|
|
98
114
|
def video_details_file(director, resume, runtime, stream_details, date_added, file, last_played, plot, title,
|
@@ -125,14 +141,8 @@ module KodiClient
|
|
125
141
|
|
126
142
|
attr_reader :audio, :subtitle, :video
|
127
143
|
|
128
|
-
|
129
|
-
|
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
|
144
|
+
type_mapping ['audio', Player::AudioStream, true], ['subtitle', Player::Subtitle, true],
|
145
|
+
['video', Player::VideoStream, true]
|
136
146
|
|
137
147
|
def initialize(audio, subtitle, video)
|
138
148
|
@audio = audio
|
@@ -34,11 +34,8 @@ module KodiClient
|
|
34
34
|
end
|
35
35
|
|
36
36
|
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
|
-
})
|
37
|
+
request = KodiRequest.new(kodi_id, GET_ADDON_DETAILS, { 'addonid' => addon_id,
|
38
|
+
'properties' => properties })
|
42
39
|
json = invoke_api(request)
|
43
40
|
|
44
41
|
result = Types::Addons::Addon.create(json['result'])
|
@@ -47,22 +44,14 @@ module KodiClient
|
|
47
44
|
end
|
48
45
|
|
49
46
|
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
|
-
})
|
47
|
+
request = KodiRequest.new(kodi_id, EXECUTE_ADDON, { 'addonid' => addon_id, 'params' => params,
|
48
|
+
'wait' => wait })
|
56
49
|
json = invoke_api(request)
|
57
50
|
KodiResponse.new(json)
|
58
51
|
end
|
59
52
|
|
60
53
|
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
|
-
})
|
54
|
+
request = KodiRequest.new(kodi_id, SET_ADDON_ENABLED, { 'addonid' => addon_id, 'enabled' => enabled })
|
66
55
|
json = invoke_api(request)
|
67
56
|
KodiResponse.new(json)
|
68
57
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'kodi_client/kodi_module'
|
4
|
+
require 'kodi_client/global_types/application_types'
|
5
|
+
|
6
|
+
module KodiClient
|
7
|
+
module Modules
|
8
|
+
# contains all Kodi Application methods
|
9
|
+
class AudioLibrary < KodiModule
|
10
|
+
|
11
|
+
CLEAN = 'AudioLibrary.Clean'
|
12
|
+
EXPORT = 'AudioLibrary.Export'
|
13
|
+
GET_ALBUM_DETAILS = 'AudioLibrary.GetAlbumDetails'
|
14
|
+
GET_ALBUMS = 'AudioLibrary.GetAlbums'
|
15
|
+
|
16
|
+
def clean(show_dialogs = true, kodi_id = 1)
|
17
|
+
request = KodiRequest.new(kodi_id, CLEAN, { 'showdialogs' => show_dialogs })
|
18
|
+
json = invoke_api(request)
|
19
|
+
KodiResponse.new(json)
|
20
|
+
end
|
21
|
+
|
22
|
+
def export(path, kodi_id = 1)
|
23
|
+
request = KodiRequest.new(kodi_id, EXPORT, { 'options' => { 'path' => path } })
|
24
|
+
json = invoke_api(request)
|
25
|
+
KodiResponse.new(json)
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_album_details(album_id, properties = Types::Audio::AudioFieldsAlbum.all_properties, kodi_id = 1)
|
29
|
+
request = KodiRequest.new(kodi_id, GET_ALBUM_DETAILS, { 'albumid' => album_id, 'properties' => properties })
|
30
|
+
json = invoke_api(request)
|
31
|
+
KodiResponse.new(json)
|
32
|
+
end
|
33
|
+
|
34
|
+
def get_albums(properties = Types::Audio::AudioFieldsAlbum.all_properties,
|
35
|
+
limits = Types::List::ListLimits.new(0, 50),
|
36
|
+
sort = Types::List::ListSort.new, include_singles = false, all_roles = false, kodi_id = 1)
|
37
|
+
request = KodiRequest.new(kodi_id, GET_ALBUMS,
|
38
|
+
{ 'properties' => properties,
|
39
|
+
'limits' => { 'start' => limits.list_start, 'end' => limits.list_end },
|
40
|
+
'sort' => { 'ignorearticle' => sort.ignore_article, 'method' => sort.method,
|
41
|
+
'order' => sort.order,
|
42
|
+
'useartistsortname' => sort.use_artist_sort_name },
|
43
|
+
'includesingles' => include_singles, 'allroles' => all_roles })
|
44
|
+
json = invoke_api(request)
|
45
|
+
KodiResponse.new(json)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -5,6 +5,68 @@ module KodiClient
|
|
5
5
|
# creates a create and create_list method by hash
|
6
6
|
module Creatable
|
7
7
|
|
8
|
+
def fields_to_map(fields)
|
9
|
+
@fields_to_map = fields
|
10
|
+
end
|
11
|
+
|
12
|
+
def type_mapping(*args)
|
13
|
+
return if args.nil?
|
14
|
+
|
15
|
+
@type_mapping = {}
|
16
|
+
args.map { |it| @type_mapping[it[0]] = Creatable::CreateMap.new(it[1], it[2].nil? ? false : it[2]) }
|
17
|
+
end
|
18
|
+
|
19
|
+
def lazy_type_mapping
|
20
|
+
{}
|
21
|
+
end
|
22
|
+
|
23
|
+
def create_list(hash)
|
24
|
+
hash.nil? ? [] : hash.map { |it| create(it) }.reject(&:nil?)
|
25
|
+
end
|
26
|
+
|
27
|
+
def create(hash)
|
28
|
+
return nil if hash.nil?
|
29
|
+
|
30
|
+
if @fields_to_map.nil? || @fields_to_map.empty?
|
31
|
+
fields = @kodi_fields
|
32
|
+
return nil if @kodi_fields.none? { |it| !hash[it.to_s.gsub('_', '')].nil? }
|
33
|
+
else
|
34
|
+
fields = @fields_to_map
|
35
|
+
end
|
36
|
+
|
37
|
+
mapping = @type_mapping.nil? ? lazy_type_mapping : @type_mapping
|
38
|
+
args = fields.map do |it|
|
39
|
+
field = it.to_s.gsub('_', '')
|
40
|
+
Creatable.extract_field_from_hash(field, hash, mapping)
|
41
|
+
end
|
42
|
+
|
43
|
+
new(*args)
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.hash_to_arr(hash, fields, mapping = {})
|
47
|
+
return nil if hash.nil?
|
48
|
+
|
49
|
+
fields.map do |it|
|
50
|
+
field = it.to_s.gsub('_', '')
|
51
|
+
extract_field_from_hash(field, hash, mapping)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def hash_to_arr(hash, fields)
|
56
|
+
Creatable.hash_to_arr(hash, fields, @type_mapping.nil? ? {} : @type_mapping)
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.extract_field_from_hash(field, hash, mapping)
|
60
|
+
map = mapping[field]
|
61
|
+
return nil if hash[field].nil? && map.nil?
|
62
|
+
|
63
|
+
return hash[field] if map.nil?
|
64
|
+
|
65
|
+
return map.type.create_list(hash[field]) if map.is_list
|
66
|
+
|
67
|
+
map.type.create(hash[field])
|
68
|
+
end
|
69
|
+
|
8
70
|
def attr_accessor(*args)
|
9
71
|
attr_reader(*args)
|
10
72
|
attr_writer(*args)
|
@@ -30,23 +92,15 @@ module KodiClient
|
|
30
92
|
end
|
31
93
|
end
|
32
94
|
|
33
|
-
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
def create(hash)
|
38
|
-
return nil if hash.nil?
|
39
|
-
return nil if @kodi_fields.none? { |it| !hash[it].nil? }
|
95
|
+
# mapping class with the type and if it is a list field or not
|
96
|
+
class CreateMap
|
40
97
|
|
41
|
-
|
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
|
98
|
+
attr_reader :type, :is_list
|
47
99
|
|
48
|
-
|
49
|
-
|
100
|
+
def initialize(type, is_list = false)
|
101
|
+
@type = type
|
102
|
+
@is_list = is_list
|
103
|
+
end
|
50
104
|
end
|
51
105
|
end
|
52
106
|
end
|
data/lib/kodi_client.rb
CHANGED
@@ -5,6 +5,7 @@ require 'json'
|
|
5
5
|
|
6
6
|
require 'kodi_client/Chainable'
|
7
7
|
require 'kodi_client/method/addons'
|
8
|
+
require 'kodi_client/method/audio_library'
|
8
9
|
require 'kodi_client/method/application'
|
9
10
|
require 'kodi_client/method/favourites'
|
10
11
|
require 'kodi_client/method/files'
|
@@ -23,10 +24,11 @@ module KodiClient
|
|
23
24
|
class Client
|
24
25
|
include Chainable
|
25
26
|
|
26
|
-
attr_reader :addons, :application, :favourites, :files, :gui, :input, :player, :profiles, :system
|
27
|
+
attr_reader :audio_library, :addons, :application, :favourites, :files, :gui, :input, :player, :profiles, :system
|
27
28
|
|
28
29
|
def initialize
|
29
30
|
@addons = KodiClient::Modules::Addons.new
|
31
|
+
@audio_library = KodiClient::Modules::AudioLibrary.new
|
30
32
|
@application = KodiClient::Modules::Application.new
|
31
33
|
@favourites = KodiClient::Modules::Favourites.new
|
32
34
|
@files = KodiClient::Modules::Files.new
|
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.6.
|
4
|
+
version: 0.6.1
|
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-
|
11
|
+
date: 2021-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- lib/kodi_client/kodi_module.rb
|
63
63
|
- lib/kodi_client/method/addons.rb
|
64
64
|
- lib/kodi_client/method/application.rb
|
65
|
+
- lib/kodi_client/method/audio_library.rb
|
65
66
|
- lib/kodi_client/method/favourites.rb
|
66
67
|
- lib/kodi_client/method/files.rb
|
67
68
|
- lib/kodi_client/method/gui.rb
|