kodi_client 0.5.7 → 0.6.3

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.
Files changed (35) 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 +1 -2
  5. data/lib/kodi_client/kodi_module.rb +0 -7
  6. data/lib/kodi_client/method/addons.rb +6 -21
  7. data/lib/kodi_client/method/application.rb +1 -4
  8. data/lib/kodi_client/method/audio_library.rb +46 -0
  9. data/lib/kodi_client/method/favourites.rb +1 -4
  10. data/lib/kodi_client/method/files.rb +85 -0
  11. data/lib/kodi_client/method/gui.rb +1 -4
  12. data/lib/kodi_client/method/input.rb +1 -5
  13. data/lib/kodi_client/method/player.rb +1 -6
  14. data/lib/kodi_client/method/profiles.rb +1 -4
  15. data/lib/kodi_client/method/system.rb +1 -5
  16. data/lib/kodi_client/{global_types → types}/addon_types.rb +9 -26
  17. data/lib/kodi_client/{global_types → types}/application_types.rb +16 -25
  18. data/lib/kodi_client/types/audio_types.rb +221 -0
  19. data/lib/kodi_client/{global_types → types}/favourites_types.rb +1 -10
  20. data/lib/kodi_client/types/files_types.rb +63 -0
  21. data/lib/kodi_client/{global_types → types}/global_types.rb +0 -4
  22. data/lib/kodi_client/{global_types → types}/gui_types.rb +2 -14
  23. data/lib/kodi_client/{global_types → types}/input_types.rb +0 -2
  24. data/lib/kodi_client/{global_types → types}/item_types.rb +5 -1
  25. data/lib/kodi_client/{global_types → types}/list_types.rb +193 -64
  26. data/lib/kodi_client/{global_types → types}/media_types.rb +5 -7
  27. data/lib/kodi_client/{global_types → types}/player_type.rb +11 -36
  28. data/lib/kodi_client/{global_types → types}/profiles_types.rb +2 -17
  29. data/lib/kodi_client/{global_types → types}/pvr_type.rb +0 -2
  30. data/lib/kodi_client/{global_types → types}/system_types.rb +0 -3
  31. data/lib/kodi_client/{global_types → types}/video_types.rb +32 -25
  32. data/lib/kodi_client/util/creatable.rb +69 -15
  33. data/lib/kodi_client.rb +37 -9
  34. metadata +23 -20
  35. data/lib/kodi_client/global_types/audio_types.rb +0 -88
