5 import java.util.logging.Level;
6 import java.util.logging.Logger;
7 import saccubus.util.IOUtil;
15 * 説明: ニコニコ動画の動画をコメントつきで保存
19 * 著作権: Copyright (c) 2007 PSI
30 private static final Logger logger = Logger.getLogger(Chat.class.getName());
32 private static final int CMD_LOC_DEF = 0;
34 private static final int CMD_LOC_TOP = 1;
36 private static final int CMD_LOC_BOTTOM = 2;
38 @SuppressWarnings("unused")
39 private static final int CMD_SIZE_MAX = 3;
41 private static final int CMD_SIZE_DEF = 0;
43 private static final int CMD_SIZE_BIG = 1;
45 private static final int CMD_SIZE_SMALL = 2;
47 @SuppressWarnings("unused")
48 private static final int COMMENT_FONT_SIZE[] = { 24, // DEF
53 private static final int CMD_COLOR_DEF = 0;
55 private static final int CMD_COLOR_RED = 1;
57 private static final int CMD_COLOR_ORANGE = 2;
59 private static final int CMD_COLOR_YELLOW = 3;
61 private static final int CMD_COLOR_PINK = 4;
63 private static final int CMD_COLOR_BLUE = 5;
65 private static final int CMD_COLOR_PURPLE = 6;
67 private static final int CMD_COLOR_CYAN = 7;
69 private static final int CMD_COLOR_GREEN = 8;
71 private static final int CMD_COLOR_NICOWHITE = 9;
73 private static final int CMD_COLOR_MARINEBLUE = 10;
75 private static final int CMD_COLOR_MADYELLOW = 11;
77 private static final int CMD_COLOR_PASSIONORANGE = 12;
79 private static final int CMD_COLOR_NOBLEVIOLET = 13;
81 private static final int CMD_COLOR_ELEMENTALGREEN = 14;
83 private static final int CMD_COLOR_TRUERED = 15;
85 private static final int CMD_COLOR_BLACK = 16;
88 @SuppressWarnings("unused")
92 private int Color = 0;
96 private int Location = 0;
102 @SuppressWarnings("unused")
103 private int UserID = 0;
106 private int Vpos = 0;
108 private String Comment = "";
113 public void setDate(String date_str) {
114 Date = Integer.parseInt(date_str);
115 logger.log(Level.FINE, "date:" + date_str);
118 public void setMail(String mail_str) {
119 logger.log(Level.FINE, "mail:" + mail_str);
120 Color = CMD_COLOR_DEF;
122 Location = CMD_LOC_DEF;
123 if (mail_str == null) {
126 String element[] = mail_str.split(" ");
127 for (int i = 0; i < element.length; i++) {
128 String str = element[i].toLowerCase();
130 if (str.equals("ue")) {
131 Location = CMD_LOC_TOP;
132 } else if (str.equals("shita")) {
133 Location = CMD_LOC_BOTTOM;
134 } else if (str.equals("big")) {
136 } else if (str.equals("small")) {
137 Size = CMD_SIZE_SMALL;
138 } else if (str.equals("red")) {
139 Color = CMD_COLOR_RED;
140 } else if (str.equals("orange")) {
141 Color = CMD_COLOR_ORANGE;
142 } else if (str.equals("yellow")) {
143 Color = CMD_COLOR_YELLOW;
144 } else if (str.equals("pink")) {
145 Color = CMD_COLOR_PINK;
146 } else if (str.equals("blue")) {
147 Color = CMD_COLOR_BLUE;
148 } else if (str.equals("purple")) {
149 Color = CMD_COLOR_PURPLE;
150 } else if (str.equals("cyan")) {
151 Color = CMD_COLOR_CYAN;
152 } else if (str.equals("green")) {
153 Color = CMD_COLOR_GREEN;
154 } else if (str.equals("niconicowhite") || str.equals("white2")) {
155 Color = CMD_COLOR_NICOWHITE;
156 } else if (str.equals("arineblue") || str.equals("blue2")) {
157 Color = CMD_COLOR_MARINEBLUE;
158 } else if (str.equals("madyellow") || str.equals("yellow2")) {
159 Color = CMD_COLOR_MADYELLOW;
160 } else if (str.equals("passionorange") || str.equals("orange2")) {
161 Color = CMD_COLOR_PASSIONORANGE;
162 } else if (str.equals("nobleviolet") || str.equals("purple2")) {
163 Color = CMD_COLOR_NOBLEVIOLET;
164 } else if (str.equals("elementalgreen") || str.equals("green2")) {
165 Color = CMD_COLOR_ELEMENTALGREEN;
166 } else if (str.equals("truered") || str.equals("red2")) {
167 Color = CMD_COLOR_TRUERED;
168 } else if (str.equals("black")) {
169 Color = CMD_COLOR_BLACK;
171 logger.log(Level.WARNING, "Unknown command:" + str);
176 public void setNo(String no_str) {
178 No = Integer.parseInt(no_str);
179 } catch (Exception e) {
182 logger.log(Level.FINE, "no:" + no_str);
185 public void setUserID(String user_id_str) {
186 logger.log(Level.FINE, "user_id:" + user_id_str);
188 UserID = Integer.parseInt(user_id_str);
189 } catch (Exception e) {
194 public void setVpos(String vpos_str) {
195 logger.log(Level.FINE, "vpos:" + vpos_str);
197 Vpos = Integer.parseInt(vpos_str);
198 } catch (Exception e) {
204 public void setComment(String com_str) {
205 logger.log(Level.FINE, "Comment[" + com_str.length() + "]:" + com_str);
206 if (Comment.equals("")) {
213 public void write(OutputStream os) throws IOException {
216 a = (Comment + "\0").getBytes("UnicodeLittleUnmarked");
217 } catch (UnsupportedEncodingException ex) {
218 logger.log(Level.SEVERE, null, ex);
220 IOUtil.writeInt(os, No);
221 IOUtil.writeInt(os, Vpos);
222 IOUtil.writeInt(os, Location);
223 IOUtil.writeInt(os, Size);
224 IOUtil.writeInt(os, Color);
225 IOUtil.writeInt(os, a.length);
228 } catch (IOException ex1) {
229 logger.log(Level.SEVERE, null, ex1);