Last active
September 14, 2017 19:48
-
-
Save troutcolor/808517764b08233bec94573088e84269 to your computer and use it in GitHub Desktop.
After downloading the json of a set of boos via the audioboo api and downloading and re-uploading the associated mp3s this AppleScript creates posts on my blog for all of the mp3s using the descriptions, dates tags etc from AudioBoo(m)
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
--mp3s have been downloaded and then uploaded to a folder on the web | |
--I could not manage to create enclosures on blog posts with AppleScript | |
global myBlogUsername, myBlogPass, myBlogPass, boonote, mp3uploadfolder, boojson | |
set myBlogUsername to "USERNAME" | |
set myBlogPass to "PASSWORD" | |
set boonote to "<em>This audio file was orginally posted to AudioBoo(m) with the mobile app. It has been downloaded and posted here since audioboom no longer supports free accounts.</em>" | |
set mp3uploadfolder to "http://johnjohnston.info/exboos/" | |
set boojson to (read POSIX file "Users/john/Desktop/audioboom/johnjohnston.json") | |
tell application "JSON Helper" | |
set boos to read JSON from boojson | |
set postsmade to {} | |
repeat with thisboo from 1 to 58 | |
set boo to item thisboo of audio_clips of body of boos | |
set thesetags to {} | |
set c to count of tags of boo | |
repeat with x from 1 to c | |
set t to normalised_tag of item x of tags of boo | |
set end of thesetags to t | |
end repeat | |
set AppleScript's text item delimiters to ", " | |
set tagsstring to thesetags as text | |
set AppleScript's text item delimiters to "" | |
set t to title of boo | |
try | |
set d to description of boo | |
on error | |
set d to "" | |
end try | |
set u to username of user of boo | |
set mp3f to high_mp3 of urls of boo | |
try | |
set latitude to latitude of location of boo | |
set longitude to longitude of location of boo | |
set place to description of location of boo | |
set OpenStreetMapLink to "<a href='https://www.openstreetmap.org/#map=17/" & latitude & "/" & longitude & "'>" & place & "</a>" | |
on error | |
set OpenStreetMapLink to " " | |
end try | |
set dateposted to uploaded_at of boo | |
set d to d & return & OpenStreetMapLink & return & return & boonote | |
set mp3 to mp3uploadfolder & my filenamefromurl(mp3f) | |
set terms to {category:{"ExBoo", "wwwd"}, kind:{"audio"}, post_tag:thesetags} | |
set poststrut to {post_type:"post", post_date:dateposted, post_status:"publish", post_format:"audio", post_title:t, post_content:mp3 & return & d, terms_names:terms} | |
set end of postsmade to my postToBlog(poststrut) | |
end repeat | |
return postsmade | |
end tell | |
on postToBlog(poststrut) | |
tell application "http://johnjohnston.info/blog/xmlrpc.php" | |
set myPosts to call xmlrpc {method name:"wp.newPost", parameters:{"1", myBlogUsername, myBlogPass, poststrut}} | |
return myPosts | |
end tell | |
end postToBlog | |
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