kodi_client 0.5.5 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -1
  3. data/kodi_client.gemspec +3 -3
  4. data/lib/kodi_client/Chainable.rb +3 -1
  5. data/lib/kodi_client/global_types/addon_types.rb +50 -52
  6. data/lib/kodi_client/global_types/application_types.rb +21 -23
  7. data/lib/kodi_client/global_types/audio_types.rb +179 -29
  8. data/lib/kodi_client/global_types/favourites_types.rb +14 -17
  9. data/lib/kodi_client/global_types/files_types.rb +68 -0
  10. data/lib/kodi_client/global_types/global_types.rb +18 -24
  11. data/lib/kodi_client/global_types/gui_types.rb +15 -16
  12. data/lib/kodi_client/global_types/item_types.rb +10 -2
  13. data/lib/kodi_client/global_types/list_types.rb +326 -98
  14. data/lib/kodi_client/global_types/media_types.rb +21 -13
  15. data/lib/kodi_client/global_types/player_type.rb +110 -110
  16. data/lib/kodi_client/global_types/profiles_types.rb +14 -14
  17. data/lib/kodi_client/global_types/system_types.rb +7 -9
  18. data/lib/kodi_client/global_types/video_types.rb +80 -43
  19. data/lib/kodi_client/method/addons.rb +7 -19
  20. data/lib/kodi_client/method/application.rb +1 -1
  21. data/lib/kodi_client/method/audio_library.rb +49 -0
  22. data/lib/kodi_client/method/favourites.rb +1 -1
  23. data/lib/kodi_client/method/files.rb +89 -0
  24. data/lib/kodi_client/method/gui.rb +2 -2
  25. data/lib/kodi_client/method/player.rb +6 -6
  26. data/lib/kodi_client/method/profiles.rb +2 -2
  27. data/lib/kodi_client/method/system.rb +1 -1
  28. data/lib/kodi_client/util/comparable.rb +4 -1
  29. data/lib/kodi_client/util/creatable.rb +106 -0
  30. data/lib/kodi_client.rb +10 -22
  31. metadata +9 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3f04d9b1f829af8765bb790f49accaa47bebd71b1d4e1755b1776782d089fdb
4
- data.tar.gz: 29d45652a206f4d32c05103a520eb984c5925a775dfe9479535b57d6d5d3a477
3
+ metadata.gz: 5fea7dad06fe723225e4d8bf268db09490af87c98a74f653e5966f170d1156fd
4
+ data.tar.gz: a4d8a3dfcac1a85abbf1c073b0c2f6016de9de9d07249eabc5067fe47c829727
5
5
  SHA512:
6
- metadata.gz: 17431c4ec21d3b0f315847aacca3efd821afb1d4d0dcee1deae25196b4ad0a74effb6b08e53a6a97c727dd5302eef409560e55b39ee02f002e55bd73e01eefda
7
- data.tar.gz: 3461b3f8babd1636c722a4d2fab9ac8391446c4f0144f8c744a87555fe155b1b7197ccd1f559951fef133ba9324934a89a9ea75682388efaf68d45e71b70f42a
6
+ metadata.gz: 031fcbe6dc03750fa90d3b8d395f903082d6b2b8586f3fe49ff3d9d5ca3375501e2b8e34305808399026de10bd62a5cfc00bf3ad5fc505cb5043e47ba2cdc85f
7
+ data.tar.gz: 6e9622971b0e8737130feddefca5ac49a8efd4073dd4ec9719b524c2cb7ba3781e915322a03bd1ffac63fe4ab48b3ed1428a83135a69223add9a041b8ff1288d
data/README.md CHANGED
@@ -6,10 +6,11 @@ Currently implemented are the following Methods:
6
6
  * Addons
7
7
  * Application
8
8
  * Favourites
9
+ * Files
9
10
  * GUI
10
11
  * Input
11
12
  * Player
12
- * Profile
13
+ * Profiles
13
14
  * System
14
15
 
15
16
  ## Installation
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.5'
5
+ spec.version = '0.6.1'
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, '\
11
- 'favourites, gui, input, player, profile and system (more will be added with the time). '\
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'
@@ -24,7 +24,7 @@ module KodiClient
24
24
  client = def_client
25
25
  options = def_options
26
26
  set_command.call(options)
27
- client.apply_options(options)
27
+ client.apply_options_to_methods(options)
28
28
  client
29
29
  end
30
30
 
@@ -43,5 +43,7 @@ module KodiClient
43
43
  end
44
44
  @options
45
45
  end
46
+
47
+ private :def_client, :def_options, :merge_options
46
48
  end
47
49
  end
@@ -1,8 +1,10 @@
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'
7
+ require 'kodi_client/util/creatable'
6
8
 
7
9
  module KodiClient
8
10
  module Types
@@ -10,7 +12,7 @@ module KodiClient
10
12
 
11
13
  # Addon Types https://kodi.wiki/view/JSON-RPC_API/v12#Addon.Types
12
14
  module AddonTypes
13
- include Iterable
15
+ extend Iterable
14
16
 
15
17
  UNKNOWN = 'unknown'
16
18
  KODI_ADSP = 'kodi.adsp'
@@ -51,7 +53,8 @@ module KodiClient
51
53
 
52
54
  # Addon.Content https://kodi.wiki/view/JSON-RPC_API/v12#Addon.Content
53
55
  module AddonContent
54
- include Iterable
56
+ extend Iterable
57
+
55
58
  UNKNOWN = 'unknown'
56
59
  AUDIO = 'audio'
57
60
  EXECUTABLE = 'executable'
@@ -83,33 +86,27 @@ module KodiClient
83
86
  # represents addon dependency
84
87
  class AddonDependency
85
88
  include Comparable
89
+ extend Creatable
86
90
 
87
- attr_reader :addonid, :optional, :version
91
+ attr_reader :addon_id, :optional, :version
88
92
 
89
- def initialize(hash)
90
- @addonid = hash['addonid']
91
- @optional = hash['optional']
92
- @version = hash['version']
93
- end
94
-
95
- def ==(other)
96
- compare(self, other)
93
+ def initialize(addon_id, optional, version)
94
+ @addon_id = addon_id
95
+ @optional = optional
96
+ @version = version
97
97
  end
98
98
  end
99
99
 
100
100
  # represents addon extra info
101
101
  class AddonExtraInfo
102
102
  include Comparable
103
+ extend Creatable
103
104
 
104
105
  attr_reader :key, :value
105
106
 
106
- def initialize(hash)
107
- @key = hash['key']
108
- @value = hash['value']
109
- end
110
-
111
- def ==(other)
112
- compare(self, other)
107
+ def initialize(key, value)
108
+ @key = key
109
+ @value = value
113
110
  end
114
111
  end
115
112
 
@@ -117,64 +114,65 @@ module KodiClient
117
114
  class AddonDetails
118
115
  include Comparable
119
116
  include Items::ItemDetailsBase
117
+ extend Creatable
120
118
 
121
119
  attr_reader :addon_id, :author, :broken, :dependencies, :description, :disclaimer, :enabled, :extra_info,
122
120
  :fan_art, :installed, :name, :path, :rating, :summary, :thumbnail, :type, :version
123
121
 
124
- def initialize(hash)
125
- @addon_id = hash['addonid']
126
- @author = hash['author']
127
- @broken = hash['broken']
128
- @dependencies = hash['dependencies'].nil? ? nil : hash['dependencies'].map { |it| AddonDependency.new(it) }
129
- @description = hash['description']
130
- @disclaimer = hash['disclaimer']
131
- @enabled = hash['enabled']
132
- @extra_info = hash['extrainfo'].nil? ? nil : hash['extrainfo'].map { |it| AddonExtraInfo.new(it) }
133
- @fan_art = hash['fanart']
134
- @installed = hash['installed']
135
- @name = hash['name']
136
- @path = hash['path']
137
- @rating = hash['rating']
138
- @summary = hash['summary']
139
- @thumbnail = hash['thumbnail']
140
- @type = hash['type']
141
- @version = hash['version']
142
- item_details_base(hash)
143
- end
144
-
145
- def ==(other)
146
- compare(self, other)
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]
124
+
125
+ type_mapping ['dependencies', AddonDependency, true], ['extrainfo', AddonExtraInfo, true]
126
+
127
+ def initialize(addon_id, author, broken, dependencies, description, disclaimer, enabled, extra_info,
128
+ fan_art, installed, name, path, rating, summary, thumbnail, type, version, label)
129
+ @addon_id = addon_id
130
+ @author = author
131
+ @broken = broken
132
+ @dependencies = dependencies
133
+ @description = description
134
+ @disclaimer = disclaimer
135
+ @enabled = enabled
136
+ @extra_info = extra_info
137
+ @fan_art = fan_art
138
+ @installed = installed
139
+ @name = name
140
+ @path = path
141
+ @rating = rating
142
+ @summary = summary
143
+ @thumbnail = thumbnail
144
+ @type = type
145
+ @version = version
146
+ item_details_base(label)
147
147
  end
148
148
  end
149
149
 
150
150
  # getAddons return
151
151
  class Addons
152
152
  include Comparable
153
+ extend Creatable
153
154
 
154
155
  attr_reader :addons, :limits
155
156
 
156
- def initialize(hash)
157
- @addons = hash['addons'].map { |it| AddonDetails.new(it) }
158
- @limits = List::ListLimitsReturned.new(hash['limits'])
159
- end
157
+ type_mapping ['addons', AddonDetails, true], ['limits', List::ListLimitsReturned]
160
158
 
161
- def ==(other)
162
- compare(self, other)
159
+ def initialize(addons, limits)
160
+ @addons = addons
161
+ @limits = limits
163
162
  end
164
163
  end
165
164
 
166
165
  # getAddon return
167
166
  class Addon
168
167
  include Comparable
168
+ extend Creatable
169
169
 
170
170
  attr_reader :addon
171
171
 
172
- def initialize(hash)
173
- @addon = AddonDetails.new(hash['addon'])
174
- end
172
+ type_mapping ['addon', AddonDetails]
175
173
 
176
- def ==(other)
177
- compare(self, other)
174
+ def initialize(addon)
175
+ @addon = addon
178
176
  end
179
177
  end
180
178
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'kodi_client/util/comparable'
4
4
  require 'kodi_client/util/iterable'
5
+ require 'kodi_client/util/creatable'
5
6
 
6
7
  module KodiClient
7
8
  module Types
@@ -19,38 +20,35 @@ module KodiClient
19
20
  LANGUAGE = 'language'
20
21
  end
21
22
 
22
- # Application.Property.Value https://kodi.wiki/view/JSON-RPC_API/v12#Application.Property.Value
23
- class PropertyValue
23
+ # represent application properties version
24
+ class Version
24
25
  include Comparable
26
+ extend Creatable
25
27
 
26
- attr_reader :name, :version, :muted, :volume
27
-
28
- def initialize(hash)
29
- @name = hash['name']
30
- @version = hash['version'].nil? ? nil : Version.new(hash['version'])
31
- @muted = hash['muted']
32
- @volume = hash['volume']
33
- end
28
+ attr_reader :major, :minor, :revision, :tag
34
29
 
35
- def ==(other)
36
- compare(self, other)
30
+ def initialize(major, minor, revision, tag)
31
+ @major = major
32
+ @minor = minor
33
+ @revision = revision
34
+ @tag = tag
37
35
  end
38
36
  end
39
37
 
40
- # represent application properties version
41
- class Version
38
+ # Application.Property.Value https://kodi.wiki/view/JSON-RPC_API/v12#Application.Property.Value
39
+ class PropertyValue
42
40
  include Comparable
43
- attr_reader :major, :minor, :revision, :tag
41
+ extend Creatable
44
42
 
45
- def initialize(hash)
46
- @major = hash['major']
47
- @minor = hash['minor']
48
- @revision = hash['revision']
49
- @tag = hash['tag']
50
- end
43
+ attr_reader :name, :version, :muted, :volume
44
+
45
+ type_mapping ['version', Version]
51
46
 
