0.0.22 • Published 1 year ago

@sequencemedia/itunes-library-stream v0.0.22

Weekly downloads
23
License
MIT
Repository
github
Last release
1 year ago

@sequencemedia/itunes-library-stream

Streaming parser for iTunes Library XML files

Usage

itunes.createStream()

Creates a stream to parse the iTunes Library.xml file and generate:

  • Each track
  • A collection of all tracks
  • Each playlist
  • A collection of all playlists
  • Each playlist item
  • Each collection of playlist items
  • The complete library

Every object is defined either as a Map or a Set (depending on whichever more closely resembles the XML).

Example ES

import { createReadStream } from 'fs'
import { resolve } from 'path'
import userhome from 'userhome'
import itunes from '@sequencmedia/itunes-library-stream'

import itunes, {
  LIBRARY,
  TRACKS,
  TRACK,
  PLAYLISTS,
  PLAYLIST,
  PLAYLIST_ITEMS,
  PLAYLIST_ITEM
} from '@sequencemedia/itunes-library-stream'

const filePath = resolve(userhome(), 'Music/iTunes/iTunes Music Library.xml')

createReadStream(filePath)
  .pipe(itunes.createStream())
  .on('data', ({
  	[LIBRARY]: library,
  	[TRACKS]: tracks,
  	[TRACK]: track,
  	[PLAYLISTS]: playlists,
  	[PLAYLIST]: playlist,
  	[PLAYLIST_ITEMS]: playlistItems,
  	[PLAYLIST_ITEM]: playlistItem
  }) => {
  	if (library) { /* A `Map` instance, contains _all_ tracks and playlists */ }
  	if (tracks) { /* A `Map` instance, contains _all_ tracks  */ }
  	if (track) { /* A `Map` instance. A track  */ }
  	if (playlists) { /* A `Set` instance, contains _all_ playlists */ }
  	if (playlist) { /* A `Map` instance. A playlist  */ }
  	if (playlistItems) { /* A `Set` instance, contains _all_ playlist items (belonging to a playlist) */ }
  	if (playlistItem) { /* A `Map` instance. A playlist item (belonging to a playlist) */ }
  })
  .on('end', () => {
  	console.log('Processing is complete!')
  })

License

MIT. See LICENSE.md for details.

0.0.22

1 year ago

0.0.20

3 years ago

0.0.21

3 years ago

0.0.19

3 years ago

0.0.18

3 years ago

0.0.17

3 years ago

0.0.16

4 years ago

0.0.15

4 years ago

0.0.14

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago