I recently stumbled upon a YouTube video that showed how to record Spotify songs on your Mac for offline listening. The easiest way is to use an application called 'Audio Hijack Pro' records audio natively from different sources/applications.
After installing this application, you can record Spotify radio as a single track with a press of a button and then manually split the tracks using any audio splitter/ tool.
I wanted to automate this process and a few more clicks on Google I came across a non-working script which gave me some direction into how this can be achieved.
The script attached below will fire off Spotify and 'Audio Hijack Pro' and when the user selects to record, it will split the songs adding some basic ID3 tags along the way. Have fun.
After installing this application, you can record Spotify radio as a single track with a press of a button and then manually split the tracks using any audio splitter/ tool.
I wanted to automate this process and a few more clicks on Google I came across a non-working script which gave me some direction into how this can be achieved.
The script attached below will fire off Spotify and 'Audio Hijack Pro' and when the user selects to record, it will split the songs adding some basic ID3 tags along the way. Have fun.
(* Script to record and tag spotify tracks, by Lloyd Moore *)
(* Lloyd's script didn't work for me initially but after few changes it worked! *)
tell application "Spotify"
repeat
try
play
set currentTrack to (current track)
set trackName to (name of current track)
tell application "Audio Hijack Pro"
set theSession to my getSession()
end tell
set loop to true
repeat while loop
if trackName is not equal to name of current track then
try
set trackName to name of current track
set trackArtist to artist of current track
set trackAlbum to album of current track
my recordTrack(theSession, trackName, trackArtist, trackAlbum)
on error
set loop to false
end try
end if
delay 1
end repeat
end try
delay 1
end repeat
end tell
on getSession()
tell application "Audio Hijack Pro"
set sessionName to "spotifySession"
try
set theSession to first session whose name is sessionName --By name
on error
set theSession to (make new application session at end of sessions)
end try
set name of theSession to sessionName
end tell
return theSession
end getSession
on recordTrack(theSession, trackName, trackArtist, trackAlbum)
tell application "Audio Hijack Pro"
tell theSession
split recording
set output folder to "~/Desktop"
set output name format to "%tag_title -- %tag_artist"
set title tag to trackName
set artist tag to trackArtist
set album tag to trackAlbum
end tell
end tell
end recordTrack
This comment has been removed by the author.
ReplyDeleteThanks for your comment. Were you able to record the songs? and was they automatically splitting? If not, try the following steps:
ReplyDelete1. Open the script in AppleScript and hit Run. Click on 'Events' on the bottom of the screen and you will see events scrolling.
2. It should start Audio Hijack Pro and Spotify.
3. Click on 'Hijack' button on Audio Hijack Pro. It will say the program needs to restart. Just say yes to restart.
4. Now run any song on Spotify and you should see the level's on Audio Hijack Pro move. This means Audio Hijack Pro has hijacked the audio signal. Also switch to 'Tags' tab to see if Audio Hijack Pro is picking up the right Title/Artist/Album of the song.
5. Switch to another song on Spotify and see if the Title/Artist/Album are updated on Audio Hijack Pro.
6. Hit 'Record' on Audio Hijack Pro and quickly switch to Spotify and fire the playlist you want to record.
Try all steps and let me know if this works.
Hey Shahid. I just gave this a try last night and I was really impressed with how well it works! All I had to do was make some minor modifications to the script for a different output directory and different tagging (I prefer: %tag_artist_-_%tag_title)
ReplyDeleteBut I am having one little problem with it:
Sometimes when it switches to the next song, for some reason the output file from Audio Hijack doesn't update the tag information, so I get a duplicate file with a 1 at the end. For example:
Artist_-_Song.mp3
Artist_-_Song1.mp3
The audio of "Artist_-_Song1.mp3" is correct and is actually the next song, but the tags didn't get updated, forcing me to manually rename it. It's like Audio Hijacker doesn't update the tags fast enough before it starts outputting the file. Possibly? But then usually the next song will tag correctly.
Has this happened to you, and do you know how to fix it?
Also 1 more question, do you know if it's possible to pull the album track number information in? I would prefer to have the exported songs in the same order as the album. Currently I am having to use Mucommander to sort the download folder by date, and then manually add "01", "02", etc. to the filename of each song.
Regardless, I'm really impressed with how well this script works and I appreciate your posting it!
Thanks!
Thanks Rob. I haven't used the script much but I have also encountered the problem you have described. I have tried to narrow down the problem and I think it happens on the next song after the Spotify plays its ads. I dont know if this can be fixed.
DeleteOn your comment about track number I believe the only information available from Spotify are the 3 parameters (track, artist, and album).
Shahid, I can confirm this doesn't have anything to do with ads, because I used it with a Spotify premium account.
ReplyDeleteA little tip on Spotify premium: There is an android app called "Spotify Auto Signup" which allows you to generate 48 hour free trials of premium. Only takes a minute to do every two days. (Spotify grants a 48 hour trial of premium when you register on the mobile app. But if you give it bogus information, or use this app, you can get a trial over and over)
I've been doing it for several weeks and it is definitely worth the small time investment. No more muting ads manually at work, plus the Audio hijack is capturing a 320kbps stream. :) The only possible downside is not being able to save playlists straight inside spotify because I am switching usernames every 2 days. Solution: Use Delicious to bookmark links to albums on spotify. Works great on the desktop and on android :)
Cheers
-Robert
P.S... Just because you generate the trial on mobile doesn't mean you can't use it on the desktop :) I just paste the username into an email to myself. The password for the user accounts generated by spotify auto signup is always the same and easy to remember: abc123
ReplyDeleteBrilliant ;)
Shahid, Thanks its sound cool.
ReplyDeleteI tried to apply, but when the song end and script run, show an error:
Domain: NSOSStatusErrorDomain
Code: -1708
NSLocalizedDescription: AppleScript Error
NSLocalizedRecoverySuggestion: {
OSAScriptErrorNumberKey = "-1708";
}
OSAScriptErrorNumberKey: -1708
Could you help me?
Thanks
Here is a better version http://joonix.se/post/25716608379/spotify-offline-playlist
ReplyDeleteThanks Johny. I tried your script and it works really well. Thanks for sharing.
DeleteHi, I recently upgraded to OS Mavericks and now have trouble with this script. It no longer starts a new track after the song ends, but rather records a few seconds of the following song, then begins a new track. Any suggestions?
ReplyDeleteThanks!
I have started using http://joonix.se/post/25716608379/spotify-offline-playlist this script and it works fine on Mavericks.
DeleteHi. This does not seem to work out in Yosemite v.10.10.2 along with Audio Hijack 3.1.0. Anyone have a clue on how to make it work? Would be awesome.
ReplyDeletehello!! Very interesting discussion glad that I came across such informative post. Keep up the good work friend. Glad to be part of your net community.
ReplyDeleteAcheter des écoutes spotify