52
- def ==(other)
53
- compare(self, other)
47
+ def initialize(name, version, muted, volume)
48
+ @name = name
49
+ @version = version
50
+ @muted = muted
51
+ @volume = volume
54
52
  end
55
53
  end
56
54
  end
@@ -3,6 +3,7 @@
3
3
  require 'kodi_client/global_types/media_types'
4
4
  require 'kodi_client/util/comparable'
5
5
  require 'kodi_client/util/iterable'
6
+ require 'kodi_client/util/creatable'
6
7
 
7
8
  module KodiClient
8
9
  module Types
@@ -11,18 +12,15 @@ module KodiClient
11
12
  # Audio.Contributor https://kodi.wiki/view/JSON-RPC_API/v12#Audio.Contributors
12
13
  class AudioContributor
13
14
  include Comparable
15
+ extend Creatable
14
16
 
15
17
  attr_reader :artist_id, :name, :role, :role_id
16
18
 
17
- def initialize(hash)
18
- @artist_id = hash['artistid']
19
- @name = hash['name']
20
- @role = hash['role']
21
- @role_id = hash['roleid']
22
- end
23
-
24
- def ==(other)
25
- compare(self, other)
19
+ def initialize(artist_id, name, role, role_id)
20
+ @artist_id = artist_id
21
+ @name = name
22
+ @role = role
23
+ @role_id = role_id
26
24
  end
27
25
  end
28
26
 
@@ -40,11 +38,21 @@ module KodiClient
40
38
 
41
39
  attr_reader :art, :date_added, :genre
42
40
 
43
- def audio_details_base(hash)
44
- @art = Types::Media::MediaArtwork.new(hash['art'])
45
- @date_added = hash['date_added']
46
- @genre = hash['genre']
47
- media_details_base(hash)
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
+
46
+ def audio_details_base_by_hash(hash)
47
+ audio_details_base(*Creatable.hash_to_arr(hash, %w[art date_added genre fan_art thumbnail label]),
48
+ audio_details_base_mappings)
49
+ end
50
+
51
+ def audio_details_base(art, date_added, genre, fan_art, thumbnail, label)
52
+ @art = art
53
+ @date_added = date_added
54
+ @genre = genre
55
+ media_details_base(fan_art, thumbnail, label)
48
56
  end
49
57
  end
50
58
 
@@ -52,23 +60,165 @@ module KodiClient
52
60
  module AudioDetailsMedia
53
61
  include AudioDetailsBase
54
62
 
55
- attr_reader :artist, :artist_id, :display_artist, :musicbrainz_albumartist_id, :original_date, :rating,
63
+ attr_reader :artist, :artist_id, :display_artist, :musicbrainz_album_artist_id, :original_date, :rating,
56
64
  :release_date, :sort_artist, :title, :user_rating, :votes, :year
57
65
 
58
- def audio_details_media(hash)
59
- @artist = hash['artist']
60
- @artist_id = hash['artistid']
61
- @display_artist = hash['displayartist']
62
- @musicbrainz_albumartist_id = hash['musicbrainzalbumartistid']
63
- @original_date = hash['originaldate']
64
- @rating = hash['rating']
65
- @release_date = hash['releasedate']
66
- @sort_artist = hash['sortartist']
67
- @title = hash['title']
68
- @user_rating = hash['userrating']
69
- @votes = hash['votes']
70
- @year = hash['year']
71
- audio_details_base(hash)
66
+ def audio_details_media_mappings
67
+ audio_details_base_mappings
68
+ end
69
+
70
+ def audio_details_media_by_hash(hash)
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))
76
+ end
77
+
78
+ def audio_details_media(artist, artist_id, display_artist, musicbrainz_album_artist_id, original_date,
79
+ rating, release_date, sort_artist, title, user_rating, votes, year,
80
+ art, date_added, genre, fan_art, thumbnail, label)
81
+ @artist = artist
82
+ @artist_id = artist_id
83
+ @display_artist = display_artist
84
+ @musicbrainz_album_artist_id = musicbrainz_album_artist_id
85
+ @original_date = original_date
86
+ @rating = rating
87
+ @release_date = release_date
88
+ @sort_artist = sort_artist
89
+ @title = title
90
+ @user_rating = user_rating
91
+ @votes = votes
92
+ @year = year
93
+ audio_details_base(art, date_added, genre, fan_art, thumbnail, label)
94
+ end
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
72
222
  end
