Skip to content

Commit

Permalink
Merge pull request #89 from mediacloud/indexed_date_edits
Browse files Browse the repository at this point in the history
Update story_list() to handle indexed_date values with or without microseconds
  • Loading branch information
NullPxl authored Feb 15, 2024
2 parents 8e92c5b + 7ad11b0 commit 9cc7d78
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions mediacloud/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ def story_list(self, query: str, start_date: dt.date, end_date: dt.date, collect
results = self._query('search/story-list', params)
for s in results['stories']:
s['publish_date'] = dt.date.fromisoformat(s['publish_date'][:10]) if s['publish_date'] else None
s['indexed_date'] = dt.datetime.strptime(s['indexed_date'][:19], '%Y-%m-%d %H:%M:%S')\
if s['indexed_date'] else None
s['indexed_date'] = dt.datetime.fromisoformat(s['indexed_date']) if s['indexed_date'] else None
return results['stories'], results['pagination_token']

def story(self, story_id: str) -> Dict:
Expand Down

0 comments on commit 9cc7d78

Please sign in to comment.