summaryrefslogtreecommitdiff
path: root/include/rss_parser.h
blob: 256e0cec205afed122bc94577ba5cca67d5a76b8 (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
#ifndef RSS_PARSER__H
#define RSS_PARSER__H

#include <string>

#include <rss.h>
#include <rsspp.h>

namespace newsbeuter {

	class configcontainer;
	class cache;

	class rss_parser {
		public:
			rss_parser(const char * uri, cache * c, configcontainer *, rss_ignores * ii);
			~rss_parser();
			std::tr1::shared_ptr<rss_feed> parse();
			bool check_and_update_lastmodified();
		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);
			unsigned int monthname_to_number(const std::string& mon);
			void set_rtl(std::tr1::shared_ptr<rss_feed> feed, const char * lang);
			int correct_year(int year);

			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::tr1::shared_ptr<rss_feed> feed);
			void fill_feed_items(std::tr1::shared_ptr<rss_feed> feed);

			void set_item_title(std::tr1::shared_ptr<rss_feed> feed, std::tr1::shared_ptr<rss_item> x, rsspp::item& item);
			void set_item_author(std::tr1::shared_ptr<rss_item> x, rsspp::item& item);
			void set_item_content(std::tr1::shared_ptr<rss_item> x, rsspp::item& item);
			void set_item_enclosure(std::tr1::shared_ptr<rss_item> x, rsspp::item& item);
			std::string get_guid(rsspp::item& item);

			void add_item_to_feed(std::tr1::shared_ptr<rss_feed> feed, std::tr1::shared_ptr<rss_item> item);

			void handle_content_encoded(std::tr1::shared_ptr<rss_item> x, rsspp::item& item);
			void handle_itunes_summary(std::tr1::shared_ptr<rss_item> x, rsspp::item& item);
			bool is_html_type(const std::string& type);

			std::string my_uri;
			cache * ch;
			configcontainer *cfgcont;
			bool skip_parsing;
			bool is_valid;
			rss_ignores * ign;
			rsspp::feed f;
	};

}

#endif