Skip to content

Instantly share code, notes, and snippets.

@ryanaslett
Forked from iolloyd/Spot the Hijack
Created December 19, 2012 20:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ryanaslett/4340164 to your computer and use it in GitHub Desktop.
Save ryanaslett/4340164 to your computer and use it in GitHub Desktop.
#* Script to record and tag spotify tracks, by Lloyd Moore, modified by Ryan Aslett *)
#(* Make sure you are already recording in Audio Hijack Pro with a session called 'spotifySession' *)
tell application "Spotify"
set currentTrack to (current track)
set trackName to (name of currentTrack)
set trackNumber to (track number of currentTrack)
set trackAlbum to (album of currentTrack)
set discNumber to (disc number of currentTrack)
set albumArtist to (album artist of currentTrack)
tell application "Audio Hijack Pro"
set theSession to my getSession()
end tell
repeat
if trackName is not equal to (name of currentTrack) then
set trackName to name of current track
set trackArtist to artist of current track
set trackNumber to track number of current track
set trackAlbum to album of current track
set discNumber to disc number of current track
set albumArtist to album artist of current track
my recordTrack(theSession, trackName, trackArtist, trackNumber, trackAlbum, discNumber, albumArtist)
end if
delay 1
end repeat
end tell
on recordTrack(theSession, trackName, trackArtist, trackNumber, trackAlbum, discNumber, albumArtist)
tell application "Audio Hijack Pro"
tell theSession
set title tag to trackName
set artist tag to trackArtist
set track number tag to trackNumber
set album artist tag to albumArtist
set album tag to trackAlbum
set disc number tag to discNumber
set output folder to "~/Desktop"
set output name format to "%tag_title -- %tag_artist"
split recording
end tell
end tell
end recordTrack
on getSession()
tell application "Audio Hijack Pro"
set sessionName to "spotifySession"
try
set theSession to (first item of (every session whose name is sessionName))
theSession is not null
on error
set theSession to (make new application session at end of sessions)
set name of theSession to sessionName
end try
end tell
return theSession
end getSession
@ryanaslett
Copy link
Author

I too was having problems with lloyds script not updating the track names fast enough, so I reordered the operations and additionally added in any other metadata that was available via spotify.

@housito
Copy link

housito commented Jan 23, 2013

Hi, the script is working very good for me! It is possible to add the year field and the artwork??? Thanks in advance!

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