apple_music_library 0.4.0 → 0.5.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90fcf6cf83ff9c5cf4bf0cf022ad5b4038c0464277a86e20c658580661cb233a
4
- data.tar.gz: 3498457024ed7a40644dc14baa9eccb7b1f072e92d28f7739cf49959c86d90ea
3
+ metadata.gz: 28f3fe7d3df7d724f7e7290f9eb6c33e2dae08d22e60ed07dfeb87c9bda9c283
4
+ data.tar.gz: 302301b2f8dd1826f71d18474fa15dfa804babf481b46ab4db99694364e0342f
5
5
  SHA512:
6
- metadata.gz: 86f0e0d87e57d27a93034f0b055399c37c2a265984726eba7b1dc2e6ddd15a2ebb34a11676c64411417e772320ec170bad7b52eb91c35f703a9cd6286c923a74
7
- data.tar.gz: 4ebe190007f3e9426dfe6968b61934cea5bc23e63cb72d4a824de9ff5a97061abd27b9dc91639c4af8492f438d04623338581a5c99697dbb920cbc1f89d6af19
6
+ metadata.gz: 5bcb31d7d2326fe4d6f614a6a29a6c69b4e47e349a235b47234afc97f10618630eb4ae995bfc2c402fe2629d080e6834067cc2b6606ba22132c1662af9d19c1e
7
+ data.tar.gz: d1785f58aab9a2a75d1c77ce165f37307141af7dc25833d12f669dbc0c201a9633384187c9d71b36e3a5e7a8c1f7a8696d8e14197b826f5538d5b49e3310cd82
data/CHANGELOG.md CHANGED
@@ -3,7 +3,11 @@
3
3
  ## [Unreleased]
4
4
  - Ability to print out playlist folder hierarchy
5
5
 
6
- ## 0.4.0 - 2022-03-10
6
+ ## 0.5.0 - 2022-03-11
7
+ ### Added
8
+ - Basic functionality for track ratings via the #rating, #star_rating, and #loved
9
+
10
+ ## 0.4.0 - 2022-03-11
7
11
  ### Added
8
12
  - Basic functionality for Playlist Folders
9
13
  ### Fixed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- apple_music_library (0.4.0)
4
+ apple_music_library (0.5.0)
5
5
  facets (~> 3.1)
6
6
  plist (~> 3.6)
7
7
 
data/README.md CHANGED
@@ -44,6 +44,9 @@ end
44
44
  artist = library.artist('XTC')
45
45
  puts artist.tracks.count
46
46
 
47
+ # Get favorite tracks by this artists
48
+ favorite_tracks = artist.tracks.select{|t| t.loved? || t.star_rating > 3}
49
+
47
50
  # Display track counts per genre
48
51
  library.genres.each do |genre|
49
52
  puts "#{genre.tracks.count} #{genre.name}"
@@ -76,8 +76,8 @@ module AppleMusicLibrary
76
76
  PlaylistFolder.find_by_name(playlist_folder_name)
77
77
  end
78
78
 
79
- def tracks
80
- @tracks ||= Track.all
79
+ def tracks(filter = nil)
80
+ filter.present? ? Track.send(filter) : Track.all
81
81
  end
82
82
 
83
83
  def track(track_id)
@@ -24,6 +24,7 @@ module AppleMusicLibrary
24
24
  'Rating',
25
25
  'Album Rating',
26
26
  'Album Rating Computed',
27
+ 'Loved',
27
28
  'Normalization',
28
29
  'Persistent ID',
29
30
  'Track Type',
@@ -55,6 +56,10 @@ module AppleMusicLibrary
55
56
  @@tracks.values
56
57
  end
57
58
 
59
+ def self.loved
60
+ @loved ||= self.all.select{|t| t.loved?}
61
+ end
62
+
58
63
  def id
59
64
  track_id
60
65
  end
@@ -71,6 +76,14 @@ module AppleMusicLibrary
71
76
  @info['Genre']
72
77
  end
73
78
 
79
+ def star_rating
80
+ rating / 20
81
+ end
82
+
83
+ def loved?
84
+ loved
85
+ end
86
+
74
87
  ATTRIBUTES.each do |track_attribute|
75
88
  define_method(track_attribute.to_s.snakecase) do
76
89
  @info[track_attribute]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AppleMusicLibrary
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apple_music_library
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Gehman