kodi_client 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/kodi_client.gemspec +1 -1
- data/lib/kodi_client/extensions/creatable.rb +7 -12
- data/lib/kodi_client/types/audio/audio_details_artist_type.rb +1 -2
- data/lib/kodi_client/types/audio/audio_details_base_type.rb +1 -2
- data/lib/kodi_client/types/audio/audio_details_media_type.rb +4 -0
- data/lib/kodi_client/types/audio/audio_details_song_type.rb +2 -6
- data/lib/kodi_client/types/items/item_details_base_type.rb +1 -1
- data/lib/kodi_client/types/list/list_item_all_type.rb +1 -4
- data/lib/kodi_client/types/list/list_item_base_type.rb +11 -8
- data/lib/kodi_client/types/list/list_item_file_type.rb +2 -4
- data/lib/kodi_client/types/media/media_details_base_type.rb +2 -1
- data/lib/kodi_client/types/video/video_details_file_type.rb +8 -8
- data/lib/kodi_client/types/video/video_details_item_type.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9680c9f9dfa0c615b2f9291c9b8cf6eebc7eada7f505cbea740392d1713fabf
|
4
|
+
data.tar.gz: 965748a029340c66498531049584de14255e91206e5781be0cd41f3d392e32f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98754c7aa49b524de6a1569361dac82f42eb34dc760b599588db0431832c467e5b19f62732f46482da267ff6858db4c2ccbfbedcba768b52e01fb819abb2aa76
|
7
|
+
data.tar.gz: 2bea819a70f7bc67009966e2f428d9a64c3514e26a4de7cb5f96dcb57bb74fb9d57abb9812adee779385dd4f0863f2a5811900cd5f0a02f1897102b5b6b1501e
|
data/kodi_client.gemspec
CHANGED
@@ -20,13 +20,11 @@ module KodiClient
|
|
20
20
|
return if args.nil?
|
21
21
|
|
22
22
|
@type_mapping = {}
|
23
|
-
args.map { |it| @type_mapping[it[0]] = Creatable
|
23
|
+
args.map { |it| @type_mapping[it[0]] = Creatable.arr_to_mapping(it) }
|
24
24
|
end
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
def lazy_type_mapping
|
29
|
-
{}
|
26
|
+
def self.arr_to_mapping(arr)
|
27
|
+
Creatable::CreateMap.new(arr[1], arr[2].nil? ? false : arr[2])
|
30
28
|
end
|
31
29
|
|
32
30
|
# expects the given hash is a list of hashes and calls #create on each element
|
@@ -51,7 +49,7 @@ module KodiClient
|
|
51
49
|
fields = @fields_to_map
|
52
50
|
end
|
53
51
|
|
54
|
-
mapping = @type_mapping.nil? ?
|
52
|
+
mapping = @type_mapping.nil? ? {} : @type_mapping
|
55
53
|
args = fields.map do |it|
|
56
54
|
field = it.to_s.gsub('_', '')
|
57
55
|
Creatable.extract_field_from_hash(field, hash, mapping)
|
@@ -65,22 +63,19 @@ module KodiClient
|
|
65
63
|
# used
|
66
64
|
# @param hash [Hash] the given hash
|
67
65
|
# @param fields [Array<String>] the fields to extract
|
68
|
-
# @param mapping [Hash<String
|
66
|
+
# @param mapping [Hash<String>, Array<Array<String>>] optional mapping if a field contains a complex type
|
69
67
|
# @return [Array] an array containing the values of hash[field] in the given field order
|
70
68
|
def self.hash_to_arr(hash, fields, mapping = {})
|
71
69
|
return nil if hash.nil?
|
72
70
|
|
71
|
+
mapping = mapping.map { |it| arr_to_mapping(it) } unless mapping.is_a?(Hash)
|
72
|
+
|
73
73
|
fields.map do |it|
|
74
74
|
field = it.to_s.gsub('_', '')
|
75
75
|
extract_field_from_hash(field, hash, mapping)
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
# map to self.hash_to_arr. The mapping is taken from #type_mapping
|
80
|
-
def hash_to_arr(hash, fields)
|
81
|
-
Creatable.hash_to_arr(hash, fields, @type_mapping.nil? ? {} : @type_mapping)
|
82
|
-
end
|
83
|
-
|
84
79
|
# extracts the given field from the given hash and optionally applies mapping if given
|
85
80
|
# @param field [String] the field name
|
86
81
|
# @param hash [Hash, nil] the hash where to extract the field from
|
@@ -18,8 +18,7 @@ module KodiClient
|
|
18
18
|
sort_name source_id style type years_active art date_added genre fan_art thumbnail
|
19
19
|
label]
|
20
20
|
|
21
|
-
type_mapping ['songgenres', Genre, true], ['art', Types::Media::MediaArtwork],
|
22
|
-
['roles', AudioArtistRole, true]
|
21
|
+
type_mapping ['songgenres', Genre, true], ['art', Types::Media::MediaArtwork], ['roles', AudioArtistRole, true]
|
23
22
|
|
24
23
|
def initialize(artist, artist_id, born, compilation_artist, description, died, disambiguation, disbanded,
|
25
24
|
formed, gender, instrument, is_album_artist, mood, musicbrainz_artist_id, roles, song_genres,
|
@@ -10,8 +10,7 @@ module KodiClient
|
|
10
10
|
attr_reader :art, :date_added, :genre
|
11
11
|
|
12
12
|
def audio_details_base_mappings
|
13
|
-
|
14
|
-
mappings.merge(media_details_base_mappings)
|
13
|
+
[['art', Types::Media::MediaArtwork]] + media_details_base_mappings
|
15
14
|
end
|
16
15
|
|
17
16
|
def audio_details_base_by_hash(hash)
|
@@ -7,6 +7,10 @@ module KodiClient
|
|
7
7
|
module AudioDetailsMedia
|
8
8
|
include AudioDetailsBase
|
9
9
|
|
10
|
+
def self.included(base)
|
11
|
+
base.extend(self)
|
12
|
+
end
|
13
|
+
|
10
14
|
attr_reader :artist, :artist_id, :display_artist, :musicbrainz_album_artist_id, :original_date, :rating,
|
11
15
|
:release_date, :sort_artist, :title, :user_rating, :votes, :year
|
12
16
|
|
@@ -8,7 +8,6 @@ module KodiClient
|
|
8
8
|
include AudioDetailsMedia
|
9
9
|
include Extensions::Comparable
|
10
10
|
extend Extensions::Creatable
|
11
|
-
extend AudioDetailsMedia
|
12
11
|
|
13
12
|
attr_reader :album, :album_artist, :album_artist_id, :album_id, :album_release_type, :bitrate, :bpm, :channels,
|
14
13
|
:comment, :contributors, :disc, :disc_title, :display_composer, :display_conductor,
|
@@ -16,6 +15,8 @@ module KodiClient
|
|
16
15
|
:musicbrainz_artist_id, :musicbrainz_track_id, :play_count, :sample_rate, :song_id, :source_id,
|
17
16
|
:track
|
18
17
|
|
18
|
+
type_mapping ['contributors', Types::Audio::AudioContributor, true], *audio_details_media_mappings
|
19
|
+
|
19
20
|
fields_to_map %w[album album_artist album_artist_id album_id album_release_type bitrate bpm channels
|
20
21
|
comment contributors disc disc_title display_composer display_conductor display_lyricist
|
21
22
|
display_orchestra duration file genre_id last_played lyrics mood musicbrainz_artist_id
|
@@ -24,11 +25,6 @@ module KodiClient
|
|
24
25
|
rating release_date sort_artist title user_rating votes year
|
25
26
|
art date_added genre fan_art thumbnail label]
|
26
27
|
|
27
|
-
def self.lazy_type_mapping
|
28
|
-
mapping = { 'contributors' => Extensions::Creatable::CreateMap.new(Types::Audio::AudioContributor, true) }
|
29
|
-
mapping.merge(audio_details_media_mappings)
|
30
|
-
end
|
31
|
-
|
32
28
|
def initialize(album, album_artist, album_artist_id, album_id, album_release_type, bitrate, bpm, channels,
|
33
29
|
comment, contributors, disc, disc_title, display_composer, display_conductor, display_lyricist,
|
34
30
|
display_orchestra, duration, file, genre_id, last_played, lyrics, mood, musicbrainz_artist_id,
|
@@ -8,7 +8,6 @@ module KodiClient
|
|
8
8
|
include ListItemBase
|
9
9
|
include Extensions::Comparable
|
10
10
|
extend Extensions::Creatable
|
11
|
-
extend ListItemBase
|
12
11
|
|
13
12
|
attr_reader :channel, :channel_number, :channel_type, :end_time, :hidden, :locked, :start_time,
|
14
13
|
:sub_channel_number
|
@@ -27,9 +26,7 @@ module KodiClient
|
|
27
26
|
fan_art thumbnail label artist artist_id display_artist musicbrainz_album_artist_id
|
28
27
|
rating sort_artist user_rating year genre]
|
29
28
|
|
30
|
-
|
31
|
-
list_item_base_mappings
|
32
|
-
end
|
29
|
+
type_mapping(*list_item_base_mappings)
|
33
30
|
|
34
31
|
def initialize(channel, channel_number, channel_type, end_time, hidden, locked, start_time, sub_channel_number,
|
35
32
|
album, album_artist, album_artist_id, album_id, album_release_type, album_status, bit_rate,
|
@@ -8,6 +8,10 @@ module KodiClient
|
|
8
8
|
include Video::VideoDetailsFile
|
9
9
|
include Audio::AudioDetailsMedia
|
10
10
|
|
11
|
+
def self.included(base)
|
12
|
+
base.extend(self)
|
13
|
+
end
|
14
|
+
|
11
15
|
attr_reader :album, :album_artist, :album_artist_id, :album_id, :album_release_type, :album_status, :bit_rate,
|
12
16
|
:bpm, :cast, :channels, :comment, :compilation, :contributors, :country, :description, :disc,
|
13
17
|
:disc_title, :display_composer, :display_conductor, :display_lyricist, :display_orchestra,
|
@@ -19,14 +23,13 @@ module KodiClient
|
|
19
23
|
:trailer, :tv_show_id, :type, :unique_id, :votes, :watched_episodes, :writer
|
20
24
|
|
21
25
|
def list_item_base_mappings
|
22
|
-
|
23
|
-
'cast'
|
24
|
-
'contributors'
|
25
|
-
'resume'
|
26
|
-
'streamdetails'
|
27
|
-
'art'
|
28
|
-
|
29
|
-
mappings.merge(video_details_file_mappings).merge(audio_details_media_mappings)
|
26
|
+
[
|
27
|
+
['cast', Video::VideoCast, true],
|
28
|
+
['contributors', Audio::AudioContributor, true],
|
29
|
+
['resume', Video::VideoResume],
|
30
|
+
['streamdetails', Video::StreamDetails],
|
31
|
+
['art', Media::MediaArtwork]
|
32
|
+
] + video_details_file_mappings + audio_details_media_mappings
|
30
33
|
end
|
31
34
|
|
32
35
|
def list_item_base_by_hash(hash)
|
@@ -8,7 +8,6 @@ module KodiClient
|
|
8
8
|
include ListItemBase
|
9
9
|
include Extensions::Comparable
|
10
10
|
extend Extensions::Creatable
|
11
|
-
extend ListItemBase
|
12
11
|
|
13
12
|
attr_reader :file, :file_type, :last_modified, :mime_type, :size
|
14
13
|
|
@@ -26,9 +25,8 @@ module KodiClient
|
|
26
25
|
fan_art thumbnail label artist artist_id display_artist musicbrainz_album_artist_id
|
27
26
|
rating sort_artist user_rating year genre]
|
28
27
|
|
29
|
-
|
30
|
-
|
31
|
-
end
|
28
|
+
type_mapping(*list_item_base_mappings)
|
29
|
+
|
32
30
|
|
33
31
|
def initialize(file_type, last_modified, mime_type, size,
|
34
32
|
album, album_artist, album_artist_id, album_id, album_release_type, album_status, bit_rate,
|
@@ -14,7 +14,8 @@ module KodiClient
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def media_details_base_by_hash(hash)
|
17
|
-
media_details_base(*Extensions::Creatable.hash_to_arr(hash, %w[fan_art thumbnail label]),
|
17
|
+
media_details_base(*Extensions::Creatable.hash_to_arr(hash, %w[fan_art thumbnail label]),
|
18
|
+
media_details_base_mappings)
|
18
19
|
end
|
19
20
|
|
20
21
|
def media_details_base(fan_art, thumbnail, label)
|
@@ -10,17 +10,17 @@ module KodiClient
|
|
10
10
|
attr_reader :director, :resume, :runtime, :stream_details
|
11
11
|
|
12
12
|
def video_details_file_mappings
|
13
|
-
|
14
|
-
'resume'
|
15
|
-
'streamdetails'
|
16
|
-
|
17
|
-
mappings.merge(video_details_item_mappings)
|
13
|
+
[
|
14
|
+
['resume', VideoResume],
|
15
|
+
['streamdetails', StreamDetails]
|
16
|
+
] + video_details_item_mappings
|
18
17
|
end
|
19
18
|
|
20
19
|
def video_details_file_by_hash(hash)
|
21
|
-
video_details_file(*Extensions::Creatable.hash_to_arr(hash, %w[director resume runtime stream_details
|
22
|
-
|
23
|
-
|
20
|
+
video_details_file(*Extensions::Creatable.hash_to_arr(hash, %w[director resume runtime stream_details
|
21
|
+
date_added file last_played plot title art
|
22
|
+
play_count fan_art thumbnail label],
|
23
|
+
video_details_file_mappings))
|
24
24
|
end
|
25
25
|
|
26
26
|
def video_details_file(director, resume, runtime, stream_details, date_added, file, last_played, plot, title,
|
@@ -15,7 +15,7 @@ module KodiClient
|
|
15
15
|
|
16
16
|
def video_details_item_by_hash(hash)
|
17
17
|
video_details_item(*Extensions::Creatable.hash_to_arr(hash, %w[date_added file last_played plot title art
|
18
|
-
|
18
|
+
play_count fan_art thumbnail label],
|
19
19
|
video_details_item_mappings))
|
20
20
|
end
|
21
21
|
|