Skip to content

Commit

Permalink
chore: iterator fix in itunes search
Browse files Browse the repository at this point in the history
  • Loading branch information
danjac committed Aug 29, 2024
1 parent 5a834d9 commit edb6ae0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions radiofeed/podcasts/itunes.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def search(client: Client, search_term: str, limit: int) -> Iterator[Feed]:

def _fetch_itunes_results(
client: Client, search_term: str, limit: int
) -> list[dict[str, str]]:
) -> Iterator[dict[str, str]]:
try:
response = client.get(
"https://itunes.apple.com/search",
Expand All @@ -51,13 +51,13 @@ def _fetch_itunes_results(
"Accept": "application/json",
},
)
return response.json()["results"]
yield from response.json().get("results", [])

except httpx.HTTPError:
return []
return


def _parse_feeds_from_json(results: list[dict[str, str]]) -> Iterator[Feed]:
def _parse_feeds_from_json(results: Iterator[dict[str, str]]) -> Iterator[Feed]:
for result in results:
try:
yield Feed(
Expand Down

0 comments on commit edb6ae0

Please sign in to comment.