Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

com.github.pireba:itunesparser

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

com.github.pireba:itunesparser

A Java parser for the iTunes Library XML file.

  • 1.1
  • Source
  • Maven
  • Socket score

Version published
Maintainers
1
Source

iTunes Parser

A Java parser for the iTunes Library XML file.

Depencies

dom4j to parse the XML file. https://dom4j.github.io/

How to use

Create a parser object

File file = new File("/home/phillip/iTunes Library.xml");
Parser parser = new Parser(file);

Parse the XML file

try {
    parser.parse()
} catch ( DocumentException e ) {
    e.printStackTrace();
}

Library

The global properties of the iTunes Library (application version, path to music folder etc.) are stored in a Library object. If a property of the Library is not set in the XML file, the getter returns null.

Get the Library object and print some properties

Library library = parser.getLibrary();
System.out.println(library.getApplicationVersion());
System.out.println(library.getMusicFolder());
...

Tracks

The properties of a Track (name, artist etc.) are stored in a Track object. If a property of a Track is not set in the XML file, the getter returns null. The Tracks of the Library are collected in a Track Map. The Map key is the Track ID of the Track.

Get the Map with Tracks and print some properties of one

Map<Integer, Track> tracks = parser.getTracks();
Track track1 = tracks.get(100);
System.out.println(track1.getName());
System.out.println(track1.isDisabled());
...

Iterate through the Tracks

Map<Integer, Track> tracks = parser.getTracks();
for ( Track track : tracks.values() ) {
    System.out.println(track.getName());
}

Playlists

The properties of a Playlist (name, is folder etc.) are stored in a Playlist object. If a property of a Playlist is not set in the XML file, the getter returns null. The Playlists of the Library are collected in a Playlist Map. The Map key is the Playlist ID of the Playlist. The Tracks of a Playlist are collected as a Track Map in the attribute "playlistItems".

Get the Map with Playlists and print some properties of one

Map<Integer, Playlist> playlists = parser.getPlaylists();
Playlist playlist1 = playlists.get(100);
System.out.println(playlist1.getName());
System.out.println(playlist1.isFolder());
...

Iterate through the Playlists

Map<Integer, Playlist> playlists = parser.getPlaylists();
for ( Playlist playlist;playlists.values() ) {
    System.out.println(playlist.getName());
}

Get the Tracks of a Playlist

Map<Integer, Playlist> playlists = parser.getPlaylists();
Playlist playlist1 = playlists.get(100);
Map<Integer, Track> tracksOfPlaylist1 = playlist1.getPlaylistItems();
for ( Track track : tracksOfPlaylist1.values() ) {
    System.out.println(track.getName());
}

TODO

  • Save the order of the songs in a playlist.

FAQs

Package last updated on 11 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc