apple_music_library 0.5.0 → 0.6.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: 28f3fe7d3df7d724f7e7290f9eb6c33e2dae08d22e60ed07dfeb87c9bda9c283
4
- data.tar.gz: 302301b2f8dd1826f71d18474fa15dfa804babf481b46ab4db99694364e0342f
3
+ metadata.gz: 63c39fb0820781890a73912185de50cd207af719b59d25a022626374f1ab8eac
4
+ data.tar.gz: 99d363ef519977c4b2786684e539289a58cf76503e397c34c7060f42a02c52aa
5
5
  SHA512:
6
- metadata.gz: 5bcb31d7d2326fe4d6f614a6a29a6c69b4e47e349a235b47234afc97f10618630eb4ae995bfc2c402fe2629d080e6834067cc2b6606ba22132c1662af9d19c1e
7
- data.tar.gz: d1785f58aab9a2a75d1c77ce165f37307141af7dc25833d12f669dbc0c201a9633384187c9d71b36e3a5e7a8c1f7a8696d8e14197b826f5538d5b49e3310cd82
6
+ metadata.gz: e8f45294602867c1de2a10ad3dbe1d88ad02508dc6060712c0cdb436e032c93ea5eb35f69eb0a9e9f1c5dae98089666d8928919f140b668d1c8980b11a7ec517
7
+ data.tar.gz: d0724a89d0d22c4be3a65550253284e176102e3c2c2f085ace60418516ba333ed7ebbdc25fda382ee18303d47bf29eeef256b533b231c733813f473c3c28a3a5
data/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  ## [Unreleased]
4
4
  - Ability to print out playlist folder hierarchy
5
5
 
6
+ ## 0.6.0 - 2022-03-11
7
+ ### Added
8
+ - Ability to sort list top artists by play count
9
+
6
10
  ## 0.5.0 - 2022-03-11
7
11
  ### Added
8
12
  - Basic functionality for track ratings via the #rating, #star_rating, and #loved
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- apple_music_library (0.5.0)
4
+ apple_music_library (0.6.0)
5
5
  facets (~> 3.1)
6
6
  plist (~> 3.6)
7
7
 
data/README.md CHANGED
@@ -44,9 +44,14 @@ end
44
44
  artist = library.artist('XTC')
45
45
  puts artist.tracks.count
46
46
 
47
- # Get favorite tracks by this artists
47
+ # Get favorite tracks by this artist
48
48
  favorite_tracks = artist.tracks.select{|t| t.loved? || t.star_rating > 3}
49
49
 
50
+ # List out the most played artists
51
+ library.artists(:most_played).each do |artist|
52
+ puts "#{artist.play_count} :: #{artist.name}"
53
+ end
54
+
50
55
  # Display track counts per genre
51
56
  library.genres.each do |genre|
52
57
  puts "#{genre.tracks.count} #{genre.name}"
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
 
19
19
  spec.metadata["homepage_uri"] = spec.homepage
20
20
  spec.metadata["source_code_uri"] = "https://github.com/pugetive/apple_music_library"
21
- # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
21
+ spec.metadata["changelog_uri"] = "https://github.com/pugetive/apple_music_library/blob/main/CHANGELOG.md"
22
22
 
23
23
  # Specify which files should be added to the gem when it is released.
24
24
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -15,6 +15,14 @@ module AppleMusicLibrary
15
15
  @@artists.values
16
16
  end
17
17
 
18
+ def self.most_played(limit = 20)
19
+ if limit.nil?
20
+ self.all.sort_by(&:play_count).reverse
21
+ else
22
+ self.all.sort_by(&:play_count).reverse.take(limit)
23
+ end
24
+ end
25
+
18
26
  def self.find_or_create(name)
19
27
  if @@artists[name]
20
28
  return @@artists[name]
@@ -49,5 +57,9 @@ module AppleMusicLibrary
49
57
  @tracks
50
58
  end
51
59
 
60
+ def play_count
61
+ tracks.map(&:play_count).sum
62
+ end
63
+
52
64
  end
53
65
  end
@@ -44,8 +44,8 @@ module AppleMusicLibrary
44
44
  @albums ||= Album.all
45
45
  end
46
46
 
47
- def artists
48
- @artists ||= Artist.all
47
+ def artists(filter = nil, limit = nil)
48
+ filter.present? ? Artist.send(filter, limit) : Artist.all
49
49
  end
50
50
 
51
51
  def artist(artist_name)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AppleMusicLibrary
4
- VERSION = "0.5.0"
4
+ VERSION = "0.6.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.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Gehman
@@ -140,6 +140,7 @@ licenses:
140
140
  metadata:
141
141
  homepage_uri: https://github.com/pugetive/apple_music_library
142
142
  source_code_uri: https://github.com/pugetive/apple_music_library
143
+ changelog_uri: https://github.com/pugetive/apple_music_library/blob/main/CHANGELOG.md
143
144
  post_install_message:
144
145
  rdoc_options: []
145
146
  require_paths: