diff options
author | Pacien TRAN-GIRARD | 2015-08-11 13:01:54 +0200 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2015-08-11 13:01:54 +0200 |
commit | ab3a2646acd4f085c892c0c93cc4beffa7901190 (patch) | |
tree | f1fb8282cf60280ae17be705ae18aebc4245e498 | |
parent | 45b8d0637a0669c3281fc0449b08a93ea0b7a809 (diff) | |
download | afeedprocessor-ab3a2646acd4f085c892c0c93cc4beffa7901190.tar.gz |
Properly form category list from tags
-rw-r--r-- | afeedprocessor/afeedparser.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/afeedprocessor/afeedparser.py b/afeedprocessor/afeedparser.py index 0c23187..a01d3f0 100644 --- a/afeedprocessor/afeedparser.py +++ b/afeedprocessor/afeedparser.py | |||
@@ -12,13 +12,19 @@ class FeedParser: | |||
12 | def get_first(lst): | 12 | def get_first(lst): |
13 | return lst[0] if lst and len(lst) > 0 else None | 13 | return lst[0] if lst and len(lst) > 0 else None |
14 | 14 | ||
15 | @staticmethod | ||
16 | def get_terms(lst): | ||
17 | if lst is None: | ||
18 | return None | ||
19 | return [e['term'] for e in lst] | ||
20 | |||
15 | def get_rss_item_for_entry(self, entry): | 21 | def get_rss_item_for_entry(self, entry): |
16 | return PyRSS2Gen.RSSItem( | 22 | return PyRSS2Gen.RSSItem( |
17 | title=entry.get('title'), | 23 | title=entry.get('title'), |
18 | link=entry.get('link'), | 24 | link=entry.get('link'), |
19 | description=entry.get('description'), | 25 | description=entry.get('description'), |
20 | author=entry.get('author'), | 26 | author=entry.get('author'), |
21 | categories=entry.get('tags'), | 27 | categories=self.get_terms(entry.get('tags')), |
22 | comments=entry.get('comments'), | 28 | comments=entry.get('comments'), |
23 | enclosure=self.get_first(entry.get('enclosures')), | 29 | enclosure=self.get_first(entry.get('enclosures')), |
24 | guid=entry.get('id'), | 30 | guid=entry.get('id'), |
@@ -39,7 +45,7 @@ class FeedParser: | |||
39 | pubDate=self.date_tuple_to_datetime(feed.get('published_parsed')), | 45 | pubDate=self.date_tuple_to_datetime(feed.get('published_parsed')), |
40 | lastBuildDate=self.date_tuple_to_datetime(feed.get('updated_parsed')), | 46 | lastBuildDate=self.date_tuple_to_datetime(feed.get('updated_parsed')), |
41 | 47 | ||
42 | categories=feed.get('tags'), | 48 | categories=self.get_terms(feed.get('tags')), |
43 | generator=feed.get('generator'), | 49 | generator=feed.get('generator'), |
44 | docs=feed.get('docs'), | 50 | docs=feed.get('docs'), |
45 | cloud=feed.get('cloud'), | 51 | cloud=feed.get('cloud'), |