diff options
author | Pacien TRAN-GIRARD | 2015-08-11 18:09:22 +0200 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2015-08-11 18:09:22 +0200 |
commit | bb310224001a2404b90b8dfdc4ceccbbe929fbc0 (patch) | |
tree | 89d9d44fc1f9a725c8ed47735e1484cbc8a4db54 | |
parent | 603bd06729a7fec937ed679bc60654457a823f30 (diff) | |
download | afeedprocessor-bb310224001a2404b90b8dfdc4ceccbbe929fbc0.tar.gz |
-rw-r--r-- | afeedprocessor/afeedparser.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/afeedprocessor/afeedparser.py b/afeedprocessor/afeedparser.py index 3e7653b..3cb2c89 100644 --- a/afeedprocessor/afeedparser.py +++ b/afeedprocessor/afeedparser.py | |||
@@ -13,10 +13,10 @@ class FeedParser: | |||
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 | 15 | @staticmethod |
16 | def get_terms(lst): | 16 | def get_keys(lst, key): |
17 | if lst is None: | 17 | if lst is None: |
18 | return None | 18 | return None |
19 | return [e['term'] for e in lst] | 19 | return [e[key] for e in lst] |
20 | 20 | ||
21 | def get_rss_item_for_entry(self, entry): | 21 | def get_rss_item_for_entry(self, entry): |
22 | rss_item = PyRSS2Gen.RSSItem( | 22 | rss_item = PyRSS2Gen.RSSItem( |
@@ -24,7 +24,7 @@ class FeedParser: | |||
24 | link=entry.get('link'), | 24 | link=entry.get('link'), |
25 | description=entry.get('description'), | 25 | description=entry.get('description'), |
26 | author=entry.get('author'), | 26 | author=entry.get('author'), |
27 | categories=self.get_terms(entry.get('tags')), | 27 | categories=self.get_keys(entry.get('tags'), 'term'), |
28 | comments=entry.get('comments'), | 28 | comments=entry.get('comments'), |
29 | enclosure=self.get_first(entry.get('enclosures')), | 29 | enclosure=self.get_first(entry.get('enclosures')), |
30 | guid=entry.get('id'), | 30 | guid=entry.get('id'), |
@@ -43,12 +43,12 @@ class FeedParser: | |||
43 | 43 | ||
44 | language=feed.get('language'), | 44 | language=feed.get('language'), |
45 | copyright=feed.get('rights'), | 45 | copyright=feed.get('rights'), |
46 | managingEditor=feed.get('contributors'), | 46 | managingEditor=self.get_first(self.get_keys(feed.get('contributors'), 'name')), |
47 | webMaster=feed.get('publisher'), | 47 | webMaster=feed.get('publisher'), |
48 | pubDate=self.date_tuple_to_datetime(feed.get('published_parsed')), | 48 | pubDate=self.date_tuple_to_datetime(feed.get('published_parsed')), |
49 | lastBuildDate=self.date_tuple_to_datetime(feed.get('updated_parsed')), | 49 | lastBuildDate=self.date_tuple_to_datetime(feed.get('updated_parsed')), |
50 | 50 | ||
51 | categories=self.get_terms(feed.get('tags')), | 51 | categories=self.get_keys(feed.get('tags'), 'term'), |
52 | generator=feed.get('generator'), | 52 | generator=feed.get('generator'), |
53 | docs=feed.get('docs'), | 53 | docs=feed.get('docs'), |
54 | cloud=feed.get('cloud'), | 54 | cloud=feed.get('cloud'), |