Skip to content

Instantly share code, notes, and snippets.

@lucasgonze
Created August 10, 2011 21:28
Show Gist options
  • Save lucasgonze/1138336 to your computer and use it in GitHub Desktop.
Save lucasgonze/1138336 to your computer and use it in GitHub Desktop.
convert Spotify playlist to XSPF, semi-manual
# -*- coding: utf-8 -*-
# Quickie to convert a Spotify playlist into XSPF.
# In Spotify open your playlist, select all tracks, copy.
# Open a text editor and paste.
# You'll have a list of lines formatted as
# artist name – track title
# Save the list to a file.
# Send the file into this script via stdin.
# for example: cat tracklisting.txt | ruby ./spotify2xspf.rb | pbcopy
require 'builder'
xml = Builder::XmlMarkup.new(:target => $stdout, :indent => 2)
xml.playlist("version"=>"1","xmlns"=>"http://xspf.org/ns/0/") do
xml.trackList do
while str = gets
arr = str.chomp.split(" – ")
artist = arr.shift
title = arr.join(" – ")
next if( ! artist || artist.length == 0 || ! title || title.length == 0 )
xml.track do
xml.artist(artist)
xml.title(title)
end
end
end #end trackList
end #end playlist
Deadmau5 – 4x4=12 (Continuous Mix)
Deadmau5 – Some Chords
Deadmau5 – Sofi Needs A Ladder
Deadmau5 – A City In Florida
Deadmau5 – Bad Selection
Deadmau5 – Animal Rights
Deadmau5 – I Said (Michael Woods Remix)
Deadmau5 – Cthulhu Sleeps
Deadmau5 – Right This Second
Deadmau5 – Raise Your Weapon (Original Mix)
Deadmau5 – One Trick Pony
Deadmau5 – Everything Before
STS9 – Scheme
STS9 – When the Dust Settles
STS9 – Scheme Reprise
STS9 – Golden Gate
STS9 – Winter Sun
Major Lazer Feat. M.I.A. & Busy Signal – Sound Of Siren
Major Lazer Feat. Collie Buddz & Lindi Ortega – Good Enuff - Cash Flow Dub
Major Lazer – Bruk Out - Buraka Som Sistema Mix
Major Lazer Feat. Miss Banks – Can't Stop Now - K.L.A.M. Remix
Major Lazer – Jump Up - Thom Yorke Remix
Little Dragon – A New
Little Dragon – Looking Glass
Little Dragon – My Step
Little Dragon – Feather
Little Dragon – Thunder Love
Little Dragon – Never Never
Little Dragon – Runabout
Little Dragon – Swimming
Little Dragon – Blinking Pigs
Little Dragon – Come Home
Little Dragon – Fortune
Julieta Venegas – Canciones De Amor
Julieta Venegas – Me Voy
Julieta Venegas A Dueto Con Dante – Primer Dia
Julieta Venegas – Limón Y Sal
Julieta Venegas – Dulce Compañia
Julieta Venegas – De Que Me Sirve
Julieta Venegas – A Donde Sea
Julieta Venegas – Mirame Bien
Julieta Venegas – No Seré
Julieta Venegas – Ultima Vez
Julieta Venegas;Anita Tijoux – Eres Para Mí
Julieta Venegas – No Hace Falta
Julieta Venegas – Te Voy A Mostrar
Julieta Venegas – Sin Documentos
Julieta Venegas – Seria Feliz - En Vivo
Josh Ritter – Girl In The War
Josh Ritter – Wolves
Josh Ritter – Monster Ballads
Josh Ritter – Lillian, Egypt
Josh Ritter – Idaho
Josh Ritter – In The Dark
Josh Ritter – One More Mouth
Josh Ritter – Good Man
Josh Ritter – Best For The Best
Josh Ritter – Thin Blue Flame
Josh Ritter – Here At The Right Time
Mavis Staples – Don't Knock
Mavis Staples – You Are Not Alone
Mavis Staples – Downward Road
Mavis Staples – In Christ There Is No East Or West
Mavis Staples – Creep Along Moses
Mavis Staples – Losing You
Mavis Staples – I Belong To The Band
Mavis Staples – Last Train
Mavis Staples – Only The Lord Knows
Mavis Staples – Wrote A Song For Everyone
Mavis Staples – We're Gonna Make It
Mavis Staples – Wonderful Savior
Mavis Staples – Too Close/On My Way To Heaven
!!! Chk Chik Chick – The Step
!!! Chk Chik Chick – Hammerhead
!!! Chk Chik Chick – Kookooka Fuk-U
!!! Chk Chik Chick – Storm The Legion
!!! Chk Chik Chick – There's No Fucking Rules, Dude
!!! Chk Chik Chick – Intensify
!!! Chk Chik Chick – Feel Good Hit Of The Fall
Latyrx – Latyrx
Latyrx – Say That
Latyrx – The Quickening
Latyrx – Balcony Beach
Latyrx – Live 90.3 '94
Latyrx – The Muzappers Mix: Aim For The Flickering Flame/Rankin' #1
Latyrx – Funky Granules
Latyrx – Bad News
Latyrx – Off [With] Their Heads
Latyrx – Interlude
Latyrx – Burnt Pride
Latyrx – Scratchapella
Latyrx – The Wreckoning
Latyrx – Burning Hot In Cali On A Saturday Night
Junip – In Every Direction
Junip – Always
Junip – Rope & Summit
Junip – Without You
Junip – It's Alright
Junip – Howl
Junip – Sweet & Bitter
Junip – Don't Let It Pass
Junip – Off Point
Junip – To The Grain
Junip – Tide
Junip – Rope & Summit
Junip – Far Away
Junip – At The Doors
Junip – Loops
Junip – Black Refuge
Junip – Turn To The Assassin
Junip – Official
Junip – Chugga-Chugga
Junip – The Ghost Of Tom Joad
Charles Bradley – The World (Is Going Up In Flames)
Charles Bradley – The Telephone Song
Charles Bradley – Golden Rule
Charles Bradley – I Believe In Your Love
Charles Bradley – Trouble In The Land
Charles Bradley – Lovin' You, Baby
Charles Bradley – No Time For Dreaming
Charles Bradley – How Long
Charles Bradley – In You (I Found a Love)
Charles Bradley – Why Is It So Hard
Charles Bradley – Since Our Last Goodbye
Charles Bradley – Heartaches and Pain
The Infamous Stringdusters – You Can't Stop The Changes
The Infamous Stringdusters – In God's Country
The Infamous Stringdusters – All The Same
The Infamous Stringdusters – Magic #9
The Infamous Stringdusters – Those Who've Gone On
The Infamous Stringdusters – It'll Be Alright
The Infamous Stringdusters – Masquerade
The Infamous Stringdusters – Taking A Chance On The Truth
The Infamous Stringdusters – Toy Rockets
The Infamous Stringdusters – Love One Another
The Infamous Stringdusters – 17 Cents
The Infamous Stringdusters – Not Tonight
The Infamous Stringdusters – The Deputy
Tune-Yards – My Country
Tune-Yards – Es-so
Tune-Yards – Gangsta
Tune-Yards – Powa
Tune-Yards – Riotriot
Tune-Yards – Bizness
Tune-Yards – Doorstep
Tune-Yards – You Yes You
Tune-Yards – Wooly Wolly Gong
Tune-Yards – Killa
Pajama Club – From A Friend To A Friend
Pajama Club – Tell Me What You Want
Wye Oak – Two Small Deaths
Wye Oak – The Alter
Wye Oak – Holy Holy
Wye Oak – Dogs Eyes
Wye Oak – Civilian
Wye Oak – Fish
Wye Oak – Plains
Wye Oak – Hot As Day
Wye Oak – We Were Wealth
Wye Oak – Doubt
Ty Segall – Fist Heart Mighty Dawn Dart
Ty Segall – Buick Mackane
Ty Segall – The Slider
Ty Segall – Woodland Rock
Ty Segall – Salamanda Palaganda
Ty Segall – Elemental Child
Lord Huron – Mighty
Lord Huron – Son of a Gun
Lord Huron – The Stranger
Lord Huron – When Will I See You Again
The Fresh & Onlys – Summer Of Love
The Fresh & Onlys – Waterfall
The Fresh & Onlys – Strange Disposition
The Fresh & Onlys – Tropical Island Suite
The Fresh & Onlys – I'm All Shook Up
The Fresh & Onlys – Be My Hooker
The Fresh & Onlys – Fascinated
The Fresh & Onlys – Plague Of Frogs
The Fresh & Onlys – Who Needs A Man
The Fresh & Onlys – Red Light, Green Light
The Fresh & Onlys – I'm A Thief
Grouplove – Colours
Grouplove – Naked Kids
Grouplove – Gold Coast
Grouplove – Getaway Car
Grouplove – Don't Say Oh Well
Grouplove – Get Giddy
Diego's Umbrella – Das Borjka
Diego's Umbrella – Gypsy Confidential
Diego's Umbrella – The Fiberoptic Elflord
Diego's Umbrella – Theme Of The Glowing Amigo
Diego's Umbrella – Viva La Juerga
Diego's Umbrella – Here As I Lay
Diego's Umbrella – Mtv Brasil
Diego's Umbrella – Pants!
Diego's Umbrella – Beastslayer Of Valenar
Diego's Umbrella – Kalashnikov
Diego's Umbrella – Doppleganger
Diego's Umbrella – Voyage To Tarnihan
Arcade Fire – The Suburbs
Arcade Fire – Ready To Start
Arcade Fire – Modern Man
Arcade Fire – Rococo
Arcade Fire – Empty Room
Arcade Fire – City With No Children
Arcade Fire – Half Light I
Arcade Fire – Half Light II (No Celebration)
Arcade Fire – Suburban War
Arcade Fire – Month Of May
Arcade Fire – Wasted Hours - Extended version
Arcade Fire – Deep Blue
Arcade Fire – We Used To Wait
Arcade Fire – Sprawl I (Flatland)
Arcade Fire – Sprawl II (Mountains Beyond Mountains)
Arcade Fire – The Suburbs (Continued)
Arcade Fire – Culture War
Arcade Fire – Speaking In Tongues
The Decemberists – Don't Carry It All
The Decemberists – Calamity Song
The Decemberists – Rise To Me
The Decemberists – Rox In The Box
The Decemberists – January Hymn
The Decemberists – Down By The Water
The Decemberists – All Arise!
The Decemberists – June Hymn
The Decemberists – This Is Why We Fight
The Decemberists – Dear Avery
John Fogerty – Paradise
John Fogerty – Never Ending Song Of Love
John Fogerty – Garden Party
John Fogerty – I Don't Care (Just As Long As You Love Me)
John Fogerty – Back Home Again
John Fogerty – I'll Be There (If Ever You Want Me)
John Fogerty – Change In The Weather
John Fogerty – Moody River
John Fogerty – Heaven's Just A Sin Away
John Fogerty – Fallin' Fallin' Fallin'
John Fogerty – Haunted House
John Fogerty – When Will I Be Loved
John Fogerty – Blue Ridge Mountain Blues - From The Concert At Royal Albert Hall "Comin Down The Road"
@lucasgonze
Copy link
Author

arr.join(" – ") is to avoid breaking track titles that happen to contain the delimiter.

@lucasgonze
Copy link
Author

Fixed character encoding issues by using builder instead of puts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment