Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added more detailed results to the feed_list query #96

Merged
merged 6 commits into from
Nov 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions mediacloud/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,14 @@ def collection(self, collection_id: int):
return self._query(f'sources/collections/{collection_id}/', None)

def collection_list(self, platform: Optional[str] = None, name: Optional[str] = None,
limit: Optional[int] = 0, offset: Optional[int] = 0) -> Dict:
limit: Optional[int] = 0, offset: Optional[int] = 0, source_id: Optional[int] = None) -> Dict:
params: Dict[Any, Any] = dict(limit=limit, offset=offset)
if name:
params['name'] = name
if platform:
params['platform'] = platform
if source_id:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming source_id 0 is unlikely to exist?!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that strikes me as a fair assumption!!

params['source_id'] = source_id
return self._query('sources/collections/', params)

def source(self, source_id:int):
Expand All @@ -94,7 +96,7 @@ def source_list(self, platform: Optional[str] = None, name: Optional[str] = None
def feed_list(self, source_id: Optional[int] = None,
modified_since: Optional[Union[dt.datetime, int, float]] = None,
modified_before: Optional[Union[dt.datetime, int, float]] = None,
limit: Optional[int] = 0, offset: Optional[int] = 0) -> Dict:
limit: Optional[int] = 0, offset: Optional[int] = 0, return_details: bool = False) -> Dict:
params: Dict[Any, Any] = dict(limit=limit, offset=offset)
if source_id:
params['source_id'] = source_id
Expand All @@ -111,7 +113,10 @@ def epoch_param(t, param):

epoch_param(modified_since, 'modified_since')
epoch_param(modified_before, 'modified_before')


if return_details:
return {'results':self._query('sources/feeds/details/', params)['feeds']}

return self._query('sources/feeds/', params)


Expand Down
Loading