73
223
  end
74
224
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'kodi_client/util/comparable'
4
4
  require 'kodi_client/util/iterable'
5
+ require 'kodi_client/util/creatable'
5
6
  require 'kodi_client/global_types/list_types'
6
7
 
7
8
  module KodiClient
@@ -32,36 +33,32 @@ module KodiClient
32
33
  # Favourite.Details.Favourite https://kodi.wiki/view/JSON-RPC_API/v12#Favourite.Details.Favourite
33
34
  class DetailsFavourite
34
35
  include Comparable
36
+ extend Creatable
35
37
 
36
38
  attr_reader :path, :thumbnail, :title, :type, :window, :window_parameter
37
39
 
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)
40
+ def initialize(path, thumbnail, title, type, window, window_parameter)
41
+ @path = path
42
+ @thumbnail = thumbnail
43
+ @title = title
44
+ @type = type
45
+ @window = window
46
+ @window_parameter = window_parameter
49
47
  end
50
48
  end
51
49
 
52
50
  # return type for Favourites.GetFavourites
53
51
  class GetFavouriteReturned
54
52
  include Comparable
53
+ extend Creatable
55
54
 
56
55
  attr_reader :favourites, :limits
57
56
 
58
- def initialize(hash)
59
- @favourites = hash['favourites'].map { |it| DetailsFavourite.new(it) }
60
- @limits = Types::List::ListLimitsReturned.new(hash['limits'])
61
- end
57
+ type_mapping ['favourites', DetailsFavourite, true], ['limits', Types::List::ListLimitsReturned]
62
58
 
63
- def ==(other)
64
- compare(self, other)
59
+ def initialize(favourites, limits)
60
+ @favourites = favourites
61
+ @limits = limits
65
62
  end
66
63
  end
67
64
  end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'kodi_client/util/comparable'
4
+ require 'kodi_client/util/iterable'
5
+ require 'kodi_client/util/creatable'
6
+ require 'kodi_client/global_types/list_types'
7
+
8
+ module KodiClient
9
+ module Types
10
+ module Files
11
+
12
+ # Files.Media https://kodi.wiki/view/JSON-RPC_API/v12#Files.Media
13
+ module Media
14
+ extend Iterable
15
+
16
+ VIDEO = 'video'
17
+ MUSIC = 'music'
18
+ PICTURES = 'pictures'
19
+ FILES = 'files'
20
+ PROGRAMS = 'programs'
21
+ end
22
+
23
+ # return value for GetDirectory
24
+ class GetDirectoryReturned
25
+ include Comparable
26
+ extend Creatable
27
+
28
+ attr_reader :files, :limits
29
+
30
+ type_mapping ['files', List::ListItemFile, true], ['limits', List::ListLimitsReturned]
31
+
32
+ def initialize(files, limits)
33
+ @files = files
34
+ @limits = limits
35
+ end
36
+ end
37
+
38
+ # return value for GetSources
39
+ class GetSourcesReturned
40
+ include Comparable
41
+ extend Creatable
42
+
43
+ attr_reader :sources, :limits
44
+
45
+ type_mapping ['sources', List::FileLabel, true], ['limits', List::ListLimitsReturned]
46
+
47
+ def initialize(sources, limits)
48
+ @sources = sources
49
+ @limits = limits
50
+ end
51
+ end
52
+
53
+ # return value for GetPrepareDownload
54
+ class PrepareDownloadReturned
55
+ include Comparable
56
+ extend Creatable
57
+
58
+ attr_reader :details, :mode, :protocol
59
+
60
+ def initialize(details, mode, protocol)
61
+ @details = details
62
+ @mode = mode
63
+ @protocol = protocol
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end