apple_music_library 0.11.0 → 0.13.1

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: 7b345adc65b1d7e12d09e6a7019a857b8abd77ae831420d92e33266b0106fd61
4
- data.tar.gz: a372d17051416b41edfd62095b5f09b35bd0ca580dffbf545650caac9c0283c8
3
+ metadata.gz: 8b462ccaf045f625899fb62099d659bbe3f7a3b8ea46cc59e376623656ed2646
4
+ data.tar.gz: f96477c3e0fc3243e44753970cd15c9ead277e3f8fed96d822dbdbeeabd3b328
5
5
  SHA512:
6
- metadata.gz: 1261413cf1b0583017abcc2189f986927820a67faa1d970e70fbe42e4ecf27bfa41adaf3599829f210cbfd5f12b1dda8c544f935405a43dced50f8349f2d7a28
7
- data.tar.gz: 1cda8031165413f399bfa1eeaf58187063435f0a5598cf190b11cabc3785d7a45f0ce99d356e3176aad894ba48bcbb911cc183254ff821c136807bb669db867a
6
+ metadata.gz: 559439425509081f89e3386783a4825529c85bcca29b48b0db7a962fdf8ea3221db926876db353d9663283c1c8b6f25dcd77444926a6778567be9868d6c1239a
7
+ data.tar.gz: f6d84390ebd8fcb18a9fea28ced25edb255cac78038fef702e7744195b240c666d6fea4201e8de00cebc2ffec487746b456fb6d55162203bd9b97da822c6d357
data/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
3
3
  ## [Unreleased]
4
4
  - Ability to print out playlist folder hierarchy
5
5
 
6
+ ## 0.13.1 - 2022-03-16
7
+ ### Fixed
8
+ - Now strips leading/trailing whitespace from artist and track names
9
+
10
+ ## 0.13.0 - 2022-03-26
11
+ ### Added
12
+ - Added handling for system verses user-created playlists
13
+
14
+ ## 0.12.0 - 2022-03-26
15
+ ### Added
16
+ - Added handling for smart versus regular playlists
17
+
6
18
  ## 0.11.0 - 2022-03-19
7
19
  ### Added
8
20
  - Added Decade model to retrieve track and album info per decade
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- apple_music_library (0.11.0)
4
+ apple_music_library (0.13.1)
5
5
  facets (~> 3.1)
6
6
  plist (~> 3.6)
7
7
 
data/README.md CHANGED
@@ -32,12 +32,29 @@ library = AppleMusicLibrary.new('path/to/Library.xml')
32
32
  # Count albums
33
33
  puts library.albums.count
34
34
 
35
- # Show playlist inside playlist folder
35
+ # Show playlists contained in a playlist folder
36
36
  playlist_folder = library.playlist_folder('Folder for Testing')
37
37
  playlist_folder.playlists.each do |playlist|
38
38
  puts playlist.name
39
39
  end
40
40
 
41
+ # List all playlists
42
+ library.playlists.each do |playlist|
43
+ puts playlist.name
44
+ end
45
+
46
+ # List only 'smart' playlists
47
+ library.playlists(:smart).each do |playlist|
48
+ puts playlist.name
49
+ end
50
+
51
+ # List all regular (not 'smart') playlists
52
+ # This filter also excludes apple-created playlists (e.g. the 'Library' and 'Downloaded' playlists)
53
+ library.playlists(:regular).each do |playlist|
54
+ puts playlist.name
55
+ end
56
+
57
+
41
58
  # Show tracks in a specific playlist
42
59
  playlist = library.playlist('XTC Favorites')
43
60
  playlist.tracks.each do |track|
@@ -88,10 +105,10 @@ end
88
105
 
89
106
  # Print a report on all decades in the library
90
107
  # e.g.
91
- # 1990-1999 - 7217 tracks on 1030 albums
92
- # 2000-2009 - 9083 tracks on 1876 albums
93
- # 2010-2019 - 4729 tracks on 1046 albums
94
- # 2020-2029 - 1074 tracks on 455 albums
108
+ # 1970-1979 - 336 tracks on 10 albums
109
+ # 1980-1989 - 816 tracks on 16 albums
110
+ # 1990-1999 - 300 tracks on 8 albums
111
+ # 2000-2009 - 110 tracks on 5 albums
95
112
  library.decades_report
96
113
 
97
114
 
@@ -6,7 +6,7 @@ module AppleMusicLibrary
6
6
  @@artists = {}
7
7
 
8
8
  def initialize(name)
9
- @name = name
9
+ @name = name.strip
10
10
  @albums = []
11
11
  @tracks = []
12
12
  end
@@ -54,8 +54,9 @@ module AppleMusicLibrary
54
54
  Genre.find_by_name(genre_name)
55
55
  end
56
56
 
57
- def playlists
58
- @playlists ||= Playlist.all
57
+ def playlists(filter = nil)
58
+ return Playlist.all unless filter
59
+ Playlist.send(filter)
59
60
  end
60
61
 
61
62
  def playlist(playlist_name)
@@ -8,16 +8,25 @@ module AppleMusicLibrary
8
8
 
9
9
  @@playlists = {}
10
10
 
11
- ATTRIBUTES = ['Name',
12
- 'Description',
13
- 'Playlist ID',
14
- 'Playlist Persistent ID',
15
- 'Parent Persistent ID',
16
- 'All Items',
17
- 'Smart Info',
18
- 'Smart Criteria',
19
- 'Playlist Items',
20
- 'Folder']
11
+ ATTRIBUTES = [
12
+ 'Name',
13
+ 'Description',
14
+ 'Playlist ID',
15
+ 'Playlist Persistent ID',
16
+ 'Parent Persistent ID',
17
+ 'All Items',
18
+ 'Smart Info',
19
+ 'Smart Criteria',
20
+ 'Playlist Items',
21
+ 'Folder'
22
+ ]
23
+
24
+ SYSTEM_PLAYLISTS = [
25
+ 'Downloaded',
26
+ 'Library',
27
+ 'Music',
28
+ 'Recently Played'
29
+ ]
21
30
 
22
31
  def initialize(info)
23
32
  @info = info
@@ -37,6 +46,18 @@ module AppleMusicLibrary
37
46
  @@playlists.values
38
47
  end
39
48
 
49
+ def self.smart
50
+ @@playlists.values.select{|p| p.smart?}
51
+ end
52
+
53
+ def self.regular
54
+ @@playlists.values.select{|p| !p.smart? and !p.system?}
55
+ end
56
+
57
+ def self.system
58
+ @@playlists.values.select{|p| p.system?}
59
+ end
60
+
40
61
  def self.find_by_name(playlist_name)
41
62
  results = @@playlists.values.select{|p| p.name == playlist_name}
42
63
  if results.size == 1
@@ -59,6 +80,14 @@ module AppleMusicLibrary
59
80
  folder.present?
60
81
  end
61
82
 
83
+ def smart?
84
+ smart_info.present?
85
+ end
86
+
87
+ def system?
88
+ SYSTEM_PLAYLISTS.include?(name)
89
+ end
90
+
62
91
  def token
63
92
  :playlist
64
93
  end
@@ -2,7 +2,7 @@ require 'facets'
2
2
 
3
3
  module AppleMusicLibrary
4
4
  class Track
5
- attr_reader :artist, :album, :genre
5
+ attr_reader :artist, :album, :genre, :info
6
6
 
7
7
  # 'Artist', The #artist, #album, and #genre methods return objects rather than strings and have methods like #artist_name to retrieve the strings.
8
8
  # 'Album',
@@ -105,7 +105,7 @@ module AppleMusicLibrary
105
105
 
106
106
  ATTRIBUTES.each do |track_attribute|
107
107
  define_method(track_attribute.to_s.snakecase) do
108
- @info[track_attribute]
108
+ @info[track_attribute].class.name == 'String' ? @info[track_attribute].strip : @info[track_attribute]
109
109
  end
110
110
  end
111
111
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AppleMusicLibrary
4
- VERSION = "0.11.0"
4
+ VERSION = "0.13.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apple_music_library
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Gehman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-19 00:00:00.000000000 Z
11
+ date: 2022-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print