@@ -0,0 +1,221 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KodiClient
4
+ module Types
5
+ module Audio
6
+
7
+ # Audio.Contributor https://kodi.wiki/view/JSON-RPC_API/v12#Audio.Contributors
8
+ class AudioContributor
9
+ include Comparable
10
+ extend Creatable
11
+
12
+ attr_reader :artist_id, :name, :role, :role_id
13
+
14
+ def initialize(artist_id, name, role, role_id)
15
+ @artist_id = artist_id
16
+ @name = name
17
+ @role = role
18
+ @role_id = role_id
19
+ end
20
+ end
21
+
22
+ # Audio.Album.ReleaseType https://kodi.wiki/view/JSON-RPC_API/v12#Audio.Album.ReleaseType
23
+ module AudioAlbumReleaseType
24
+ extend Iterable
25
+
26
+ ALBUM = 'album'
27
+ SINGLE = 'single'
28
+ end
29
+
30
+ # Audio.Details.Base https://kodi.wiki/view/JSON-RPC_API/v12#Audio.Details.Base
31
+ module AudioDetailsBase
32
+ include Media::MediaDetailsBase
33
+
34
+ attr_reader :art, :date_added, :genre
35
+
36
+ def audio_details_base_mappings
37
+ mappings = { 'art' => Creatable::CreateMap.new(Types::Media::MediaArtwork) }
38
+ mappings.merge(media_details_base_mappings)
39
+ end
40
+
41
+ def audio_details_base_by_hash(hash)
42
+ audio_details_base(*Creatable.hash_to_arr(hash, %w[art date_added genre fan_art thumbnail label]),
43
+ audio_details_base_mappings)
44
+ end
45
+
46
+ def audio_details_base(art, date_added, genre, fan_art, thumbnail, label)
47
+ @art = art
48
+ @date_added = date_added
49
+ @genre = genre
50
+ media_details_base(fan_art, thumbnail, label)
51
+ end
52
+ end
53
+
54
+ # Audio.Details.Media https://kodi.wiki/view/JSON-RPC_API/v12#Audio.Details.Media
55
+ module AudioDetailsMedia
56
+ include AudioDetailsBase
57
+
58
+ attr_reader :artist, :artist_id, :display_artist, :musicbrainz_album_artist_id, :original_date, :rating,
59
+ :release_date, :sort_artist, :title, :user_rating, :votes, :year
60
+
61
+ def audio_details_media_mappings
62
+ audio_details_base_mappings
63
+ end
64
+
65
+ def audio_details_media_by_hash(hash)
66
+ audio_details_media(*Creatable.hash_to_arr(hash, %w[artist artist_id display_artist
67
+ musicbrainz_album_artist_id original_date rating
68
+ release_date sort_artist title user_rating votes year art
69
+ date_added genre fan_art thumbnail label],
70
+ audio_details_base_mappings))
71
+ end
72
+
73
+ def audio_details_media(artist, artist_id, display_artist, musicbrainz_album_artist_id, original_date,
74
+ rating, release_date, sort_artist, title, user_rating, votes, year,
75
+ art, date_added, genre, fan_art, thumbnail, label)
76
+ @artist = artist
77
+ @artist_id = artist_id
78
+ @display_artist = display_artist
79
+ @musicbrainz_album_artist_id = musicbrainz_album_artist_id
80
+ @original_date = original_date
81
+ @rating = rating
82
+ @release_date = release_date
83
+ @sort_artist = sort_artist
84
+ @title = title
85
+ @user_rating = user_rating
86
+ @votes = votes
87
+ @year = year
88
+ audio_details_base(art, date_added, genre, fan_art, thumbnail, label)
89
+ end
90
+ end
91
+
92
+ # Audio.Fields.Album https://kodi.wiki/view/JSON-RPC_API/v12#Audio.Fields.Album
93
+ module AudioFieldsAlbum
94
+ extend Iterable
95
+
96
+ #album id
97
+ ALBUM_DURATION = 'albumduration'
98
+ ALBUM_LABEL = 'albumlabel'
99
+ ALBUM_STATUS = 'albumstatus'
100
+ ART = 'art'
101
+ ARTIST = 'artist'
102
+ ARTIST_ID = 'artistid'
103
+ COMPILATION = 'compilation'
104
+ DATE_ADDED = 'dateadded'
105
+ DATE_MODIFIED = 'datemodified'
106
+ DATE_NEW = 'datenew'
107
+ DESCRIPTION = 'description'
108
+ DISPLAY_ARTIST = 'displayartist'
109
+ FAN_ART = 'fanart'
110
+ GENRE = 'genre'
111
+ IS_BOX_SET = 'isboxset'
112
+ LAST_PLAYED = 'lastplayed'
113
+ MOOD = 'mood'
114
+ MUSICBRAINZ_ALBUM_ARTIST_ID = 'musicbrainzalbumartistid'
115
+ MUSICBRAINZ_ALBUM_ID = 'musicbrainzalbumid'
116
+ MUSICBRAINZ_RELEASE_GROUP_ID = 'musicbrainzreleasegroupid'
117
+ ORIGINAL_DATE = 'originaldate'
118
+ PLAY_COUNT = 'playcount'
119
+ RATING = 'rating'
120
+ RELEASE_DATE = 'releasedate'
121
+ RELEASE_TYPE = 'releasetype'
122
+ SONG_GENRES = 'songgenres'
123
+ SORT_ARTIST = 'sortartist'
124
+ SOURCE_ID = 'sourceid'
125
+ STYLE = 'style'
126
+ THEME = 'theme'
127
+ THUMBNAIL = 'thumbnail'
128
+ TITLE = 'title'
129
+ TOTAL_DISCS = 'totaldiscs'
130
+ TYPE = 'type'
131
+ USER_RATING = 'userrating'
132
+ VOTES = 'votes'
133
+ YEAR = 'year'
134
+ end
135
+
136
+ # Audio.Details.Genres https://kodi.wiki/view/JSON-RPC_API/v12#Audio.Details.Genres
137
+ class Genre
138
+ include Comparable
139
+ extend Creatable
140
+
141
+ attr_reader :genre_id, :title
142
+
143
+ def initialize(genre_id, title)
144
+ @genre_id = genre_id
145
+ @title = title
146
+ end
147
+ end
148
+
149
+ # Audio.Details.Album https://kodi.wiki/view/JSON-RPC_API/v12#Audio.Details.Album
150
+ class DetailsAlbum
151
+ include AudioDetailsMedia
152
+ include Comparable
153
+ extend Creatable
154
+
155
+ attr_reader :album_duration, :album_id, :album_label, :album_status, :compilation, :date_modified, :date_new,
156
+ :description, :is_box_set, :last_played, :mood, :musicbrainz_album_id, :musicbrainz_release_group_id,
157
+ :play_count, :release_type, :song_genres, :source_id, :style, :theme, :total_discs, :type
158
+
159
+ fields_to_map %w[album_duration album_id album_label album_status art artist artist_id compilation date_added
160
+ date_modified date_new description display_artist fan_art genre is_box_set label last_played
161
+ mood musicbrainz_album_artist_id musicbrainz_album_id musicbrainz_release_group_id
162
+ original_date play_count rating release_date release_type song_genres sort_artist source_id
163
+ style theme thumbnail title total_discs type user_rating votes year]
164
+
165
+ type_mapping ['songgenres', Genre, true], ['art', Types::Media::MediaArtwork]
166
+
167
+ def initialize(album_duration, album_id, album_label, album_status, art, artist, artist_id, compilation,
168
+ date_added, date_modified, date_new, description, display_artist, fan_art, genre, is_box_set,
169
+ label, last_played, mood, musicbrainz_album_artist_id, musicbrainz_album_id,
170
+ musicbrainz_release_group_id, original_date, play_count, rating, release_date, release_type,
171
+ song_genres, sort_artist, source_id, style, theme, thumbnail, title, total_discs, type,
172
+ user_rating, votes, year)
173
+ @album_duration = album_duration
174
+ @album_id = album_id
175
+ @album_label = album_label
176
+ @album_status = album_status
177
+ @compilation = compilation
178
+ @date_modified = date_modified
179
+ @date_new = date_new
180
+ @description = description
181
+ @is_box_set = is_box_set
182
+ @last_played = last_played
183
+ @mood = mood
184
+ @musicbrainz_album_id = musicbrainz_album_id
185
+ @musicbrainz_release_group_id = musicbrainz_release_group_id
186
+ @play_count = play_count
187
+ @release_type = release_type
188
+ @song_genres = song_genres
189
+ @source_id = source_id
190
+ @style = style
191
+ @theme = theme
192
+ @total_discs = total_discs
193
+ @type = type
194
+ audio_details_media(artist, artist_id, display_artist, musicbrainz_album_artist_id, original_date,
195
+ rating, release_date, sort_artist, title, user_rating, votes, year,
196
+ art, date_added, genre, fan_art, thumbnail, label)
197
+ end
198
+ end
199
+
200
+ # return type for AudioLibrary.GetAlbums
201
+ class GetAlbumsReturned
202
+ include Comparable
203
+ extend Creatable
204
+
205
+ attr_reader :albums, :limits
206
+
207
+ def self.lazy_type_mapping
208
+ {
209
+ 'albums' => Creatable::CreateMap.new(DetailsAlbum, true),
210
+ 'limits' => Creatable::CreateMap.new(List::ListLimitsReturned)
211
+ }
212
+ end
213
+
214
+ def initialize(albums, limits)
215
+ @albums = albums
216
+ @limits = limits
217
+ end
218
+ end
219
+ end
220
+ end
221
+ end
@@ -1,10 +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
- require 'kodi_client/global_types/list_types'
7
-
8
3
  module KodiClient
