最近写了个小工具,通过抓取RSS生成适合Kindle展示的Mobi格式的文件,并发送到Kindle 个人图书馆,也算是继续“自动化”之旅。
代码前前后后写了个把月,趁着放假期间,决定把它搞定。使用方法什么的就不多说了,项目开源到Github上去了,上面有使用说明。
这篇文章简单得聊聊项目本身以及总结的一些问题。
首先来看看项目的组织结构图:
大致分为三大部分:
/**
* get parsing rss links
*
* @return the String array of all links
*/
String[] getFeedLinks();/**
* parse feed with given urls
*
* @param urls the URL Array
* @return the BaseFeed Array
*/
BaseFeed[] parse(URL[] urls);/**
* output full text from a entrylink
*
* @param entryLink the string of the entry link url
* @return the full text
*/
String fullTextFrom(String entryLink);/**
* push a img obj to the image store
*
* @param img the instance of BaseImage
*/
public void push(BaseImage img);
/**
* get all image objs with the feed
*
* @param feed the instance of BaseFeed
* @return the map of all the images per feed
*/
public Map<String, BaseImage> getAllImageObjsWithFeed(BaseFeed feed);/**
* generate mobi file with a list of feeds
*
* @param feeds the List of BaseFeed instances
* @return return the generated mobi file path
*/
String generate(List<BaseFeed> feeds);/**
* save a entry
*
* @param entry the instance of BaseEntry
*/
void save(BaseEntry entry);
/**
* check is entry exists
*
* @param entry the instance of BaseEntry
* @return if exists return true otherwise return false
*/
boolean entryExists(BaseEntry entry);
/**
* get processed entry (the func for cache entry)
*
* @param entry the instance of BaseEntry
* @return return the processed entry
*/
BaseEntry getProcessedEntry(BaseEntry entry);
/**
* get a feed‘s all entry (processed)
*
* @param feed the instance of BaseFeed
* @return the map of the feed‘s entries (key is entry‘s link)
*/
Map<String, BaseEntry> getAllEntryPerFeed(BaseFeed feed);/**
* do strip
* @param originalFilePath the original file path
* @param newFilePath the new path
*/
void doStrip(String originalFilePath, String newFilePath);/**
* send mobi file from path
* @param filePath the mobi file path
*/
void sendFrom(String filePath);原文:http://blog.csdn.net/yanghua_kobe/article/details/18950969