--- /dev/null
+/*$Id$*/
+package nicobrowser;
+
+import java.util.Date;
+
+public class NicoContent {
+
+ private String pageLink;
+ private String imageLink;
+ private String title;
+ private Date publishedDate;
+
+ public String getPageLink() {
+ return pageLink;
+ }
+
+ public void setPageLink(String pageLink) {
+ this.pageLink = pageLink;
+ }
+
+ public String getImageLink() {
+ return imageLink;
+ }
+
+ public void setImageLink(String imageLink) {
+ this.imageLink = imageLink;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ void setPublishedDate(Date publishedDate) {
+ this.publishedDate = publishedDate;
+ }
+
+ public Date getPublishedDate() {
+ return publishedDate;
+ }
+}
/*$Id$*/
package nicobrowser;
+import com.sun.syndication.feed.synd.SyndContentImpl;
import com.sun.syndication.feed.synd.SyndEntryImpl;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.io.FeedException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Enumeration;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
+import javax.swing.text.MutableAttributeSet;
+import javax.swing.text.html.HTML;
+import javax.swing.text.html.HTMLEditorKit;
+import javax.swing.text.html.parser.ParserDelegator;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.cookie.CookiePolicy;
* @param listNo マイリストNo.
* @return 動画一覧.
*/
- public List<SyndEntryImpl> loadMyList(String listNo) {
+ public List<NicoContent> loadMyList(String listNo) {
List<SyndEntryImpl> list = null;
String url = new String(MY_LIST_PAGE_HEADER + listNo + "?rss=atom");
Logger.getLogger(NicoHttpClient.class.getName()).
} finally {
get.releaseConnection();
}
- return list;
+ List<NicoContent> contList;
+ if (list == null) {
+ contList = new ArrayList<NicoContent>();
+ } else {
+ contList = createContentsList(list);
+ }
+ return contList;
+ }
+
+ private List<NicoContent> createContentsList(List<SyndEntryImpl> list) {
+ class CallBack extends HTMLEditorKit.ParserCallback {
+
+ private String imageLink;
+
+ @Override
+ public void handleSimpleTag(HTML.Tag t, MutableAttributeSet a, int pos) {
+// System.out.println("--------<" + t.toString() + ">--------");
+// printAttributes(a);
+ if (HTML.Tag.IMG.equals(t)) {
+ imageLink = a.getAttribute(HTML.Attribute.SRC).toString();
+ }
+ }
+
+ // 属性を表示
+// private void printAttributes(MutableAttributeSet a) {
+// Enumeration e = a.getAttributeNames();
+// while (e.hasMoreElements()) {
+// Object key = e.nextElement();
+// System.out.println("---- " + key.toString() + " : " + a.getAttribute(key));
+// }
+// }
+ public String getImageLink() {
+ return imageLink;
+ }
+ }
+
+ List contList = new ArrayList<NicoContent>();
+
+ for (SyndEntryImpl entry : list) {
+ NicoContent content = new NicoContent();
+
+ content.setTitle(entry.getTitle());
+ content.setPageLink(entry.getLink());
+ content.setPublishedDate(entry.getPublishedDate());
+
+ // サムネイル画像リンクの取得
+ CallBack callBack = new CallBack();
+ for (SyndContentImpl sc : (List<SyndContentImpl>) entry.getContents()) {
+ try {
+ Reader reader = new StringReader(sc.getValue());
+ new ParserDelegator().parse(reader, callBack, true);
+ } catch (IOException ex) {
+ Logger.getLogger(NicoHttpClient.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ content.setImageLink(callBack.getImageLink());
+
+ // リストへ追加.
+ contList.add(content);
+ }
+ return contList;
}
}