Created
May 28, 2012 11:15
-
-
Save orangeclover/2818596 to your computer and use it in GitHub Desktop.
ATNDから申込者のアイコンをダウンロードし、座席表用のアカウントつき画像を作成する座席表職人のためのGroovyスクリプト
This file contains hidden or 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
| import groovy.swing.j2d.GraphicsRenderer | |
| import javax.imageio.ImageIO | |
| /** | |
| * Created by IntelliJ IDEA. | |
| * User: orangeclover | |
| * Date: 12/05/19 | |
| * Time: 22:31 | |
| * To change this template use File | Settings | File Templates. | |
| */ | |
| if (!args || args.size() !=1) { | |
| println "usge:groovy Atnd.groovy http://atnd.org/events/XXXXXX" | |
| System.exit(1) | |
| } | |
| def eventID = "" | |
| (args[0] =~ (/(?<=http:\/\/atnd.org\/events\/).*/)).each{ | |
| eventID = it | |
| } | |
| assert eventID.isNumber() == true | |
| def eventUrl = "http://api.atnd.org/events/users/?event_id=${eventID}" | |
| def parser = new XmlSlurper() | |
| def xml = parser.parse(eventUrl) | |
| assert xml.size() != 0 | |
| assert xml.events.event.users.user.size() != 0 | |
| def listFile = new File("list.txt").newWriter() | |
| xml.events.event.users.user.each{ | |
| assert it.getClass() == groovy.util.slurpersupport.NodeChild | |
| def id = it.twitter_id | |
| def imgUrl = it.twitter_img | |
| try { | |
| img = ImageIO.read(imgUrl.toURL()) | |
| gr = new GraphicsRenderer() | |
| gr.renderToFile("@${id}.png", img.width + 100, img.height + 20){ | |
| antialias("on") | |
| image(image: img, x:0,y:0) | |
| font(new java.awt.Font('Tahoma', java.awt.Font.BOLD, 15)) | |
| text( x:0, y:img.height + 5, text: "@${id}", borderColor: no, fill: 'blue') | |
| } | |
| } catch (Exception e) { | |
| listFile.writeLine("\t${id} 例外発生:" + e) | |
| } | |
| listFile.writeLine("[twitter:@${id}]") | |
| } | |
| listFile.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment