Hexer10 / youtube_explode_dart

Dart library to interact with many Youtube APIs
https://pub.dev/packages/youtube_explode_dart
BSD 3-Clause "New" or "Revised" License
299 stars 122 forks source link

[BUG] issue implementing pagination using the .nextPage() method #266

Open Samriddhi-Karmacharya opened 8 months ago

Samriddhi-Karmacharya commented 8 months ago

Describe the bug The .nextPage() method provided by the SearchList and also VidoSearchList tends to return videos that have already been fetched in the initial search api call resulting in duplicate videos in the lisitng. Is this the expected beahvaiour or am I doing something wrong?

To Reproduce Include the code which doesn't work in the code markdown..

 Future<VideoModelList> fetchVideosFromExplode(String videoName,
      {bool loadMore = false}) async {
    try {
      final ytExplode = YoutubeExplode();
      final searchList = await ytExplode.search.search(videoName);
      log('search results from explode $searchList');
      log('---------------------------');

      if (loadMore) {
        final searches = await searchList.nextPage();
        if (searches != null) {
          var videosList = VideoModelList.fromJson(searches);
          return videosList;
        } else {
          return VideoModelList(videoList: []);
        }
      } else {
        var videosList = VideoModelList.fromJson(searchList);
        return videosList;
      }
    } on YoutubeExplodeException catch (e) {
      throw YoutubeExplodeException(e.message);
    } catch (e) {
      log('video search from explode error $e');
      throw ServerException();
    }
  }

Stacktrace Include here the stacktrace (if applicable).

Enviroment: (please complete the following information):

Hexer10 commented 8 months ago

Hi, I've run some tests and I did not get any duplicates videos. Does the error happen with every query or only with some? (if so please provide one). Also, are you able to repruduce the issues in Dart (without running it on flutter)?