Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Samriddhi-Karmacharya opened this issue Dec 18, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@Samriddhi-Karmacharya
Copy link

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):

  • Enviroment: [Flutter o Dart VM]
  • Version 3.10.5
  • YoutubeExplode Version ^2.0.1
@Samriddhi-Karmacharya Samriddhi-Karmacharya added the bug Something isn't working label Dec 18, 2023
@Hexer10
Copy link
Owner

Hexer10 commented Dec 18, 2023

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)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants