Last active
September 9, 2017 19:21
-
-
Save troutcolor/bcfad4dff0000f3781f5c32f88657883 to your computer and use it in GitHub Desktop.
AppleScript to download mp3s with particular tag from AudioBoom. Also save json with post info to file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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