OSDN Git Service

サムネイル取得情報取得機能を追加(やっつけver)
authoryukihane <yukihane.feather@gmail.com>
Sun, 21 Aug 2011 02:42:18 +0000 (11:42 +0900)
committeryukihane <yukihane.feather@gmail.com>
Sun, 21 Aug 2011 02:42:18 +0000 (11:42 +0900)
src/nicobrowser/util/RssContent.groovy [new file with mode: 0644]
src/nicobrowser/util/RssContentParse.groovy [new file with mode: 0644]

diff --git a/src/nicobrowser/util/RssContent.groovy b/src/nicobrowser/util/RssContent.groovy
new file mode 100644 (file)
index 0000000..4119943
--- /dev/null
@@ -0,0 +1,26 @@
+package nicobrowser.util
+
+/**
+ * RSSから取得したコンテンツです.
+ * @author yuki
+ */
+class RssContent {
+    String video_id,
+    title,
+    description,
+    thumbnail_url,
+    first_retrieve,
+    length,
+    movie_type,
+    size_high,
+    size_low,
+    view_counter,
+    comment_num,
+    mylist_counter,
+    last_res_body,
+    watch_url,
+    thumb_type,
+    embeddable,
+    no_live_play
+}
+
diff --git a/src/nicobrowser/util/RssContentParse.groovy b/src/nicobrowser/util/RssContentParse.groovy
new file mode 100644 (file)
index 0000000..8e4381c
--- /dev/null
@@ -0,0 +1,32 @@
+package nicobrowser.util
+
+/**
+ * http://ext.nicovideo.jp/api/getthumbinfo/sm** のInputStreamからエンティティを生成します.
+ * @author yuki
+ */
+class RssContentParser {
+    RssContent parse(InputStream is){
+        def xml = new XmlSlurper().parse(is)
+        def t = xml.thumb[0]
+
+        new RssContent(
+            video_id: t.video_id[0].text(),
+            title: t.title[0].text(),
+            description: t.description[0].text(),
+            thumbnail_url: t.thumbnail_url[0].text(),
+            first_retrieve: t.first_retrieve[0].text(),
+            length: t.length[0].text(),
+            movie_type: t.movie_type[0].text(),
+            size_high: t.size_high[0].text(),
+            size_low: t.size_low[0].text(),
+            view_counter: t.view_counter[0].text(),
+            comment_num: t.comment_num[0].text(),
+            mylist_counter: t.mylist_counter[0].text(),
+            last_res_body: t.last_res_body[0].text(),
+            watch_url: t.watch_url[0].text(),
+            thumb_type: t.thumb_type[0].text(),
+            embeddable: t.embeddable[0].text(),
+            no_live_play: t.no_live_play[0].text()
+            )
+    }
+}