ilpost-api-wrapper 0.2.0__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ilpost_api_wrapper-0.2.0/ilpost_api_wrapper.egg-info → ilpost_api_wrapper-0.3.0}/PKG-INFO +1 -1
- {ilpost_api_wrapper-0.2.0 → ilpost_api_wrapper-0.3.0}/ilpost/client.py +27 -12
- {ilpost_api_wrapper-0.2.0 → ilpost_api_wrapper-0.3.0/ilpost_api_wrapper.egg-info}/PKG-INFO +1 -1
- {ilpost_api_wrapper-0.2.0 → ilpost_api_wrapper-0.3.0}/pyproject.toml +1 -1
- {ilpost_api_wrapper-0.2.0 → ilpost_api_wrapper-0.3.0}/LICENSE +0 -0
- {ilpost_api_wrapper-0.2.0 → ilpost_api_wrapper-0.3.0}/README.md +0 -0
- {ilpost_api_wrapper-0.2.0 → ilpost_api_wrapper-0.3.0}/ilpost/__init__.py +0 -0
- {ilpost_api_wrapper-0.2.0 → ilpost_api_wrapper-0.3.0}/ilpost/cli.py +0 -0
- {ilpost_api_wrapper-0.2.0 → ilpost_api_wrapper-0.3.0}/ilpost/models.py +0 -0
- {ilpost_api_wrapper-0.2.0 → ilpost_api_wrapper-0.3.0}/ilpost/py.typed +0 -0
- {ilpost_api_wrapper-0.2.0 → ilpost_api_wrapper-0.3.0}/ilpost_api_wrapper.egg-info/SOURCES.txt +0 -0
- {ilpost_api_wrapper-0.2.0 → ilpost_api_wrapper-0.3.0}/ilpost_api_wrapper.egg-info/dependency_links.txt +0 -0
- {ilpost_api_wrapper-0.2.0 → ilpost_api_wrapper-0.3.0}/ilpost_api_wrapper.egg-info/entry_points.txt +0 -0
- {ilpost_api_wrapper-0.2.0 → ilpost_api_wrapper-0.3.0}/ilpost_api_wrapper.egg-info/top_level.txt +0 -0
- {ilpost_api_wrapper-0.2.0 → ilpost_api_wrapper-0.3.0}/setup.cfg +0 -0
|
@@ -13,17 +13,19 @@ _BASE_URL = "https://api.ilpost.org/search/api/site_search/"
|
|
|
13
13
|
|
|
14
14
|
def _build_filters(
|
|
15
15
|
content_type: Optional[ContentType] = None,
|
|
16
|
-
category: Optional[str] = None,
|
|
16
|
+
category: Optional[Union[str, list[str]]] = None,
|
|
17
17
|
date_range: Optional[DateRange] = None,
|
|
18
18
|
) -> str:
|
|
19
19
|
parts: list[str] = []
|
|
20
20
|
if content_type is not None:
|
|
21
21
|
parts.append(f"ctype:{content_type.value}")
|
|
22
22
|
if category is not None:
|
|
23
|
-
|
|
23
|
+
cats = [category] if isinstance(category, str) else category
|
|
24
|
+
for cat in cats:
|
|
25
|
+
parts.append(f"category:{cat}")
|
|
24
26
|
if date_range is not None:
|
|
25
27
|
parts.append(f"pub_date:{date_range.value}")
|
|
26
|
-
return "
|
|
28
|
+
return ";".join(parts)
|
|
27
29
|
|
|
28
30
|
|
|
29
31
|
class IlPostClient:
|
|
@@ -52,7 +54,7 @@ class IlPostClient:
|
|
|
52
54
|
hits: int = 10,
|
|
53
55
|
sort: Union[SortOrder, str] = SortOrder.RELEVANCE,
|
|
54
56
|
content_type: Optional[ContentType] = None,
|
|
55
|
-
category: Optional[str] = None,
|
|
57
|
+
category: Optional[Union[str, list[str]]] = None,
|
|
56
58
|
date_range: Optional[DateRange] = None,
|
|
57
59
|
filters: Optional[str] = None,
|
|
58
60
|
) -> SearchResult:
|
|
@@ -61,7 +63,18 @@ class IlPostClient:
|
|
|
61
63
|
Parameters
|
|
62
64
|
----------
|
|
63
65
|
query:
|
|
64
|
-
Search term.
|
|
66
|
+
Search term. Supports:
|
|
67
|
+
|
|
68
|
+
- Exact phrase: ``'"goffredo fofi"'``
|
|
69
|
+
- Boolean OR: ``"fofi | berlusconi"`` (``|`` and ``OR`` both work)
|
|
70
|
+
- Boolean AND: ``"fofi AND berlusconi"`` or just ``"fofi berlusconi"``
|
|
71
|
+
- Boolean NOT: ``"berlusconi NOT fininvest"``
|
|
72
|
+
|
|
73
|
+
The following syntax does **not** work and should be avoided:
|
|
74
|
+
|
|
75
|
+
- Field prefix (``title:fofi``, ``content:fofi``) — treated as literal tokens
|
|
76
|
+
- Boost operator (``berlusconi^10``) — the numeric value becomes a search token
|
|
77
|
+
- Proximity queries (``"goffredo fofi"~5``) — inflates results unpredictably
|
|
65
78
|
page:
|
|
66
79
|
1-based page number (default: 1).
|
|
67
80
|
hits:
|
|
@@ -73,15 +86,17 @@ class IlPostClient:
|
|
|
73
86
|
Filter by content type: ``ContentType.ARTICLES``, ``ContentType.PODCASTS``,
|
|
74
87
|
or ``ContentType.NEWSLETTERS``.
|
|
75
88
|
category:
|
|
76
|
-
Filter articles by editorial category
|
|
77
|
-
|
|
78
|
-
|
|
89
|
+
Filter articles by editorial category. Pass a single string
|
|
90
|
+
(e.g. ``"politica"``) or a list to AND multiple categories together
|
|
91
|
+
(e.g. ``["cultura", "libri"]``). Only meaningful when
|
|
92
|
+
``content_type=ContentType.ARTICLES`` or no content type filter is set.
|
|
79
93
|
date_range:
|
|
80
94
|
Filter by publication date: ``DateRange.ALL_TIME``, ``DateRange.PAST_YEAR``,
|
|
81
95
|
or ``DateRange.PAST_30_DAYS``.
|
|
82
96
|
filters:
|
|
83
|
-
Raw pre-encoded filter string (e.g. ``"ctype:articoli
|
|
84
|
-
When provided, overrides ``content_type``,
|
|
97
|
+
Raw pre-encoded filter string (e.g. ``"ctype:articoli;pub_date:ultimo_anno"``).
|
|
98
|
+
Filters are separated by ``;``. When provided, overrides ``content_type``,
|
|
99
|
+
``category``, and ``date_range``.
|
|
85
100
|
|
|
86
101
|
Returns
|
|
87
102
|
-------
|
|
@@ -110,7 +125,7 @@ class IlPostClient:
|
|
|
110
125
|
page: int = 1,
|
|
111
126
|
hits: int = 10,
|
|
112
127
|
sort: Union[SortOrder, str] = SortOrder.RELEVANCE,
|
|
113
|
-
category: Optional[str] = None,
|
|
128
|
+
category: Optional[Union[str, list[str]]] = None,
|
|
114
129
|
date_range: Optional[DateRange] = None,
|
|
115
130
|
) -> SearchResult:
|
|
116
131
|
"""Search articles only. Convenience wrapper around :meth:`search`."""
|
|
@@ -169,7 +184,7 @@ class IlPostClient:
|
|
|
169
184
|
hits: int = 10,
|
|
170
185
|
sort: Union[SortOrder, str] = SortOrder.RELEVANCE,
|
|
171
186
|
content_type: Optional[ContentType] = None,
|
|
172
|
-
category: Optional[str] = None,
|
|
187
|
+
category: Optional[Union[str, list[str]]] = None,
|
|
173
188
|
date_range: Optional[DateRange] = None,
|
|
174
189
|
max_pages: Optional[int] = None,
|
|
175
190
|
):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ilpost_api_wrapper-0.2.0 → ilpost_api_wrapper-0.3.0}/ilpost_api_wrapper.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{ilpost_api_wrapper-0.2.0 → ilpost_api_wrapper-0.3.0}/ilpost_api_wrapper.egg-info/entry_points.txt
RENAMED
|
File without changes
|
{ilpost_api_wrapper-0.2.0 → ilpost_api_wrapper-0.3.0}/ilpost_api_wrapper.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|