Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def storyList(self, solr_query='', solr_filter='', last_processed_stories_id=0, rows=20,
wc=False, feeds_id=None, sort=MediaCloud.SORT_PROCESSED_STORIES_ID, raw_1st_download=False,
corenlp=False, sentences=False, text=False, ap_stories_id=0, show_feeds=False):
# Search for stories and page through results
stories = self._queryForJson(self.V2_API_URL+'stories/list',
{'q': solr_query,
'fq': solr_filter,
'last_processed_stories_id': last_processed_stories_id,
'rows': rows,
'raw_1st_download': 1 if raw_1st_download else 0,
'corenlp': 1 if corenlp else 0, # this is slow - use storyCoreNlList instead
'sentences': 1 if sentences else 0,
'text': 1 if text else 0,
'ap_stories_id': 1 if ap_stories_id else 0,
'sort': sort,
'wc': 1 if wc is True else 0,
'feeds_id': feeds_id,
'show_feeds': 1 if show_feeds is True else 0,
def _stream_story_list_csv(filename, q, fq, stories_per_page=500, sort=MediaCloud.SORT_PROCESSED_STORIES_ID,
page_limit=None):
props = ['stories_id', 'publish_date', 'title', 'url', 'language', 'ap_syndicated',
'themes', 'media_id', 'media_name', 'media_url']
if INCLUDE_MEDIA_METADATA_IN_CSV:
metadata_cols = ['media_pub_country', 'media_pub_state', 'media_language', 'media_about_country',
'media_media_type']
props += metadata_cols
timestamped_filename = csv.safe_filename(filename)
headers = {
"Content-Disposition": "attachment;filename=" + timestamped_filename
}
return Response(_story_list_by_page_as_csv_row(user_mediacloud_key(), q, fq, stories_per_page, sort, page_limit, props),
mimetype='text/csv; charset=utf-8', headers=headers)