Skip to content
iTunes Library XML Decoder written in F#
F#
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.paket
ITunesParser.Tests
ITunesParser
.gitignore
ITunesParser.sln
ReadMe.md
paket.dependencies
paket.lock

ReadMe.md

ITunes Parser for F#

This F# Library has both a PList XML Parser and iTunes XML Parser

Usage

// Learn more about F# at http://fsharp.org. See the 'F# Tutorial' project
// for more guidance on F# programming.
#load "Scripts/load-references-debug.fsx"

open System.IO
open ITunesParser.Parser
open ITunesParser.Types
open ITunesParser.Generator

// string
let path = Path.Combine(__SOURCE_DIRECTORY__, "Library.xml")
let xml = File.OpenText(path).ReadToEnd()

let library = 
    xml
    |> ParsePList
    |> GetLibrary

let playlists = 
    let exceptions = [| "Library"; "Music"; "Movies"; "TV Shows"; "Podcasts" |]
    match library with
    | Success x -> 
        x.Playlists
        |> Seq.filter (fun p -> exceptions |> Array.contains (p.Name) |> not)
        |> List.ofSeq
    | Failure _ -> []

let printPlayList (playList : PlayList) = 
    printfn "## %s" playList.Name
    printfn "| Title | Artist | Album |"
    printfn "| :---- | :----- | :---- |"
    for track in playList.Items do
        printfn "| %s | %s | %s" track.Name track.Artist track.Album

playlists |> Seq.iter printPlayList
You can’t perform that action at this time.