AppleScript to download mp3s with particular tag from AudioBoom. Also save json with post info to file
set downloadfolder to "/Users/john/Desktop/audioboom/edutalk/" | |
--so this next bit could be a loop but doing it manual was not much of a hassle | |
set pagecount to 9 | |
set tag to "edutalk" | |
set itemcount to 100 | |
tell application "JSON Helper" | |
set bURL to "https://api.audioboom.com/tag/" & tag & "/audio_clips?page[items]=" & itemcount & "&page[number]=" & pagecount | |
set boos to fetch JSON from bURL | |
set myFile to open for access "Macintosh HD:Users:john:Desktop:audioboom:edutalk_" & pagecount & ".json" with write permission | |
set boohoo to make JSON from boos | |
write boohoo to myFile | |
close access myFile | |
set imageCount to count of audio_clips of body of boos | |
set mp3urls to {} | |
repeat with boo in audio_clips of body of boos | |
set end of mp3urls to high_mp3 of urls of boo | |
end repeat | |
end tell | |
repeat with mp3 in mp3urls | |
set cmd to "curl -L " & mp3 & " > " & downloadfolder & filenamefromurl(mp3) | |
do shell script cmd | |
end repeat | |
return cmd | |
on filenamefromurl(theurl) | |
set s to "url=\"" & theurl & "\"; echo \"${url##*/}\"" | |
return do shell script s | |
end filenamefromurl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment