amugofjava / podcast_search

A simple library providing programmatic access to the iTunes search API for podcasts.
MIT License
41 stars 26 forks source link

France podcast charts exception if limit too high #16

Closed Feichtmeier closed 1 year ago

Feichtmeier commented 1 year ago

For some countries like france (lol) the charts errors out with

flutter: media_kit: WARNING: package:media_kit_native_event_loop not found.
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: RangeError (index): Invalid value: Valid value range is empty: 0
#0      List.[] (dart:core-patch/growable_array.dart:264:36)
#1      ITunesSearch._chartsToResults
itunes_search.dart:177
<asynchronous suspension>
#2      ITunesSearch.charts
itunes_search.dart:151
<asynchronous suspension>
#3      PodcastService.search
podcast_service.dart:34
<asynchronous suspension>

when the limit is too high Limit on ~50~ 20 is okay :D but above 20 is too much.

Should this be handled on my side or is this indeed to handle here?

Best regards :wave:

amugofjava commented 1 year ago

Thanks for reporting this @Feichtmeier. The issue is on my side. I am assuming that if I request x number of results I will always get that number back. It looks like, once you get over 40 (at least for France) you always get 1 less than you request.

amugofjava commented 1 year ago

The iTunes charts API only returns basic information about each podcast. podcast_search uses the lookup API for each result to fetch the full details for each podcast. Sometimes this lookup can return no result which podcast_search was not handling resulting in the error.

This has been fixed in master.

Feichtmeier commented 1 year ago

Cool thanks! Feel free to close if it's fixed 😸 the good thing about this bug was that it improved my podcast service 😎👌