Skip to content

Commit 98c0403

Browse files
Make "title" optional in "search"
1 parent 18dd288 commit 98c0403

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,23 @@ from simplejustwatchapi import search
5858
results = search("title", "US", "en", 5, True, 0, {"nfx", "apv"})
5959
```
6060

61-
Only the first argument is required, it specifies a title to search.
61+
No arguments are required.
6262

6363
| | Argument | Type | Required | Default value | Description |
6464
|---|-------------|--------|----------|---------------------|--------------------------------------------------------|
65-
| 1 | `title` | `str` | **YES** | - | Title to look up |
65+
| 1 | `title` | `str` | NO | - | Title to look up |
6666
| 2 | `country` | `str` | NO | `"US"` | Country to search for offers |
6767
| 3 | `language` | `str` | NO | `"en"` | Language of responses |
6868
| 4 | `count` | `int` | NO | `4` | Up to how many entries should be returned |
6969
| 5 | `best_only` | `bool` | NO | `True` | Determines whether only best offers should be returned |
7070
| 6 | `offset` | `int` | NO | `0` | How many titles should be skipped from the output |
7171
| 7 | `providers` | `list[str] \| str \| None`| NO | `None` | Determines whether only best offers should be returned |
7272

73-
`title` is just a string to look up.
73+
`title` is just a string to look up. If empty, or not provided, you'll get a selection of popular titles,
74+
similar to [`popular`](#popular) function.
75+
76+
> **Note**: value of `title` isn't stripped, so passing a string
77+
with multiple spaces will look them up. For more than 1 space it will (probably) always return an empty list.
7478

7579
`country` must be **ISO 3166-1 alpha-2** 2-letter code , e.g. `US`, `GB`, `FR`.
7680
It should be uppercase, however lowercase codes are automatically converted to uppercase.
@@ -442,7 +446,7 @@ https://www.justwatch.com/us?providers=nfx,prv
442446
So the codes for them are `nfx` and `prv` for the US.
443447

444448

445-
### Stored output from other commands with offers
449+
### Stored output from other functions with offers
446450

447451
The codes are also returned when looking up offers (through pretty much any function aside from `providers`) through `OfferPackage` and its `short_name` field.
448452
For example, to get a `dict` "**full name**": "**code**" you can:

src/simplejustwatchapi/justwatch.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525

2626
def search(
27-
title: str,
27+
title: str = "",
2828
country: str = "US",
2929
language: str = "en",
3030
count: int = 4,
@@ -35,6 +35,11 @@ def search(
3535
"""
3636
Search JustWatch for given title.
3737
38+
If no ``title`` is provided (or an empty string, as per default value) you'll get a
39+
selection of "popular" titles. Without ``title`` the output is very similar to ``popular``
40+
function. This argument isn't stripped, so passing string with only spaces will
41+
look for those spaces.
42+
3843
Returns a list of entries up to ``count``.
3944
4045
``offset`` specifies how many first entries should be skipped. This is done on API side,
@@ -58,7 +63,7 @@ def search(
5863
You can look up values through ``providers`` function.
5964
6065
Args:
61-
title (str): Title to search.
66+
title (str): Title to search, empty string by default.
6267
country (str): Country to search for offers, ``US`` by default.
6368
language (str): Language of responses, ``en`` by default.
6469
count (int): How many responses should be returned.
@@ -91,6 +96,8 @@ def popular(
9196
"""
9297
Look up all currently popular titles on JustWatch.
9398
99+
This function returns similar values as ``search`` with no ``title`` provided.
100+
94101
Returns a list of entries up to ``count``.
95102
96103
``offset`` specifies how many first entries should be skipped. This is done on API side,

0 commit comments

Comments
 (0)