Skip to content

Commit 1165bae

Browse files
authored
Merge pull request #20 from ArchiveLabs/search-with-title
Allow search to specify optional metadata.title
2 parents 3d5b3b0 + 674034b commit 1165bae

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

pyopds2/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ def create(
213213
response: Optional SearchResponse for paginated search results
214214
paginate: Whether to add pagination links (requires data)
215215
"""
216-
metadata = metadata or Metadata(title="OPDS Catalog")
216+
if not metadata:
217+
metadata = Metadata(title=response.title or "OPDS Catalog")
217218
links = links or []
218219
publications = publications or []
219220

pyopds2/provider.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class SearchResponse:
7676
sort: Optional[str]
7777
records: List[DataProviderRecord]
7878
total: int
79+
title: Optional[str] = None
7980

8081
def get_search_url(self, **kwargs: str) -> str:
8182
base_url = self.provider.SEARCH_URL.replace("{?query}", "")
@@ -118,6 +119,7 @@ def search(
118119
limit: int = 50,
119120
offset: int = 0,
120121
sort: Optional[str] = None,
122+
title: Optional[str] = None,
121123
) -> 'DataProvider.SearchResponse':
122124
"""Search for publications matching the query.
123125
@@ -126,6 +128,7 @@ def search(
126128
limit: Maximum number of results to return (default: 50)
127129
offset: Offset for pagination (default: 0)
128130
sort: Optional sorting parameter
131+
title: Title to pass along to Catalog.create
129132
130133
Returns:
131134
SearchResponse object containing search results
@@ -137,5 +140,6 @@ def search(
137140
query=query,
138141
limit=limit,
139142
offset=offset,
140-
sort=sort
143+
sort=sort,
144+
title=title,
141145
)

0 commit comments

Comments
 (0)