kodi_client 0.5.0 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/kodi_client.gemspec +5 -2
- data/lib/kodi_client/global_types/audio_types.rb +0 -1
- data/lib/kodi_client/global_types/favourites_types.rb +2 -2
- data/lib/kodi_client/global_types/global_types.rb +12 -4
- data/lib/kodi_client/global_types/input_types.rb +1 -1
- data/lib/kodi_client/global_types/list_types.rb +74 -0
- data/lib/kodi_client/global_types/profiles_types.rb +70 -0
- data/lib/kodi_client/global_types/pvr_type.rb +2 -0
- data/lib/kodi_client/kodi_module.rb +1 -0
- data/lib/kodi_client/method/profiles.rb +48 -0
- data/lib/kodi_client.rb +16 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3f04d9b1f829af8765bb790f49accaa47bebd71b1d4e1755b1776782d089fdb
|
4
|
+
data.tar.gz: 29d45652a206f4d32c05103a520eb984c5925a775dfe9479535b57d6d5d3a477
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17431c4ec21d3b0f315847aacca3efd821afb1d4d0dcee1deae25196b4ad0a74effb6b08e53a6a97c727dd5302eef409560e55b39ee02f002e55bd73e01eefda
|
7
|
+
data.tar.gz: 3461b3f8babd1636c722a4d2fab9ac8391446c4f0144f8c744a87555fe155b1b7197ccd1f559951fef133ba9324934a89a9ea75682388efaf68d45e71b70f42a
|
data/README.md
CHANGED
data/kodi_client.gemspec
CHANGED
@@ -2,12 +2,15 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'kodi_client'
|
5
|
-
spec.version = '0.5.
|
5
|
+
spec.version = '0.5.5'
|
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,
|
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). '\
|
12
|
+
'For more information how to use it and how to activate Remote Control in Kodi, '\
|
13
|
+
'please check the github page https://github.com/cfe86/RubyKodiClient'
|
11
14
|
spec.homepage = 'https://github.com/cfe86/RubyKodiClient'
|
12
15
|
spec.license = 'MIT'
|
13
16
|
spec.required_ruby_version = '>= 2.5.0'
|
@@ -30,7 +30,7 @@ module KodiClient
|
|
30
30
|
end
|
31
31
|
|
32
32
|
# Favourite.Details.Favourite https://kodi.wiki/view/JSON-RPC_API/v12#Favourite.Details.Favourite
|
33
|
-
class
|
33
|
+
class DetailsFavourite
|
34
34
|
include Comparable
|
35
35
|
|
36
36
|
attr_reader :path, :thumbnail, :title, :type, :window, :window_parameter
|
@@ -56,7 +56,7 @@ module KodiClient
|
|
56
56
|
attr_reader :favourites, :limits
|
57
57
|
|
58
58
|
def initialize(hash)
|
59
|
-
@favourites = hash['favourites'].map { |it|
|
59
|
+
@favourites = hash['favourites'].map { |it| DetailsFavourite.new(it) }
|
60
60
|
@limits = Types::List::ListLimitsReturned.new(hash['limits'])
|
61
61
|
end
|
62
62
|
|
@@ -18,7 +18,7 @@ module KodiClient
|
|
18
18
|
|
19
19
|
# rotate for clockwise and counter clockwise
|
20
20
|
module Rotate
|
21
|
-
|
21
|
+
extend Iterable
|
22
22
|
|
23
23
|
CLOCKWISE = 'clockwise'
|
24
24
|
COUNTER_CLOCKWISE = 'counterclockwise'
|
@@ -26,7 +26,7 @@ module KodiClient
|
|
26
26
|
|
27
27
|
# direction for left, right, up, down
|
28
28
|
module Direction
|
29
|
-
|
29
|
+
extend Iterable
|
30
30
|
|
31
31
|
LEFT = 'left'
|
32
32
|
RIGHT = 'right'
|
@@ -36,7 +36,7 @@ module KodiClient
|
|
36
36
|
|
37
37
|
# enum for prev/next
|
38
38
|
module NextPrev
|
39
|
-
|
39
|
+
extend Iterable
|
40
40
|
|
41
41
|
NEXT = 'next'
|
42
42
|
PREV = 'previous'
|
@@ -46,7 +46,7 @@ module KodiClient
|
|
46
46
|
|
47
47
|
# Global.IncrementDecrement https://kodi.wiki/view/JSON-RPC_API/v12#Global.IncrementDecrement
|
48
48
|
module IncrementDecrement
|
49
|
-
|
49
|
+
extend Iterable
|
50
50
|
|
51
51
|
INCREMENT = 'increment'
|
52
52
|
DECREMENT = 'decrement'
|
@@ -99,6 +99,14 @@ module KodiClient
|
|
99
99
|
compare(self, other)
|
100
100
|
end
|
101
101
|
end
|
102
|
+
|
103
|
+
# available Password Encryptions
|
104
|
+
module PasswordEncryption
|
105
|
+
extend Iterable
|
106
|
+
|
107
|
+
NONE = 'none'
|
108
|
+
MD5 = 'md5'
|
109
|
+
end
|
102
110
|
end
|
103
111
|
end
|
104
112
|
end
|
@@ -41,6 +41,33 @@ module KodiClient
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
# ascending/descending for sorting
|
45
|
+
module SortOrder
|
46
|
+
extend Iterable
|
47
|
+
|
48
|
+
ASCENDING = 'ascending'
|
49
|
+
DESCENDING = 'descending'
|
50
|
+
end
|
51
|
+
|
52
|
+
# List.Sort https://kodi.wiki/view/JSON-RPC_API/v12#List.Sort
|
53
|
+
class ListSort
|
54
|
+
include Comparable
|
55
|
+
|
56
|
+
attr_reader :ignore_article, :method, :order, :use_artist_sort_name
|
57
|
+
|
58
|
+
def initialize(ignore_article = false, method = ListSortMethod::NONE,
|
59
|
+
sortOrder = SortOrder::ASCENDING, use_artist_sort_name = false)
|
60
|
+
@ignore_article = ignore_article
|
61
|
+
@method = method
|
62
|
+
@order = SortOrder::ASCENDING
|
63
|
+
@use_artist_sort_name = use_artist_sort_name
|
64
|
+
end
|
65
|
+
|
66
|
+
def ==(other)
|
67
|
+
compare(self, other)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
44
71
|
# List.Fields.All https://kodi.wiki/view/JSON-RPC_API/v12#List.Fields.All
|
45
72
|
module ListFieldsAll
|
46
73
|
extend Iterable
|
@@ -241,6 +268,53 @@ module KodiClient
|
|
241
268
|
compare(self, other)
|
242
269
|
end
|
243
270
|
end
|
271
|
+
|
272
|
+
# methods for list sorting
|
273
|
+
module ListSortMethod
|
274
|
+
extend Iterable
|
275
|
+
|
276
|
+
NONE = 'none'
|
277
|
+
LABEL = 'label'
|
278
|
+
DATE = 'date'
|
279
|
+
SIZE = 'size'
|
280
|
+
FILE = 'file'
|
281
|
+
PATH = 'path'
|
282
|
+
DRIVE_TYPE = 'drivetype'
|
283
|
+
TITLE = 'title'
|
284
|
+
TRACK = 'track'
|
285
|
+
TIME = 'time'
|
286
|
+
ARTIST = 'artist'
|
287
|
+
ALBUM = 'album'
|
288
|
+
ALBUM_TYPE = 'albumtype'
|
289
|
+
GENRE = 'genre'
|
290
|
+
COUNTRY = 'country'
|
291
|
+
YEAR = 'year'
|
292
|
+
RATING = 'rating'
|
293
|
+
USER_RATING = 'userrating'
|
294
|
+
VOTES = 'votes'
|
295
|
+
TOP_250 = 'top250'
|
296
|
+
PROGRAM_COUNT = 'programcount'
|
297
|
+
PLAYLIST = 'playlist'
|
298
|
+
EPISODE = 'episode'
|
299
|
+
SEASON = 'season'
|
300
|
+
TOTAL_EPISODES = 'totalepisodes'
|
301
|
+
WATCHED_EPISODES = 'watchedepisodes'
|
302
|
+
TV_SHOW_STATUS = 'tvshowstatus'
|
303
|
+
TV_SHOW_TITLE = 'tvshowtitle'
|
304
|
+
SORT_TITLE = 'sorttitle'
|
305
|
+
PRODUCTION_CODE = 'productioncode'
|
306
|
+
MPAA = 'mpaa'
|
307
|
+
STUDIO = 'studio'
|
308
|
+
DATE_ADDED = 'dateadded'
|
309
|
+
LAST_PLAYED = 'lastplayed'
|
310
|
+
PLAY_COUNT = 'playcount'
|
311
|
+
LISTENERS = 'listeners'
|
312
|
+
BITRATE = 'bitrate'
|
313
|
+
RANDOM = 'random'
|
314
|
+
TOTAL_DISCS = 'totaldiscs'
|
315
|
+
ORIGINAL_DATE = 'originaldate'
|
316
|
+
BPM = 'bpm'
|
317
|
+
end
|
244
318
|
end
|
245
319
|
end
|
246
320
|
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'kodi_client/util/comparable'
|
4
|
+
require 'kodi_client/util/iterable'
|
5
|
+
require 'kodi_client/global_types/item_types'
|
6
|
+
|
7
|
+
module KodiClient
|
8
|
+
module Types
|
9
|
+
module Profiles
|
10
|
+
|
11
|
+
# Profiles.Fields.Profile https://kodi.wiki/view/JSON-RPC_API/v12#Profiles.Fields.Profile
|
12
|
+
module FieldsProfile
|
13
|
+
extend Iterable
|
14
|
+
|
15
|
+
LOCK_MODE = 'lockmode'
|
16
|
+
THUMBNAIL = 'thumbnail'
|
17
|
+
end
|
18
|
+
|
19
|
+
# Profiles.Details.Profile https://kodi.wiki/view/JSON-RPC_API/v12#Profiles.Details.Profile
|
20
|
+
class DetailsProfile
|
21
|
+
include Comparable
|
22
|
+
include Items::ItemDetailsBase
|
23
|
+
|
24
|
+
attr_reader :lock_mode, :thumbnail
|
25
|
+
|
26
|
+
def initialize(hash)
|
27
|
+
@lock_mode = hash['lockmode']
|
28
|
+
@thumbnail = hash['thumbnail']
|
29
|
+
item_details_base(hash)
|
30
|
+
end
|
31
|
+
|
32
|
+
def ==(other)
|
33
|
+
compare(self, other)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# return type for Profiles.GetProfiles
|
38
|
+
class GetProfilesReturned
|
39
|
+
include Comparable
|
40
|
+
|
41
|
+
attr_reader :limits, :profiles
|
42
|
+
|
43
|
+
def initialize(hash)
|
44
|
+
@limits = Types::List::ListLimitsReturned.new(hash['limits'])
|
45
|
+
@profiles = hash['profiles'].nil? ? [] : hash['profiles'].map { |it| Types::Profiles::DetailsProfile.new(it) }
|
46
|
+
end
|
47
|
+
|
48
|
+
def ==(other)
|
49
|
+
compare(self, other)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Profiles.Password https://kodi.wiki/view/JSON-RPC_API/v12#Profiles.Password
|
54
|
+
class ProfilePassword
|
55
|
+
include Comparable
|
56
|
+
|
57
|
+
attr_reader :value, :encryption
|
58
|
+
|
59
|
+
def initialize(value, encryption = Types::Global::PasswordEncryption::MD5)
|
60
|
+
@value = value
|
61
|
+
@encryption = encryption
|
62
|
+
end
|
63
|
+
|
64
|
+
def ==(other)
|
65
|
+
compare(self, other)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -17,6 +17,7 @@ module KodiClient
|
|
17
17
|
h = request.instance_variables.each_with_object({}) do |var, hash|
|
18
18
|
hash[var.to_s.delete('@')] = request.instance_variable_get(var)
|
19
19
|
end
|
20
|
+
|
20
21
|
@http_client ||= build_client
|
21
22
|
response = @http_client.post(@endpoint_url, json: h).to_s
|
22
23
|
JSON.parse(response)
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'kodi_client/kodi_module'
|
4
|
+
require 'kodi_client/global_types/profiles_types'
|
5
|
+
|
6
|
+
module KodiClient
|
7
|
+
module Modules
|
8
|
+
# contains all Kodi Application methods
|
9
|
+
class Profiles < KodiModule
|
10
|
+
|
11
|
+
GET_CURRENT_PROFILE = 'Profiles.GetCurrentProfile'
|
12
|
+
GET_PROFILES = 'Profiles.GetProfiles'
|
13
|
+
LOAD_PROFILE = 'Profiles.LoadProfile'
|
14
|
+
|
15
|
+
def get_current_profile(properties = Types::Profiles::FieldsProfile.all_properties, kodi_id = 1)
|
16
|
+
request = KodiRequest.new(kodi_id, GET_CURRENT_PROFILE, { 'properties' => properties })
|
17
|
+
json = invoke_api(request)
|
18
|
+
result = json['result'].nil? ? nil : Types::Profiles::DetailsProfile.new(json['result'])
|
19
|
+
json['result'] = result
|
20
|
+
KodiResponse.new(json)
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_profiles(properties = Types::Profiles::FieldsProfile.all_properties,
|
24
|
+
limit = Types::List::ListLimits.new(0, 50),
|
25
|
+
sort = Types::List::ListSort.new, kodi_id = 1)
|
26
|
+
request = KodiRequest.new(kodi_id, GET_PROFILES,
|
27
|
+
{ 'properties' => properties,
|
28
|
+
'limits' => { 'start' => limit.list_start, 'end' => limit.list_end },
|
29
|
+
'sort' => { 'ignorearticle' => sort.ignore_article, 'method' => sort.method,
|
30
|
+
'order' => sort.order,
|
31
|
+
'useartistsortname' => sort.use_artist_sort_name } })
|
32
|
+
json = invoke_api(request)
|
33
|
+
result = json['result'].nil? ? nil : Types::Profiles::GetProfilesReturned.new(json['result'])
|
34
|
+
json['result'] = result
|
35
|
+
KodiResponse.new(json)
|
36
|
+
end
|
37
|
+
|
38
|
+
def load_profile(profile_name, password, prompt = false, kodi_id = 1)
|
39
|
+
request = KodiRequest.new(kodi_id, LOAD_PROFILE,
|
40
|
+
{ 'profile' => profile_name,
|
41
|
+
'password' => { 'value' => password.value, 'encryption' => password.encryption },
|
42
|
+
'prompt' => prompt })
|
43
|
+
json = invoke_api(request)
|
44
|
+
KodiResponse.new(json)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/kodi_client.rb
CHANGED
@@ -10,6 +10,7 @@ require 'kodi_client/method/favourites'
|
|
10
10
|
require 'kodi_client/method/gui'
|
11
11
|
require 'kodi_client/method/input'
|
12
12
|
require 'kodi_client/method/player'
|
13
|
+
require 'kodi_client/method/profiles'
|
13
14
|
require 'kodi_client/method/system'
|
14
15
|
|
15
16
|
|
@@ -21,7 +22,7 @@ module KodiClient
|
|
21
22
|
class Client
|
22
23
|
include Chainable
|
23
24
|
|
24
|
-
attr_reader :addons, :application, :gui, :player, :input, :favourites, :system
|
25
|
+
attr_reader :addons, :application, :gui, :player, :input, :favourites, :system, :profiles
|
25
26
|
|
26
27
|
def initialize
|
27
28
|
@addons = KodiClient::Modules::Addons.new
|
@@ -30,6 +31,7 @@ module KodiClient
|
|
30
31
|
@gui = KodiClient::Modules::GUI.new
|
31
32
|
@input = KodiClient::Modules::Input.new
|
32
33
|
@player = KodiClient::Modules::Player.new
|
34
|
+
@profiles = KodiClient::Modules::Profiles.new
|
33
35
|
@system = KodiClient::Modules::System.new
|
34
36
|
end
|
35
37
|
|
@@ -40,7 +42,20 @@ module KodiClient
|
|
40
42
|
@input.apply_options(options)
|
41
43
|
@player.apply_options(options)
|
42
44
|
@favourites.apply_options(options)
|
45
|
+
@profiles.apply_options(options)
|
43
46
|
@system.apply_options(options)
|
44
47
|
end
|
45
48
|
end
|
46
49
|
end
|
50
|
+
|
51
|
+
client = KodiClient.connect('10.88.111.7', 8080).auth('kodi', 'pw')
|
52
|
+
a = client.profiles
|
53
|
+
b = a.get_current_profile
|
54
|
+
puts b
|
55
|
+
# # a.player_open('http://10.88.111.7:1238/%25/2734c6a5037a2c2cafb3b3c184e1ee6f/Breaking%2520Bad%2520-%2520S01E01%2520-%2520Pilot.mkv')
|
56
|
+
# a.player_open('C:\Users\Chris\Downloads\bla\Breaking Bad - S01E01 - Pilot.mkv')
|
57
|
+
# c = a.get_view_mode
|
58
|
+
# puts c
|
59
|
+
# a = KodiClient.connect('10.88.111.7', 8080).auth('kodi', 'pw')
|
60
|
+
# b = a.application
|
61
|
+
# b.quit
|
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.
|
4
|
+
version: 0.5.5
|
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 and system (more will
|
29
|
-
with the time). For more information how to use it and how to activate
|
30
|
-
in Kodi, please check the github page https://github.com/cfe86/RubyKodiClient
|
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
|
31
31
|
email:
|
32
32
|
- christian.feier@gmail.com
|
33
33
|
executables: []
|
@@ -54,6 +54,7 @@ files:
|
|
54
54
|
- lib/kodi_client/global_types/list_types.rb
|
55
55
|
- lib/kodi_client/global_types/media_types.rb
|
56
56
|
- lib/kodi_client/global_types/player_type.rb
|
57
|
+
- lib/kodi_client/global_types/profiles_types.rb
|
57
58
|
- lib/kodi_client/global_types/pvr_type.rb
|
58
59
|
- lib/kodi_client/global_types/system_types.rb
|
59
60
|
- lib/kodi_client/global_types/video_types.rb
|
@@ -64,6 +65,7 @@ files:
|
|
64
65
|
- lib/kodi_client/method/gui.rb
|
65
66
|
- lib/kodi_client/method/input.rb
|
66
67
|
- lib/kodi_client/method/player.rb
|
68
|
+
- lib/kodi_client/method/profiles.rb
|
67
69
|
- lib/kodi_client/method/system.rb
|
68
70
|
- lib/kodi_client/options.rb
|
69
71
|
- lib/kodi_client/util/comparable.rb
|