javac.classpath=\\r
${libs.HttpClient3.classpath}:\\r
${libs.Log4J.classpath}:\\r
- ${libs.Codec.classpath}\r
+ ${libs.Codec.classpath}:\\r
+ ${libs.Rome.classpath}\r
# Space-separated list of extra javac options\r
javac.compilerargs=\r
javac.deprecation=false\r
# Property libs.Log4J.classpath is set here just to make sharing of project simpler.\r
# The library definition has always preference over this property.\r
libs.Log4J.classpath=../../../java/commons/commons-logging-1.1/commons-logging-adapters-1.1.jar;../../../java/commons/commons-logging-1.1/commons-logging-api-1.1.jar\r
+# Property libs.Rome.classpath is set here just to make sharing of project simpler.\r
+# The library definition has always preference over this property.\r
+libs.Rome.classpath=../../../java/commons/rome-0.9/rome-0.9.jar;../../../java/commons/jdom-1.1/build/jdom.jar\r
main.class=nicobrowser.MainWindow\r
manifest.file=manifest.mf\r
meta.inf.dir=${src.dir}/META-INF\r
/*$Id$*/
package nicobrowser;
+import com.sun.syndication.feed.synd.SyndEntryImpl;
+import com.sun.syndication.feed.synd.SyndFeed;
+import com.sun.syndication.io.FeedException;
+import com.sun.syndication.io.SyndFeedInput;
+import java.io.BufferedReader;
import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.httpclient.HttpClient;
"https://secure.nicovideo.jp/secure/login?site=niconico";
private static final String LOGOUT_PAGE =
"https://secure.nicovideo.jp/secure/logout";
+ private static final String MY_LIST_PAGE_HEADER =
+ "http://www.nicovideo.jp/mylist/";
private NicoHttpClient() {
super();
return auth;
}
- public void loadMyList(String listNo) {
-
- }
-
public boolean logout() {
boolean result = false;
GetMethod method = new GetMethod(LOGOUT_PAGE);
try {
int statusCode = executeMethod(method);
+ Logger.getLogger(NicoHttpClient.class.getName()).
+ log(Level.INFO, "ログアウトステータスコード: " + statusCode);
+
if (statusCode == HttpStatus.SC_OK) {
result = true;
}
}
return result;
}
+
+ /**
+ * マイリストに登録した動画一覧の取得.
+ * 「公開」設定にしていないリストからは取得できない.
+ * ログインしていなくても取得可能.
+ * @param listNo マイリストNo.
+ * @return 動画一覧.
+ */
+ public List<SyndEntryImpl> loadMyList(String listNo) {
+ List<SyndEntryImpl> list = null;
+ String url = new String(MY_LIST_PAGE_HEADER + listNo + "?rss=atom");
+ Logger.getLogger(NicoHttpClient.class.getName()).
+ log(Level.INFO, "マイリストURL: " + url);
+
+ GetMethod get = new GetMethod(url);
+
+ try {
+ int statusCode = executeMethod(get);
+ Reader reader = new BufferedReader(new InputStreamReader(get.getResponseBodyAsStream(), "UTF-8"));
+ SyndFeedInput input = new SyndFeedInput();
+ SyndFeed feed = input.build(reader);
+
+ list = (List<SyndEntryImpl>) feed.getEntries();
+
+ } catch (IllegalArgumentException ex) {
+ Logger.getLogger(NicoHttpClient.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (FeedException ex) {
+ Logger.getLogger(NicoHttpClient.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (IOException ex) {
+ Logger.getLogger(NicoHttpClient.class.getName()).log(Level.SEVERE, null, ex);
+ } finally {
+ get.releaseConnection();
+ }
+ return list;
+ }
}
/*$Id$*/
package nicobrowser;
+import java.util.List;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
*/
public class NicoHttpClientTest {
+ static final String OK_MAIL = "niconico.senyou@live.jp";
+ static final String OK_PASS = "piyopiyo";
+ static final String OK_LIST_NO = "4315046";
+
public NicoHttpClientTest() {
}
assertEquals(false, result);
// ログイン成功ケース
- mail = "niconico.senyou@live.jp";
- password = "piyopiyo";
+ mail = OK_MAIL;
+ password = OK_PASS;
result = instance.login(mail, password);
assertEquals(true, result);
}
@Test
public void loadMyList() {
System.out.println("loadMyList");
-
+
NicoHttpClient instance = NicoHttpClient.getInstance();
-
- instance.logout();
+ List list;
+ list = instance.loadMyList(OK_LIST_NO);
+ assertNotNull(list);
+ assertNotSame(0, list.size());
+ list = instance.loadMyList("XXXX");
+ assertNotNull(list);
+ assertSame(0, list.size());
}
}