Last active
December 24, 2017 13:44
-
-
Save kphrx/06db0570322e291acfa4a62f35a31418 to your computer and use it in GitHub Desktop.
#NowPlaying tweet by TwitterScripter
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
on NPSaveAsPICT(theFile, theData) | |
try | |
set fh to open for access file theFile with write permission | |
write theData to fh | |
close access fh | |
on error errMsg number errNum | |
try | |
close access fh | |
end try | |
log {errNum, errMsg} | |
end try | |
end NPSaveAsPICT | |
on NPSelectTweetAccount(acct) | |
return choose from list acct | |
end NPSelectTweetAccount | |
set picDir to path to "pdoc" as text | |
set npDir to (picDir & "NowPlaying:") | |
tell application "Finder" | |
if (exists folder npDir) then | |
set npFolder to npDir | |
else | |
set npFolder to (make new folder at picDir with properties {name:"NowPlaying"}) as text | |
end if | |
end tell | |
tell application "iTunes" | |
try | |
set NPTrack to current track | |
on error errMsg number errNum | |
return | |
end try | |
tell NPTrack | |
if not(exists artworks) then | |
return | |
end if | |
set trackName to name | |
set artistName to artist | |
set albumName to album | |
set fileName to npFolder & trackName as text | |
set jpgExt to ".jpg" as text | |
set artworkFile to fileName & jpgExt as text | |
my NPSaveAsPICT(artworkFile, data of artwork 1) | |
end tell | |
end tell | |
display dialog "ツイートする文章を入力" default answer "#NowPlaying " & trackName & " / " & artistName & " (" & albumName & ")" with icon file artworkFile | |
set TweetText to text returned of the result | |
tell application "Twitter Scripter" | |
set TweetAccount to my NPSelectTweetAccount(available accounts) | |
tweet TweetText using account TweetAccount with image artworkFile | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not working on macOS High Sierra 10.13