kodi_client 0.5.7 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0dd073d0e999df44e921b07f3aab1c148ee3647a584e2de13a2c070a151f7a2b
4
- data.tar.gz: 00ac80c0f82b4bfcb0031e8cc2abf6e4c894ccff58515fcdfd08fbe1c3b7fb63
3
+ metadata.gz: 5686743b785e5b591798992689064cec6c1e0d48a54721b97d9d28ae5a97ded3
4
+ data.tar.gz: fc7516af1d65c10ef63897253979bdb67b8d74f6f11bb74c959ccc942f8c026e
5
5
  SHA512:
6
- metadata.gz: b1a718355773fd1a1e12127f334f74a9bc1d9382ec47e9143a2dc776e1bb056157f4ac5ca0ec1232b14c27c8cc55bacacae1b37e0b831213af7472c2aeef16ec
7
- data.tar.gz: e6dccd2f74a7c2f7a4790635b21f01730c88a69bfe47c6b8905b500dade3b650689506640a2428c00824ca03097658906563a7f88806aad094a3dc64d7edcf0c
6
+ metadata.gz: ed6fbc05813a0f0a606c08c2e18606603af576e06f4af5941912097b477ad0a622a5ea7f47c7ce52062188b38522d60522337a06261d23f6894f5e1fbb6480c6
7
+ data.tar.gz: fb200b6342ff5a29d291d60e8c8e61d53de6012bcc5b29058e16ae2eee8d3df9583ed7e8f6f78a72a2da02481d74e9e48d6dbc945dbad73ed85526e711220532
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.7'
5
+ spec.version = '0.6.0'
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'
@@ -0,0 +1,82 @@
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
+ def self.create(hash)
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
38
+
39
+ def initialize(files, limits)
40
+ @files = files
41
+ @limits = limits
42
+ end
43
+ end
44
+
45
+ # return value for GetSources
46
+ class GetSourcesReturned
47
+ include Comparable
48
+ extend Creatable
49
+
50
+ attr_reader :sources, :limits
51
+
52
+ def self.create(hash)
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
60
+
61
+ def initialize(sources, limits)
62
+ @sources = sources
63
+ @limits = limits
64
+ end
65
+ end
66
+
67
+ # return value for GetPrepareDownload
68
+ class PrepareDownloadReturned
69
+ include Comparable
70
+ extend Creatable
71
+
72
+ attr_reader :details, :mode, :protocol
73
+
74
+ def initialize(details, mode, protocol)
75
+ @details = details
76
+ @mode = mode
77
+ @protocol = protocol
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
@@ -153,6 +153,95 @@ module KodiClient
153
153
  YEAR = 'year'
154
154
  end
155
155
 
