Skip to content

Commit

Permalink
Merge pull request #96 from pgulley/id_queries
Browse files Browse the repository at this point in the history
Added more detailed results to the feed_list query
  • Loading branch information
pgulley authored Nov 7, 2024
2 parents b86da17 + 14accb1 commit 2d613bc
Showing 1 changed file with 8 additions and 3 deletions.
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:
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

0 comments on commit 2d613bc

Please sign in to comment.