9
4
  module Types
10
5
  module Favourites
@@ -54,11 +49,7 @@ module KodiClient
54
49
 
55
50
  attr_reader :favourites, :limits
56
51
 
57
- def self.create(hash)
58
- favourites = DetailsFavourite.create_list(hash['favourites'])
59
- limits = Types::List::ListLimitsReturned.create(hash['limits'])
60
- new(favourites, limits)
61
- end
52
+ type_mapping ['favourites', DetailsFavourite, true], ['limits', Types::List::ListLimitsReturned]
62
53
 
63
54
  def initialize(favourites, limits)
64
55
  @favourites = favourites
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KodiClient
4
+ module Types
5
+ module Files
6
+
7
+ # Files.Media https://kodi.wiki/view/JSON-RPC_API/v12#Files.Media
8
+ module Media
9
+ extend Iterable
10
+
11
+ VIDEO = 'video'
12
+ MUSIC = 'music'
13
+ PICTURES = 'pictures'
14
+ FILES = 'files'
15
+ PROGRAMS = 'programs'
16
+ end
17
+
18
+ # return value for GetDirectory
19
+ class GetDirectoryReturned
20
+ include Comparable
21
+ extend Creatable
22
+
23
+ attr_reader :files, :limits
24
+
25
+ type_mapping ['files', List::ListItemFile, true], ['limits', List::ListLimitsReturned]
26
+
27
+ def initialize(files, limits)
28
+ @files = files
29
+ @limits = limits
30
+ end
31
+ end
32
+
33
+ # return value for GetSources
34
+ class GetSourcesReturned
35
+ include Comparable
36
+ extend Creatable
37
+
38
+ attr_reader :sources, :limits
39
+
40
+ type_mapping ['sources', List::FileLabel, true], ['limits', List::ListLimitsReturned]
41
+
42
+ def initialize(sources, limits)
43
+ @sources = sources
44
+ @limits = limits
45
+ end
46
+ end
47
+
48
+ # return value for GetPrepareDownload
49
+ class PrepareDownloadReturned
50
+ include Comparable
51
+ extend Creatable
52
+
53
+ attr_reader :details, :mode, :protocol
54
+
55
+ def initialize(details, mode, protocol)
56
+ @details = details
57
+ @mode = mode
58
+ @protocol = protocol
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -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 Global
@@ -1,10 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'kodi_client/global_types/global_types'
4
- require 'kodi_client/util/comparable'
5
- require 'kodi_client/util/iterable'
6
- require 'kodi_client/util/creatable'
7
-
8
3
  module KodiClient
9
4
  module Types
10
5
  module GUI
@@ -168,15 +163,8 @@ module KodiClient
168
163
 
169
164
  attr_reader :current_control, :current_window, :fullscreen, :skin, :stereoscopic_mode
170
165
 
171
- def self.create(hash)
172
- return nil if hash.nil?
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
166
+ type_mapping ['currentcontrol', Global::IdLabel], ['currentwindow', Global::IdLabel],
167
+ ['skin', Global::IdName], ['stereoscopicmode', StereoscopyMode]
180
168
 
181
169
  def initialize(current_control, current_window, fullscreen, skin, stereoscopic_mode)
182
170
  @current_control = current_control
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'kodi_client/util/iterable'
4
-
5
3
  module KodiClient
6
4
  module Types
7
5
  module Input
@@ -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['label'])
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)