diff --git a/mediacloud/api.py b/mediacloud/api.py index 3613cd7..8928fd8 100644 --- a/mediacloud/api.py +++ b/mediacloud/api.py @@ -63,6 +63,10 @@ class DirectoryApi(BaseApi): PLATFORM_TWITTER = "twitter" PLATFORM_REDDIT = "reddit" + 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: params: Dict[Any, Any] = dict(limit=limit, offset=offset) @@ -72,6 +76,9 @@ def collection_list(self, platform: Optional[str] = None, name: Optional[str] = params['platform'] = platform return self._query('sources/collections/', params) + def source(self, source_id:int): + return self._query(f'sources/sources/{source_id}/', None) + def source_list(self, platform: Optional[str] = None, name: Optional[str] = None, collection_id: Optional[int] = None, limit: Optional[int] = 0, offset: Optional[int] = 0) -> Dict: diff --git a/mediacloud/test/api_directory_test.py b/mediacloud/test/api_directory_test.py index 8ac8f2b..df88f1b 100644 --- a/mediacloud/test/api_directory_test.py +++ b/mediacloud/test/api_directory_test.py @@ -106,3 +106,13 @@ def test_feed_list_modified_before(self): break offset += limit assert len(feeds) > 0 + + def test_get_collection(self): + us_national_id = 34412234 + response = self._directory.collection(us_national_id) + assert response["name"] == "United States - National" + + def test_get_source(self): + nyt_id = 1 + response = self._directory.source(nyt_id) + assert response["name"] == "nytimes.com" \ No newline at end of file