5 import saccubus.util.IOUtil;
13 * 説明: ニコニコ動画の動画をコメントつきで保存
17 * 著作権: Copyright (c) 2007 PSI
28 private static final int CMD_LOC_DEF = 0;
30 private static final int CMD_LOC_TOP = 1;
32 private static final int CMD_LOC_BOTTOM = 2;
34 @SuppressWarnings("unused")
35 private static final int CMD_SIZE_MAX = 3;
37 private static final int CMD_SIZE_DEF = 0;
39 private static final int CMD_SIZE_BIG = 1;
41 private static final int CMD_SIZE_SMALL = 2;
43 @SuppressWarnings("unused")
44 private static final int COMMENT_FONT_SIZE[] = { 24, // DEF
49 private static final int CMD_COLOR_DEF = 0;
51 private static final int CMD_COLOR_RED = 1;
53 private static final int CMD_COLOR_ORANGE = 2;
55 private static final int CMD_COLOR_YELLOW = 3;
57 private static final int CMD_COLOR_PINK = 4;
59 private static final int CMD_COLOR_BLUE = 5;
61 private static final int CMD_COLOR_PURPLE = 6;
63 private static final int CMD_COLOR_CYAN = 7;
65 private static final int CMD_COLOR_GREEN = 8;
67 private static final int CMD_COLOR_NICOWHITE = 9;
69 private static final int CMD_COLOR_MARINEBLUE = 10;
71 private static final int CMD_COLOR_MADYELLOW = 11;
73 private static final int CMD_COLOR_PASSIONORANGE = 12;
75 private static final int CMD_COLOR_NOBLEVIOLET = 13;
77 private static final int CMD_COLOR_ELEMENTALGREEN = 14;
79 private static final int CMD_COLOR_TRUERED = 15;
81 private static final int CMD_COLOR_BLACK = 16;
84 @SuppressWarnings("unused")
88 private int Color = 0;
92 private int Location = 0;
98 @SuppressWarnings("unused")
99 private int UserID = 0;
102 private int Vpos = 0;
104 private String Comment = "";
109 public void setDate(String date_str) {
110 Date = Integer.parseInt(date_str);
111 // System.out.println("date:" + date_str);
114 public void setMail(String mail_str) {
115 // System.out.println("mail:" + mail_str);
116 Color = CMD_COLOR_DEF;
118 Location = CMD_LOC_DEF;
119 if (mail_str == null) {
122 String element[] = mail_str.split(" ");
123 for (int i = 0; i < element.length; i++) {
124 String str = element[i].toLowerCase();
126 if (str.equals("ue")) {
127 Location = CMD_LOC_TOP;
128 } else if (str.equals("shita")) {
129 Location = CMD_LOC_BOTTOM;
130 } else if (str.equals("big")) {
132 } else if (str.equals("small")) {
133 Size = CMD_SIZE_SMALL;
134 } else if (str.equals("red")) {
135 Color = CMD_COLOR_RED;
136 } else if (str.equals("orange")) {
137 Color = CMD_COLOR_ORANGE;
138 } else if (str.equals("yellow")) {
139 Color = CMD_COLOR_YELLOW;
140 } else if (str.equals("pink")) {
141 Color = CMD_COLOR_PINK;
142 } else if (str.equals("blue")) {
143 Color = CMD_COLOR_BLUE;
144 } else if (str.equals("purple")) {
145 Color = CMD_COLOR_PURPLE;
146 } else if (str.equals("cyan")) {
147 Color = CMD_COLOR_CYAN;
148 } else if (str.equals("green")) {
149 Color = CMD_COLOR_GREEN;
150 } else if (str.equals("niconicowhite") || str.equals("white2")) {
151 Color = CMD_COLOR_NICOWHITE;
152 } else if (str.equals("arineblue") || str.equals("blue2")) {
153 Color = CMD_COLOR_MARINEBLUE;
154 } else if (str.equals("madyellow") || str.equals("yellow2")) {
155 Color = CMD_COLOR_MADYELLOW;
156 } else if (str.equals("passionorange") || str.equals("orange2")) {
157 Color = CMD_COLOR_PASSIONORANGE;
158 } else if (str.equals("nobleviolet") || str.equals("purple2")) {
159 Color = CMD_COLOR_NOBLEVIOLET;
160 } else if (str.equals("elementalgreen") || str.equals("green2")) {
161 Color = CMD_COLOR_ELEMENTALGREEN;
162 } else if (str.equals("truered") || str.equals("red2")) {
163 Color = CMD_COLOR_TRUERED;
164 } else if (str.equals("black")) {
165 Color = CMD_COLOR_BLACK;
167 // System.out.println("Unknown command:" + str);
172 public void setNo(String no_str) {
174 No = Integer.parseInt(no_str);
175 } catch (Exception e) {
178 // System.out.println("no:" + no_str);
181 public void setUserID(String user_id_str) {
182 // System.out.println("user_id:" + user_id_str);
184 UserID = Integer.parseInt(user_id_str);
185 } catch (Exception e) {
190 public void setVpos(String vpos_str) {
191 // System.out.println("vpos:" + vpos_str);
193 Vpos = Integer.parseInt(vpos_str);
194 } catch (Exception e) {
200 public void setComment(String com_str) {
201 // System.out.println("Comment[" + com_str.length() + "]:" + com_str);
202 if (Comment.equals("")) {
209 public void write(OutputStream os) throws IOException {
212 a = (Comment + "\0").getBytes("UnicodeLittleUnmarked");
213 } catch (UnsupportedEncodingException ex) {
214 ex.printStackTrace();
216 IOUtil.writeInt(os, No);
217 IOUtil.writeInt(os, Vpos);
218 IOUtil.writeInt(os, Location);
219 IOUtil.writeInt(os, Size);
220 IOUtil.writeInt(os, Color);
221 IOUtil.writeInt(os, a.length);
224 } catch (IOException ex1) {
225 ex1.printStackTrace();