Package org.ryu22e.nico2cal.service

Source Code of org.ryu22e.nico2cal.service.NicoliveRssService

package org.ryu22e.nico2cal.service;

import java.io.IOException;
import java.net.URL;

import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.io.FeedException;
import com.sun.syndication.io.SyndFeedInput;
import com.sun.syndication.io.XmlReader;

/**
* ニコニコ生放送RSSを操作するサービスクラス。
* @author ryu22e
*
*/
public final class NicoliveRssService {

    /**
     * RSSフィードのURL。
     */
    private static final String FEED_URL = "http://live.nicovideo.jp/rss";

    /**
     * ニコニコ生放送のRSSフィードを取得する。
     * @return ニコニコ生放送のRSSフィード
     * @throws IOException RSSフィードの取得に失敗した場合。
     * @throws FeedException RSSフィードのパースに失敗した場合。
     */
    public SyndFeed getFeed() throws FeedException, IOException {
        URL feedUrl = new URL(FEED_URL);
        SyndFeedInput input = new SyndFeedInput();
        return input.build(new XmlReader(feedUrl.openStream()));
    }

}
TOP

Related Classes of org.ryu22e.nico2cal.service.NicoliveRssService

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.