156
+ # List.Fields.Files https://kodi.wiki/view/JSON-RPC_API/v12#List.Fields.Files
157
+ module ListFieldFiles
158
+ extend Iterable
159
+
160
+ ALBUM = 'album'
161
+ ALBUMARTIST = 'albumartist'
162
+ ALBUMARTISTID = 'albumartistid'
163
+ ALBUMID = 'albumid'
164
+ ALBUMLABEL = 'albumlabel'
165
+ ART = 'art'
166
+ ARTIST = 'artist'
167
+ ARTISTID = 'artistid'
168
+ CAST = 'cast'
169
+ COMMENT = 'comment'
170
+ COUNTRY = 'country'
171
+ DATEADDED = 'dateadded'
172
+ DESCRIPTION = 'description'
173
+ DIRECTOR = 'director'
174
+ DISC = 'disc'
175
+ DISPLAYARTIST = 'displayartist'
176
+ DURATION = 'duration'
177
+ EPISODE = 'episode'
178
+ EPISODEGUIDE = 'episodeguide'
179
+ FANART = 'fanart'
180
+ FILE = 'file'
181
+ FIRSTAIRED = 'firstaired'
182
+ GENRE = 'genre'
183
+ GENREID = 'genreid'
184
+ IMDBNUMBER = 'imdbnumber'
185
+ LASTMODIFIED = 'lastmodified'
186
+ LASTPLAYED = 'lastplayed'
187
+ LYRICS = 'lyrics'
188
+ MIMETYPE = 'mimetype'
189
+ MOOD = 'mood'
190
+ MPAA = 'mpaa'
191
+ MUSICBRAINZALBUMARTISTID = 'musicbrainzalbumartistid'
192
+ MUSICBRAINZALBUMID = 'musicbrainzalbumid'
193
+ MUSICBRAINZARTISTID = 'musicbrainzartistid'
194
+ MUSICBRAINZTRACKID = 'musicbrainztrackid'
195
+ ORIGINALTITLE = 'originaltitle'
196
+ PLAYCOUNT = 'playcount'
197
+ PLOT = 'plot'
198
+ PLOTOUTLINE = 'plotoutline'
199
+ PREMIERED = 'premiered'
200
+ PRODUCTIONCODE = 'productioncode'
201
+ RATING = 'rating'
202
+ RESUME = 'resume'
203
+ RUNTIME = 'runtime'
204
+ SEASON = 'season'
205
+ SET = 'set'
206
+ SETID = 'setid'
207
+ SHOWLINK = 'showlink'
208
+ SHOWTITLE = 'showtitle'
209
+ SIZE = 'size'
210
+ SORTTITLE = 'sorttitle'
211
+ SPECIALSORTEPISODE = 'specialsortepisode'
212
+ SPECIALSORTSEASON = 'specialsortseason'
213
+ STREAMDETAILS = 'streamdetails'
214
+ STUDIO = 'studio'
215
+ STYLE = 'style'
216
+ TAG = 'tag'
217
+ TAGLINE = 'tagline'
218
+ THEME = 'theme'
219
+ THUMBNAIL = 'thumbnail'
220
+ TITLE = 'title'
221
+ TOP250 = 'top250'
222
+ TRACK = 'track'
223
+ TRAILER = 'trailer'
224
+ TVSHOWID = 'tvshowid'
225
+ UNIQUEID = 'uniqueid'
226
+ VOTES = 'votes'
227
+ WATCHEDEPISODES = 'watchedepisodes'
228
+ WRITER = 'writer'
229
+ YEAR = 'year'
230
+ end
231
+
232
+ # File/Label tuple
233
+ class FileLabel
234
+ include Comparable
235
+ extend Creatable
236
+
237
+ attr_reader :file, :label
238
+
239
+ def initialize(file, label)
240
+ @file = file
241
+ @label = label
242
+ end
243
+ end
244
+
156
245
  # List.Item.Base https://kodi.wiki/view/JSON-RPC_API/v12#List.Item.Base
157
246
  module ListItemBase
158
247
  include Video::VideoDetailsFile
@@ -299,7 +388,7 @@ module KodiClient
299
388
  stream_details = Types::Video::Streams.create(hash['streamdetails'])
300
389
  art = Types::Media::MediaArtwork.create(hash['art'])
301
390
  hash['type'] = 'unknown' if hash['type'].nil?
302
- new(*Creatable.hash_to_arr(hash, %w[channel channel_number channel_type end_time hidden locked start_time
391
+ new(*Creatable.hash_to_arr(hash, %w[channel channel_number channel_type end_time hidden locked start_time
303
392
  sub_channel_number album album_artist album_artist_id album_id
304
393
  album_release_type album_status bit_rate bpm]), cast,
305
394
  hash['channels'], hash['comment'], hash['compilation'], contributors,
@@ -356,9 +445,76 @@ module KodiClient
356
445
  fan_art, thumbnail, label, artist, artist_id, display_artist, musicbrainz_album_artist_id,
357
446
  rating, sort_artist, user_rating, year, genre)
358
447
  end
448
+ end
449
+
450
+ # List.Item.File https://kodi.wiki/view/JSON-RPC_API/v12#List.Item.File
451
+ class ListItemFile
452
+ include ListItemBase
453
+ include Comparable
454
+ extend Creatable
455
+
456
+ attr_reader :file, :file_type, :last_modified, :mime_type, :size
457
+
458
+ def self.create(hash)
459
+ return nil if hash.nil?
460
+
461
+ cast = Types::Video::VideoCast.create_list(hash['cast'])
462
+ contributors = Types::Audio::AudioContributor.create_list(hash['contributors'])
463
+ resume = Types::Video::VideoResume.create(hash['resume'])
464
+ stream_details = Types::Video::Streams.create(hash['streamdetails'])
465
+ art = Types::Media::MediaArtwork.create(hash['art'])
466
+ hash['type'] = 'unknown' if hash['type'].nil?
467
+ new(*Creatable.hash_to_arr(hash, %w[file_type last_modified mime_type size]),
468
+ *Creatable.hash_to_arr(hash, %w[album album_artist album_artist_id album_id
469
+ album_release_type album_status bit_rate bpm]), cast,
470
+ hash['channels'], hash['comment'], hash['compilation'], contributors,
471
+ *Creatable.hash_to_arr(hash, %w[country description disc disc_title display_composer
472
+ display_conductor display_lyricist display_orchestra duration
473
+ dyn_path episode episode_guide first_aired id imdb_number
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]))
486
+ end
359
487
 
360
- def ==(other)
361
- compare(self, other)
488
+ def initialize(file_type, last_modified, mime_type, size,
489
+ album, album_artist, album_artist_id, album_id, album_release_type, album_status, bit_rate,
490
+ bpm, cast, channels, comment, compilation, contributors, country, description, disc,
491
+ disc_title, display_composer, display_conductor, display_lyricist, display_orchestra,
492
+ duration, dyn_path, episode, episode_guide, first_aired, id, imdb_number, is_box_set,
493
+ lyrics, media_path, mood, mpaa, musicbrainz_artist_id, musicbrainz_track_id, original_date,
494
+ original_title, plot_outline, premiered, production_code, release_date, release_type,
495
+ sample_rate, season, set, set_id, show_link, show_title, sort_title, special_sort_episode,
496
+ special_sort_season, studio, style, tag, tag_line, theme, top250, total_discs, track,
497
+ trailer, tv_show_id, type, unique_id, votes, watched_episodes, writer, director, resume,
498
+ runtime, stream_details, date_added, file, last_played, plot, title, art, play_count,
499
+ fan_art, thumbnail, label, artist, artist_id, display_artist, musicbrainz_album_artist_id,
500
+ rating, sort_artist, user_rating, year, genre)
501
+ @file = file
502
+ @file_type = file_type
503
+ @last_modified = last_modified
504
+ @mime_type = mime_type
505
+ @size = size
506
+ list_item_base(album, album_artist, album_artist_id, album_id, album_release_type, album_status, bit_rate,
507
+ bpm, cast, channels, comment, compilation, contributors, country, description, disc,
508
+ disc_title, display_composer, display_conductor, display_lyricist, display_orchestra,
509
+ duration, dyn_path, episode, episode_guide, first_aired, id, imdb_number, is_box_set,
510
+ lyrics, media_path, mood, mpaa, musicbrainz_artist_id, musicbrainz_track_id, original_date,
511
+ original_title, plot_outline, premiered, production_code, release_date, release_type,
512
+ sample_rate, season, set, set_id, show_link, show_title, sort_title, special_sort_episode,
513
+ special_sort_season, studio, style, tag, tag_line, theme, top250, total_discs, track,
514
+ trailer, tv_show_id, type, unique_id, votes, watched_episodes, writer, director, resume,
515
+ runtime, stream_details, date_added, file, last_played, plot, title, art, play_count,
516
+ fan_art, thumbnail, label, artist, artist_id, display_artist, musicbrainz_album_artist_id,
517
+ rating, sort_artist, user_rating, year, genre)
362
518
  end
363
519
  end
364
520
 
@@ -126,6 +126,8 @@ module KodiClient
126
126
  attr_reader :audio, :subtitle, :video
127
127
 
128
128
  def self.create(hash)
129
+ return nil if hash.nil?
130
+
129
131
  audio = Types::Player::AudioStream.create_list(hash['audio'])
130
132
  subtitle = Types::Player::Subtitle.create_list(hash['subtitle'])
131
133
  video = Types::Player::VideoStream.create_list(hash['video'])
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'kodi_client/kodi_module'
4
+ require 'kodi_client/global_types/files_types'
5
+ require 'kodi_client/global_types/list_types'
6
+
7
+ module KodiClient
8
+ module Modules
9
+ # contains all Kodi Application methods
10
+ class Files < KodiModule
11
+
12
+ GET_DIRECTORY = 'Files.GetDirectory'
13
+ GET_FILE_DETAILS = 'Files.GetFileDetails'
14
+ GET_SOURCES = 'Files.GetSources'
15
+ PREPARE_DOWNLOAD = 'Files.PrepareDownload'
16
+ SET_FILE_DETAILS = 'Files.SetFileDetails'
17
+
18
+ def get_directory(directory, media = Types::Files::Media::FILES,
19
+ properties = Types::List::ListFieldFiles.all_properties,
20
+ sort = Types::List::ListSort.new,
21
+ limits = Types::List::ListLimits.new(0, 50), kodi_id = 1)
22
+ request = KodiRequest.new(kodi_id, GET_DIRECTORY,
23
+ {
24
+ 'directory' => directory,
25
+ 'media' => media,
26
+ 'properties' => properties,
27
+ 'sort' => { 'ignorearticle' => sort.ignore_article, 'method' => sort.method,
28
+ 'order' => sort.order,
29
+ 'useartistsortname' => sort.use_artist_sort_name },
30
+ 'limits' => { 'start' => limits.list_start, 'end' => limits.list_end }
31
+ })
32
+ json = invoke_api(request)
33
+ result = KodiClient::Types::Files::GetDirectoryReturned.create(json['result'])
34
+ json['result'] = result
35
+ KodiResponse.new(json)
36
+ end
37
+
38
+ def get_file_details(file, media = Types::Files::Media::FILES,
39
+ properties = Types::List::ListFieldFiles.all_properties, kodi_id = 1)
40
+ request = KodiRequest.new(kodi_id, GET_FILE_DETAILS,
41
+ {
42
+ 'file' => file,
43
+ 'media' => media,
44
+ 'properties' => properties
45
+ })
46
+ json = invoke_api(request)
47
+ result = KodiClient::Types::List::ListItemFile.create(json['result'])
48
+ json['result'] = result
49
+ KodiResponse.new(json)
50
+ end
51
+
52
+ def get_sources(media = Types::Files::Media::FILES,
53
+ sort = Types::List::ListSort.new,
54
+ limits = Types::List::ListLimits.new(0, 50), kodi_id = 1)
55
+ request = KodiRequest.new(kodi_id, GET_SOURCES,
56
+ {
57
+ 'media' => media,
58
+ 'sort' => { 'ignorearticle' => sort.ignore_article, 'method' => sort.method,
59
+ 'order' => sort.order,
60
+ 'useartistsortname' => sort.use_artist_sort_name },
61
+ 'limits' => { 'start' => limits.list_start, 'end' => limits.list_end }
62
+ })
63
+ json = invoke_api(request)
64
+ result = KodiClient::Types::Files::GetSourcesReturned.create(json['result'])
65
+ json['result'] = result
66
+ KodiResponse.new(json)
67
+ end
68
+
69
+ def prepare_download(path, kodi_id = 1)
70
+ request = KodiRequest.new(kodi_id, PREPARE_DOWNLOAD, { 'path' => path })
71
+ json = invoke_api(request)
72
+ result = KodiClient::Types::Files::PrepareDownloadReturned.create(json['result'])
73
+ json['result'] = result
74
+ KodiResponse.new(json)
75
+ end
76
+
77
+ def set_file_details(file, media = Types::Files::Media::VIDEO, play_count = nil, last_played = nil,
78
+ resume = nil, kodi_id = 1)
79
+ params = { 'file' => file, 'media' => media}
80
+ params['playcount'] = play_count unless play_count.nil?
81
+ params['lastplayed'] = last_played unless last_played.nil?
82
+ params['resume'] = resume unless resume.nil?
83
+ request = KodiRequest.new(kodi_id, SET_FILE_DETAILS, params)
84
+ json = invoke_api(request)
85
+ KodiResponse.new(json)
86
+ end
87
+ end
88
+ end
89
+ end
data/lib/kodi_client.rb CHANGED
@@ -7,6 +7,7 @@ require 'kodi_client/Chainable'
7
7
  require 'kodi_client/method/addons'
8
8
  require 'kodi_client/method/application'
9
9
  require 'kodi_client/method/favourites'
10
+ require 'kodi_client/method/files'
10
11
  require 'kodi_client/method/gui'
11
12
  require 'kodi_client/method/input'
12
13
  require 'kodi_client/method/player'
@@ -22,12 +23,13 @@ module KodiClient
22
23
  class Client
23
24
  include Chainable
24
25
 
25
- attr_reader :addons, :application, :gui, :player, :input, :favourites, :system, :profiles
26
+ attr_reader :addons, :application, :favourites, :files, :gui, :input, :player, :profiles, :system
26
27
 
27
28
  def initialize
28
29
  @addons = KodiClient::Modules::Addons.new
29
30
  @application = KodiClient::Modules::Application.new
30
31
  @favourites = KodiClient::Modules::Favourites.new
32
+ @files = KodiClient::Modules::Files.new
31
33
  @gui = KodiClient::Modules::GUI.new
32
34
  @input = KodiClient::Modules::Input.new
33
35
  @player = KodiClient::Modules::Player.new
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kodi_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.7
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Feier
@@ -25,9 +25,9 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 5.0.4
27
27
  description: A client for the Kodi JSON API v12, currently implemented methods are
28
- addons, application, favourites, gui, input, player, profile and system (more will
29
- be added with the time). For more information how to use it and how to activate
30
- Remote Control in Kodi, please check the github page https://github.com/cfe86/RubyKodiClient
28
+ Addons, Application, Favourites, Files, GUI, Input, Player, Profiles and System
29
+ (more will be added with the time). For more information how to use it and how to
30
+ activate Remote Control in Kodi, please check the github page https://github.com/cfe86/RubyKodiClient
31
31
  email:
32
32
  - christian.feier@gmail.com
33
33
  executables: []
@@ -47,6 +47,7 @@ files:
47
47
  - lib/kodi_client/global_types/application_types.rb
48
48
  - lib/kodi_client/global_types/audio_types.rb
49
49
  - lib/kodi_client/global_types/favourites_types.rb
50
+ - lib/kodi_client/global_types/files_types.rb
50
51
  - lib/kodi_client/global_types/global_types.rb
51
52
  - lib/kodi_client/global_types/gui_types.rb
52
53
  - lib/kodi_client/global_types/input_types.rb
@@ -62,6 +63,7 @@ files:
62
63
  - lib/kodi_client/method/addons.rb
63
64
  - lib/kodi_client/method/application.rb
64
65
  - lib/kodi_client/method/favourites.rb
66
+ - lib/kodi_client/method/files.rb
65
67
  - lib/kodi_client/method/gui.rb
66
68
  - lib/kodi_client/method/input.rb
67
69
  - lib/kodi_client/method/player.rb