• R/O
  • SSH
  • HTTPS

pxv: Commit


Commit MetaInfo

Revision3 (tree)
Time2010-08-30 02:16:45
Authorjkawamoto

Log Message

(empty log message)

Change Summary

Incremental Difference

--- trunk/src/pxv/Image.java (revision 2)
+++ trunk/src/pxv/Image.java (revision 3)
@@ -87,7 +87,7 @@
8787
8888 }
8989
90- public int getID(){
90+ public int getId(){
9191 return this.id;
9292 }
9393
@@ -157,30 +157,28 @@
157157
158158 //----------------------------------------------------------------------------
159159 public User getAuthor(){
160- return this.getAuthor(50);
160+ return this.api.findUser(this.getAuthorId(), this.getAuthorName());
161161 }
162162
163- public User getAuthor(final int depth){
163+ //----------------------------------------------------------------------------
164+ @Override
165+ public String toString(){
164166
165- try {
167+ final StringBuilder ret = new StringBuilder();
168+ ret.append(this.getClass().getName());
169+ ret.append("[id: ");
170+ ret.append(this.getId());
171+ ret.append(", title: ");
172+ ret.append(this.getTitle());
173+ ret.append(", author name: ");
174+ ret.append(this.getAuthorName());
175+ ret.append(", data: ");
176+ ret.append(this.getDate());
177+ ret.append("]");
166178
167- for(final User u : this.api.findUsers(this.getAuthorName(), depth)){
179+ return ret.toString();
168180
169- if(u.getId() == this.getAuthorId()){
181+ }
170182
171- return u;
172183
173- }
174-
175- }
176-
177- } catch (IOException e) {
178- // TODO 自動生成された catch ブロック
179- e.printStackTrace();
180- }
181-
182- return null;
183-
184- }
185-
186184 }
--- trunk/src/pxv/PixivAPI.java (revision 2)
+++ trunk/src/pxv/PixivAPI.java (revision 3)
@@ -64,6 +64,11 @@
6464 //============================================================================
6565 // Constructors
6666 //============================================================================
67+ /**
68+ * PixivAPI インスタンスを作成する.
69+ *
70+ * @throws IOException I/O エラーが発生した場合.
71+ */
6772 public PixivAPI() throws IOException{
6873
6974 this.base = new URL(BaseURL);
@@ -240,6 +245,73 @@
240245 return this.getUsers(SearchUser, String.format("nick=%s", URLEncoder.encode(name , UTF8)), size);
241246 }
242247
248+ public User findUser(final int id, final String name){
249+
250+ final List<User> ret = new ArrayList<User>();
251+ try{
252+
253+ for(int i = 0; ret.size() == 0 && i < 100; ++i){
254+
255+ final URL url = new URL(this.base, String.format("%s.php?nick=%s&%s=%s&p=%d", SearchUser, URLEncoder.encode(name, UTF8), SessionID, this.session, i));
256+ final HttpURLConnection con = (HttpURLConnection) url.openConnection();
257+ con.connect();
258+
259+ if(con.getResponseCode() == 200){
260+
261+ final Reader in = new InputStreamReader(con.getInputStream());
262+ CSVParser.parse(in, new Handler(){
263+
264+ @Override
265+ public void update(final String[] data) {
266+
267+ try {
268+
269+ final User u = new User(PixivAPI.this, data);
270+ if(u.getId() == id){
271+
272+ ret.add(u);
273+
274+ }
275+
276+ } catch (IOException e) {
277+
278+ // TODO 自動生成された catch ブロック
279+ e.printStackTrace();
280+
281+ }
282+
283+ }
284+
285+ });
286+ in.close();
287+
288+ }else{
289+
290+ break;
291+
292+ }
293+
294+ }
295+
296+ }catch(final IOException e){
297+
298+ // TODO 自動生成された catch ブロック
299+ e.printStackTrace();
300+
301+ }
302+
303+ if(ret.size() != 0){
304+
305+ return ret.get(0);
306+
307+ }else{
308+
309+ return null;
310+
311+ }
312+
313+ }
314+
243315 //----------------------------------------------------------------------------
244316 // APIs for user
245317 //----------------------------------------------------------------------------
@@ -518,7 +590,6 @@
518590
519591 }
520592
521-
522593 }
523594
524595 }
--- trunk/src/pxv/User.java (revision 2)
+++ trunk/src/pxv/User.java (revision 3)
@@ -103,6 +103,12 @@
103103 return this.api.getImageSize(this);
104104 }
105105
106+ /**
107+ * このユーザの投稿画像を指定した数だけ取得する.
108+ *
109+ * @param size 取得する画像数
110+ * @return 取得した画像のリスト
111+ */
106112 public List<Image> getImages(final int size){
107113 return this.api.getImages(this, size);
108114 }
--- trunk/readme.txt (nonexistent)
+++ trunk/readme.txt (revision 3)
@@ -0,0 +1,21 @@
1+pxv: A pixiv API wrapper for Java (version 0.1)
2+=================================
3+
4+概要
5+---------------------------------
6+イラストコミュニケーションサービス pixiv の API を Java から利用するためのライブラリです.
7+リファレンスは添付の Javadoc をご覧下さい.
8+またリファレンスのオンライン版は http://pxv.sourceforge.jp/javadoc/ から閲覧することができます.
9+
10+
11+ライセンス
12+---------------------------------------
13+本ソフトウェアは、GNU Lesser General Public License (GNU LGPL) バージョン 3 のもとで配布されています.
14+
15+このプログラムはフリーソフトウェアです.
16+あなたはこれを,フリーソフトウェア財団によって発行された GNU Lesser General Public License
17+(バージョン3か、それ以降のバージョンのうちどれか) が定める条件の下で再頒布または改変することができます.
18+
19+このプログラムは有用であることを願って頒布されますが,全くの無保証です.
20+商業可能性の保証や特定目的への適合性は,言外に示されたものも含め,全く存在しません.
21+詳しくは GNU Lesser General Public License をご覧ください.
\ No newline at end of file
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Show on old repository browser