itunes_parser 1.0.3 → 1.1.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 +4 -4
- data/README.md +39 -27
- data/Rakefile +10 -1
- data/itunes_parser.gemspec +3 -1
- data/lib/itunes_parser.rb +5 -3
- data/lib/itunes_parser/playlist.rb +2 -2
- data/lib/itunes_parser/track.rb +1 -1
- data/lib/itunes_parser/version.rb +1 -1
- metadata +38 -11
- data/.travis.yml +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e92d82868f89d8747bedf453b78c04eb7ea451b
|
4
|
+
data.tar.gz: 29777165cf09ccb0fbd7696c0ed72f3de2761c2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a362c78a6e8ab9bfb12a809ff2f983b4aaf50b755779a0675e60df15a3529cf7845c8c47b6cc1f42635d12d176cdfc060412afc104bce87507844a71d93ee517
|
7
|
+
data.tar.gz: 94bcb866ecd30cba7f6acc72016ac480f1fb1f03507a6aa3f4713e423ae126ddc7a7f88db51578d6a7eb0346da925e84c02af639dfd03f2aa2bb5fed4f61dfdd
|
data/README.md
CHANGED
@@ -1,14 +1,29 @@
|
|
1
1
|
# ItunesParser
|
2
|
+
[](https://gemnasium.com/elfenars/itunes_parser)
|
3
|
+
[](https://codeclimate.com/github/elfenars/itunes_parser)
|
2
4
|
|
3
|
-
|
5
|
+
A simple and fast iTunes Library XML parser based on nokogiri-plist.
|
6
|
+
|
7
|
+
## Description
|
8
|
+
|
9
|
+
The iTunes Library XML is a PList file, so logically,
|
10
|
+
the best way to parse this is with a PList parser.
|
11
|
+
|
12
|
+
The main concept is to keep things simple, using Arrays and Hashes,
|
13
|
+
so you can later use the items within the XML file as you please.
|
14
|
+
|
15
|
+
|
16
|
+
## Dependencies:
|
17
|
+
|
18
|
+
* Ruby >= 2.0.0
|
19
|
+
* Nokogiri-plist ~> 0.5
|
4
20
|
|
5
21
|
## Installation
|
6
22
|
|
7
23
|
Add this line to your application's Gemfile:
|
8
24
|
|
9
|
-
|
10
|
-
|
11
|
-
```
|
25
|
+
gem 'itunes_parser'
|
26
|
+
|
12
27
|
|
13
28
|
And then execute:
|
14
29
|
|
@@ -22,54 +37,51 @@ Or install it yourself as:
|
|
22
37
|
|
23
38
|
First, create a new instance:
|
24
39
|
|
25
|
-
ip = ItunesParser.new("/route/to/the/file.xml")
|
40
|
+
ip = ItunesParser.new(xml_dir: "/route/to/the/file.xml")
|
26
41
|
|
27
42
|
Then you can:
|
28
43
|
|
29
44
|
* Check all the playlists:
|
30
45
|
|
31
|
-
|
32
|
-
ip.playlists
|
33
|
-
```
|
46
|
+
ip.playlists
|
34
47
|
|
35
48
|
* Or get them with just the ID and Name:
|
36
49
|
|
37
|
-
|
38
|
-
ip.playlists(pretty: true)
|
39
|
-
```
|
50
|
+
ip.playlists(pretty: true)
|
40
51
|
|
41
|
-
* And then show
|
52
|
+
* And then show a playlist tracks based on the ID:
|
42
53
|
|
43
|
-
|
44
|
-
a.playlist_tracks(id: <playlist_id>)
|
45
|
-
```
|
54
|
+
a.playlist_tracks(id: <playlist_id>)
|
46
55
|
|
47
56
|
* Or check all the tracks:
|
48
57
|
|
49
|
-
|
50
|
-
a.tracks
|
51
|
-
```
|
58
|
+
a.tracks
|
52
59
|
|
53
60
|
* Of course you can also get just the ID and Name:
|
54
61
|
|
55
|
-
|
56
|
-
a.tracks(pretty: true)
|
57
|
-
```
|
62
|
+
a.tracks(pretty: true)
|
58
63
|
|
59
64
|
* And check just one track based on the ID:
|
60
65
|
|
61
|
-
|
62
|
-
|
63
|
-
|
66
|
+
a.track(id: <track_id>)
|
67
|
+
|
68
|
+
## Author
|
64
69
|
|
70
|
+
Copyright (c)
|
71
|
+
* [Feña Agar](http://fernandoagar.cl) (fernando.agar@gmail.com)
|
65
72
|
|
66
73
|
## Development
|
67
74
|
|
68
75
|
You can use the example XML in the ```examples``` folder and check it in the console running ```bin/console```.
|
69
76
|
|
70
|
-
**THIS GEM IS STILL UNDER DEVELOPMENT**
|
71
|
-
|
72
77
|
## Contributing
|
73
78
|
|
74
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/elfenars/itunes_parser.
|
79
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/elfenars/itunes_parser.
|
80
|
+
This project is intended to be a safe, welcoming space for collaboration,
|
81
|
+
and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
82
|
+
|
83
|
+
## License
|
84
|
+
|
85
|
+
This library is distributed under the UNLICENSE license.
|
86
|
+
Please see the [LICENSE](https://github.com/elfenars/itunes_parser/blob/master/LICENSE) file.
|
75
87
|
|
data/Rakefile
CHANGED
data/itunes_parser.gemspec
CHANGED
@@ -22,8 +22,10 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.10"
|
24
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "minitest", "~> 5.8"
|
26
|
+
spec.add_development_dependency "minitest-reporters", "~> 1.1"
|
25
27
|
spec.add_development_dependency "pry", "~> 0.10"
|
28
|
+
spec.add_development_dependency "pry-rescue", "~> 1.4"
|
26
29
|
|
27
30
|
spec.add_runtime_dependency "nokogiri-plist", "~> 0.5"
|
28
|
-
spec.add_development_dependency "rspec", "~> 3"
|
29
31
|
end
|
data/lib/itunes_parser.rb
CHANGED
@@ -4,9 +4,11 @@ module ItunesParser
|
|
4
4
|
class << self
|
5
5
|
|
6
6
|
def new(args)
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
raise ArgumentError, 'No Library file specified' if args[:file].nil? || args[:file].empty?
|
8
|
+
|
9
|
+
xml_file = open(args[:file])
|
10
|
+
plist = PList.new(file: xml_file)
|
11
|
+
xml_file.close
|
10
12
|
|
11
13
|
plist
|
12
14
|
end
|
@@ -16,13 +16,13 @@ module ItunesParser
|
|
16
16
|
|
17
17
|
# Shows one playlist.
|
18
18
|
# Returns Hash with playlist info.
|
19
|
-
def playlist(id
|
19
|
+
def playlist(id)
|
20
20
|
playlists.select{|pl| pl["Playlist ID"] == id}.first
|
21
21
|
end
|
22
22
|
|
23
23
|
# Shows all tracks of a playlist.
|
24
24
|
# Returns Array of Hashes, each Hash is a track.
|
25
|
-
def playlist_tracks(id
|
25
|
+
def playlist_tracks(id)
|
26
26
|
tracks = []
|
27
27
|
|
28
28
|
playlist(id: id)["Playlist Items"].each do |playlist_item|
|
data/lib/itunes_parser/track.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itunes_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Feña Agar
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,34 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.8'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.8'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest-reporters
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.1'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.1'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: pry
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,33 +81,33 @@ dependencies:
|
|
53
81
|
- !ruby/object:Gem::Version
|
54
82
|
version: '0.10'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
84
|
+
name: pry-rescue
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
58
86
|
requirements:
|
59
87
|
- - "~>"
|
60
88
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
62
|
-
type: :
|
89
|
+
version: '1.4'
|
90
|
+
type: :development
|
63
91
|
prerelease: false
|
64
92
|
version_requirements: !ruby/object:Gem::Requirement
|
65
93
|
requirements:
|
66
94
|
- - "~>"
|
67
95
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
96
|
+
version: '1.4'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
98
|
+
name: nokogiri-plist
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
72
100
|
requirements:
|
73
101
|
- - "~>"
|
74
102
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
76
|
-
type: :
|
103
|
+
version: '0.5'
|
104
|
+
type: :runtime
|
77
105
|
prerelease: false
|
78
106
|
version_requirements: !ruby/object:Gem::Requirement
|
79
107
|
requirements:
|
80
108
|
- - "~>"
|
81
109
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
110
|
+
version: '0.5'
|
83
111
|
description: A fast and simple iTunes XML parser based on nokogiri-plist
|
84
112
|
email:
|
85
113
|
- ferliagno@gmail.com
|
@@ -88,7 +116,6 @@ extensions: []
|
|
88
116
|
extra_rdoc_files: []
|
89
117
|
files:
|
90
118
|
- ".gitignore"
|
91
|
-
- ".travis.yml"
|
92
119
|
- CODE_OF_CONDUCT.md
|
93
120
|
- Gemfile
|
94
121
|
- LICENSE
|
data/.travis.yml
DELETED