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] crashes when fetching videos from channel which are having upcoming or premiering videos #309

Open
SP-XD opened this issue Nov 3, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@SP-XD
Copy link

SP-XD commented Nov 3, 2024

Describe the bug
Crashes when fetching videos from channels which are having upcoming or premiering videos

To Reproduce
Fetch a channel which is having an upcoming or premiering video

Stacktrace

[log] onError(VideosBloc, FormatException: Invalid radix-10 number (at character 1)
      PREMIERE
      ^
      , #0      int._handleFormatError (dart:core-patch/integers_patch.dart:127:5)
      #1      int._parseRadix (dart:core-patch/integers_patch.dart:138:16)
integers_patch.dart:138
      #2      int._parse (dart:core-patch/integers_patch.dart:99:12)
integers_patch.dart:99
      #3      int.parse (dart:core-patch/integers_patch.dart:61:12)
integers_patch.dart:61
      #4      StringUtility.toDuration (package:youtube_explode_dart/src/extensions/helpers_extension.dart:69:36)
helpers_extension.dart:69
      #5      _InitialData._parseContent (package:youtube_explode_dart/src/reverse_engineering/pages/channel_upload_page.dart:204:17)
channel_upload_page.dart:204
      #6      MappedListIterable.elementAt (dart:_internal/iterable.dart:425:31)
iterable.dart:425
      #7      ListIterator.moveNext (dart:_internal/iterable.dart:354:26)
iterable.dart:354
      #8      NonNullsIterator.moveNext (dart:_internal/iterable.dart:921:20)
iterable.dart:921
      #9      new _GrowableList._ofOther (dart:core-patch/growable_array.dart:202:26)
growable_array.dart:202
      #10     new _GrowableList.of (dart:core-patch/growable_array.dart:152:26)
growable_array.dart:152
      #11     new List.of (dart:core-patch/array_patch.dart:39:18)
array_patch.dart:39
      #12     Iterable.toList (dart:core/iterable.dart:498:7)
iterable.dart:498
      #13     _InitialData._getUploads (package:youtube_explode_dart/src/reverse_engineering/pages/channel_upload_page.dart:75:48)
channel_upload_page.dart:75
      #14     _InitialData.uploads (package:youtube_explode_dart/src/reverse_engineering/pages/channel_upload_page.dart:68:43)
channel_upload_page.dart:68
      #15     _InitialData.uploads (package:youtube_explode_dart/src/reverse_engineering/pages/channel_upload_page.dart)
      #16     ChannelUploadPage.uploads (package:youtube_explode_dart/src/reverse_engineering/pages/channel_upload_page.dart:21:55)
channel_upload_page.dart:21
      #17     ChannelUploadPage.uploads (package:youtube_explode_dart/src/reverse_engineering/pages/channel_upload_page.dart)
      #18     ChannelClient.getUploadsFromPage (package:youtube_explode_dart/src/channels/channel_client.dart:158:12)
channel_client.dart:158
      <asynchronous suspension>
      #19     VideosRepository.getChannelVideos (package:midnight_suspense/src/data/repositories/videos_repository.dart:14:22)
videos_repository.dart:14
      <asynchronous suspension>
      #20     new VideosBloc.<anonymous closure>.<anonymous closure> (package:midnight_suspense/src/features/videos/bloc/videos_bloc.dart:21:22)
videos_bloc.dart:21
      <asynchronous suspension>
      #21     new VideosBloc.<anonymous closure> (package:midnight_suspense/src/features/videos/bloc/videos_bloc.dart:15:7)
videos_bloc.dart:15
      <asynchronous suspension>
      #22     Bloc.on.<anonymous closure>.handleEvent (package:bloc/src/bloc.dart:229:13)
bloc.dart:229
      <asynchronous suspension>
      )

Enviroment:

  • Enviroment: [Flutter]
  • Flutter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.0, on macOS 15.0.1 24A348 darwin-arm64, locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0-rc1)
[!] Xcode - develop for iOS and macOS (Xcode 16.0)
    ! iOS 18.0 Simulator not installed; this may be necessary for iOS and macOS development.
      To download and install the platform, open Xcode, select Xcode > Settings > Platforms,
      and click the GET button for the required platform.

      For more information, please visit:
        https://developer.apple.com/documentation/xcode/installing-additional-simulator-runtimes
[✓] Android Studio (version 2024.1)
[✓] VS Code (version 1.94.2)
[✓] Connected device (1 available)
[✓] Network resources

  • YoutubeExplode Version [2.3.5]

Fix

I have a probable fix: I have added both UPCOMING and PREMIERE conditions locally but didn't get the time to test them, as it's hard to find channels with upcoming videos.

File:  youtube_explode_dart/src/extensions/helpers_extension.dart:59:5

  Duration? toDuration() {
    if (this == 'SHORTS' || this == "UPCOMING" || this == "PREMIERE" || trim().isEmpty) {
      return null;
    }
   ...
   }
@SP-XD SP-XD added the bug Something isn't working label Nov 3, 2024
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

1 participant