Created
June 4, 2012 11:14
-
-
Save orangeclover/2867774 to your computer and use it in GitHub Desktop.
Zusaarから申込者のアイコンをダウンロードし、座席表用のアカウントつき画像を作成する座席表職人のための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.json.JsonSlurper | |
| import groovy.swing.j2d.* | |
| import javax.imageio.*; | |
| if (!args || args.size() !=1) { | |
| println "usge:groovy Zusaar.groovy http://www.zusaar.com/event/XXXXXX" | |
| System.exit(1) | |
| } | |
| def eventID = "" | |
| (args[0] =~ (/(?<=http:\/\/www.zusaar.com\/event\/).*/)).each{ | |
| eventID = it | |
| } | |
| assert eventID.isNumber() == true | |
| def eventUrl = "http://www.zusaar.com/api/event/user/?event_id=${eventID}".toURL() | |
| def parser = new JsonSlurper() | |
| def json = parser.parseText(eventUrl.text) | |
| assert json.size() != 0 | |
| assert json.event.users.nickname[0].size() != 0 | |
| def listFile = new File("list.txt").newWriter() | |
| json.event.users.nickname[0].each{ | |
| assert it.getClass() == String | |
| def id = it | |
| def imgUrl = "http://usericons.relucks.org/twitter/${id}" | |
| 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