summaryrefslogtreecommitdiff
path: root/include/rssparser.h
blob: 8d51a6e72f2fce41483b983659f7b2ba1b0f9e56 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#ifndef NEWSBOAT_RSSPARSER_H_
#define NEWSBOAT_RSSPARSER_H_

#include <memory>
#include <string>

#include "remoteapi.h"
#include "rss/feed.h"

namespace rsspp {
class Item;
}

namespace newsboat {

class Cache;
class ConfigContainer;
class CurlHandle;
class RssFeed;
class RssIgnores;
class RssItem;

class RssParser {
public:
	RssParser(const std::string& uri,
		Cache* c,
		ConfigContainer*,
		RssIgnores* ii,
		RemoteApi* a = 0);
	~RssParser();
	std::shared_ptr<RssFeed> parse();
	bool check_and_update_lastmodified();

	void set_easyhandle(CurlHandle* h)
	{
		easyhandle = h;
	}

private:
	void replace_newline_characters(std::string& str);
	std::string render_xhtml_title(const std::string& title,
		const std::string& link);
	time_t parse_date(const std::string& datestr);
	void set_rtl(std::shared_ptr<RssFeed> feed, const std::string& lang);

	void retrieve_uri(const std::string& uri);
	void download_http(const std::string& uri);
	void get_execplugin(const std::string& plugin);
	void download_filterplugin(const std::string& filter,
		const std::string& uri);
	void parse_file(const std::string& file);

	void fill_feed_fields(std::shared_ptr<RssFeed> feed);
	void fill_feed_items(std::shared_ptr<RssFeed> feed);

	void set_item_title(std::shared_ptr<RssFeed> feed,
		std::shared_ptr<RssItem> x,
		const rsspp::Item& item);
	void set_item_author(std::shared_ptr<RssItem> x,
		const rsspp::Item& item);
	void set_item_content(std::shared_ptr<RssItem> x,
		const rsspp::Item& item);
	void set_item_enclosure(std::shared_ptr<RssItem> x,
		const rsspp::Item& item);
	std::string get_guid(const rsspp::Item& item) const;

	void add_item_to_feed(std::shared_ptr<RssFeed> feed,
		std::shared_ptr<RssItem> item);

	void handle_content_encoded(std::shared_ptr<RssItem> x,
		const rsspp::Item& item) const;
	void handle_itunes_summary(std::shared_ptr<RssItem> x,
		const rsspp::Item& item);
	bool is_html_type(const std::string& type);
	void fetch_ttrss(const std::string& feed_id);
	void fetch_newsblur(const std::string& feed_id);
	void fetch_ocnews(const std::string& feed_id);
	void fetch_miniflux(const std::string& feed_id);
	void fetch_freshrss(const std::string& feed_id);

	std::string my_uri;
	Cache* ch;
	ConfigContainer* cfgcont;
	RssIgnores* ign;
	rsspp::Feed f;
	RemoteApi* api;
	bool is_ttrss;
	bool is_newsblur;
	bool is_ocnews;
	bool is_miniflux;
	bool is_freshrss;

	CurlHandle* easyhandle;
};

} // namespace newsboat

#endif /* NEWSBOAT_RSSPARSER_H_ */